Ejemplo n.º 1
0
        //ToDo : учет associate model?
        // GlobalTransform of the bone at the binding moment.
        //
        // (Comments from fbxcluster.h)
        // Transformation matrices. A link has three transformation matrices:
        // - Transform refers to the global initial transform of the geometry node(geometry is the attribute of the node) that contains the link node.
        // - TransformLink refers to global initial transform of the link(bone) node.
        // - TransformAssociateModel refers to the global initial transform of the associate model.
        //
        // For example, given a mesh binding with several bones(links), Transform is the global transform
        // of the mesh at the binding moment, TransformLink is the global transform of the bone(link)
        // at the binding moment, TransformAssociateModel is the global transform of the associate model
        // at the binding moment.

        FbxAMatrix GetInitialTransform()
        {
            if (cluster == null)
            {
                return(FbxMath.EvaluateGlobalTransform(Node));
            }

            //Each cluster is associated with a FbxNode (bone)
            //cluster.GetLink().GetUniqueID() == Node.GetUniqueID();


            //??? Учитывать ли AxisSystem?
            //??? Не совсем понятны отличаи globalMeshTransform == skin.GetGeometry().GetNode().EvaluateGlobalTransform(), от cluster.GetTransformMatrix()

            //matrix associated with the geometry node containing the link. (global transform of the mesh at the binding moment)
            FbxAMatrix globalMeshInitialTransform = new FbxAMatrix();

            cluster.GetTransformMatrix(globalMeshInitialTransform);

            //Get matrix associated with the link node (bind pose,  bone transform) at the binding moment
            FbxAMatrix boneInitialTransform = new FbxAMatrix();

            cluster.GetTransformLinkMatrix(boneInitialTransform);
            //Дополнительная матрица которую cluster ассоциирует с Node - Трансформация в момент привязки.

            //bind pose matrix that is local for the mesh = Inverse(TransformMatrix) * TransformLinkMatrix
            FbxAMatrix localBindPose = (globalMeshInitialTransform.mul(geometryOffset).Inverse()).mul(boneInitialTransform);

            //globalMeshTransform * Inverse(globalMeshInitialTransform) * boneInitialTransform
            return(globalMeshTransform.mul(geometryOffset).mul(localBindPose));
        }