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));
        }
Exemplo n.º 2
0
 public bool Equals(FbxTimeSpan other)
 {
     if (object.ReferenceEquals(other, null))
     {
         return(false);
     }
     return(_equals(other));
 }
Exemplo n.º 3
0
 public void GetTimelineDefaultTimeSpan(FbxTimeSpan pTimeSpan)
 {
     FbxWrapperNativePINVOKE.FbxGlobalSettings_GetTimelineDefaultTimeSpan(swigCPtr, FbxTimeSpan.getCPtr(pTimeSpan));
     if (FbxWrapperNativePINVOKE.SWIGPendingException.Pending)
     {
         throw FbxWrapperNativePINVOKE.SWIGPendingException.Retrieve();
     }
 }
Exemplo n.º 4
0
 public void UnionAssignment(FbxTimeSpan pSpan, int pDirection)
 {
     FbxWrapperNativePINVOKE.FbxTimeSpan_UnionAssignment__SWIG_0(swigCPtr, FbxTimeSpan.getCPtr(pSpan), pDirection);
     if (FbxWrapperNativePINVOKE.SWIGPendingException.Pending)
     {
         throw FbxWrapperNativePINVOKE.SWIGPendingException.Retrieve();
     }
 }
Exemplo n.º 5
0
 public void SetLocalTimeSpan(FbxTimeSpan pTimeSpan)
 {
     FbxWrapperNativePINVOKE.FbxAnimStack_SetLocalTimeSpan(swigCPtr, FbxTimeSpan.getCPtr(pTimeSpan));
     if (FbxWrapperNativePINVOKE.SWIGPendingException.Pending)
     {
         throw FbxWrapperNativePINVOKE.SWIGPendingException.Retrieve();
     }
 }
