Пример #1
0
        private static Matrix4x4 CalculateGlobalTransformFlver(FLVER.Bone bone, FLVER2 flver)
        {
            Matrix4x4 localTransform = bone.ComputeLocalTransform();

            //Matrix4x4 localTransform = Matrix4x4.CreateTranslation(bone.Translation)
            //    * Matrix4x4.CreateRotationY(bone.Rotation.Y)
            //    * Matrix4x4.CreateRotationY(bone.Rotation.Z)
            //    * Matrix4x4.CreateRotationY(bone.Rotation.X)
            //    * Matrix4x4.CreateScale(bone.Scale);

            if (bone.ParentIndex >= 0)
            {
                localTransform *= CalculateGlobalTransformFlver(flver.Bones[bone.ParentIndex], flver);
            }

            return(localTransform);
        }
Пример #2
0
        public static Matrix4x4 GetBoneObjectMatrix(FLVER.Bone bone, List <FLVER.Bone> bones)
        {
            var res        = Matrix4x4.Identity;
            var parentBone = bone;

            do
            {
                res *= bone.ComputeLocalTransform();
                if (parentBone.ParentIndex >= 0)
                {
                    parentBone = bones[parentBone.ParentIndex];
                }
                else
                {
                    parentBone = null;
                }
            }while (parentBone != null);

            return(res);
        }