Пример #1
0
            /// <summary>
            /// Export an AnimationCurve.
            /// NOTE: This is not used for rotations, because we need to convert from
            /// quaternion to euler and various other stuff.
            /// </summary>
            protected void ExportAnimCurve(UnityEngine.Object unityObj,
                                           AnimationCurve unityAnimCurve,
                                           string unityPropertyName,
                                           FbxScene fbxScene,
                                           FbxAnimLayer fbxAnimLayer)
            {
                FbxPropertyChannelPair fbxPropertyChannelPair;

                if (!FbxPropertyChannelPair.TryGetValue(unityPropertyName, out fbxPropertyChannelPair))
                {
                    Debug.LogWarning(string.Format("no mapping from Unity '{0}' to fbx property", unityPropertyName));
                    return;
                }

                GameObject unityGo = GetGameObject(unityObj);

                if (unityGo == null)
                {
                    Debug.LogError(string.Format("cannot find gameobject for {0}", unityObj.ToString()));
                    return;
                }

                FbxNode fbxNode;

                if (!MapUnityObjectToFbxNode.TryGetValue(unityGo, out fbxNode))
                {
                    Debug.LogError(string.Format("no fbx node for {0}", unityGo.ToString()));
                    return;
                }

                // map unity property name to fbx property
                var fbxProperty = fbxNode.FindProperty(fbxPropertyChannelPair.Property, false);

                if (!fbxProperty.IsValid())
                {
                    Debug.LogError(string.Format("no fbx property {0} found on {1} ", fbxPropertyChannelPair.Property, fbxNode.GetName()));
                    return;
                }

                if (Verbose)
                {
                    Debug.Log("Exporting animation for " + unityObj.ToString() + " (" + unityPropertyName + ")");
                }

                // Create the AnimCurve on the channel
                FbxAnimCurve fbxAnimCurve = fbxProperty.GetCurve(fbxAnimLayer, fbxPropertyChannelPair.Channel, true);

                // copy Unity AnimCurve to FBX AnimCurve.
                fbxAnimCurve.KeyModifyBegin();

                for (int keyIndex = 0, n = unityAnimCurve.length; keyIndex < n; ++keyIndex)
                {
                    var key     = unityAnimCurve [keyIndex];
                    var fbxTime = FbxTime.FromSecondDouble(key.time);
                    fbxAnimCurve.KeyAdd(fbxTime);
                    fbxAnimCurve.KeySet(keyIndex, fbxTime, key.value);
                }

                fbxAnimCurve.KeyModifyEnd();
            }
Пример #2
0
        public FbxScene GetPoseScene()
        {
            global::System.IntPtr cPtr = fbx_wrapperPINVOKE.FbxCharacterPose_GetPoseScene(swigCPtr);
            FbxScene ret = (cPtr == global::System.IntPtr.Zero) ? null : new FbxScene(cPtr, false);

            return(ret);
        }
Пример #3
0
            /// <summary>
            /// Process fbxScene. If system units don't match then bake the convertion into the position
            /// and vertices of objects.
            /// </summary>
            public void ProcessScene(FbxScene fbxScene)
            {
                Debug.Log(string.Format("Scene name: {0}", fbxScene.GetName()));

                var           fbxSettings   = fbxScene.GetGlobalSettings();
                FbxSystemUnit fbxSystemUnit = fbxSettings.GetSystemUnit();

                if (fbxSystemUnit != UnitySystemUnit)
                {
                    Debug.Log(string.Format("converting system unit to match Unity. Expected {0}, found {1}",
                                            UnitySystemUnit, fbxSystemUnit));

                    ConvertScene(fbxScene, UnitySystemUnit);
                }
                else
                {
                    Debug.Log(string.Format("file system units {0}", fbxSystemUnit));
                }

                // The Unity axis system has Y up, Z forward, X to the right (left-handed).
                FbxAxisSystem fbxAxisSystem = fbxSettings.GetAxisSystem();

                if (fbxAxisSystem != UnityAxisSystem)
                {
                    Debug.LogWarning(string.Format("file axis system do not match Unity, Expected {0} found {1}",
                                                   AxisSystemToString(UnityAxisSystem),
                                                   AxisSystemToString(fbxAxisSystem)));
                }

                ProcessNode(fbxScene.GetRootNode());

                return;
            }
