Keyframe.kl

Types

Keyframe (struct)

A sequence of keyframes defining animation over time.

The keyframe represents a single control key on an keyframetrack, which is essentially an animation curve. A keyframe provide various interpolation methods from keyframe to the next.

When interpolating Bezier keyframes, the tangent values are defined as a gradient and fraction pair. The tangent x value is the fraction between this key and the next. A value of 0.333 generates a handle that stretches one third the distance from this key to the next. The tangent y value is the gradient of the handle. A value of 0.0 creates a flat handle, and a value of 1.0 generates a handle whose slope is 45 degrees.

Storing keyframe handles as fractions and gradients is consistent with the major DCCs, and ensures that the curve shape is maintained as the keys are edited in the curve editor.

参考

KeyframeTrack

/*
** Example: keyframe.kl
*/

require Animation, Util;

operator entry(){

    // create two keys using Bezier Interpolation
    Keyframe keyA(0.0, 0.0, Vec2(-0.333, 0.0), Vec2(-0.333, 0.0));
    Keyframe keyB(100.0, 4.0);

    // interpolate the keys for a given time
    report("Bezier Interpolation : value:" + unitTestPrint(keyA.interpolate(keyB, 2.0)));

    keyA.interpolation = Keyframe_Interpolation_Linear;
    keyB.interpolation = Keyframe_Interpolation_Linear;
    report("Linear Interpolation : value:" + unitTestPrint(keyA.interpolate(keyB, 2.0)));

 	keyA.interpolation = Keyframe_Interpolation_Constant;
    keyB.interpolation = Keyframe_Interpolation_Constant;
    report("Constant Interpolation : value:" + unitTestPrint(keyA.interpolate(keyB, 2.0)));

    keyA.interpolation = Keyframe_Interpolation_Constant_Next;
    keyB.interpolation = Keyframe_Interpolation_Constant_Next;
    report("Constant_Next Interpolation : value:" + unitTestPrint(keyA.interpolate(keyB, 2.0)));
}

/*
** Output:

Bezier Interpolation : value:+0.117782
Linear Interpolation : value:+0.080001
Constant Interpolation : value:+0.0
Constant_Next Interpolation : value:+4.0

*/

Members

Scalar time  
Scalar value  
Integer interpolation  
Vec2 inTangent  
Vec2 outTangent  

Methods

  Keyframe ( in Keyframe other )
  Keyframe ( in Scalar time, in Scalar value )
  Keyframe ( in Scalar time, in Scalar value, in Vec2 inTangent, in Vec2 outTangent )
  Keyframe ( in Scalar time, in Scalar value, in Vec2 inTangent, in Vec2 outTangent, in Integer interpolation )
  Keyframe ()
Keyframe clone ? ()
String getDesc ? ( in String indent )
String getDesc ? ()
Scalar interpolate ? ( in Keyframe key2, in Scalar t )
Scalar linearInterpolate ? ( in Keyframe key2, in Scalar b )