Beispiel #1
0
        public void RotateScaledCubeCenteredPivot()
        {
            ResetTransforms();
            CollisionComponent collision = new CollisionComponent();

            collision.SetCube(new Cube(new Float4(0.5f), new Float4(0.5f), Quaternion.Default));

            GameTransform.Scale    = new Float4(10);
            GameTransform.Rotation = new Quaternion(new Float3(0, 0, 1), 90.0f);
            GameTransform.Pivot    = new Float4(5);
            var converted = collision.ExtractCube(GameTransform);

            Assert.AreEqual(new Float4(5), converted.Center);
            Assert.AreEqual(new Float4(5), converted.Size);
            Assert.AreEqual(new Quaternion(new Float3(0, 0, 1), 90.0f).ToFloat4(), converted.Rotation.ToFloat4());
        }
Beispiel #2
0
        public void RotateScaledCubeCustomPivot()
        {
            ResetTransforms();
            CollisionComponent collision = new CollisionComponent();

            collision.SetCube(new Cube(new Float4(0.5f), new Float4(0.5f), Quaternion.Default));

            GameTransform.Scale    = new Float4(10);
            GameTransform.Rotation = new Quaternion(new Float3(0, 0, 1), 90.0f);
            GameTransform.Pivot    = new Float4(0);
            var converted = collision.ExtractCube(GameTransform);

            // Precision
            Assert.AreEqual(-5.0f, converted.Center.X, Constants.Epsilon);
            Assert.AreEqual(5.0f, converted.Center.Y, Constants.Epsilon);
            Assert.AreEqual(5.0f, converted.Center.Z, Constants.Epsilon);

            Assert.AreEqual(new Float4(5), converted.Size);
            Assert.AreEqual(new Quaternion(new Float3(0, 0, 1), 90.0f).ToFloat4(), converted.Rotation.ToFloat4());
        }