Axiom.Animating.NodeAnimationTrack.GetInterpolatedKeyFrame C# (CSharp) Метод

GetInterpolatedKeyFrame() публичный Метод

Gets a KeyFrame object which contains the interpolated transforms at the time index specified.
The KeyFrame objects held by this class are transformation snapshots at discrete points in time. Normally however, you want to interpolate between these keyframes to produce smooth movement, and this method allows you to do this easily. In animation terminology this is called 'tweening'.
public GetInterpolatedKeyFrame ( float time, KeyFrame kf ) : KeyFrame
time float The time (in relation to the whole animation sequence).
kf KeyFrame
Результат KeyFrame
	    public override KeyFrame GetInterpolatedKeyFrame( float time, KeyFrame kf )
		{
			// note: this is an un-attached keyframe
			TransformKeyFrame result = (TransformKeyFrame)kf;
			result.Time = time;

			// Keyframe pointers
			KeyFrame kBase1, kBase2;
			TransformKeyFrame k1, k2;
			short firstKeyIndex;

			float t = GetKeyFramesAtTime( time, out kBase1, out kBase2, out firstKeyIndex );
			k1 = (TransformKeyFrame)kBase1;
			k2 = (TransformKeyFrame)kBase2;

			if ( t == 0.0f )
			{
				// just use k1
				result.Rotation = k1.Rotation;
				result.Translate = k1.Translate;
				result.Scale = k1.Scale;
			}
			else
			{
				// interpolate by t
				InterpolationMode mode = parent.InterpolationMode;
				RotationInterpolationMode rim = parent.RotationInterpolationMode;

				switch ( mode )
				{
					case InterpolationMode.Linear:
						{
							// linear interoplation
							// Rotation
							// Interpolate to nearest rotation if mUseShortestPath set
							if ( rim == RotationInterpolationMode.Linear )
								result.Rotation = Quaternion.Nlerp( t, k1.Rotation, k2.Rotation, useShortestPath );
							else // RotationInterpolationMode.Spherical
								result.Rotation = Quaternion.Slerp( t, k1.Rotation, k2.Rotation, useShortestPath );
							result.Translate = k1.Translate + ( ( k2.Translate - k1.Translate ) * t );
							result.Scale = k1.Scale + ( ( k2.Scale - k1.Scale ) * t );

						}
						break;
					case InterpolationMode.Spline:
						{
							// spline interpolation
							if ( isSplineRebuildNeeded )
							{
								BuildInterpolationSplines();
							}

							result.Rotation = rotationSpline.Interpolate( firstKeyIndex, t, useShortestPath );
							result.Translate = positionSpline.Interpolate( firstKeyIndex, t );
							result.Scale = scaleSpline.Interpolate( firstKeyIndex, t );
						}
						break;

				}
			}

			// return the resulting keyframe
			return result;
		}