public CreateNodeKeyFrame ( float time ) : |
||
time | float | |
return |
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); //} } }
/// <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; } }