Exemplo n.º 1
0
        public void localVerpTest()
        {
            //TODO: Finish this test after Ludum Dare 48
            var obj1_world = new Vector3(2, 2);
            var obj1_rot   = 45;
            var obj2_world = new Vector3(-4, 2);
            var ojb2_local = new Vector3(-3, 3);
            var verp       = new Vector3(0.5f, 0, 0);
            var expected   = new Vector3(0.5f, 0.5f);

            Debug.Log("creating a gameobject");
            var obj1 = new GameObject("obj1");

            Debug.Log("done");
            obj1.transform.position    = obj1_world;
            obj1.transform.eulerAngles = new Vector3(0, 0, obj1_rot);

            var tPoint = obj1.transform.TransformPoint(obj2_world);
            var tVec   = obj1.transform.TransformVector(obj2_world);
            var tDir   = obj1.transform.TransformDirection(obj2_world);

            var msg = $"{nameof(obj1)}:\n";

            msg += new Dictionary <object, object>()
            {
                { "pos", obj1.transform.position },
                { "rot", obj1.transform.eulerAngles },
                { "left", -obj1.transform.right }
            }.JoinString("\n");
            LogUtils.Log(msg);

            LogUtils.Log($"{nameof(tPoint)} = {tPoint}", $"{nameof(tVec)} = {tVec}", $"{nameof(tDir)} = {tDir}");

            var actual = TransformUtils.LocalVerp(obj1.transform, obj2_world, verp);

            // Unity's Vector3's don't work with NUnit's Is.EqualTo()...
            Assert.That(actual == expected, Is.True, $"{actual} == {expected}");
        }