public void AnimCurve_SingleKey_AllResultsSame() { // given: var ac = new FbxAnimCurve(""); FbxTime time; time = new FbxTime(100); var key = new FbxAnimCurveKey(time, 1.5f); ac.KeyAdd(time, key); double value; // when: time = new FbxTime(0); value = ac.Evaluate(time); // then: Assert.AreEqual(1.5, value); // when: time = new FbxTime(100); value = ac.Evaluate(time); // then: Assert.AreEqual(1.5, value); // when: time = new FbxTime(200); value = ac.Evaluate(time); // then: Assert.AreEqual(1.5, value); }
public void AnimCurveKey_SetTangentWeights_TangentWeightsGetSet() { // given: var key = new FbxAnimCurveKey(); key.SetTangentWeightMode(FbxAnimCurveDef.EWeightedMode.eWeightedAll); // require: Assert.AreEqual(FbxAnimCurveDef.EWeightedMode.eWeightedAll, key.GetTangentWeightMode()); Assert.AreEqual(FbxAnimCurveDef.sDEFAULT_WEIGHT, key.GetDataFloat(FbxAnimCurveDef.EDataIndex.eRightWeight)); Assert.AreEqual(FbxAnimCurveDef.sDEFAULT_WEIGHT, key.GetDataFloat(FbxAnimCurveDef.EDataIndex.eNextLeftWeight)); // when: key.SetTangentWeightAndAdjustTangent(FbxAnimCurveDef.EDataIndex.eRightWeight, 0.234f); // then: Assert.AreEqual(0.234f, key.GetDataFloat(FbxAnimCurveDef.EDataIndex.eRightWeight), 0.0001f); Assert.AreEqual(FbxAnimCurveDef.sDEFAULT_WEIGHT, key.GetDataFloat(FbxAnimCurveDef.EDataIndex.eNextLeftWeight)); // when: key.SetTangentWeightAndAdjustTangent(FbxAnimCurveDef.EDataIndex.eNextLeftWeight, 0.567f); // then: Assert.AreEqual(0.234f, key.GetDataFloat(FbxAnimCurveDef.EDataIndex.eRightWeight), 0.0001f); Assert.AreEqual(0.567f, key.GetDataFloat(FbxAnimCurveDef.EDataIndex.eNextLeftWeight), 0.0001f); }
public FbxAnimCurveKey(FbxAnimCurveKey pFKey) : this(FbxWrapperNativePINVOKE.new_FbxAnimCurveKey__SWIG_3(FbxAnimCurveKey.getCPtr(pFKey)), true) { if (FbxWrapperNativePINVOKE.SWIGPendingException.Pending) { throw FbxWrapperNativePINVOKE.SWIGPendingException.Retrieve(); } }
public void AnimCurve_ThreeKeyVaryInTime_EvaluationsAreCorrect() { // given: var ac = new FbxAnimCurve(""); FbxTime time; FbxAnimCurveKey key; time = new FbxTime(-150); key = new FbxAnimCurveKey(time, 0.0f); ac.KeyAdd(time, key); time = new FbxTime(1100); key = new FbxAnimCurveKey(time, 1.0f); ac.KeyAdd(time, key); time = new FbxTime(1900); key = new FbxAnimCurveKey(time, 2.0f); ac.KeyAdd(time, key); // then: time = new FbxTime(-200); Assert.AreEqual(0.000000f, ac.Evaluate(time), 0.000001); time = new FbxTime(-150); Assert.AreEqual(0.000000f, ac.Evaluate(time), 0.000001); time = new FbxTime(-100); Assert.AreEqual(0.039663f, ac.Evaluate(time), 0.000001); time = new FbxTime(0); Assert.AreEqual(0.117218f, ac.Evaluate(time), 0.000001); time = new FbxTime(100); Assert.AreEqual(0.192976f, ac.Evaluate(time), 0.000001); time = new FbxTime(200); Assert.AreEqual(0.267609f, ac.Evaluate(time), 0.000001); time = new FbxTime(333); Assert.AreEqual(0.366290f, ac.Evaluate(time), 0.000001); time = new FbxTime(500); Assert.AreEqual(0.491509f, ac.Evaluate(time), 0.000001); time = new FbxTime(666); Assert.AreEqual(0.620321f, ac.Evaluate(time), 0.000001); time = new FbxTime(900); Assert.AreEqual(0.815218f, ac.Evaluate(time), 0.000001); time = new FbxTime(1000); Assert.AreEqual(0.905136f, ac.Evaluate(time), 0.000001); time = new FbxTime(1100); Assert.AreEqual(1.000000f, ac.Evaluate(time), 0.000001); time = new FbxTime(1200); Assert.AreEqual(1.103992f, ac.Evaluate(time), 0.000001); time = new FbxTime(1333); Assert.AreEqual(1.259135f, ac.Evaluate(time), 0.000001); time = new FbxTime(1654); Assert.AreEqual(1.678126f, ac.Evaluate(time), 0.000001); time = new FbxTime(1800); Assert.AreEqual(1.871999f, ac.Evaluate(time), 0.000001); time = new FbxTime(1900); Assert.AreEqual(2.000000f, ac.Evaluate(time), 0.000001); time = new FbxTime(2000); Assert.AreEqual(2.000000f, ac.Evaluate(time), 0.000001); time = new FbxTime(2100); Assert.AreEqual(2.000000f, ac.Evaluate(time), 0.000001); time = new FbxTime(2300); Assert.AreEqual(2.000000f, ac.Evaluate(time), 0.000001); }
public void AnimCurve_ThreeKeyVaryInValue_EvaluationsAreCorrect() { // given: var ac = new FbxAnimCurve(""); FbxTime time; FbxAnimCurveKey key; time = new FbxTime(0); key = new FbxAnimCurveKey(time, -0.23f); ac.KeyAdd(time, key); time = new FbxTime(1000); key = new FbxAnimCurveKey(time, 1.6724f); ac.KeyAdd(time, key); time = new FbxTime(2000); key = new FbxAnimCurveKey(time, 1.11645f); ac.KeyAdd(time, key); // then: time = new FbxTime(-200); Assert.AreEqual(-0.230000f, ac.Evaluate(time), 0.000001); time = new FbxTime(-150); Assert.AreEqual(-0.230000f, ac.Evaluate(time), 0.000001); time = new FbxTime(-100); Assert.AreEqual(-0.230000f, ac.Evaluate(time), 0.000001); time = new FbxTime(0); Assert.AreEqual(-0.230000f, ac.Evaluate(time), 0.000001); time = new FbxTime(100); Assert.AreEqual(-0.028697f, ac.Evaluate(time), 0.000001); time = new FbxTime(200); Assert.AreEqual(0.189814f, ac.Evaluate(time), 0.000001); time = new FbxTime(333); Assert.AreEqual(0.494413f, ac.Evaluate(time), 0.000001); time = new FbxTime(500); Assert.AreEqual(0.874847f, ac.Evaluate(time), 0.000001); time = new FbxTime(666); Assert.AreEqual(1.219098f, ac.Evaluate(time), 0.000001); time = new FbxTime(900); Assert.AreEqual(1.581723f, ac.Evaluate(time), 0.000001); time = new FbxTime(1000); Assert.AreEqual(1.672400f, ac.Evaluate(time), 0.000001); time = new FbxTime(1100); Assert.AreEqual(1.716368f, ac.Evaluate(time), 0.000001); time = new FbxTime(1200); Assert.AreEqual(1.718544f, ac.Evaluate(time), 0.000001); time = new FbxTime(1333); Assert.AreEqual(1.669369f, ac.Evaluate(time), 0.000001); time = new FbxTime(1654); Assert.AreEqual(1.405046f, ac.Evaluate(time), 0.000001); time = new FbxTime(1800); Assert.AreEqual(1.266974f, ac.Evaluate(time), 0.000001); time = new FbxTime(1900); Assert.AreEqual(1.183107f, ac.Evaluate(time), 0.000001); time = new FbxTime(2000); Assert.AreEqual(1.116450f, ac.Evaluate(time), 0.000001); time = new FbxTime(2100); Assert.AreEqual(1.116450f, ac.Evaluate(time), 0.000001); time = new FbxTime(2300); Assert.AreEqual(1.116450f, ac.Evaluate(time), 0.000001); }
public void AnimCurve_TwoKeyVaryInTime_EvaluationsAreCorrect() { // given: var ac = new FbxAnimCurve(""); FbxTime time; FbxAnimCurveKey key; time = new FbxTime(100); key = new FbxAnimCurveKey(time, 0.0f); ac.KeyAdd(time, key); time = new FbxTime(1300); key = new FbxAnimCurveKey(time, 1.0f); ac.KeyAdd(time, key); // then: time = new FbxTime(-200); Assert.AreEqual(0.0f, ac.Evaluate(time), 0.000001); time = new FbxTime(-100); Assert.AreEqual(0.0f, ac.Evaluate(time), 0.000001); time = new FbxTime(0); Assert.AreEqual(0.0f, ac.Evaluate(time), 0.000001); time = new FbxTime(100); Assert.AreEqual(0.0f, ac.Evaluate(time), 0.000001); time = new FbxTime(200); Assert.AreEqual(0.0833333f, ac.Evaluate(time), 0.000001); time = new FbxTime(250); Assert.AreEqual(0.125f, ac.Evaluate(time), 0.000001); time = new FbxTime(300); Assert.AreEqual(0.166667, ac.Evaluate(time), 0.000001); time = new FbxTime(333); Assert.AreEqual(0.194167f, ac.Evaluate(time), 0.000001); time = new FbxTime(400); Assert.AreEqual(0.25f, ac.Evaluate(time), 0.000001); time = new FbxTime(500); Assert.AreEqual(0.333333f, ac.Evaluate(time), 0.000001); time = new FbxTime(600); Assert.AreEqual(0.416667f, ac.Evaluate(time), 0.000001); time = new FbxTime(666); Assert.AreEqual(0.471667f, ac.Evaluate(time), 0.000001); time = new FbxTime(700); Assert.AreEqual(0.5f, ac.Evaluate(time), 0.000001); time = new FbxTime(750); Assert.AreEqual(0.541667, ac.Evaluate(time), 0.000001); time = new FbxTime(800); Assert.AreEqual(0.583333f, ac.Evaluate(time), 0.000001); time = new FbxTime(900); Assert.AreEqual(0.666667f, ac.Evaluate(time), 0.000001); time = new FbxTime(1000); Assert.AreEqual(0.75f, ac.Evaluate(time), 0.000001); time = new FbxTime(1100); Assert.AreEqual(0.833333f, ac.Evaluate(time), 0.000001); time = new FbxTime(1200); Assert.AreEqual(0.916667f, ac.Evaluate(time), 0.000001); time = new FbxTime(1300); Assert.AreEqual(1.0f, ac.Evaluate(time), 0.000001); time = new FbxTime(1400); Assert.AreEqual(1.0f, ac.Evaluate(time), 0.000001); }
public FbxAnimCurveKey assign(FbxAnimCurveKey pFKey) { FbxAnimCurveKey ret = new FbxAnimCurveKey(FbxWrapperNativePINVOKE.FbxAnimCurveKey_assign(swigCPtr, FbxAnimCurveKey.getCPtr(pFKey)), false); if (FbxWrapperNativePINVOKE.SWIGPendingException.Pending) { throw FbxWrapperNativePINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public virtual FbxAnimCurveKey KeyGet(int pIndex) { FbxAnimCurveKey ret = new FbxAnimCurveKey(NativeMethods.FbxAnimCurve_KeyGet(swigCPtr, pIndex), true); if (NativeMethods.SWIGPendingException.Pending) { throw NativeMethods.SWIGPendingException.Retrieve(); } return(ret); }
public void AnimCurve_TwoKeyVaryInValue_EvaluationsAreCorrect() { // given: var ac = new FbxAnimCurve(""); FbxTime time; FbxAnimCurveKey key; time = new FbxTime(0); key = new FbxAnimCurveKey(time, -0.1f); ac.KeyAdd(time, key); time = new FbxTime(1000); key = new FbxAnimCurveKey(time, 2.3f); ac.KeyAdd(time, key); // then: time = new FbxTime(-200); Assert.AreEqual(-0.1f, ac.Evaluate(time), 0.000001); time = new FbxTime(-100); Assert.AreEqual(-0.1f, ac.Evaluate(time), 0.000001); time = new FbxTime(0); Assert.AreEqual(-0.1f, ac.Evaluate(time), 0.000001); time = new FbxTime(100); Assert.AreEqual(0.14f, ac.Evaluate(time), 0.00001); time = new FbxTime(200); Assert.AreEqual(0.38f, ac.Evaluate(time), 0.00001); time = new FbxTime(250); Assert.AreEqual(0.5f, ac.Evaluate(time), 0.00001); time = new FbxTime(300); Assert.AreEqual(0.62f, ac.Evaluate(time), 0.00001); time = new FbxTime(333); Assert.AreEqual(0.6992f, ac.Evaluate(time), 0.00000001); time = new FbxTime(400); Assert.AreEqual(0.86f, ac.Evaluate(time), 0.00001); time = new FbxTime(500); Assert.AreEqual(1.1f, ac.Evaluate(time), 0.00001); time = new FbxTime(600); Assert.AreEqual(1.34f, ac.Evaluate(time), 0.00001); time = new FbxTime(666); Assert.AreEqual(1.4984f, ac.Evaluate(time), 0.00001); time = new FbxTime(700); Assert.AreEqual(1.58f, ac.Evaluate(time), 0.00001); time = new FbxTime(750); Assert.AreEqual(1.7, ac.Evaluate(time), 0.00001); time = new FbxTime(800); Assert.AreEqual(1.82f, ac.Evaluate(time), 0.00001); time = new FbxTime(900); Assert.AreEqual(2.06, ac.Evaluate(time), 0.00001); time = new FbxTime(1000); Assert.AreEqual(2.3f, ac.Evaluate(time), 0.000001); time = new FbxTime(1100); Assert.AreEqual(2.3f, ac.Evaluate(time), 0.000001); time = new FbxTime(1200); Assert.AreEqual(2.3f, ac.Evaluate(time), 0.000001); }
public void AnimCurve_TwoKeyBasic_EvaluationsAreCorrect() { // given: var ac = new FbxAnimCurve(""); FbxTime time; FbxAnimCurveKey key; time = new FbxTime(0); key = new FbxAnimCurveKey(time, 0.0f); ac.KeyAdd(time, key); time = new FbxTime(1000); key = new FbxAnimCurveKey(time, 1.0f); ac.KeyAdd(time, key); // then: time = new FbxTime(-200); Assert.AreEqual(0.0f, ac.Evaluate(time), 0.000001); time = new FbxTime(-100); Assert.AreEqual(0.0f, ac.Evaluate(time), 0.000001); time = new FbxTime(0); Assert.AreEqual(0.0f, ac.Evaluate(time), 0.000001); time = new FbxTime(100); Assert.AreEqual(0.1f, ac.Evaluate(time), 0.00001); time = new FbxTime(200); Assert.AreEqual(0.2f, ac.Evaluate(time), 0.00001); time = new FbxTime(250); Assert.AreEqual(0.25, ac.Evaluate(time), 0.00001); time = new FbxTime(300); Assert.AreEqual(0.3f, ac.Evaluate(time), 0.00001); time = new FbxTime(333); Assert.AreEqual(0.333f, ac.Evaluate(time), 0.00001); time = new FbxTime(400); Assert.AreEqual(0.4f, ac.Evaluate(time), 0.00001); time = new FbxTime(500); Assert.AreEqual(0.5f, ac.Evaluate(time), 0.00001); time = new FbxTime(600); Assert.AreEqual(0.6f, ac.Evaluate(time), 0.00001); time = new FbxTime(666); Assert.AreEqual(0.666f, ac.Evaluate(time), 0.00001); time = new FbxTime(700); Assert.AreEqual(0.7f, ac.Evaluate(time), 0.00001); time = new FbxTime(750); Assert.AreEqual(0.75f, ac.Evaluate(time), 0.000001); time = new FbxTime(800); Assert.AreEqual(0.8f, ac.Evaluate(time), 0.000001); time = new FbxTime(900); Assert.AreEqual(0.9f, ac.Evaluate(time), 0.000001); time = new FbxTime(1000); Assert.AreEqual(1.0f, ac.Evaluate(time), 0.000001); time = new FbxTime(1100); Assert.AreEqual(1.0f, ac.Evaluate(time), 0.000001); time = new FbxTime(1200); Assert.AreEqual(1.0f, ac.Evaluate(time), 0.000001); }
public void AnimCurve_ThreeKeyBasic_EvaluationsAreCorrect() { // given: var ac = new FbxAnimCurve(""); FbxTime time; FbxAnimCurveKey key; time = new FbxTime(0); key = new FbxAnimCurveKey(time, 0.0f); ac.KeyAdd(time, key); time = new FbxTime(1000); key = new FbxAnimCurveKey(time, 1.0f); ac.KeyAdd(time, key); time = new FbxTime(2000); key = new FbxAnimCurveKey(time, 2.0f); ac.KeyAdd(time, key); // then: time = new FbxTime(-200); Assert.AreEqual(0.000000f, ac.Evaluate(time), 0.000001); time = new FbxTime(-100); Assert.AreEqual(0.000000f, ac.Evaluate(time), 0.000001); time = new FbxTime(0); Assert.AreEqual(0.000000f, ac.Evaluate(time), 0.000001); time = new FbxTime(100); Assert.AreEqual(0.100000f, ac.Evaluate(time), 0.000001); time = new FbxTime(200); Assert.AreEqual(0.200000f, ac.Evaluate(time), 0.000001); time = new FbxTime(333); Assert.AreEqual(0.333000f, ac.Evaluate(time), 0.000001); time = new FbxTime(500); Assert.AreEqual(0.500000f, ac.Evaluate(time), 0.000001); time = new FbxTime(666); Assert.AreEqual(0.666000f, ac.Evaluate(time), 0.000001); time = new FbxTime(900); Assert.AreEqual(0.900000f, ac.Evaluate(time), 0.000001); time = new FbxTime(1000); Assert.AreEqual(1.000000f, ac.Evaluate(time), 0.000001); time = new FbxTime(1100); Assert.AreEqual(1.100000f, ac.Evaluate(time), 0.000001); time = new FbxTime(1333); Assert.AreEqual(1.333000f, ac.Evaluate(time), 0.000001); time = new FbxTime(1654); Assert.AreEqual(1.654000f, ac.Evaluate(time), 0.000001); time = new FbxTime(1900); Assert.AreEqual(1.900000f, ac.Evaluate(time), 0.000001); time = new FbxTime(2000); Assert.AreEqual(2.000000f, ac.Evaluate(time), 0.000001); time = new FbxTime(2100); Assert.AreEqual(2.000000f, ac.Evaluate(time), 0.000001); time = new FbxTime(2300); Assert.AreEqual(2.000000f, ac.Evaluate(time), 0.000001); }
public void AnimCurveKey_Create_HasDefaultValues() { // when: var key = new FbxAnimCurveKey(); // then: Assert.AreEqual(0L, key.GetTime().Get()); Assert.AreEqual(0.0, key.GetValue()); Assert.AreEqual(FbxAnimCurveDef.ETangentMode.eTangentAuto, key.GetTangentMode()); Assert.AreEqual(FbxAnimCurveDef.EInterpolationType.eInterpolationCubic, key.GetInterpolation()); Assert.AreEqual(FbxAnimCurveDef.EWeightedMode.eWeightedNone, key.GetTangentWeightMode()); Assert.AreEqual(FbxAnimCurveDef.EConstantMode.eConstantNext, key.GetConstantMode()); Assert.AreEqual(FbxAnimCurveDef.EVelocityMode.eVelocityNone, key.GetTangentVelocityMode()); Assert.AreEqual(FbxAnimCurveDef.ETangentVisibility.eTangentShowNone, key.GetTangentVisibility()); Assert.True(!key.GetBreak()); }
//ToDo : ??? Только для одного Layer грузить? Хотя у Layers должны быть одинаковые отсчеты времени, если они должны смешиваться? static void LoadKeyFrames(AnimationTrackInfo animationTrack, FbxPropertyTFbxDouble3 transformProperty, HashSet <double> keyFrames, string xChannelName, string yChannelName, string zChannelName) { for (int i = 0; i < animationTrack.GetLayerCount(); i++) { FbxAnimLayer pAnimLayer = animationTrack.GetLayer(i); FbxAnimCurve pAnimCurve = null; pAnimCurve = transformProperty.GetCurve(pAnimLayer, xChannelName); if (pAnimCurve != null) { for (int j = 0; j < pAnimCurve.KeyGetCount(); j++) { FbxAnimCurveKey key = pAnimCurve.KeyGet(j); //ToDo :? Учитывать key.GetInterpolation(); double time = key.GetTime().GetSecondDouble(); keyFrames.Add(time); } } pAnimCurve = transformProperty.GetCurve(pAnimLayer, yChannelName); if (pAnimCurve != null) { for (int j = 0; j < pAnimCurve.KeyGetCount(); j++) { FbxAnimCurveKey key = pAnimCurve.KeyGet(j); double time = key.GetTime().GetSecondDouble(); keyFrames.Add(time); } } pAnimCurve = transformProperty.GetCurve(pAnimLayer, zChannelName); if (pAnimCurve != null) { for (int j = 0; j < pAnimCurve.KeyGetCount(); j++) { FbxAnimCurveKey key = pAnimCurve.KeyGet(j); double time = key.GetTime().GetSecondDouble(); keyFrames.Add(time); } } } }
public void AnimCurveKey_SetWeightLeftThenRight_WeightIsAll() { // given: var key = new FbxAnimCurveKey(); // require: Assert.AreEqual(FbxAnimCurveDef.EWeightedMode.eWeightedNone, key.GetTangentWeightMode()); // when: key.SetTangentWeightMode(FbxAnimCurveDef.EWeightedMode.eWeightedNextLeft); // then: Assert.AreEqual(FbxAnimCurveDef.EWeightedMode.eWeightedNextLeft, key.GetTangentWeightMode()); // when: key.SetTangentWeightMode(FbxAnimCurveDef.EWeightedMode.eWeightedRight, FbxAnimCurveDef.EWeightedMode.eWeightedRight); // then: Assert.AreEqual(FbxAnimCurveDef.EWeightedMode.eWeightedAll, key.GetTangentWeightMode()); }
public void Property_AttachCurveNode_IsAnimated() { // given: var node = new FbxNode("node"); var acn = new FbxAnimCurveNode("acn"); var x = new FbxAnimCurve("x"); var scene = new FbxScene("scene"); var layer = new FbxAnimLayer("layer"); var stack = new FbxAnimStack("stack"); var time = new FbxTime(0); var key = new FbxAnimCurveKey(time, 1.0f); x.KeyAdd(time, key); scene.ConnectSrcObject(node); scene.ConnectSrcObject(acn); scene.ConnectSrcObject(x); scene.ConnectSrcObject(layer); scene.ConnectSrcObject(stack); layer.ConnectSrcObject(acn); stack.ConnectSrcObject(layer); acn.AddChannel <double>("x", 1.0); acn.ConnectToChannel(x, 0U); // require: Assert.False(node.LclTranslation.IsAnimated()); // when: node.LclTranslation.ConnectSrcObject(acn); // then: Assert.True(node.LclTranslation.IsAnimated()); }
public void TestBasics() { var scene = FbxScene.Create(Manager, "scene"); using (FbxAnimCurve curve = FbxAnimCurve.Create(scene, "curve")) { // test KeyModifyBegin (make sure it doesn't crash) curve.KeyModifyBegin(); // test KeyAdd int last = 0; int index = curve.KeyAdd(FbxTime.FromFrame(5), ref last); Assert.GreaterOrEqual(index, 0); // test KeyAdd null FbxTime Assert.That(() => { curve.KeyAdd(null); }, Throws.Exception.TypeOf <System.ArgumentNullException>()); Assert.That(() => { curve.KeyAdd(null, ref last); }, Throws.Exception.TypeOf <System.ArgumentNullException>()); // test KeySet FbxTime keyTime = FbxTime.FromSecondDouble(3); curve.KeySet(index, keyTime, 5); // test KeyGetValue, KeyGetTime, KeyGetCount Assert.AreEqual(5, curve.KeyGetValue(index)); Assert.AreEqual(keyTime, curve.KeyGetTime(index)); Assert.AreEqual(1, curve.KeyGetCount()); // test don't crash FbxAnimCurveKey key = curve.KeyGet(index); Assert.That(key, Is.Not.Null); // make sure none of the variations crash curve.KeySet(index, new FbxTime(), 5, FbxAnimCurveDef.EInterpolationType.eInterpolationConstant ); curve.KeySet(index, new FbxTime(), 0, FbxAnimCurveDef.EInterpolationType.eInterpolationCubic, FbxAnimCurveDef.ETangentMode.eTangentAuto ); curve.KeySet(index, new FbxTime(), 0, FbxAnimCurveDef.EInterpolationType.eInterpolationCubic, FbxAnimCurveDef.ETangentMode.eTangentAuto, 4 ); curve.KeySet(index, new FbxTime(), 0, FbxAnimCurveDef.EInterpolationType.eInterpolationCubic, FbxAnimCurveDef.ETangentMode.eTangentAuto, 0, 3); curve.KeySet(index, new FbxTime(), 0, FbxAnimCurveDef.EInterpolationType.eInterpolationCubic, FbxAnimCurveDef.ETangentMode.eTangentAuto, 0, 0, FbxAnimCurveDef.EWeightedMode.eWeightedAll); curve.KeySet(index, new FbxTime(), 0, FbxAnimCurveDef.EInterpolationType.eInterpolationCubic, FbxAnimCurveDef.ETangentMode.eTangentAuto, 0, 0, FbxAnimCurveDef.EWeightedMode.eWeightedAll, 0); curve.KeySet(index, new FbxTime(), 0, FbxAnimCurveDef.EInterpolationType.eInterpolationCubic, FbxAnimCurveDef.ETangentMode.eTangentAuto, 0, 0, FbxAnimCurveDef.EWeightedMode.eWeightedAll, 0, 0); curve.KeySet(index, new FbxTime(), 0, FbxAnimCurveDef.EInterpolationType.eInterpolationCubic, FbxAnimCurveDef.ETangentMode.eTangentAuto, 0, 0, FbxAnimCurveDef.EWeightedMode.eWeightedAll, 0, 0, 0); curve.KeySet(index, new FbxTime(), 0, FbxAnimCurveDef.EInterpolationType.eInterpolationCubic, FbxAnimCurveDef.ETangentMode.eTangentAuto, 0, 0, FbxAnimCurveDef.EWeightedMode.eWeightedAll, 0, 0, 0, 0); // more setter test curve.KeySetTangentMode(index, FbxAnimCurveDef.ETangentMode.eTangentUser); Assert.That(curve.KeyGetTangentMode(index), Is.EqualTo(FbxAnimCurveDef.ETangentMode.eTangentUser)); curve.KeySetTangentMode(index, FbxAnimCurveDef.ETangentMode.eTangentGenericBreak); Assert.That(curve.KeyGetTangentMode(index), Is.EqualTo(FbxAnimCurveDef.ETangentMode.eTangentGenericBreak)); // test settings key parameters key.SetTangentMode(FbxAnimCurveDef.ETangentMode.eTangentUser); // Set break is only meaningful if tangent is eTangentAuto or eTangentUser key.SetBreak(true); Assert.True(key.GetBreak()); key.SetDataFloat(FbxAnimCurveDef.EDataIndex.eRightSlope, 1.0f); Assert.That(key.GetDataFloat(FbxAnimCurveDef.EDataIndex.eRightSlope), Is.EqualTo(1.0f).Within(float.Epsilon)); key.SetBreak(false); Assert.False(key.GetBreak()); // key.SetTangentWeightMode(FbxAnimCurveDef.EWeightedMode.eWeightedAll); key.SetTangentWeightMode(FbxAnimCurveDef.EWeightedMode.eWeightedAll, FbxAnimCurveDef.EWeightedMode.eWeightedAll); Assert.That(key.GetTangentWeightMode(), Is.EqualTo(FbxAnimCurveDef.EWeightedMode.eWeightedAll)); // key.SetBreak(true); key.SetTangentWeightAndAdjustTangent(FbxAnimCurveDef.EDataIndex.eRightSlope, 1.0); key.SetTangentWeightAndAdjustTangent(FbxAnimCurveDef.EDataIndex.eNextLeftSlope, 1.0); key.SetTangentWeightAndAdjustTangent(FbxAnimCurveDef.EDataIndex.eWeights, 1.0); key.SetTangentWeightAndAdjustTangent(FbxAnimCurveDef.EDataIndex.eRightWeight, 1.0); key.SetTangentWeightAndAdjustTangent(FbxAnimCurveDef.EDataIndex.eNextLeftWeight, 1.0); key.SetBreak(false); // key.SetTangentVelocityMode(FbxAnimCurveDef.EVelocityMode.eVelocityAll); key.SetTangentVelocityMode(FbxAnimCurveDef.EVelocityMode.eVelocityAll, FbxAnimCurveDef.EVelocityMode.eVelocityAll); Assert.That(key.GetTangentVelocityMode(), Is.EqualTo(FbxAnimCurveDef.EVelocityMode.eVelocityAll)); // key.SetTangentVisibility(FbxAnimCurveDef.ETangentVisibility.eTangentShowLeft); Assert.That(key.GetTangentVisibility(), Is.EqualTo(FbxAnimCurveDef.ETangentVisibility.eTangentShowLeft)); // test KeyModifyEnd (make sure it doesn't crash) curve.KeyModifyEnd(); } // Also test that the AnimCurveBase can't be created. Assert.That(() => FbxAnimCurveBase.Create(Manager, ""), Throws.Exception.TypeOf <System.NotImplementedException>()); Assert.That(() => FbxAnimCurveBase.Create(FbxObject.Create(Manager, ""), ""), Throws.Exception.TypeOf <System.NotImplementedException>()); }
public void Property_MultipleStacks_GetCurveNodeOnlyGetsCurvesOnTheCurrentStack() { // given: var node = new FbxNode("node"); var scene = new FbxScene("scene"); var acn1 = new FbxAnimCurveNode("acn1"); var ac1 = new FbxAnimCurve("ac1"); var layer1 = new FbxAnimLayer("layer1"); var stack1 = new FbxAnimStack("stack1"); var acn2 = new FbxAnimCurveNode("acn2"); var ac2 = new FbxAnimCurve("ac2"); var layer2 = new FbxAnimLayer("layer2"); var stack2 = new FbxAnimStack("stack2"); var time = new FbxTime(0); var key = new FbxAnimCurveKey(time, 1.0f); ac1.KeyAdd(time, key); var time2 = new FbxTime(0); var key2 = new FbxAnimCurveKey(time2, 1.0f); ac2.KeyAdd(time2, key2); scene.ConnectSrcObject(node); scene.ConnectSrcObject(acn1); scene.ConnectSrcObject(ac1); scene.ConnectSrcObject(layer1); scene.ConnectSrcObject(stack1); scene.ConnectSrcObject(acn2); scene.ConnectSrcObject(ac2); scene.ConnectSrcObject(layer2); scene.ConnectSrcObject(stack2); acn1.AddChannel <double>("x", 1.0); acn1.ConnectToChannel(ac1, 0U); layer1.ConnectSrcObject(acn1); stack1.ConnectSrcObject(layer1); acn2.AddChannel <double>("y", -1.0); acn2.ConnectToChannel(ac2, 0U); layer2.ConnectSrcObject(acn2); stack2.ConnectSrcObject(layer2); scene.SetCurrentAnimationStack(stack1); node.LclTranslation.ConnectSrcObject(acn1); node.LclRotation.ConnectSrcObject(acn2); // require: Assert.AreSame(stack1, scene.GetCurrentAnimationStack()); Assert.AreSame(acn1, node.LclTranslation.GetCurveNode()); Assert.Null(node.LclRotation.GetCurveNode()); // when: scene.SetCurrentAnimationStack(stack2); // then: Assert.Null(node.LclTranslation.GetCurveNode()); Assert.AreSame(acn2, node.LclRotation.GetCurveNode()); }
void Run() { FbxManager manager = FbxManager.Create(); FbxIOSettings setting = FbxIOSettings.Create(manager, "IOSRoot"); manager.SetIOSettings(setting); FbxImporter impoter = FbxImporter.Create(manager, ""); bool status = impoter.Initialize(@"D:\develop\FbxWrapper\1.fbx", -1, setting); Log.Info(status); if (!status) { return; } FbxScene scene = FbxScene.Create(manager, "scene1"); status = impoter.Import(scene); Log.Info(status); int numTrack = scene.GetSrcObjectCount(FbxAnimStack.ClassId); Log.Info("num stack " + numTrack); FbxObject obj = scene.GetSrcObject(FbxAnimStack.ClassId, 0); FbxAnimStack stack = FbxAnimStack.Cast(obj); if (stack == null) { Log.Error("can not get anim stack!"); return; } FbxCriteria cri = FbxCriteria.ObjectTypeStrict(FbxAnimLayer.ClassId); int numLayer = stack.GetMemberCount(cri); Log.Info("anim layer count : " + numLayer); FbxAnimLayer layer = null; if (numLayer > 0) { FbxObject layerobj = stack.GetMember(cri, 0); layer = FbxAnimLayer.Cast(layerobj); if (layer == null) { Log.Error("anim layer is null!"); return; } Log.Info("anim layer name " + layer.GetName()); } Log.Info("node count " + scene.GetNodeCount()); for (int i = 0; i < scene.GetNodeCount(); i++) { FbxNode node = scene.GetNode(i); Log.Info("node " + i + " " + node.GetName()); if (node.LclTranslation.IsAnimated(layer)) { FbxAnimCurveNode curveNode = node.LclTranslation.GetCurveNode(layer); if (curveNode == null) { Log.Error("curve node is null"); } else { for (int c = 0; c < curveNode.GetCurveCount(0); c++) { FbxAnimCurve curve = curveNode.GetCurve(0, (uint)c); if (curve != null) { Log.Info("curve " + curve.GetName()); Log.Info("key count " + curve.KeyGetCount()); FbxAnimCurveKey key = curve.KeyGet(0); FbxTime t = key.GetTime(); Log.Info("key " + t.GetTimeString() + " value " + key.GetValue()); } } } } if (node.GetNodeAttribute() != null) { Log.Info("got attribu"); FbxNodeAttribute att = node.GetNodeAttribute(); PrintAttribute(att); } else { Log.Info("att count " + node.GetNodeAttributeCount()); for (int j = 0; j < node.GetNodeAttributeCount(); j++) { FbxNodeAttribute att = node.GetNodeAttributeByIndex(j); PrintAttribute(att); } } FbxVector4 rot = node.GetPostRotation(FbxNode.EPivotSet.eSourcePivot); FbxQuaternion q; } }
void Run() { FbxManager manager = FbxManager.Create(); FbxIOSettings setting = FbxIOSettings.Create(manager, "IOSRoot"); //fbxiosettingspath.h //PostProcessSteps.CalculateTangentSpace = #define EXP_TANGENTSPACE EXP_GEOMETRY "|" IOSN_TANGENTS_BINORMALS //PostProcessSteps.JoinIdenticalVertices = #define IOSN_DXF_WELD_VERTICES "WeldVertices" //PostProcessSteps.Triangulate = #define IOSN_TRIANGULATE "Triangulate" //PostProcessSteps.RemoveComponent = //PostProcessSteps.GenerateSmoothNormals = //setting.AddProperty() setting.SetBoolProp("Import|AdvOptGrp|Dxf|WeldVertices", true); setting.SetBoolProp("Triangulate", true); manager.SetIOSettings(setting); FbxImporter impoter = FbxImporter.Create(manager, ""); bool status = impoter.Initialize(@"1.fbx", -1, setting); Log.Info(status); if (!status) { return; } FbxScene scene = FbxScene.Create(manager, "scene1"); status = impoter.Import(scene); Log.Info(status); int numTrack = scene.GetSrcObjectCount(FbxCriteria.ObjectType(FbxAnimStack.ClassId)); Log.Info("num stack " + numTrack); FbxObject obj = scene.GetSrcObject(FbxCriteria.ObjectType(FbxAnimStack.ClassId), 0); FbxAnimStack stack = FbxAnimStack.Cast(obj); if (stack == null) { Log.Error("can not get anim stack!"); return; } FbxCriteria cri = FbxCriteria.ObjectTypeStrict(FbxAnimLayer.ClassId); int numLayer = stack.GetMemberCount(cri); Log.Info("anim layer count : " + numLayer); FbxAnimLayer layer = null; if (numLayer > 0) { FbxObject layerobj = stack.GetMember(cri, 0); layer = FbxAnimLayer.Cast(layerobj); if (layer == null) { Log.Error("anim layer is null!"); return; } Log.Info("anim layer name " + layer.GetName()); } Log.Info("node count " + scene.GetNodeCount()); for (int i = 0; i < scene.GetNodeCount(); i++) { FbxNode node = scene.GetNode(i); Log.Info("node " + i + " " + node.GetName() + " ChildCount:" + node.GetChildCount()); //---------------- //node.LclTranslation.IsAnimated //---------------- //ToDo : if (node.LclTranslation.IsAnimated(layer)) { FbxAnimCurveNode curveNode = node.LclTranslation.GetCurveNode(layer); if (curveNode == null) { Log.Error("curve node is null"); } else { for (int c = 0; c < curveNode.GetCurveCount(0); c++) { FbxAnimCurve curve = curveNode.GetCurve(0, (uint)c); if (curve != null) { Log.Info("curve " + curve.GetName()); Log.Info("key count " + curve.KeyGetCount()); FbxAnimCurveKey key = curve.KeyGet(0); FbxTime t = key.GetTime(); Log.Info("key " + t.GetTimeString() + " value " + key.GetValue()); } } } } if (node.GetNodeAttribute() != null) { Log.Info("got attribu"); FbxNodeAttribute att = node.GetNodeAttribute(); PrintAttribute(manager, att); } else { Log.Info("att count " + node.GetNodeAttributeCount()); for (int j = 0; j < node.GetNodeAttributeCount(); j++) { FbxNodeAttribute att = node.GetNodeAttributeByIndex(j); PrintAttribute(manager, att); } } FbxVector4 rot = node.GetPostRotation(FbxNode.EPivotSet.eSourcePivot); FbxQuaternion q; } }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(FbxAnimCurveKey obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }
public void AnimCurve_Evaluate() { // given: var ac = new FbxAnimCurve(""); FbxTime time; time = new FbxTime(100); var key = new FbxAnimCurveKey(time, 1.5f); ac.KeyAdd(time, key); FbxTime time2; time2 = new FbxTime(10000); var key2 = new FbxAnimCurveKey(time2, 2.3f); ac.KeyAdd(time2, key2); double value; // when: time = new FbxTime(0); value = ac.Evaluate(time); // then: Assert.AreEqual(1.5f, value); // when: time = new FbxTime(100); value = ac.Evaluate(time); // then: Assert.AreEqual(1.5f, value); // when: time = new FbxTime(500); value = ac.Evaluate(time); // then: Assert.AreEqual(1.53232f, value, 0.00001f); // when: time = new FbxTime(9000); value = ac.Evaluate(time); // then: Assert.AreEqual(2.21919f, value, 0.00001f); // when: time = new FbxTime(10000); value = ac.Evaluate(time); // then: Assert.AreEqual(2.3f, value); // when: time = new FbxTime(11000); value = ac.Evaluate(time); // then: Assert.AreEqual(2.3f, value); }
public virtual FbxAnimCurveKey KeyGet(int pIndex) { FbxAnimCurveKey ret = new FbxAnimCurveKey(fbx_wrapperPINVOKE.FbxAnimCurve_KeyGet(swigCPtr, pIndex), true); return(ret); }