Пример #4
0
            /// <summary>
            /// Export the Animator component on this game object
            /// </summary>
            protected void ExportAnimationClips(GameObject unityRoot, FbxScene fbxScene)
            {
                var animator = unityRoot.GetComponent <Animator> ();

                if (!animator)
                {
                    return;
                }

                // Get the controller.
                var controller = animator.runtimeAnimatorController;

                if (!controller)
                {
                    return;
                }

                // Only export each clip once per game object.
                var exported = new HashSet <AnimationClip> ();

                foreach (var clip in controller.animationClips)
                {
                    if (exported.Add(clip))
                    {
                        ExportAnimationClip(clip, unityRoot, fbxScene);
                    }
                }
            }
        protected override void CheckScene(FbxScene scene)
        {
            FbxScene origScene = CreateScene(FbxManager);

            Assert.IsNotNull(origScene);
            Assert.IsNotNull(scene);

            // Retrieve the mesh from each scene
            FbxMesh origMesh   = origScene.GetRootNode().GetChild(0).GetMesh();
            FbxMesh importMesh = scene.GetRootNode().GetChild(0).GetMesh();

            Assert.IsNotNull(origMesh);
            Assert.IsNotNull(importMesh);

            // check that the control points match
            Assert.AreEqual(origMesh.GetControlPointsCount(), importMesh.GetControlPointsCount());

            for (int i = 0; i < origMesh.GetControlPointsCount(); i++)
            {
                FbxVector4 origControlPoint   = origMesh.GetControlPointAt(i);
                FbxVector4 importControlPoint = importMesh.GetControlPointAt(i);

                // Note: Ignoring W as no matter what it is set to it always imports as 0
                Assert.AreEqual(origControlPoint.X, importControlPoint.X);
                Assert.AreEqual(origControlPoint.Y, importControlPoint.Y);
                Assert.AreEqual(origControlPoint.Z, importControlPoint.Z);
            }
        }
Пример #6
0
        protected override void CheckScene(FbxScene scene)
        {
            base.CheckScene(scene);

            FbxScene origScene = CreateScene(FbxManager);

            Assert.AreEqual(origScene.GetRootNode().GetChildCount(), origScene.GetRootNode().GetChildCount());

            FbxNode origMeshNode   = origScene.GetRootNode().GetChild(0);
            FbxNode importMeshNode = scene.GetRootNode().GetChild(0);

            FbxNode origSkelRootNode   = origScene.GetRootNode().GetChild(1);
            FbxNode importSkelRootNode = scene.GetRootNode().GetChild(1);

            // Check that the skeletons match
            CheckSkeleton(origSkelRootNode, importSkelRootNode);

            // TODO: Fix so that calling GetDeformer either allows us to downcast
            //       to FbxSkin, or so that it just returns the correct type.
            // Check that the mesh is correctly linked to the skeleton
            //CheckMeshLinkedToSkeleton(origMeshNode.GetMesh(), importMeshNode.GetMesh());
            origMeshNode.GetMesh();
            importMeshNode.GetMesh();

            // Check that bind pose is set correctly
            CheckExportBindPose(origScene, scene);
        }
Пример #7
0
            /// <summary>
            /// Unconditionally export components on this game object
            /// </summary>
            protected void ExportComponents(GameObject unityGo, FbxScene fbxScene, FbxNode fbxParentNode)
            {
                // create an FbxNode and add it as a child of fbxParentNode
                FbxNode fbxNode = FbxNode.Create(fbxScene, unityGo.name);

                NumNodes++;

                ExportTransform(unityGo.transform, fbxNode);
                var fbxProperty = ExportCustomData(unityGo.transform, fbxNode);

                if (Verbose)
                {
                    Debug.Log(string.Format("exporting {0} ({1} components)", fbxNode.GetName(), (int)fbxProperty.GetFloat()));
                }

                fbxParentNode.AddChild(fbxNode);

                // now go through our children and recurse
                foreach (Transform uniChildT in unityGo.transform)
                {
                    ExportComponents(uniChildT.gameObject, fbxScene, fbxNode);
                }

                return;
            }
        protected override FbxScene CreateScene(FbxManager manager)
        {
            // create the following node hierarchy to test:
            //       Root
            //      /    \
            // Child0    Child1
            //              |
            //            Child2
            //         /    |     \
            //    Child3  Child4  Child5
            FbxScene scene = FbxScene.Create(manager, "myScene");

            FbxNode root = FbxNode.Create(scene, "Root");

            FbxNode[] children = new FbxNode[6];
            for (int i = 0; i < children.Length; i++)
            {
                children [i] = FbxNode.Create(scene, "Child" + i);
            }

            scene.GetRootNode().AddChild(root);
            root.AddChild(children [0]);
            root.AddChild(children [1]);
            children [1].AddChild(children [2]);
            children [2].AddChild(children [3]);
            children [2].AddChild(children [4]);
            children [2].AddChild(children [5]);

            return(scene);
        }
