Example #1
0
        private static Vector3[] CreatePositions()
        {
            var top = new Vector3(0f, 1f, 0f);
            var left = new Vector3(-1f, -1f, 0f);
            var right = new Vector3(1f, -1f, 0f);

            return new[] { top, right, left };
        }
Example #2
0
        private static Vector3[] CreateColors()
        {
            var top = new Vector3(1f, 0f, 0f);
            var left = new Vector3(0f, 1f, 0f);
            var right = new Vector3(0f, 0f, 1f);

            return new[] { top, right, left };
        }
Example #3
0
        public void Up_set_and_get()
        {
            var stand = new Stand();
            var up = new Vector3(1, 2, 3);

            stand.Up = up;

            Assert.AreEqual(up, stand.Up);
        }
Example #4
0
        public void Position_set_and_get()
        {
            var stand = new Stand();
            var position = new Vector3(7, 8, 9);

            stand.Position = position;

            Assert.AreEqual(position, stand.Position);
        }
Example #5
0
        public void Direction_set_and_get()
        {
            var stand = new Stand();
            var direction = new Vector3(4, 5, 6);

            stand.Direction = direction;

            Assert.AreEqual(direction, stand.Direction);
        }
        private static Vector3[] CreateColors()
        {
            var topLeft = new Vector3(1f, 0f, 0f);
            var topRight = new Vector3(0f, 1f, 0f);
            var bottomLeft = new Vector3(0f, 0f, 1f);
            var bottomRight = new Vector3(1f, 1f, 0f);

            return new[] { topLeft, topRight, bottomLeft, bottomRight };
        }
        private static Vector3[] CreatePositions()
        {
            var topLeft = new Vector3(-1f, 1f, 0f);
            var topRight = new Vector3(1f, 1f, 0f);
            var bottomLeft = new Vector3(-1f, -1f, 0f);
            var bottomRight = new Vector3(1f, -1f, 0f);

            return new[] { topLeft, topRight, bottomLeft, bottomRight };
        }
Example #8
0
        public void Constructor_from_a_vector_sets_XYZ_to_the_vector_values_and_W_to_0()
        {
            var vector3 = new Vector3(1, 2, 3);

            var quaternion = new Quaternion(vector3);

            quaternion.W.ShouldEqual(0);
            quaternion.X.ShouldEqual(vector3.X);
            quaternion.Y.ShouldEqual(vector3.Y);
            quaternion.Z.ShouldEqual(vector3.Z);
        }
Example #9
0
        /// <summary>
        /// Calculates the view matrix.
        /// </summary>
        /// <param name="position">The position.</param>
        /// <param name="direction">The direction.</param>
        /// <param name="up">The up direction.</param>
        /// <returns>The calculated view matrix.</returns>
        public static Matrix CalculateViewMatrix(Vector3 position, Vector3 direction, Vector3 up)
        {
            var n = -direction.Normalized();
            var u = up.Cross(n).Normalized();
            var v = n.Cross(u);
            var e = -position;

            return new Matrix(
                u.X, v.X, n.X, 0,
                u.Y, v.Y, n.Y, 0,
                u.Z, v.Z, n.Z, 0,
                u.Dot(e), v.Dot(e), n.Dot(e), 1);
        }
        public void CalcualteViewMatrix_with_simple_values()
        {
            var position = new Vector3(0, 0, 3);
            var direction = new Vector3(0, 0, -1);
            var up = new Vector3(0, 1, 0);

            var view = Stand.CalculateViewMatrix(position, direction, up);

            var xna = Microsoft.Xna.Framework.Matrix.CreateLookAt(
                position.ToXna(), (position + direction).ToXna(), up.ToXna());

            Assert.AreEqual(xna.ToMath(), view);
        }