AnimationClip
Represents a reusable set of keyframe tracks that define an
animation.
This class manages a collection of KeyframeTrack objects that together
holds the animation duration, tracks, and playback behavior. In short:
It's just a set of keyframeTacks with some methods to collectively
modify them.
- Create clips from keyframe tracks
- KeyframeTrack manipulation and validation
- Set animation duration and name
- Use with AnimationMixer for playback
Methods
AnimationClip(const string& name, f32 duration, const vector<KeyframeTrack>& tracks, AnimationBlendModes blendMode = AnimationBlendModes::NormalAnimationBlendMode)
Constructor with name, duration, tracks and blend mode
| name | Animation clip name identifier | "AnimationClip" |
| duration | Duration of the animation in seconds | -1.0f (auto-calculate) |
| tracks | Dynamic Array of keyframe tracks | empty |
| blendMode | Blend mode for mixing animations | NormalAnimationBlendMode |
AnimationClip clone() const
Returns a copy of this animation clip
void resetDuration()
Resets the duration to match the longest track
void trim()
Trims all tracks to the clip duration
void optimize()
Optimizes all tracks by removing equivalent keys
void scale(f32 timeScale)
Scales all track times by a factor
| timeScale | Scale factor to apply to all tracks |
void shift(f32 timeOffset)
Shifts all track times by an offset
| timeOffset | Time offset to apply to all tracks |
bool validate() const
Validates all tracks in the clip
static AnimationClip findByName(const vector<AnimationClip>& clips, const string& name)
Searches for an AnimationClip by name in an array
| clips | Array of AnimationClips to search | |
| name | Name of the clip to find |
static AnimationClip createFromMorphTargetSequence(const string& name, const vector<string>& morphTargets, f32 fps, bool noLoop = false)
Creates AnimationClip from morph target sequence
| name | Name for the clip | |
| morphTargets | Array of morph target names | |
| fps | Frames per second | |
| noLoop | Whether to loop the animation |
static vector<AnimationClip> createClipsFromMorphTargetSequences(const vector<string>& morphTargets, f32 fps, bool noLoop = false)
Creates multiple AnimationClips from morph target sequences
| morphTargets | Array of morph target names | |
| fps | Frames per second | |
| noLoop | Whether to loop the animation |
Properties
| blendMode | AnimationBlendModes | Blend mode for mixing animations |
| duration | f32 | Duration in seconds |
| name | string | Animation clip name |
| tracks | vector<KeyframeTrack> | Array of keyframe tracks |
| uuid | string | Unique identifier |