Пример #9
0
        public static FbxAudio Create(FbxScene pContainer, string pName)
        {
            global::System.IntPtr cPtr = FbxWrapperNativePINVOKE.FbxAudio_Create__SWIG_2(FbxScene.getCPtr(pContainer), pName);
            FbxAudio ret = (cPtr == global::System.IntPtr.Zero) ? null : new FbxAudio(cPtr, false);

            return(ret);
        }
Пример #10
0
            /// <summary>
            /// Unconditionally export this mesh object to the file.
            /// We have decided; this mesh is definitely getting exported.
            /// </summary>
            public FbxMesh ExportMesh(GameObject unityGo, FbxScene fbxScene)
            {
                var meshInfo = GetMeshInfo(unityGo);

                if (!meshInfo.IsValid)
                {
                    return(null);
                }

                // create the mesh structure.
                FbxMesh fbxMesh = FbxMesh.Create(fbxScene, "Scene");

                // Create control points.
                int NumControlPoints = meshInfo.VertexCount;

                fbxMesh.InitControlPoints(NumControlPoints);

                // copy control point data from Unity to FBX
                for (int v = 0; v < NumControlPoints; v++)
                {
                    fbxMesh.SetControlPointAt(new FbxVector4(meshInfo.Vertices [v].x, meshInfo.Vertices [v].y, meshInfo.Vertices [v].z), v);
                }

                for (int f = 0; f < meshInfo.Triangles.Length / 3; f++)
                {
                    fbxMesh.BeginPolygon();
                    fbxMesh.AddPolygon(meshInfo.Triangles [3 * f]);
                    fbxMesh.AddPolygon(meshInfo.Triangles [3 * f + 1]);
                    fbxMesh.AddPolygon(meshInfo.Triangles [3 * f + 2]);
                    fbxMesh.EndPolygon();
                }

                return(fbxMesh);
            }
Пример #11
0
        public FbxScene GetScene()
        {
            global::System.IntPtr cPtr = FbxWrapperNativePINVOKE.FbxObject_GetScene(swigCPtr);
            FbxScene ret = (cPtr == global::System.IntPtr.Zero) ? null : new FbxScene(cPtr, false);

            return(ret);
        }
Пример #12
0
        protected override FbxScene CreateScene(FbxManager manager)
        {
            FbxScene scene = base.CreateScene(manager);

            // mesh shared by all instances
            FbxMesh            sharedMesh     = FbxMesh.Create(scene, m_meshName);
            FbxSurfaceMaterial sharedMaterial = FbxSurfacePhong.Create(scene, m_materialName);

            // add mesh to all nodes
            Queue <FbxNode> nodes = new Queue <FbxNode>();

            for (int i = 0; i < scene.GetRootNode().GetChildCount(); i++)
            {
                nodes.Enqueue(scene.GetRootNode().GetChild(i));
            }

            while (nodes.Count > 0)
            {
                FbxNode node = nodes.Dequeue();
                node.SetNodeAttribute(sharedMesh);
                node.AddMaterial(sharedMaterial);
                for (int i = 0; i < node.GetChildCount(); i++)
                {
                    nodes.Enqueue(node.GetChild(i));
                }
            }

            return(scene);
        }