Exemplo n.º 6
0
 public void SetReferenceTimeSpan(FbxTimeSpan pTimeSpan)
 {
     fbx_wrapperPINVOKE.FbxAnimStack_SetReferenceTimeSpan(swigCPtr, FbxTimeSpan.getCPtr(pTimeSpan));
     if (fbx_wrapperPINVOKE.SWIGPendingException.Pending)
     {
         throw fbx_wrapperPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Exemplo n.º 7
0
 public void UnionAssignment(FbxTimeSpan pSpan)
 {
     NativeMethods.FbxTimeSpan_UnionAssignment__SWIG_1(swigCPtr, FbxTimeSpan.getCPtr(pSpan));
     if (NativeMethods.SWIGPendingException.Pending)
     {
         throw NativeMethods.SWIGPendingException.Retrieve();
     }
 }
 public void SetLocalTimeSpan(FbxTimeSpan pTimeSpan)
 {
     NativeMethods.FbxAnimStack_SetLocalTimeSpan(swigCPtr, FbxTimeSpan.getCPtr(pTimeSpan));
     if (NativeMethods.SWIGPendingException.Pending)
     {
         throw NativeMethods.SWIGPendingException.Retrieve();
     }
 }
Exemplo n.º 9
0
 public void SetTimelineDefaultTimeSpan(FbxTimeSpan pTimeSpan)
 {
     fbx_wrapperPINVOKE.FbxGlobalSettings_SetTimelineDefaultTimeSpan(swigCPtr, FbxTimeSpan.getCPtr(pTimeSpan));
     if (fbx_wrapperPINVOKE.SWIGPendingException.Pending)
     {
         throw fbx_wrapperPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Exemplo n.º 10
0
 public void UnionAssignment(FbxTimeSpan pSpan)
 {
     fbx_wrapperPINVOKE.FbxTimeSpan_UnionAssignment__SWIG_1(swigCPtr, FbxTimeSpan.getCPtr(pSpan));
     if (fbx_wrapperPINVOKE.SWIGPendingException.Pending)
     {
         throw fbx_wrapperPINVOKE.SWIGPendingException.Retrieve();
     }
 }
Exemplo n.º 11
0
        public bool eq(FbxTimeSpan pTime)
        {
            bool ret = fbx_wrapperPINVOKE.FbxTimeSpan_eq(swigCPtr, FbxTimeSpan.getCPtr(pTime));

            if (fbx_wrapperPINVOKE.SWIGPendingException.Pending)
            {
                throw fbx_wrapperPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Exemplo n.º 12
0
        private bool _equals(FbxTimeSpan pTime)
        {
            bool ret = NativeMethods.FbxTimeSpan__equals(swigCPtr, FbxTimeSpan.getCPtr(pTime));

            if (NativeMethods.SWIGPendingException.Pending)
            {
                throw NativeMethods.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Exemplo n.º 13
0
        public FbxTimeSpan Intersect(FbxTimeSpan pTime)
        {
            FbxTimeSpan ret = new FbxTimeSpan(NativeMethods.FbxTimeSpan_Intersect(swigCPtr, FbxTimeSpan.getCPtr(pTime)), true);

            if (NativeMethods.SWIGPendingException.Pending)
            {
                throw NativeMethods.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Exemplo n.º 14
0
        public bool GetAnimationInterval(FbxTimeSpan pTimeInterval)
        {
            bool ret = NativeMethods.FbxAnimCurveNode_GetAnimationInterval(swigCPtr, FbxTimeSpan.getCPtr(pTimeInterval));

            if (NativeMethods.SWIGPendingException.Pending)
            {
                throw NativeMethods.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Exemplo n.º 15
0
        public FbxTimeSpan Intersect(FbxTimeSpan pTime)
        {
            FbxTimeSpan ret = new FbxTimeSpan(fbx_wrapperPINVOKE.FbxTimeSpan_Intersect(swigCPtr, FbxTimeSpan.getCPtr(pTime)), true);

            if (fbx_wrapperPINVOKE.SWIGPendingException.Pending)
            {
                throw fbx_wrapperPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Exemplo n.º 16
0
        public bool ne(FbxTimeSpan pTime)
        {
            bool ret = FbxWrapperNativePINVOKE.FbxTimeSpan_ne(swigCPtr, FbxTimeSpan.getCPtr(pTime));

            if (FbxWrapperNativePINVOKE.SWIGPendingException.Pending)
            {
                throw FbxWrapperNativePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Exemplo n.º 17
0
        public FbxTimeSpan GetLocalTimeSpan()
        {
            FbxTimeSpan ret = new FbxTimeSpan(NativeMethods.FbxAnimStack_GetLocalTimeSpan(swigCPtr), true);

            if (NativeMethods.SWIGPendingException.Pending)
            {
                throw NativeMethods.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Exemplo n.º 18
0
        public override bool GetTimeInterval(FbxTimeSpan pTimeInterval)
        {
            bool ret = fbx_wrapperPINVOKE.FbxAnimCurve_GetTimeInterval(swigCPtr, FbxTimeSpan.getCPtr(pTimeInterval));

            if (fbx_wrapperPINVOKE.SWIGPendingException.Pending)
            {
                throw fbx_wrapperPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Exemplo n.º 19
0
        public virtual bool GetTimeInterval(FbxTimeSpan pTimeInterval)
        {
            bool ret = FbxWrapperNativePINVOKE.FbxAnimCurveBase_GetTimeInterval(swigCPtr, FbxTimeSpan.getCPtr(pTimeInterval));

            if (FbxWrapperNativePINVOKE.SWIGPendingException.Pending)
            {
                throw FbxWrapperNativePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Exemplo n.º 20
0
        public void TestBasics()
        {
            using (var animStack = CreateObject("anim stack")) {
                FbxCollectionTest.GenericTests(animStack, Manager);

                // test description
                animStack.Description.Set("this is an anim stack");
                Assert.AreEqual("this is an anim stack", animStack.Description.Get());

                // test SetLocalTimeSpan (make sure it doesn't crash)
                animStack.SetLocalTimeSpan(new FbxTimeSpan());

                // test GetLocalTimeSpan
                FbxTimeSpan timeSpan = animStack.GetLocalTimeSpan();
                Assert.IsInstanceOf <FbxTimeSpan> (timeSpan);

                // test SetLocalTimeSpan with null
                Assert.That(() => { animStack.SetLocalTimeSpan(null); }, Throws.Exception.TypeOf <System.ArgumentNullException>());
            }
        }
Exemplo n.º 21
0
        public FbxTimeSpan GetLocalTimeSpan()
        {
            FbxTimeSpan ret = new FbxTimeSpan(FbxWrapperNativePINVOKE.FbxAnimStack_GetLocalTimeSpan(swigCPtr), true);

            return(ret);
        }
Exemplo n.º 22
0
        public FbxTimeSpan GetReferenceTimeSpan()
        {
            FbxTimeSpan ret = new FbxTimeSpan(fbx_wrapperPINVOKE.FbxAnimStack_GetReferenceTimeSpan(swigCPtr), true);

            return(ret);
        }
Exemplo n.º 23
0
    void ExportAnimSequenceToFbx(AnimSequence AnimSeq,
                                 ref List <FbxNode> BoneNodes,
                                 FbxAnimLayer InAnimLayer,
                                 float AnimStartOffset,
                                 float AnimEndOffset,
                                 float AnimPlayRate,
                                 float StartTime)
    {
        if (AnimSeq.SequenceLength == 0)
        {
            return;
        }

        FbxTime ExportedStartTime = new FbxTime();
        FbxTime ExportedStopTime  = new FbxTime();

        if (IsNearlyEqual(AnimSeq.FrameRate, DEFAULT_SAMPLERATE, 1.0f))
        {
            FbxTime.SetGlobalTimeMode(FbxTime.EMode.eFrames30);
            //FbxTime.SetGlobalTimeMode(FbxTime.EMode.eFrames30);
        }
        else
        {
            FbxTime.SetGlobalTimeMode(FbxTime.EMode.eCustom, AnimSeq.FrameRate);
            //ExportedStopTime.SetGlobalTimeMode(FbxTime::eCustom, FrameRate);
        }

        ExportedStartTime.SetSecondDouble(0.0f);
        ExportedStopTime.SetSecondDouble(AnimSeq.SequenceLength);
        FbxTimeSpan ExportedTimeSpan = new FbxTimeSpan();

        ExportedTimeSpan.Set(ExportedStartTime, ExportedStopTime);
        AnimStack.SetLocalTimeSpan(ExportedTimeSpan);


        // Add the animation data to the bone nodes
        for (int BoneIndex = 0; BoneIndex < BoneNodes.Count; ++BoneIndex)
        {
            FbxNode CurrentBoneNode = BoneNodes[BoneIndex];
            // Create the AnimCurves
            int            NumberOfCurves = 9;
            FbxAnimCurve[] Curves         = new FbxAnimCurve[NumberOfCurves];

            Curves[0] = CurrentBoneNode.LclTranslation.GetCurve(InAnimLayer, "X", true);
            Curves[1] = CurrentBoneNode.LclTranslation.GetCurve(InAnimLayer, "Y", true);
            Curves[2] = CurrentBoneNode.LclTranslation.GetCurve(InAnimLayer, "Z", true);

            Curves[3] = CurrentBoneNode.LclRotation.GetCurve(InAnimLayer, "X", true);
            Curves[4] = CurrentBoneNode.LclRotation.GetCurve(InAnimLayer, "Y", true);
            Curves[5] = CurrentBoneNode.LclRotation.GetCurve(InAnimLayer, "Z", true);

            Curves[6] = CurrentBoneNode.LclScaling.GetCurve(InAnimLayer, "X", true);
            Curves[7] = CurrentBoneNode.LclScaling.GetCurve(InAnimLayer, "Y", true);
            Curves[8] = CurrentBoneNode.LclScaling.GetCurve(InAnimLayer, "Z", true);

            float AnimTime    = AnimStartOffset;
            float AnimEndTime = (AnimSeq.SequenceLength - AnimEndOffset);
            // Subtracts 1 because NumFrames includes an initial pose for 0.0 second
            float   TimePerKey        = AnimSeq.StepFrame;
            float   AnimTimeIncrement = TimePerKey * AnimPlayRate;
            FbxTime ExportTime        = new FbxTime();
            ExportTime.SetSecondDouble(StartTime);

            FbxTime ExportTimeIncrement = new FbxTime();
            ExportTimeIncrement.SetSecondDouble(TimePerKey);


            //int BoneTreeIndex = Skeleton.GetSkeletonBoneIndexFromMeshBoneIndex(SkelMesh, BoneIndex);
            //int BoneTrackIndex = Skeleton.GetAnimationTrackIndex(BoneTreeIndex, AnimSeq, true);
            //if (BoneTrackIndex == INDEX_NONE)
            //{
            //    // If this sequence does not have a track for the current bone, then skip it
            //    continue;
            //}

            foreach (FbxAnimCurve Curve in Curves)
            {
                Curve.KeyModifyBegin();
            }

            bool bLastKey   = false;
            int  FrameIndex = 0;
            foreach (var v in AnimSeq.animationFames)
            {
                int lKeyIndex;
                FrameIndex++;
                if (FrameIndex == AnimSeq.animationFames.Count)
                {
                    bLastKey = true;
                }

                BoneTransformInfo BoneAtom = v[BoneIndex].BoneTransform;

                FbxDouble3    Translation = FbxDataConverter.ConvertToFbxPos(BoneAtom.position);
                FbxDouble3    Rotation    = FbxDataConverter.ConvertToFbxRot(BoneAtom.rotation);
                FbxDouble3    Scale       = FbxDataConverter.ConvertToFbxScale(BoneAtom.scale);
                FbxDouble3 [] Vectors     = new FbxDouble3[3] {
                    Translation, Rotation, Scale
                };

                // Loop over each curve and channel to set correct values
                for (int CurveIndex = 0; CurveIndex < 3; ++CurveIndex)
                {
                    for (int ChannelIndex = 0; ChannelIndex < 3; ++ChannelIndex)
                    {
                        int OffsetCurveIndex = (CurveIndex * 3) + ChannelIndex;

                        lKeyIndex = Curves[OffsetCurveIndex].KeyAdd(ExportTime);

                        Curves[OffsetCurveIndex].KeySetValue(lKeyIndex, (float)Vectors[CurveIndex].getDataValue(ChannelIndex));
                        Curves[OffsetCurveIndex].KeySetInterpolation(lKeyIndex, bLastKey ? FbxAnimCurveDef.EInterpolationType.eInterpolationConstant : FbxAnimCurveDef.EInterpolationType.eInterpolationCubic);

                        if (bLastKey)
                        {
                            Curves[OffsetCurveIndex].KeySetConstantMode(lKeyIndex, FbxAnimCurveDef.EConstantMode.eConstantStandard);
                        }
                    }
                }

                ExportTime = ExportTime.add(ExportTimeIncrement);
            }


            while (!bLastKey)
            {
                //FTransform BoneAtom;
                //AnimSeq.GetBoneTransform(BoneAtom, BoneTrackIndex, AnimTime, true);

                //FbxVector4 Translation = Converter.ConvertToFbxPos(BoneAtom.GetTranslation());
                //FbxVector4 Rotation = Converter.ConvertToFbxRot(BoneAtom.GetRotation().Euler());
                //FbxVector4 Scale = Converter.ConvertToFbxScale(BoneAtom.GetScale3D());
                //FbxVector4 Vectors[3] = { Translation, Rotation, Scale };

                //int lKeyIndex;

                //bLastKey = AnimTime >= AnimEndTime;

                //// Loop over each curve and channel to set correct values
                //for (uint CurveIndex = 0; CurveIndex < 3; ++CurveIndex)
                //{
                //    for (uint ChannelIndex = 0; ChannelIndex < 3; ++ChannelIndex)
                //    {
                //        uint OffsetCurveIndex = (CurveIndex * 3) + ChannelIndex;

                //        lKeyIndex = Curves[OffsetCurveIndex].KeyAdd(ExportTime);
                //        Curves[OffsetCurveIndex].KeySetValue(lKeyIndex, Vectors[CurveIndex][ChannelIndex]);
                //        Curves[OffsetCurveIndex].KeySetInterpolation(lKeyIndex, bLastKey ? FbxAnimCurveDef::eInterpolationConstant : FbxAnimCurveDef::eInterpolationCubic);

                //        if (bLastKey)
                //        {
                //            Curves[OffsetCurveIndex].KeySetConstantMode(lKeyIndex, FbxAnimCurveDef::eConstantStandard);
                //        }
                //    }
                //}

                //ExportTime += ExportTimeIncrement;
                //AnimTime += AnimTimeIncrement;
            }

            foreach (FbxAnimCurve Curve in Curves)
            {
                Curve.KeyModifyEnd();
            }
        }
    }
Exemplo n.º 24
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(FbxTimeSpan obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }