Пример #1
0
        private static void SetBoneRotation(BoneAssigner bone, CtMatrix4x4 tm)
        {
            CtMatrix4x4 ctMatrix4x = CtMatrix4x4.UnitMatrix();

            for (CtBone ctBone = bone.Bone; ctBone != null; ctBone = ctBone.Parent)
            {
                ctMatrix4x *= ctBone.InitMatrix;
            }
            CtMatrix4x4 ctMatrix4x2 = CtMatrix4x4.UnitMatrix();

            CtVector3D[] array = new CtVector3D[]
            {
                CtMatrix4x4.Mulv3xM4N(new CtVector3D(1f, 0f, 0f), ctMatrix4x),
                CtMatrix4x4.Mulv3xM4N(new CtVector3D(0f, 1f, 0f), ctMatrix4x),
                CtMatrix4x4.Mulv3xM4N(new CtVector3D(0f, 0f, 1f), ctMatrix4x)
            };
            array[0].Normalize();
            array[1].Normalize();
            array[2].Normalize();
            ctMatrix4x2.SetAxis3(array[0], array[1], array[2]);
            ctMatrix4x2.Transpose();
            CtMatrix4x4 ctMatrix4x3 = new CtMatrix4x4(ctMatrix4x2);

            CtMatrix4x4.Inverse(ctMatrix4x3);
            CtMatrix4x4 leftMatrix  = bone.LeftMatrix;
            CtMatrix4x4 rightMatrix = bone.RightMatrix;

            bone.Bone.TransformMatrix = ctMatrix4x2 * leftMatrix * tm * rightMatrix * ctMatrix4x3;
        }
Пример #2
0
 public void CleanPose()
 {
     for (int i = 0; i < this.Mesh.MatrixPallet.GetBoneCount(); i++)
     {
         CtBone bone = this.Mesh.MatrixPallet.GetBone(i);
         bone.TransformMatrix = CtMatrix4x4.UnitMatrix();
     }
     this.Mesh.UpdateBoneMatrices();
 }
Пример #3
0
 public BoneAssigner(CtBone bone, CtMatrix4x4 leftMatrix, CtMatrix4x4 rightMatrix)
 {
     this.Bone        = bone;
     this.LeftMatrix  = leftMatrix;
     this.RightMatrix = rightMatrix;
     if (this.LeftMatrix == null)
     {
         this.LeftMatrix = CtMatrix4x4.UnitMatrix();
     }
     if (this.RightMatrix == null)
     {
         this.RightMatrix = CtMatrix4x4.UnitMatrix();
     }
     this.ParentBone = null;
 }