예제 #1
0
        public void TestArrowGeneration()
        {
            int count = WireframeArrowVertexGenerator.VertexCount;

            VertexPositionColor[] vertices = new VertexPositionColor[count + 1];

            WireframeArrowVertexGenerator.Generate(
                vertices, 1,
                new Vector3(10.0f, 20.0f, 30.0f), Vector3.Forward,
                Color.Blue
                );

            Assert.AreEqual(Vector3.Zero, vertices[0].Position);
            Assert.AreNotEqual(Vector3.Zero, vertices[1].Position);
            Assert.AreNotEqual(Vector3.Zero, vertices[count - 1].Position);
        }
예제 #2
0
        /// <summary>Draws a wireframe arrow into the scene to visualize a vector</summary>
        /// <param name="origin">
        ///   Location at which to draw the arrow (this will form the exact center of
        ///   the drawn arrow's base)
        /// </param>
        /// <param name="direction">
        ///   Direction the arrow is pointing into. The arrow's size is relative to
        ///   the length of this vector.
        /// </param>
        /// <param name="color">Color of the wireframe to draw</param>
        public void DrawArrow(Vector3 origin, Vector3 direction, Color color)
        {
            const int VertexCount = WireframeArrowVertexGenerator.VertexCount;

            // If we would collide with the triangles in the array or there simply
            // isn't enough space left, set the overflow flag and silently skip drawing
            int proposedStart = this.lineIndex - (VertexCount - 1);

            if (proposedStart < this.triangleIndex)
            {
                this.overflowed = true;
                return;
            }

            // Generate the vertices for box' wireframe
            WireframeArrowVertexGenerator.Generate(
                this.queuedVertices, proposedStart, origin, direction, color
                );

            this.lineIndex -= VertexCount;
        }