Ejemplo n.º 1
0
        protected void ExportBindPose(FbxNode meshNode, FbxScene fbxScene, List <FbxNode> boneNodes)
        {
            FbxPose fbxPose = FbxPose.Create(fbxScene, "Pose");

            // set as bind pose
            fbxPose.SetIsBindPose(true);

            // assume each bone node has one weighted vertex cluster
            foreach (FbxNode fbxNode in boneNodes)
            {
                // EvaluateGlobalTransform returns an FbxAMatrix (affine matrix)
                // which has to be converted to an FbxMatrix so that it can be passed to fbxPose.Add().
                // The hierarchy for FbxMatrix and FbxAMatrix is as follows:
                //
                //      FbxDouble4x4
                //      /           \
                // FbxMatrix     FbxAMatrix
                //
                // Therefore we can't convert directly from FbxAMatrix to FbxMatrix,
                // however FbxMatrix has a constructor that takes an FbxAMatrix.
                FbxMatrix fbxBindMatrix = new FbxMatrix(fbxNode.EvaluateGlobalTransform());

                fbxPose.Add(fbxNode, fbxBindMatrix);
            }

            FbxMatrix bindMatrix = new FbxMatrix(meshNode.EvaluateGlobalTransform());

            fbxPose.Add(meshNode, bindMatrix);

            // add the pose to the scene
            fbxScene.AddPose(fbxPose);
        }
Ejemplo n.º 2
0
        public void Scene_AddPose_AddsPose()
        {
            // given:
            var scene = new FbxScene("Scene");
            var pose  = new FbxPose("Pose");

            // require:
            Assert.AreEqual(3, scene.GetSrcObjectCount());
            Assert.AreEqual(scene.GetRootNode(), scene.GetSrcObject(0));
            Assert.AreEqual(scene.GetGlobalSettings(), scene.GetSrcObject(1));
            Assert.AreEqual(scene.GetAnimationEvaluator(), scene.GetSrcObject(2));
            Assert.AreEqual(0, scene.GetDstObjectCount());
            Assert.AreEqual(0, scene.GetPoseCount());

            Assert.AreEqual(0, pose.GetSrcObjectCount());
            Assert.AreEqual(0, pose.GetDstObjectCount());
            Assert.AreEqual(null, pose.GetScene());

            // when:
            scene.AddPose(pose);

            // then:
            Assert.AreEqual(4, scene.GetSrcObjectCount());
            Assert.AreEqual(scene.GetRootNode(), scene.GetSrcObject(0));
            Assert.AreEqual(scene.GetGlobalSettings(), scene.GetSrcObject(1));
            Assert.AreEqual(scene.GetAnimationEvaluator(), scene.GetSrcObject(2));
            Assert.AreEqual(pose, scene.GetSrcObject(3));
            Assert.AreEqual(0, scene.GetDstObjectCount());
            Assert.AreEqual(1, scene.GetPoseCount());
            Assert.AreEqual(pose, scene.GetPose(0));

            Assert.AreEqual(0, pose.GetSrcObjectCount());
            Assert.AreEqual(1, pose.GetDstObjectCount());
            Assert.AreEqual(scene, pose.GetDstObject(0));
            Assert.AreEqual(scene, pose.GetScene());
        }