コード例 #1
0
        public void TestBoxGeneration()
        {
            int count = SolidBoxVertexGenerator.VertexCount;

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

            SolidBoxVertexGenerator.Generate(
                vertices, 1,
                new Vector3(10.0f, 20.0f, 30.0f), new Vector3(20.0f, 25.0f, 32.5f),
                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 solid (filled) box at the specified location</summary>
        /// <param name="min">Contains the coordinates of the box lesser corner</param>
        /// <param name="max">Contains the coordinates of the box greater corner</param>
        /// <param name="color">Desired color for the box</param>
        public void DrawSolidBox(Vector3 min, Vector3 max, Color color)
        {
            const int VertexCount = SolidBoxVertexGenerator.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) || (proposedEnd > MaximumDebugVertexCount))
            {
                this.overflowed = true;
                return;
            }

            // Generate the vertices for the faces of the box
            SolidBoxVertexGenerator.Generate(
                this.queuedVertices, this.triangleIndex, min, max, color
                );

            this.triangleIndex += VertexCount;
        }