示例#1
0
        public static Matrix GlobalTransformMatrix(this SkeletonFile.SkeletonBone skeletonBone)
        {
            if (skeletonBone == null)
            {
                return(Matrix.Identity);
            }

            return(LocalTransformMatrix(skeletonBone) * GlobalTransformMatrix(skeletonBone.Parent));
        }
示例#2
0
        public static Vector3 Position(this SkeletonFile.SkeletonBone skeletonBone, bool flipZ = false)
        {
            var transformMatrix = GlobalTransformMatrix(skeletonBone);
            var result          = Vector3.Transform(Vector3.Zero, transformMatrix);

            if (flipZ)
            {
                result.Z = -result.Z;
            }
            return(result);
        }
示例#3
0
        public static Matrix LocalTransformMatrix(this SkeletonFile.SkeletonBone skeletonBone)
        {
            if (skeletonBone == null)
            {
                return(Matrix.Identity);
            }

            var matrixPreRotation  = Matrix.CreateFromQuaternion(skeletonBone.PreRotation);
            var matrixPostRotation = Matrix.CreateFromQuaternion(skeletonBone.PostRotation);
            var matrixOffset       = Matrix.CreateTranslation(skeletonBone.Offset);
            var result             = matrixPreRotation * matrixPostRotation * matrixOffset;

            return(result);
        }
示例#4
0
     public static void ToString(this SkeletonFile.SkeletonBone skeletonBone, TextWriter writer, bool flipZ = false)
     {
         writer.WriteLine(@"    Name={0}, 
 ParentIndex= {1}, 
 PreRotation= {2}, 
 PostRotation={3}, 
 Offset=      {4},
 Position=    {5}",
                          skeletonBone.Name,
                          skeletonBone.ParentIndex,
                          skeletonBone.PreRotation.ToFormatString(),
                          skeletonBone.PostRotation.ToFormatString(),
                          skeletonBone.Offset.ToFormatString(),
                          skeletonBone.Position(flipZ).ToFormatString());
     }