-
-
Notifications
You must be signed in to change notification settings - Fork 32
Keyframing Animations
Coela Can't! edited this page Aug 20, 2021
·
2 revisions
KeyFrameTracks can control floating-point parameters based on a float variable reference. To instantiate a KeyFrameTrack object, specify the max number of parameters to add, the minimum value, the maximum value, the max number of keyframes, and the interpolation method. The available interpolation methods are linear interpolation, cosine interpolation, and step.
// Include header
#include "KeyFrameTrack.h"
// Floating point value to modify
float parameter = 0.0f;
// Instantiate keyframe track
KeyFrameTrack parameterTrack = KeyFrameTrack(10, 0.0f, 1.0f, 10, KeyFrameTrack::Cosine);
// Pass the parameter reference to the keyframe track
parameterTrack.AddParameter(¶meter);
// Add keyframes to the track
parameterTrack.AddKeyFrame(0.0f, 0.0f);
parameterTrack.AddKeyFrame(1.0f, 1.0f);
parameterTrack.AddKeyFrame(2.0f, 0.0f);
parameterTrack.AddKeyFrame(1.3f, 0.25f);
// Update the keyframe track to update the current value of parameter
parameterTrack.Update();
Any recommendations on additional information to add can be requested in the discussions tab. If you have additional questions, you can @ me in my Discord server or on direct message me on Twitter.