ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
AnimationTrack.h
Go to the documentation of this file.
1/**
2 * @file AnimationTrack.h
3 * @brief Declares the AnimationTrack template class for managing animation tracks with keyframes.
4 *
5 * This file contains the definition of the AnimationTrack template class, designed
6 * to handle animations with a fixed number of parameters and keyframes.
7 * The class integrates functionality for adding parameters, playing, pausing,
8 * and updating animation tracks.
9 *
10 * @author Coela Can't
11 * @date 22/12/2024
12 */
13
14#pragma once
15
16#include "../KeyFrameTrack.h" // Include for KeyFrameTrack dependency.
17
18/**
19 * @class AnimationTrack
20 * @brief A template class for managing animation tracks with keyframes.
21 *
22 * This class handles the management of animation parameters and their associated
23 * keyframes, supporting playback controls, parameter updates, and interpolation.
24 *
25 * @tparam maxParameters The maximum number of parameters this animation track can handle.
26 * @tparam maxKeyFrames The maximum number of keyframes this animation track can contain.
27 */
28template<size_t maxParameters, size_t maxKeyFrames>
30protected:
31 /**
32 * @brief Internal track object for keyframe management.
33 *
34 * This KeyFrameTrack instance handles the underlying keyframe operations
35 * for the AnimationTrack class.
36 */
38
39private:
40 /**
41 * @brief Pure virtual function to add keyframes to the track.
42 *
43 * This function must be implemented by derived classes to define
44 * how keyframes are added to the animation track.
45 */
46 virtual void AddKeyFrames() = 0;
47
48public:
49 /**
50 * @brief Default constructor.
51 *
52 * Constructs an AnimationTrack object with default settings.
53 */
55
56 /**
57 * @brief Parameterized constructor.
58 *
59 * Initializes an AnimationTrack object with the given range and interpolation method.
60 *
61 * @param min The minimum value of the parameter range.
62 * @param max The maximum value of the parameter range.
63 * @param interpMethod The interpolation method to be used for the track.
64 */
66
67 /**
68 * @brief Starts or resumes playback of the animation track.
69 */
70 void Play();
71
72 /**
73 * @brief Pauses playback of the animation track.
74 */
75 void Pause();
76
77 /**
78 * @brief Restarts the animation track's time to the beginning.
79 */
81
82 /**
83 * @brief Prints the current time of the animation track.
84 *
85 * This function outputs the current time of the track for debugging purposes.
86 */
87 void PrintTime();
88
89 /**
90 * @brief Resets the animation track to its initial state.
91 */
92 void Reset();
93
94 /**
95 * @brief Retrieves the current parameter value of the animation track.
96 *
97 * @return The current value of the parameter being animated.
98 */
100
101 /**
102 * @brief Updates the animation track and returns the current parameter value.
103 *
104 * This function advances the animation track based on the elapsed time
105 * and computes the interpolated parameter value.
106 *
107 * @return The updated parameter value.
108 */
109 float Update();
110
111 /**
112 * @brief Adds a parameter to the animation track.
113 *
114 * @param parameter A pointer to the parameter to be animated.
115 */
116 void AddParameter(float* parameter);
117};
118
119#include "AnimationTrack.tpp" // Include the template implementation.
A template class for managing animation tracks with keyframes.
void AddParameter(float *parameter)
Adds a parameter to the animation track.
void Play()
Starts or resumes playback of the animation track.
AnimationTrack(float min, float max, KeyFrameInterpolation::InterpolationMethod interpMethod)
Parameterized constructor.
void Reset()
Resets the animation track to its initial state.
void RestartTime()
Restarts the animation track's time to the beginning.
AnimationTrack()
Default constructor.
float GetParameterValue()
Retrieves the current parameter value of the animation track.
void Pause()
Pauses playback of the animation track.
void PrintTime()
Prints the current time of the animation track.
float Update()
Updates the animation track and returns the current parameter value.
virtual void AddKeyFrames()=0
Pure virtual function to add keyframes to the track.
KeyFrameTrack< maxParameters, maxKeyFrames > track
Internal track object for keyframe management.
InterpolationMethod
Enumeration of interpolation methods.
A template class for managing animations with multiple parameters and keyframes.