Пример #13
0
        public void Load(FbxScene scene, FbxManager manager, ImportOptions options, Matrix4 additionalTransform /*nodeTransform*/)
        {
            this.scene = scene;

            FbxNode rootNode = scene.GetRootNode();

            if (rootNode != null)
            {
                LoadAnimations(scene);

                var skins = new List <FbxSkin>();
                LoadSkinsFromNodeRecursive(rootNode, skins);
                Skins = skins.ToArray();

                if (HasSceneSkeleton(rootNode))
                {
                    Skeleton = new Skeleton(rootNode, this, Skins, AnimationTracks);
                }

                //for (int i = 0; i < rootNode.GetChildCount(); i++)
                //	EnumerateNodeRecursive(rootNode.GetChild(i));
                //CheckTransparencyInverting();
                ReadMeshGeometriesRecursive(manager, rootNode, options, additionalTransform);
                //if (options.ImportPostProcessFlags.HasFlag(ImportPostProcessFlags.MergeGeometriesByMaterials))
                //	MergeGeometriesByMaterials();
            }
        }
Пример #14
0
 private void ImportAnimations(FbxScene scene)
 {
     foreach (var animation in scene.Animations.List)
     {
         var n         = Model.TryFind <Node3D>(animation.AnimationKey);
         var scaleKeys = Vector3KeyReducer.Default.Reduce(animation.ScaleKeys);
         if (scaleKeys.Count != 0)
         {
             (n.Animators["Scale", animation.MarkerId] as Animator <Vector3>).Keys.AddRange(scaleKeys);
         }
         var rotKeys = QuaternionKeyReducer.Default.Reduce(animation.RotationKeys);
         if (rotKeys.Count != 0)
         {
             if (n is Camera3D)
             {
                 CorrectCameraAnimationKeys(rotKeys);
             }
             (n.Animators["Rotation", animation.MarkerId] as Animator <Quaternion>).Keys.AddRange(rotKeys);
         }
         var posKeys = Vector3KeyReducer.Default.Reduce(animation.PositionKeys);
         if (posKeys.Count != 0)
         {
             (n.Animators["Position", animation.MarkerId] as Animator <Vector3>).Keys.AddRange(posKeys);
         }
         if (!Model.Animations.Any(a => a.Id == animation.MarkerId))
         {
             Model.Animations.Add(new Lime.Animation {
                 Id = animation.MarkerId,
             });
         }
     }
 }
Пример #15
0
        public new static FbxScene Create(FbxManager pManager, string pName)
        {
            global::System.IntPtr cPtr = fbx_wrapperPINVOKE.FbxScene_Create__SWIG_0(FbxManager.getCPtr(pManager), pName);
            FbxScene ret = (cPtr == global::System.IntPtr.Zero) ? null : new FbxScene(cPtr, false);

            return(ret);
        }
Пример #16
0
        public void Scene_Create_HasProperties()
        {
            // given:
            var         scene = new FbxScene("");
            FbxProperty prop;

            // then:
            Assert.AreEqual(2, CountProperties(scene));
            Assert.AreEqual(0, scene.GetSrcPropertyCount());
            Assert.AreEqual(0, scene.GetDstPropertyCount());

            prop = scene.FindProperty("SourceObject");
            Assert.NotNull(prop);
            Assert.True(prop.IsValid());
            Assert.NotNull(scene.Roots);
            Assert.True(scene.Roots.IsValid());
            Assert.AreEqual("SourceObject", scene.Roots.GetName());
            Assert.AreSame(prop, scene.Roots);

            prop = scene.FindProperty("ActiveAnimStackName");
            Assert.NotNull(prop);
            Assert.True(prop.IsValid());
            Assert.NotNull(scene.ActiveAnimStackName);
            Assert.True(scene.ActiveAnimStackName.IsValid());
            Assert.AreEqual("ActiveAnimStackName", scene.ActiveAnimStackName.GetName());
            Assert.AreSame(prop, scene.ActiveAnimStackName);
        }
Пример #17
0
        public new static FbxScene Create(FbxObject pContainer, string pName)
        {
            global::System.IntPtr cPtr = FbxWrapperNativePINVOKE.FbxScene_Create__SWIG_1(FbxObject.getCPtr(pContainer), pName);
            FbxScene ret = (cPtr == global::System.IntPtr.Zero) ? null : new FbxScene(cPtr, false);

            return(ret);
        }
