Exemple #1
0
        public void TestBasics()
        {
            // just make sure it doesn't crash
            new FbxTimeSpan();
            new FbxTimeSpan(FbxTime.FromFrame(1), FbxTime.FromFrame(2));

            // test dispose
            DisposeTester.TestDispose(new FbxTimeSpan());
            using (new FbxTimeSpan(FbxTime.FromFrame(1), FbxTime.FromFrame(2))) { }

            Assert.That(() => { new FbxTimeSpan(null, null); }, Throws.Exception.TypeOf <System.ArgumentNullException>());

            // test Set/Get
            FbxTimeSpan timeSpan = new FbxTimeSpan();

            timeSpan.Set(FbxTime.FromFrame(2), FbxTime.FromFrame(3));
            Assert.AreEqual(FbxTime.FromFrame(2), timeSpan.GetStart());
            Assert.AreEqual(FbxTime.FromFrame(3), timeSpan.GetStop());
            Assert.That(() => { timeSpan.Set(null, null); }, Throws.Exception.TypeOf <System.ArgumentNullException>());
            timeSpan.SetStart(FbxTime.FromFrame(1));
            Assert.AreEqual(FbxTime.FromFrame(1), timeSpan.GetStart());
            timeSpan.SetStop(FbxTime.FromFrame(4));
            Assert.AreEqual(FbxTime.FromFrame(4), timeSpan.GetStop());

            // test other functions
            Assert.AreEqual(FbxTime.FromFrame(3), timeSpan.GetDuration());
            Assert.AreEqual(FbxTime.FromFrame(3), timeSpan.GetSignedDuration());
            Assert.AreEqual(1, timeSpan.GetDirection());
            Assert.IsTrue(timeSpan.IsInside(FbxTime.FromFrame(2)));

            var timeSpan2 = new FbxTimeSpan(FbxTime.FromFrame(2), FbxTime.FromFrame(10));

            Assert.AreEqual(new FbxTimeSpan(FbxTime.FromFrame(2), FbxTime.FromFrame(4)), timeSpan.Intersect(timeSpan2));

            timeSpan.UnionAssignment(timeSpan2);
            Assert.AreEqual(new FbxTimeSpan(FbxTime.FromFrame(1), FbxTime.FromFrame(10)), timeSpan);

            new FbxTimeSpan(FbxTime.FromFrame(0), FbxTime.FromFrame(1)).UnionAssignment(timeSpan2, 1);
        }
        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());

                // 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);

                // 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 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>());
        }