FaceFX Support

FaceFX Documentation and support

Curve Evaluation

FaceFX uses Hermite interpolation with tangent lengths fixed at 1/3 the distance to the next key.

A curve is defined by a set of keys, each of which has 4 parameters:

/// Hermite interpolation between two keys. /// Does not perform range checking on \a currentTime. FX_INLINE FxReal FX_CALL FxHermiteInterpolate( const FxAnimKey& first, const FxAnimKey& second, FxReal currentTime ) { FxReal time1 = first.GetTime(); FxReal time2 = second.GetTime(); FxReal deltaTime = time2 - time1; FxReal parametricTime = (currentTime - time1) / deltaTime;

FxReal p0 = first.GetValue(); FxReal p1 = second.GetValue(); FxReal m0 = first.GetSlopeOut() * deltaTime; FxReal m1 = second.GetSlopeIn() * deltaTime;

return parametricTime * (parametricTime * (parametricTime * (2.0fp0 - 2.0fp1 + m0 + m1) + (-3.0fp0 + 3.0fp1 - 2.0f*m0 - m1)) + m0) + p0; }

 Here is how to derive tangents from the slopes. Consider two keys (K1 and K2):

// Keys are sorted by increasing time, so K1’s time is less than K2’s time.

const FxAnimKey& K1 = anim.GetKey(0); const FxAnimKey& K2 = anim.GetKey(1);

FxReal time1 = K1.GetTime(); FxReal time2 = K2.GetTime();

FxReal deltaTime = time2 – time1; FxReal tangentAtKey1 = K1.GetSlopeOut() * deltaTime; FxReal tangentAtKey2 = K2.GetSlopeIn() *deltaTime;