예제 #1
0
 private void ConvertWorldToLocalSpace(STBone bone)
 {
     if (bone.ParentIndex != -1)
     {
         var mat = GetBoneTransform(bone.Parent).Inverted();
         bone.Position = Vector3.TransformPosition(bone.Position, mat);
         bone.Rotation = mat.ExtractRotation() * bone.Rotation;
     }
 }
예제 #2
0
 /// <summary>
 /// Gets the bone transform in world space.
 /// </summary>
 /// <param name="bone"></param>
 /// <returns></returns>
 public Matrix4 GetBoneTransform(STBone bone)
 {
     if (bone == null)
     {
         return(Matrix4.Identity);
     }
     if (bone.ParentIndex == -1)
     {
         return(bone.GetTransform());
     }
     else
     {
         return(bone.GetTransform() * GetBoneTransform(Bones[bone.ParentIndex]));
     }
 }
예제 #3
0
        private Matrix4 GetWorldMatrix(STBone bone)
        {
            var transform =
                Matrix4.CreateScale(bone.AnimationController.Scale) *
                Matrix4.CreateFromQuaternion(bone.AnimationController.Rotation) *
                Matrix4.CreateTranslation(bone.AnimationController.Position);

            if (bone.ParentIndex != -1 && !bone.AnimationController.WorldTransform)
            {
                return(transform * GetWorldMatrix(bone.Parent));
            }
            else
            {
                return(transform);
            }
        }