public void TestTriangleGeneration() { int count = WireframeTriangleVertexGenerator.VertexCount; VertexPositionColor[] vertices = new VertexPositionColor[count + 1]; WireframeTriangleVertexGenerator.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); }
/// <summary>Draws a wireframe 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 DrawTriangle(Vector3 a, Vector3 b, Vector3 c, Color color) { const int VertexCount = WireframeTriangleVertexGenerator.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 WireframeTriangleVertexGenerator.Generate( this.queuedVertices, proposedStart, a, b, c, color ); this.lineIndex -= VertexCount; }