Esempio n. 1
0
        public void GameobjectTranslation(
            [NUnit.Framework.Range(0, 10, 5)] int x,
            [NUnit.Framework.Range(0, 10, 5)] int y,
            [NUnit.Framework.Range(0, 10, 5)] int z)
        {
            ISpline3DPlane spline = PrepareSpline();

            Assume.That(spline is MonoBehaviour, "Test isn't valid for this spline");

            float3 a = new float3(0f, 0f, 0f);

            spline.AddControlPoint(a);
            float3 b = new float3(10f, 0f, 0f);

            spline.AddControlPoint(b);

            Assert.AreEqual(2, spline.ControlPointCount);

            // make sure everything is where it's supposed to be
            TestHelpers.CheckFloat3(a, spline.Get3DPointWorld(0f));
            TestHelpers.CheckFloat3(b, spline.Get3DPointWorld(1f));
            TestHelpers.CheckFloat2(a.xy, spline.Get2DPointWorld(0f));
            TestHelpers.CheckFloat2(b.xy, spline.Get2DPointWorld(1f));

            // move the gameobject
            float3 pos = new float3(x, y, z);

            MoveGameobject(spline, pos);

            // check that the spline has moved accordingly
            TestHelpers.CheckFloat3(a + pos, spline.Get3DPointWorld(0f));
            TestHelpers.CheckFloat3(b + pos, spline.Get3DPointWorld(1f));
            TestHelpers.CheckFloat2((a + pos).xy, spline.Get2DPointWorld(0f));
            TestHelpers.CheckFloat2((b + pos).xy, spline.Get2DPointWorld(1f));
        }
Esempio n. 2
0
        public void Rotation()
        {
            ISpline3DPlane spline = PrepareSpline();

            float3 a = new float3(10f, 5f, 0f);

            spline.AddControlPoint(a);
            TestHelpers.CheckFloat3(a, spline.Get3DPointWorld(0f));
            TestHelpers.CheckFloat2(a.xy, spline.Get2DPointWorld(0f));

            {
                // rotate a little bit
                Quaternion targetRotation = Quaternion.Euler(0f, 90f, 0f);
                spline.Forward = targetRotation;

                TestHelpers.CheckFloat3(new float3(0f, 5f, -10f), spline.Get3DPointWorld(0f));
                TestHelpers.CheckFloat2(a.xy, spline.Get2DPointWorld(0f));
            }
            {
                // Go back to the original orientation
                Quaternion targetRotation = Quaternion.Euler(0f, 0f, 0f);
                spline.Forward = targetRotation;

                TestHelpers.CheckFloat3(a, spline.Get3DPointWorld(0f));
                TestHelpers.CheckFloat2(a.xy, spline.Get2DPointWorld(0f));
            }
        }
Esempio n. 3
0
        public void GameobjectAxisTranslationRotation(
            [NUnit.Framework.Range(0, 10, 5)] int x,
            [NUnit.Framework.Range(0, 10, 5)] int y,
            [NUnit.Framework.Range(0, 10, 5)] int z,
            [NUnit.Framework.Range(-90, 90, 45)] int yRotation)
        {
            ISpline3DPlane spline = PrepareSpline();

            Assume.That(spline is MonoBehaviour, "Test isn't valid for this spline");

            float3 a = new float3(0f, 0f, 0f);

            spline.AddControlPoint(a);
            float3 b = new float3(10f, 0f, 0f);

            spline.AddControlPoint(b);

            Assert.AreEqual(2, spline.ControlPointCount);

            // make sure everything is where it's supposed to be
            TestHelpers.CheckFloat3(a, spline.Get3DPointWorld(0f));
            TestHelpers.CheckFloat2(a.xy, spline.Get2DPointWorld(0f));
            TestHelpers.CheckFloat3(b, spline.Get3DPointWorld(1f));
            TestHelpers.CheckFloat2(b.xy, spline.Get2DPointWorld(1f));

            // move the gameobject
            float3 pos = new float3(x, y, z);

            MoveGameobject(spline, pos);

            // check that the spline has moved accordingly
            TestHelpers.CheckFloat3(a + pos, spline.Get3DPointWorld(0f));
            TestHelpers.CheckFloat3(b + pos, spline.Get3DPointWorld(1f));

            {
                // rotate a little bit
                Quaternion targetRotation = Quaternion.Euler(0f, yRotation, 0f);
                spline.Forward = targetRotation;
                TestHelpers.CheckFloat3(pos + ((float3)(targetRotation * a)), spline.Get3DPointWorld(0f));
                TestHelpers.CheckFloat3(pos + ((float3)(targetRotation * b)), spline.Get3DPointWorld(1f));
            }
        }