Пример #18
0
        public static FbxAnimCurve Create(FbxScene pContainer, string pName)
        {
            global::System.IntPtr cPtr = fbx_wrapperPINVOKE.FbxAnimCurve_Create__SWIG_1(FbxScene.getCPtr(pContainer), pName);
            FbxAnimCurve          ret  = (cPtr == global::System.IntPtr.Zero) ? null : new FbxAnimCurve(cPtr, false);

            return(ret);
        }
Пример #19
0
            /// <summary>
            /// Unconditionally export components on this game object
            /// </summary>
            protected void ExportComponents(GameObject unityGo, FbxScene fbxScene, FbxNode fbxNodeParent)
            {
                // create an FbxNode and add it as a child of parent
                FbxNode fbxNode = FbxNode.Create(fbxScene, unityGo.name);

                NumNodes++;

                ExportTransform(unityGo.transform, fbxNode);
                ExportMesh(GetMeshInfo(unityGo), fbxNode, fbxScene);

                if (Verbose)
                {
                    Debug.Log(string.Format("exporting {0}", fbxNode.GetName()));
                }

                fbxNodeParent.AddChild(fbxNode);

                // now  unityGo  through our children and recurse
                foreach (Transform childT in unityGo.transform)
                {
                    ExportComponents(childT.gameObject, fbxScene, fbxNode);
                }

                return;
            }
Пример #20
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);
        }
Пример #21
0
            /// <summary>
            /// Unconditionally export components on this game object
            /// </summary>
            protected void ExportComponents(GameObject unityGo, FbxScene fbxScene, FbxNode fbxParentNode)
            {
                // create an FbxNode and add it as a child of fbxParentNode
                FbxNode fbxNode = FbxNode.Create(fbxScene, unityGo.name);

                NumNodes++;

                ExportTransform(unityGo.transform, fbxNode);

                var fbxNodeAttr = ExportNull(fbxScene);

                // set the fbxNode's node attribute
                fbxNode.SetNodeAttribute(fbxNodeAttr);
                fbxNode.SetShadingMode(FbxNode.EShadingMode.eWireFrame);

                if (Verbose)
                {
                    Debug.Log(string.Format("exporting {0}", fbxNode.GetName()));
                }

                fbxParentNode.AddChild(fbxNode);

                // now  unityGo  through our children and recurse
                foreach (Transform uniChildT in  unityGo.transform)
                {
                    ExportComponents(uniChildT.gameObject, fbxScene, fbxNode);
                }

                return;
            }
Пример #22
0
        protected FbxNode CreateSkeleton(FbxScene scene)
        {
            FbxSkeleton skelRoot = FbxSkeleton.Create(scene, "SkelRoot");

            skelRoot.SetSkeletonType(FbxSkeleton.EType.eRoot);
            FbxNode skelRootNode = FbxNode.Create(scene, "SkelRootNode");

            skelRootNode.SetNodeAttribute(skelRoot);
            skelRootNode.LclTranslation.Set(new FbxDouble3(0.0, -40.0, 0.0));

            // create skeleton limb nodes
            FbxSkeleton skelLimb1 = FbxSkeleton.Create(scene, "SkelLimb1");

            skelLimb1.SetSkeletonType(FbxSkeleton.EType.eLimbNode);
            skelLimb1.Size.Set(1.5);
            FbxNode skelLimbNode1 = FbxNode.Create(scene, "SkelLimbNode1");

            skelLimbNode1.SetNodeAttribute(skelLimb1);
            skelLimbNode1.LclTranslation.Set(new FbxDouble3(0.0, 40.0, 0.0));

            FbxSkeleton skelLimb2 = FbxSkeleton.Create(scene, "SkelLimb2");

            skelLimb2.SetSkeletonType(FbxSkeleton.EType.eLimbNode);
            skelLimb2.Size.Set(1.5);
            FbxNode skelLimbNode2 = FbxNode.Create(scene, "SkelLimbNode2");

            skelLimbNode2.SetNodeAttribute(skelLimb2);
            skelLimbNode2.LclTranslation.Set(new FbxDouble3(0.0, 40.0, 0.0));

            // build skeleton hierarchy
            skelRootNode.AddChild(skelLimbNode1);
            skelLimbNode1.AddChild(skelLimbNode2);

            return(skelRootNode);
        }
