public void AnimCurve_SingleKey_AllResultsSame() { // given: var ac = new AnimCurve(""); FbxTime time; time = new FbxTime(100); var key = new AnimCurveKey(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 AnimCurveKey(); key.SetTangentWeightMode(AnimCurveDef.EWeightedMode.eWeightedAll); // require: Assert.AreEqual(AnimCurveDef.EWeightedMode.eWeightedAll, key.GetTangentWeightMode()); Assert.AreEqual(AnimCurveDef.sDEFAULT_WEIGHT, key.GetDataFloat(AnimCurveDef.EDataIndex.eRightWeight)); Assert.AreEqual(AnimCurveDef.sDEFAULT_WEIGHT, key.GetDataFloat(AnimCurveDef.EDataIndex.eNextLeftWeight)); // when: key.SetTangentWeightAndAdjustTangent(AnimCurveDef.EDataIndex.eRightWeight, 0.234f); // then: Assert.AreEqual(0.234f, key.GetDataFloat(AnimCurveDef.EDataIndex.eRightWeight), 0.0001f); Assert.AreEqual(AnimCurveDef.sDEFAULT_WEIGHT, key.GetDataFloat(AnimCurveDef.EDataIndex.eNextLeftWeight)); // when: key.SetTangentWeightAndAdjustTangent(AnimCurveDef.EDataIndex.eNextLeftWeight, 0.567f); // then: Assert.AreEqual(0.234f, key.GetDataFloat(AnimCurveDef.EDataIndex.eRightWeight), 0.0001f); Assert.AreEqual(0.567f, key.GetDataFloat(AnimCurveDef.EDataIndex.eNextLeftWeight), 0.0001f); }
public void AnimCurve_ThreeKeyVaryInValue_EvaluationsAreCorrect() { // given: var ac = new AnimCurve(""); FbxTime time; AnimCurveKey key; time = new FbxTime(0); key = new AnimCurveKey(time, -0.23f); ac.KeyAdd(time, key); time = new FbxTime(1000); key = new AnimCurveKey(time, 1.6724f); ac.KeyAdd(time, key); time = new FbxTime(2000); key = new AnimCurveKey(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_ThreeKeyVaryInTime_EvaluationsAreCorrect() { // given: var ac = new AnimCurve(""); FbxTime time; AnimCurveKey key; time = new FbxTime(-150); key = new AnimCurveKey(time, 0.0f); ac.KeyAdd(time, key); time = new FbxTime(1100); key = new AnimCurveKey(time, 1.0f); ac.KeyAdd(time, key); time = new FbxTime(1900); key = new AnimCurveKey(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_TwoKeyVaryInTime_EvaluationsAreCorrect() { // given: var ac = new AnimCurve(""); FbxTime time; AnimCurveKey key; time = new FbxTime(100); key = new AnimCurveKey(time, 0.0f); ac.KeyAdd(time, key); time = new FbxTime(1300); key = new AnimCurveKey(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 void AnimCurve_TwoKeyVaryInValue_EvaluationsAreCorrect() { // given: var ac = new AnimCurve(""); FbxTime time; AnimCurveKey key; time = new FbxTime(0); key = new AnimCurveKey(time, -0.1f); ac.KeyAdd(time, key); time = new FbxTime(1000); key = new AnimCurveKey(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 AnimCurve(""); FbxTime time; AnimCurveKey key; time = new FbxTime(0); key = new AnimCurveKey(time, 0.0f); ac.KeyAdd(time, key); time = new FbxTime(1000); key = new AnimCurveKey(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 AnimCurve(""); FbxTime time; AnimCurveKey key; time = new FbxTime(0); key = new AnimCurveKey(time, 0.0f); ac.KeyAdd(time, key); time = new FbxTime(1000); key = new AnimCurveKey(time, 1.0f); ac.KeyAdd(time, key); time = new FbxTime(2000); key = new AnimCurveKey(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 AnimCurveKey(); // then: Assert.AreEqual(0L, key.GetTime().Get()); Assert.AreEqual(0.0, key.GetValue()); Assert.AreEqual(AnimCurveDef.ETangentMode.eTangentAuto, key.GetTangentMode()); Assert.AreEqual(AnimCurveDef.EInterpolationType.eInterpolationCubic, key.GetInterpolation()); Assert.AreEqual(AnimCurveDef.EWeightedMode.eWeightedNone, key.GetTangentWeightMode()); Assert.AreEqual(AnimCurveDef.EConstantMode.eConstantNext, key.GetConstantMode()); Assert.AreEqual(AnimCurveDef.EVelocityMode.eVelocityNone, key.GetTangentVelocityMode()); Assert.AreEqual(AnimCurveDef.ETangentVisibility.eTangentShowNone, key.GetTangentVisibility()); Assert.True(!key.GetBreak()); }
public void AnimCurveKey_SetWeightLeftThenRight_WeightIsAll() { // given: var key = new AnimCurveKey(); // require: Assert.AreEqual(AnimCurveDef.EWeightedMode.eWeightedNone, key.GetTangentWeightMode()); // when: key.SetTangentWeightMode(AnimCurveDef.EWeightedMode.eWeightedNextLeft); // then: Assert.AreEqual(AnimCurveDef.EWeightedMode.eWeightedNextLeft, key.GetTangentWeightMode()); // when: key.SetTangentWeightMode(AnimCurveDef.EWeightedMode.eWeightedRight, AnimCurveDef.EWeightedMode.eWeightedRight); // then: Assert.AreEqual(AnimCurveDef.EWeightedMode.eWeightedAll, key.GetTangentWeightMode()); }
public void Property_AttachCurveNode_IsAnimated() { // given: var node = new Node("node"); var acn = new AnimCurveNode("acn"); var x = new AnimCurve("x"); var scene = new Scene("scene"); var layer = new AnimLayer("layer"); var stack = new AnimStack("stack"); var time = new FbxTime(0); var key = new AnimCurveKey(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 Property_MultipleStacks_GetCurveNodeOnlyGetsCurvesOnTheCurrentStack() { // given: var node = new Node("node"); var scene = new Scene("scene"); var acn1 = new AnimCurveNode("acn1"); var ac1 = new AnimCurve("ac1"); var layer1 = new AnimLayer("layer1"); var stack1 = new AnimStack("stack1"); var acn2 = new AnimCurveNode("acn2"); var ac2 = new AnimCurve("ac2"); var layer2 = new AnimLayer("layer2"); var stack2 = new AnimStack("stack2"); var time = new FbxTime(0); var key = new AnimCurveKey(time, 1.0f); ac1.KeyAdd(time, key); var time2 = new FbxTime(0); var key2 = new AnimCurveKey(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()); }
public void AnimCurve_Evaluate() { // given: var ac = new AnimCurve(""); FbxTime time; time = new FbxTime(100); var key = new AnimCurveKey(time, 1.5f); ac.KeyAdd(time, key); FbxTime time2; time2 = new FbxTime(10000); var key2 = new AnimCurveKey(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); }