Beispiel #1
0
        public static void GetRefPoseTransform(int i, short[] hierarchy, teModelChunk_Skeleton skeleton,
                                               Dictionary <int, teModelChunk_Cloth.ClothNode> clothNodeMap, out teVec3 scale, out teQuat quat,
                                               out teVec3 translation)
        {
            if (clothNodeMap != null && clothNodeMap.ContainsKey(i))
            {
                Matrix thisMat   = skeleton.GetWorldSpace(i);
                Matrix parentMat = skeleton.GetWorldSpace(hierarchy[i]);

                Matrix newParentMat = thisMat * Matrix.Invert(parentMat);

                newParentMat.Decompose(out Vector3 scl2, out Quaternion rot2, out Vector3 pos2);

                quat        = new teQuat(rot2.X, rot2.Y, rot2.Z, rot2.W);
                scale       = new teVec3(scl2.X, scl2.Y, scl2.Z);
                translation = new teVec3(pos2.X, pos2.Y, pos2.Z);
            }
            else
            {
                teMtx43 bone = skeleton.Matrices34Inverted[i];

                scale       = new teVec3(bone[1, 0], bone[1, 1], bone[1, 2]);
                quat        = new teQuat(bone[0, 0], bone[0, 1], bone[0, 2], bone[0, 3]);
                translation = new teVec3(bone[2, 0], bone[2, 1], bone[2, 2]);
            }
        }
Beispiel #2
0
        public void GetWorldSpace(int idx, out teVec3 scale, out teQuat rotation, out teVec3 translation)
        {
            teMtx43 parBoneMat = Matrices34[idx];

            scale       = new teVec3(parBoneMat[1, 0], parBoneMat[1, 1], parBoneMat[1, 2]);
            rotation    = new teQuat(parBoneMat[0, 0], parBoneMat[0, 1], parBoneMat[0, 2], parBoneMat[0, 3]);
            translation = new teVec3(parBoneMat[2, 0], parBoneMat[2, 1], parBoneMat[2, 2]);
        }