Пример #23
0
 public SkeletonExporter(FbxScene scene, FLVER2 flver, HKX.HKASkeleton hKASkeleton, List <DsBone> bones)
 {
     Scene            = scene;
     this.Flver       = flver;
     this.bones       = bones;
     this.hkaSkeleton = hKASkeleton;
 }
        protected override FbxScene CreateScene(FbxManager manager)
        {
            // Create a scene with a single node that has an animation clip
            // attached to it
            FbxScene scene = FbxScene.Create(manager, "myScene");

            FbxNode animNode = FbxNode.Create(scene, "animNode");

            // setup anim stack
            FbxAnimStack fbxAnimStack = CreateAnimStack(scene);

            // add an animation layer
            FbxAnimLayer fbxAnimLayer = FbxAnimLayer.Create(scene, "animBaseLayer");

            fbxAnimStack.AddMember(fbxAnimLayer);

            // set up the translation
            CreateAnimCurves(
                animNode, fbxAnimLayer, PropertyComponentList, (index) => { return(index * 2.0); }, (index) => { return(index * 3.0f - 1); }
                );

            // TODO: avoid needing to this by creating typemaps for
            //       FbxObject::GetSrcObjectCount and FbxCast.
            //       Not trivial to do as both fbxobject.i and fbxemitter.i
            //       have to be moved up before the ignore all statement
            //       to allow use of templates.
            scene.SetCurrentAnimationStack(fbxAnimStack);
            scene.GetRootNode().AddChild(animNode);
            return(scene);
        }
