Exemple #1
0
        public void TestGetDistanceFromLoftForward(float distance, float expected)
        {
            var loft = new Lofts.LinearPath(Vector3.zero, new Vector3(0, 0, 10));

            var aiPath = new DummyAIPath(loft)
            {
                PathOffsetStart = 2,
                PathOffsetEnd   = 5,
            };

            var result = aiPath.GetDistanceFromLoftPath(distance);


            Assert.AreEqual(expected, result);
        }
Exemple #2
0
        public void TestBackward()
        {
            var loft = new Lofts.LinearPath(Vector3.zero, new Vector3(0, 0, 10));

            var aiPath = new DummyAIPath(loft)
            {
                PathOffsetStart = 1,
                PathOffsetEnd   = 2,
                SideOffsetStart = 3,
                SideOffsetEnd   = 4,
                Reverse         = true
            };

            Assert.AreEqual(10 - aiPath.PathOffsetEnd, aiPath.GetStartPathOffset());
            Assert.AreEqual(aiPath.PathOffsetStart, aiPath.GetEndPathOffset());
            Assert.AreEqual(aiPath.SideOffsetEnd, aiPath.GetStartSideOffset());
            Assert.AreEqual(aiPath.SideOffsetStart, aiPath.GetEndSideOffset());

            var startTransform = aiPath.GetTransform(0);

            Assert.AreEqual(new Vector3(4, 0, 8), startTransform.MultiplyPoint3x4(Vector3.zero));

            var endTransform = aiPath.GetTransform(aiPath.GetLength());

            Assert.AreEqual(new Vector3(3, 0, 1), endTransform.MultiplyPoint3x4(Vector3.zero));

            startTransform = aiPath.GetStartTransform();
            Assert.AreEqual(new Vector3(4, 0, 8), startTransform.MultiplyPoint3x4(Vector3.zero));

            endTransform = aiPath.GetEndTransform();
            Assert.AreEqual(new Vector3(3, 0, 1), endTransform.MultiplyPoint3x4(Vector3.zero));


            Assert.AreEqual(7, aiPath.GetLength());

            var halfLength = 3.5f;

            var halfTransform = aiPath.GetTransform(halfLength);

            Assert.AreEqual(new Vector3(3.5f, 0, 4.5f), halfTransform.MultiplyPoint3x4(Vector3.zero));

            Assert.AreEqual(new Vector3(0, 0, -1), halfTransform.MultiplyVector(Vector3.forward));
        }
Exemple #3
0
        public void TestEndTransform()
        {
            var loft = new Lofts.LinearPath(Vector3.zero, new Vector3(0, 0, 10));

            var aiPath = new DummyAIPath(loft)
            {
                PathOffsetStart = 1,
                PathOffsetEnd   = 2,
                SideOffsetStart = 3,
                SideOffsetEnd   = 4,
                Reverse         = false
            };


            var end      = aiPath.GetEndTransform().MultiplyPoint3x4(Vector3.zero);
            var zero     = aiPath.GetTransform(aiPath.GetLength()).MultiplyPoint3x4(Vector3.zero);
            var expected = new Vector3(4, 0, 8);

            Assert.AreEqual(expected, zero);
            Assert.AreEqual(expected, end);
        }