Example #1
0
        public void TestTriangleGeneration()
        {
            int count = SolidTriangleVertexGenerator.VertexCount;

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

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

            Assert.AreEqual(Vector3.Zero, vertices[0].Position);
            Assert.AreNotEqual(Vector3.Zero, vertices[1].Position);
            Assert.AreNotEqual(Vector3.Zero, vertices[count - 1].Position);
        }
Example #2
0
        /// <summary>Draws a solid (filled) triangle between three points</summary>
        /// <param name="a">First corner point of the triangle</param>
        /// <param name="b">Second corner point of the triangle</param>
        /// <param name="c">Third corner point of the triangle</param>
        /// <param name="color">Desired color of the line</param>
        public void DrawSolidTriangle(Vector3 a, Vector3 b, Vector3 c, Color color)
        {
            const int VertexCount = SolidTriangleVertexGenerator.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 proposedEnd = this.triangleIndex + VertexCount;

            if (proposedEnd > this.lineIndex)
            {
                this.overflowed = true;
                return;
            }

            // Generate the vertices for the faces of the box
            SolidTriangleVertexGenerator.Generate(
                this.queuedVertices, this.triangleIndex, a, b, c, color
                );

            this.triangleIndex += VertexCount;
        }