CreateNodeKeyFrame() 공개 메소드

Creates a new KeyFrame and adds it to this animation at the given time index.
It is better to create KeyFrames in time order. Creating them out of order can result in expensive reordering processing. Note that a KeyFrame at time index 0.0 is always created for you, so you don't need to create this one, just access it using getKeyFrame(0);
public CreateNodeKeyFrame ( float time ) : TransformKeyFrame
time float
리턴 TransformKeyFrame
        protected void TransformTrack(Matrix4 exportTransform,
									  NodeAnimationTrack newTrack, 
									  NodeAnimationTrack track,
									  Bone bone)
        {
            Matrix4 invExportTransform = exportTransform.Inverse();
            Bone oldNode = (Bone)track.TargetNode;
            Bone newNode = (Bone)newTrack.TargetNode;
            for (int i = 0; i < track.KeyFrames.Count; ++i) {
                TransformKeyFrame keyFrame = track.GetTransformKeyFrame(i);
                TransformKeyFrame newKeyFrame = newTrack.CreateNodeKeyFrame(keyFrame.Time);
                Quaternion oldOrientation = oldNode.Orientation * keyFrame.Rotation;
                Vector3 oldTranslation = oldNode.Position + keyFrame.Translate;
                Matrix4 oldTransform = Multiverse.MathLib.MathUtil.GetTransform(oldOrientation, oldTranslation);
                Matrix4 newTransform = exportTransform * oldTransform * invExportTransform;
                Quaternion newOrientation = GetRotation(newTransform);
                Vector3 newTranslation = newTransform.Translation;
                newKeyFrame.Rotation = newNode.Orientation.Inverse() * newOrientation;
                newKeyFrame.Translate = newTranslation - newNode.Position;
                //if (oldNode.Name == "Lower_Torso_BIND_jjj") {
                //    log.DebugFormat("New translation: {0}; New Position: {1}", newTranslation, newNode.Position);
                //}
            }
        }
예제 #2
0
	    /// <summary>
	    ///    Reads an animation track section.
	    /// </summary>
	    protected void ReadKeyFrame( BinaryReader reader, NodeAnimationTrack track )
		{
			float time = ReadFloat( reader );

			// create a new keyframe with the specified length
			TransformKeyFrame keyFrame = track.CreateNodeKeyFrame( time );

			// read orientation
			Quaternion rotate = ReadQuat( reader );
			keyFrame.Rotation = rotate;

			// read translation
			Vector3 translate = ReadVector3( reader );
			keyFrame.Translate = translate;

			// read scale if it is in there
			if ( currentChunkLength >= 50 )
			{
				Vector3 scale = ReadVector3( reader );
				keyFrame.Scale = scale;
			}
			else
			{
				keyFrame.Scale = Vector3.UnitScale;
			}
		}