Пример #25
0
            /// <summary>
            /// if this game object is a model prefab then export with shared components
            /// </summary>
            protected void ExportInstance(GameObject unityGo, FbxNode fbxNode, FbxScene fbxScene)
            {
                PrefabType unityPrefabType = PrefabUtility.GetPrefabType(unityGo);

                if (unityPrefabType != PrefabType.PrefabInstance)
                {
                    return;
                }

                Object unityPrefabParent = PrefabUtility.GetPrefabParent(unityGo);

                if (Verbose)
                {
                    Debug.Log(string.Format("exporting instance {0}({1})", unityGo.name, unityPrefabParent.name));
                }

                FbxMesh fbxMesh = null;

                if (!SharedMeshes.TryGetValue(unityPrefabParent.name, out fbxMesh))
                {
                    fbxMesh = ExportMesh(GetMeshInfo(unityGo), fbxNode, fbxScene);
                    SharedMeshes [unityPrefabParent.name] = fbxMesh;
                }

                if (fbxMesh == null)
                {
                    return;
                }

                // set the fbxNode containing the mesh
                fbxNode.SetNodeAttribute(fbxMesh);
                fbxNode.SetShadingMode(FbxNode.EShadingMode.eWireFrame);

                return;
            }
        protected override void CheckScene(FbxScene scene)
        {
            FbxScene origScene = CreateScene(FbxManager);

            FbxNode origAnimNode   = origScene.GetRootNode().GetChild(0);
            FbxNode importAnimNode = scene.GetRootNode().GetChild(0);

            Assert.AreEqual(origScene.GetRootNode().GetChildCount(), scene.GetRootNode().GetChildCount());
            Assert.IsNotNull(origAnimNode);
            Assert.IsNotNull(importAnimNode);
            Assert.AreEqual(origAnimNode.GetName(), importAnimNode.GetName());

            FbxAnimStack origStack   = origScene.GetCurrentAnimationStack();
            FbxAnimStack importStack = scene.GetCurrentAnimationStack();

            CheckAnimStack(origStack, importStack);

            FbxAnimLayer origLayer   = origStack.GetAnimLayerMember();
            FbxAnimLayer importLayer = importStack.GetAnimLayerMember();

            Assert.IsNotNull(origLayer);
            Assert.IsNotNull(importLayer);

            Assert.AreEqual(FbxTime.EMode.eFrames30, scene.GetGlobalSettings().GetTimeMode());

            CheckAnimCurve(origAnimNode, importAnimNode, origLayer, importLayer, PropertyComponentList);
        }
        public void TestBasics()
        {
            var scene = FbxScene.Create(Manager, "scene");
            var node  = FbxNode.Create(scene, "node");

            /* Test all we can test with a non-composite curve node, namely one that points to
             * a lcl translation. */
            var animNode = FbxAnimCurveNode.CreateTypedCurveNode(node.LclTranslation, scene);

            Assert.IsFalse(animNode.IsComposite());
            Assert.AreEqual(3, animNode.GetChannelsCount());
            Assert.AreEqual(0, animNode.GetChannelIndex(Globals.FBXSDK_CURVENODE_COMPONENT_X));
            Assert.AreEqual(Globals.FBXSDK_CURVENODE_COMPONENT_Y, animNode.GetChannelName(1));

            var xcurve = animNode.CreateCurve(animNode.GetName(), Globals.FBXSDK_CURVENODE_COMPONENT_X);

            Assert.IsNotNull(xcurve);
            var xcurve2 = animNode.CreateCurve(animNode.GetName());

            Assert.IsNotNull(xcurve2);
            var ycurve = animNode.CreateCurve(animNode.GetName(), 1);

            Assert.IsNotNull(ycurve);

            animNode.SetChannelValue(Globals.FBXSDK_CURVENODE_COMPONENT_Z, 6);
            Assert.AreEqual(6, animNode.GetChannelValue(Globals.FBXSDK_CURVENODE_COMPONENT_Z, 0));
            Assert.AreEqual(6, animNode.GetChannelValue(2, 0));
            animNode.SetChannelValue(2, 0);

            Assert.AreEqual(2, animNode.GetCurveCount(0));
            Assert.AreEqual(1, animNode.GetCurveCount(1, animNode.GetName()));

            Assert.AreEqual(xcurve, animNode.GetCurve(0));
            Assert.AreEqual(xcurve2, animNode.GetCurve(0, 1));
            Assert.AreEqual(xcurve2, animNode.GetCurve(0, 1, animNode.GetName()));
            Assert.IsNull(animNode.GetCurve(1, 1));

            var key = xcurve.KeyAdd(FbxTime.FromSecondDouble(0));

            xcurve.KeySet(key, FbxTime.FromSecondDouble(0), 5);
            key = xcurve.KeyAdd(FbxTime.FromSecondDouble(1));
            xcurve.KeySet(key, FbxTime.FromSecondDouble(1), -5);

            Assert.IsTrue(animNode.IsAnimated());
            /* TODO: build a composite anim node and test this for real. */
            Assert.IsTrue(animNode.IsAnimated(true));

            var timespan = new FbxTimeSpan();

            Assert.IsTrue(animNode.GetAnimationInterval(timespan));
            Assert.AreEqual(FbxTime.FromSecondDouble(0), timespan.GetStart());
            Assert.AreEqual(FbxTime.FromSecondDouble(1), timespan.GetStop());

            /* Get a property that isn't a Double3; add a channel for it. */
            var boolNode = FbxAnimCurveNode.CreateTypedCurveNode(node.VisibilityInheritance, scene);

            Assert.IsFalse(boolNode.IsComposite());
            Assert.IsFalse(boolNode.IsAnimated());
            Assert.IsTrue(boolNode.AddChannel("vis", 1));
        }
Пример #28
0
 public void ConvertScene(FbxScene pScene)
 {
     NativeMethods.FbxAxisSystem_ConvertScene(swigCPtr, FbxScene.getCPtr(pScene));
     if (NativeMethods.SWIGPendingException.Pending)
     {
         throw NativeMethods.SWIGPendingException.Retrieve();
     }
 }
Пример #29
0
 public virtual void ReadBegin(FbxScene pScene)
 {
     FbxWrapperNativePINVOKE.FbxPlugin_ReadBegin(swigCPtr, FbxScene.getCPtr(pScene));
     if (FbxWrapperNativePINVOKE.SWIGPendingException.Pending)
     {
         throw FbxWrapperNativePINVOKE.SWIGPendingException.Retrieve();
     }
 }
Пример #30
0
 public bool Equals(FbxScene other)
 {
     if (object.ReferenceEquals(other, null))
     {
         return(false);
     }
     return(this.swigCPtr.Handle.Equals(other.swigCPtr.Handle));
 }