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)); }
public bool Equals(FbxTimeSpan other) { if (object.ReferenceEquals(other, null)) { return(false); } return(_equals(other)); }
public void GetTimelineDefaultTimeSpan(FbxTimeSpan pTimeSpan) { FbxWrapperNativePINVOKE.FbxGlobalSettings_GetTimelineDefaultTimeSpan(swigCPtr, FbxTimeSpan.getCPtr(pTimeSpan)); if (FbxWrapperNativePINVOKE.SWIGPendingException.Pending) { throw FbxWrapperNativePINVOKE.SWIGPendingException.Retrieve(); } }
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(); } }
public void SetLocalTimeSpan(FbxTimeSpan pTimeSpan) { FbxWrapperNativePINVOKE.FbxAnimStack_SetLocalTimeSpan(swigCPtr, FbxTimeSpan.getCPtr(pTimeSpan)); if (FbxWrapperNativePINVOKE.SWIGPendingException.Pending) { throw FbxWrapperNativePINVOKE.SWIGPendingException.Retrieve(); } }
public void SetReferenceTimeSpan(FbxTimeSpan pTimeSpan) { fbx_wrapperPINVOKE.FbxAnimStack_SetReferenceTimeSpan(swigCPtr, FbxTimeSpan.getCPtr(pTimeSpan)); if (fbx_wrapperPINVOKE.SWIGPendingException.Pending) { throw fbx_wrapperPINVOKE.SWIGPendingException.Retrieve(); } }
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(); } }
public void SetTimelineDefaultTimeSpan(FbxTimeSpan pTimeSpan) { fbx_wrapperPINVOKE.FbxGlobalSettings_SetTimelineDefaultTimeSpan(swigCPtr, FbxTimeSpan.getCPtr(pTimeSpan)); if (fbx_wrapperPINVOKE.SWIGPendingException.Pending) { throw fbx_wrapperPINVOKE.SWIGPendingException.Retrieve(); } }
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(); } }
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); }
private bool _equals(FbxTimeSpan pTime) { bool ret = NativeMethods.FbxTimeSpan__equals(swigCPtr, FbxTimeSpan.getCPtr(pTime)); if (NativeMethods.SWIGPendingException.Pending) { throw NativeMethods.SWIGPendingException.Retrieve(); } return(ret); }
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); }
public bool GetAnimationInterval(FbxTimeSpan pTimeInterval) { bool ret = NativeMethods.FbxAnimCurveNode_GetAnimationInterval(swigCPtr, FbxTimeSpan.getCPtr(pTimeInterval)); if (NativeMethods.SWIGPendingException.Pending) { throw NativeMethods.SWIGPendingException.Retrieve(); } return(ret); }
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); }
public bool ne(FbxTimeSpan pTime) { bool ret = FbxWrapperNativePINVOKE.FbxTimeSpan_ne(swigCPtr, FbxTimeSpan.getCPtr(pTime)); if (FbxWrapperNativePINVOKE.SWIGPendingException.Pending) { throw FbxWrapperNativePINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public FbxTimeSpan GetLocalTimeSpan() { FbxTimeSpan ret = new FbxTimeSpan(NativeMethods.FbxAnimStack_GetLocalTimeSpan(swigCPtr), true); if (NativeMethods.SWIGPendingException.Pending) { throw NativeMethods.SWIGPendingException.Retrieve(); } return(ret); }
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); }
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); }
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>()); } }
public FbxTimeSpan GetLocalTimeSpan() { FbxTimeSpan ret = new FbxTimeSpan(FbxWrapperNativePINVOKE.FbxAnimStack_GetLocalTimeSpan(swigCPtr), true); return(ret); }
public FbxTimeSpan GetReferenceTimeSpan() { FbxTimeSpan ret = new FbxTimeSpan(fbx_wrapperPINVOKE.FbxAnimStack_GetReferenceTimeSpan(swigCPtr), true); return(ret); }
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(); } } }
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); }