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

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

Same as the Apply method, but applies to a specified Node instead of it's associated node.
public ApplyToNode ( Node node, float time, float weight, bool accumulate, float scale ) : void
node Axiom.Core.Node
time float
weight float
accumulate bool
scale float
Результат void
		public void ApplyToNode( Node node, float time, float weight, bool accumulate, float scale )
		{
			this.GetInterpolatedKeyFrame( time, kf );

			if ( accumulate )
			{
				// add to existing. Weights are not relative, but treated as absolute multipliers for the animation
				Vector3 translate = kf.Translate * weight * scale;
				node.Translate( translate );

				// interpolate between not rotation and full rotation, to point weight, so 0 = no rotate, and 1 = full rotation
				Quaternion rotate = Quaternion.Slerp( weight, Quaternion.Identity, kf.Rotation );
				node.Rotate( rotate );

				// TODO: not yet sure how to modify scale for cumulative animations
				Vector3 scaleVector = kf.Scale;
				// Not sure how to modify scale for cumulative anims... leave it alone
				//scaleVector = ((Vector3::UNIT_SCALE - kf.getScale()) * weight) + Vector3::UNIT_SCALE;
				if ( scale != 1.0f && scaleVector != Vector3.UnitScale )
					scaleVector = Vector3.UnitScale + ( scaleVector - Vector3.UnitScale ) * scale;
				node.ScaleBy( scaleVector );
			}
			else
			{
				// apply using weighted transform method
				node.WeightedTransform( weight, kf.Translate, kf.Rotation, kf.Scale );
			}
		}

Usage Example

Пример #1
0
 public void Apply(Skeleton skeleton, float time, float weight, bool accumulate, float scale)
 {
     // loop through tracks and update them all with current time
     foreach (KeyValuePair <ushort, NodeAnimationTrack> pair in nodeTrackList)
     {
         NodeAnimationTrack track = pair.Value;
         Bone bone = skeleton.GetBone(pair.Key);
         track.ApplyToNode(bone, time, weight, accumulate, scale);
     }
 }