예제 #1
0
        private void CreateSquare(float lineThickness, bool isAntiAlias, Color lineColor, Vector3[] vertices)
        {
            using (var lineContext = base.BeginLineStrips(lineThickness, isAntiAlias))
            {
                lineContext.SetVertexColor(lineColor);

                // Pass Entity ID value for a hit test purpose
                ulong selectionColor = SCRTImmediateDraw.EncodeSelectionId(EntityId, 0);
                lineContext.SetSelectionId(selectionColor);

                foreach (var v in vertices)
                {
                    SetVertex(lineContext, v);
                }
                SetVertex(lineContext, vertices.First());
                lineContext.Freeze();
                lineContext.Draw();
            }
        }
        /// <summary>
        ///     Called when the 3D Engine wishes to render this element. This is where geometry must be drawn to the 3D scene
        /// </summary>
        /// <param name="e">The <see cref="IRenderPassInfo3D" /> containing parameters for the current render pass.</param>
        public override void RenderScene(IRenderPassInfo3D e)
        {
            // y          1--------0
            // |         /|       /|
            // |       5--------4  |
            // |       |  |     |  |
            // |       |  |     |  |
            // |       |  2--------3
            // |  z    | /      |/
            // | /     6--------7
            // |/
            // ----------- X
            Vector3[] corners =
            {
                new Vector3(topLeft.X,     topLeft.Y, topLeft.Z),         //0
                new Vector3(bottomRight.X, topLeft.Y, topLeft.Z),         //1
                new Vector3(bottomRight.X, bottomRight.Y, topLeft.Z),     //2
                new Vector3(topLeft.X,     bottomRight.Y, topLeft.Z),     //3
                new Vector3(topLeft.X,     topLeft.Y, bottomRight.Z),     //4
                new Vector3(bottomRight.X, topLeft.Y, bottomRight.Z),     //5
                new Vector3(bottomRight.X, bottomRight.Y, bottomRight.Z), //6
                new Vector3(topLeft.X,     bottomRight.Y, bottomRight.Z), //7
            };

            Vector3[] normals =
            {
                new Vector3(+0.0f, +0.0f, -1.0f), //front
                new Vector3(+0.0f, +0.0f, +1.0f), //back
                new Vector3(+1.0f, +0.0f, +0.0f), //right
                new Vector3(-1.0f, +0.0f, +0.0f), //left
                new Vector3(+0.0f, +1.0f, +0.0f), //top
                new Vector3(+0.0f, -1.0f, +0.0f), //bottom
            };

            // We create a mesh context. There are various mesh render modes. The simplest is Triangles
            // For this mode we have to draw a single triangle (three vertices) for each corner of the cube
            // You can see
            using (var meshContext = base.BeginLitMesh(TSRRenderMode.TRIANGLES))
            {
                // Set the Rasterizer State for this entity
                SCRTImmediateDraw.PushRasterizerState(RasterizerStates.CullBackFacesState.TSRRasterizerState);

                // Set the color before drawing vertices
                meshContext.SetVertexColor(cubeColor);

                // Now draw the triangles. Each face of the cube is made up of two triangles
                // Front face
                SetNormal(meshContext, normals[0]);
                SetVertex(meshContext, corners[0]);
                SetVertex(meshContext, corners[2]);
                SetVertex(meshContext, corners[1]);
                SetVertex(meshContext, corners[2]);
                SetVertex(meshContext, corners[0]);
                SetVertex(meshContext, corners[3]);

                // Right side face
                SetNormal(meshContext, normals[2]);
                SetVertex(meshContext, corners[1]);
                SetVertex(meshContext, corners[2]);
                SetVertex(meshContext, corners[6]);
                SetVertex(meshContext, corners[1]);
                SetVertex(meshContext, corners[6]);
                SetVertex(meshContext, corners[5]);

                // Top face
                SetNormal(meshContext, normals[4]);
                SetVertex(meshContext, corners[2]);
                SetVertex(meshContext, corners[7]);
                SetVertex(meshContext, corners[6]);
                SetVertex(meshContext, corners[7]);
                SetVertex(meshContext, corners[2]);
                SetVertex(meshContext, corners[3]);

                // Left side face
                SetNormal(meshContext, normals[3]);
                SetVertex(meshContext, corners[3]);
                SetVertex(meshContext, corners[0]);
                SetVertex(meshContext, corners[4]);
                SetVertex(meshContext, corners[3]);
                SetVertex(meshContext, corners[4]);
                SetVertex(meshContext, corners[7]);

                // Back face
                SetNormal(meshContext, normals[1]);
                SetVertex(meshContext, corners[7]);
                SetVertex(meshContext, corners[5]);
                SetVertex(meshContext, corners[6]);
                SetVertex(meshContext, corners[7]);
                SetVertex(meshContext, corners[4]);
                SetVertex(meshContext, corners[5]);

                // Bottom face
                SetNormal(meshContext, normals[5]);
                SetVertex(meshContext, corners[0]);
                SetVertex(meshContext, corners[1]);
                SetVertex(meshContext, corners[5]);
                SetVertex(meshContext, corners[0]);
                SetVertex(meshContext, corners[5]);
                SetVertex(meshContext, corners[4]);
            }

            // Revert raster state
            SCRTImmediateDraw.PopRasterizerState();

            // Set the Rasterizer State for wireframe
            SCRTImmediateDraw.PushRasterizerState(RasterizerStates.WireframeState.TSRRasterizerState);

            // Create a Line Context for a continuous line and draw the outline of the cube
            var lineColor = Color.FromArgb(0xFF, cubeColor.R, cubeColor.G, cubeColor.B);

            CreateSquare(2.0f, true, lineColor, new[] { corners[0], corners[1], corners[2], corners[3] });
            CreateSquare(2.0f, true, lineColor, new[] { corners[4], corners[5], corners[6], corners[7] });
            CreateSquare(2.0f, true, lineColor, new[] { corners[0], corners[4], corners[7], corners[3] });
            CreateSquare(2.0f, true, lineColor, new[] { corners[5], corners[1], corners[2], corners[6] });

            // Revert raster state
            SCRTImmediateDraw.PopRasterizerState();
        }
예제 #3
0
        /// <summary>
        ///     Called when the 3D Engine wishes to render this element. This is where geometry must be drawn to the 3D scene
        /// </summary>
        /// <param name="e">The <see cref="IRenderPassInfo3D" /> containing parameters for the current render pass.</param>
        public override void RenderScene(IRenderPassInfo3D e)
        {
            float bottomRightCoordX = bottomRight.X;
            float bottomRightCoordY = bottomRight.Y;
            float bottomRightCoordZ = bottomRight.Z;
            float topLeftCoordX     = topLeft.X;
            float topLeftCoordY     = topLeft.Y;
            float topLeftCoordZ     = topLeft.Z;

            // Commented code below is the example of treating the Location value
            // as 3D point in Data Coordinates Space but not in World Coordinates Space
            //bottomRightCoordX = (float)e.XCalc.GetCoordinate(bottomRight.X) - e.WorldDimensions.X / 2.0f;
            //bottomRightCoordY = (float)e.YCalc.GetCoordinate(bottomRight.Y);
            //bottomRightCoordZ = (float)e.ZCalc.GetCoordinate(bottomRight.Z) - e.WorldDimensions.Z / 2.0f;
            //topLeftCoordX = (float)e.XCalc.GetCoordinate(topLeft.X) - e.WorldDimensions.X / 2.0f;
            //topLeftCoordY = (float)e.YCalc.GetCoordinate(topLeft.Y);
            //topLeftCoordZ = (float)e.ZCalc.GetCoordinate(topLeft.Z) - e.WorldDimensions.Z / 2.0f;

            // y          1--------0
            // |         /|       /|
            // |       5--------4  |
            // |       |  |     |  |
            // |       |  |     |  |
            // |       |  2--------3
            // |  z    | /      |/
            // | /     6--------7
            // |/
            // ----------- X
            Vector3[] corners =
            {
                new Vector3(topLeftCoordX,     topLeftCoordY, topLeftCoordZ),         //0
                new Vector3(bottomRightCoordX, topLeftCoordY, topLeftCoordZ),         //1
                new Vector3(bottomRightCoordX, bottomRightCoordY, topLeftCoordZ),     //2
                new Vector3(topLeftCoordX,     bottomRightCoordY, topLeftCoordZ),     //3
                new Vector3(topLeftCoordX,     topLeftCoordY, bottomRightCoordZ),     //4
                new Vector3(bottomRightCoordX, topLeftCoordY, bottomRightCoordZ),     //5
                new Vector3(bottomRightCoordX, bottomRightCoordY, bottomRightCoordZ), //6
                new Vector3(topLeftCoordX,     bottomRightCoordY, bottomRightCoordZ), //7
            };

            Vector3[] normals =
            {
                new Vector3(+0.0f, +0.0f, -1.0f), //front
                new Vector3(+0.0f, +0.0f, +1.0f), //back
                new Vector3(+1.0f, +0.0f, +0.0f), //right
                new Vector3(-1.0f, +0.0f, +0.0f), //left
                new Vector3(+0.0f, +1.0f, +0.0f), //top
                new Vector3(+0.0f, -1.0f, +0.0f), //bottom
            };

            // Pass Entity ID
            ulong selectionColor = SCRTImmediateDraw.EncodeSelectionId(EntityId, 0);

            SCRTImmediateDraw.SelectionColor(selectionColor);

            // We create a mesh context. There are various mesh render modes. The simplest is Triangles
            // For this mode we have to draw a single triangle (three vertices) for each corner of the cube
            // You can see
            using (var meshContext = base.BeginLitMesh(TSRRenderMode.TRIANGLES))
            {
                // Set the Rasterizer State for this entity
                SCRTImmediateDraw.PushRasterizerState(RasterizerStates.CullBackFacesState.TSRRasterizerState);

                // Set the color before drawing vertices
                meshContext.SetVertexColor(cubeColor);

                // Now draw the triangles. Each face of the cube is made up of two triangles
                // Front face
                SetNormal(meshContext, normals[0]);
                SetVertex(meshContext, corners[0]);
                SetVertex(meshContext, corners[2]);
                SetVertex(meshContext, corners[1]);
                SetVertex(meshContext, corners[2]);
                SetVertex(meshContext, corners[0]);
                SetVertex(meshContext, corners[3]);

                // Right side face
                SetNormal(meshContext, normals[2]);
                SetVertex(meshContext, corners[1]);
                SetVertex(meshContext, corners[2]);
                SetVertex(meshContext, corners[6]);
                SetVertex(meshContext, corners[1]);
                SetVertex(meshContext, corners[6]);
                SetVertex(meshContext, corners[5]);

                // Top face
                SetNormal(meshContext, normals[4]);
                SetVertex(meshContext, corners[2]);
                SetVertex(meshContext, corners[7]);
                SetVertex(meshContext, corners[6]);
                SetVertex(meshContext, corners[7]);
                SetVertex(meshContext, corners[2]);
                SetVertex(meshContext, corners[3]);

                // Left side face
                SetNormal(meshContext, normals[3]);
                SetVertex(meshContext, corners[3]);
                SetVertex(meshContext, corners[0]);
                SetVertex(meshContext, corners[4]);
                SetVertex(meshContext, corners[3]);
                SetVertex(meshContext, corners[4]);
                SetVertex(meshContext, corners[7]);

                // Back face
                SetNormal(meshContext, normals[1]);
                SetVertex(meshContext, corners[7]);
                SetVertex(meshContext, corners[5]);
                SetVertex(meshContext, corners[6]);
                SetVertex(meshContext, corners[7]);
                SetVertex(meshContext, corners[4]);
                SetVertex(meshContext, corners[5]);

                // Bottom face
                SetNormal(meshContext, normals[5]);
                SetVertex(meshContext, corners[0]);
                SetVertex(meshContext, corners[1]);
                SetVertex(meshContext, corners[5]);
                SetVertex(meshContext, corners[0]);
                SetVertex(meshContext, corners[5]);
                SetVertex(meshContext, corners[4]);
            }

            // Revert raster state
            SCRTImmediateDraw.PopRasterizerState();

            // Set the Rasterizer State for wireframe
            SCRTImmediateDraw.PushRasterizerState(RasterizerStates.WireframeState.TSRRasterizerState);

            // Create a Line Context for a continuous line and draw the outline of the cube
            var lineColor = Color.FromArgb(0xFF, cubeColor.R, cubeColor.G, cubeColor.B);

            CreateSquare(2.0f, true, lineColor, new[] { corners[0], corners[1], corners[2], corners[3] });
            CreateSquare(2.0f, true, lineColor, new[] { corners[4], corners[5], corners[6], corners[7] });
            CreateSquare(2.0f, true, lineColor, new[] { corners[0], corners[4], corners[7], corners[3] });
            CreateSquare(2.0f, true, lineColor, new[] { corners[5], corners[1], corners[2], corners[6] });

            // Revert raster state
            SCRTImmediateDraw.PopRasterizerState();
        }
예제 #4
0
        /// <summary>
        ///     Called when the 3D Engine wishes to render this element. This is where geometry must be drawn to the 3D scene
        /// </summary>
        /// <param name="e">The <see cref="IRenderPassInfo3D" /> containing parameters for the current render pass.</param>
        public override void RenderScene(IRenderPassInfo3D e)
        {
            // y          2--------0
            // |         /|       /|
            // |       3--------1  |
            // |       |  |     |  |
            // |       |  |     |  |
            // |       |  6--------4
            // |  z    | /      |/
            // | /     7--------5
            // |/
            // ----------- X

            Vector3[] points;
            //Vector3[] normals;

            Vector3[] normals =
            {
                new Vector3(+0.0f, +0.0f, -1.0f), //front
                new Vector3(+0.0f, +0.0f, +1.0f), //back
                new Vector3(+1.0f, +0.0f, +0.0f), //right
                new Vector3(-1.0f, +0.0f, +0.0f), //left
                new Vector3(+0.0f, +1.0f, +0.0f), //top
                new Vector3(+0.0f, -1.0f, +0.0f), //bottom
                //new Vector3(+0.0f, +0.0f, +0.0f) //center
            };

            switch (checkShape)
            {
            case CheckShape.Line:

                if (firstPos.Y > secondPos.Y)
                {
                    points = new Vector3[] {
                        new Vector3(firstPos.X, firstPos.Y, firstPos.Z),
                        new Vector3(secondPos.X, firstPos.Y, secondPos.Z),
                        new Vector3(firstPos.X, 0, firstPos.Z),
                        new Vector3(secondPos.X, 0, secondPos.Z)
                    };
                }
                else
                {
                    points = new Vector3[] {
                        new Vector3(firstPos.X, secondPos.Y, firstPos.Z),
                        new Vector3(secondPos.X, secondPos.Y, secondPos.Z),
                        new Vector3(firstPos.X, 0, firstPos.Z),
                        new Vector3(secondPos.X, 0, secondPos.Z)
                    };
                }

                using (var rectContext = base.BeginLitMesh(TSRRenderMode.TRIANGLES))
                {
                    SCRTImmediateDraw.PushRasterizerState(RasterizerStates.CullBackFacesState.TSRRasterizerState);
                    rectContext.SetVertexColor(lineColor);

                    SetNormal(rectContext, normals[0]);     // Front
                    SetVertex(rectContext, points[0]);
                    SetVertex(rectContext, points[2]);
                    SetVertex(rectContext, points[1]);
                    SetVertex(rectContext, points[1]);
                    SetVertex(rectContext, points[2]);
                    SetVertex(rectContext, points[3]);

                    SetNormal(rectContext, normals[1]);     // Back
                    SetVertex(rectContext, points[0]);
                    SetVertex(rectContext, points[3]);
                    SetVertex(rectContext, points[2]);
                    SetVertex(rectContext, points[3]);
                    SetVertex(rectContext, points[0]);
                    SetVertex(rectContext, points[1]);
                }
                SCRTImmediateDraw.PopRasterizerState();

                SCRTImmediateDraw.PushRasterizerState(RasterizerStates.WireframeState.TSRRasterizerState);
                DrawSquareLine(new Vector3[] { points[0], points[1], points[3], points[2] });
                SCRTImmediateDraw.PopRasterizerState();
                break;

            case CheckShape.Rect:
                points = new Vector3[] {
                    new Vector3(firstPos.X, firstPos.Y, firstPos.Z),     // Top
                    new Vector3(secondPos.X, firstPos.Y, firstPos.Z),
                    new Vector3(firstPos.X, secondPos.Y, secondPos.Z),
                    new Vector3(secondPos.X, secondPos.Y, secondPos.Z),
                    new Vector3(firstPos.X, 0, firstPos.Z),     // Bottom
                    new Vector3(secondPos.X, 0, firstPos.Z),
                    new Vector3(firstPos.X, 0, secondPos.Z),
                    new Vector3(secondPos.X, 0, secondPos.Z)
                };

                using (var cubeContext = base.BeginLitMesh(TSRRenderMode.TRIANGLES))
                {
                    SCRTImmediateDraw.PushRasterizerState(RasterizerStates.CullBackFacesState.TSRRasterizerState);
                    cubeContext.SetVertexColor(faceColor);

                    // y          2--------0
                    // |         /|       /|
                    // |       3--------1  |
                    // |       |  |     |  |
                    // |       |  |     |  |
                    // |       |  6--------4
                    // |  z    | /      |/
                    // | /     7--------5
                    // |/
                    // ----------- X

                    SetNormal(cubeContext, normals[5]);     // Front
                    SetVertex(cubeContext, points[0]);
                    SetVertex(cubeContext, points[6]);
                    SetVertex(cubeContext, points[2]);
                    SetVertex(cubeContext, points[6]);
                    SetVertex(cubeContext, points[0]);
                    SetVertex(cubeContext, points[4]);

                    SetNormal(cubeContext, normals[1]);     // Back
                    SetVertex(cubeContext, points[5]);
                    SetVertex(cubeContext, points[3]);
                    SetVertex(cubeContext, points[7]);
                    SetVertex(cubeContext, points[5]);
                    SetVertex(cubeContext, points[1]);
                    SetVertex(cubeContext, points[3]);

                    SetNormal(cubeContext, normals[2]);     // Left
                    SetVertex(cubeContext, points[4]);
                    SetVertex(cubeContext, points[0]);
                    SetVertex(cubeContext, points[1]);
                    SetVertex(cubeContext, points[4]);
                    SetVertex(cubeContext, points[1]);
                    SetVertex(cubeContext, points[5]);

                    SetNormal(cubeContext, normals[3]);     // right
                    SetVertex(cubeContext, points[2]);
                    SetVertex(cubeContext, points[6]);
                    SetVertex(cubeContext, points[7]);
                    SetVertex(cubeContext, points[2]);
                    SetVertex(cubeContext, points[7]);
                    SetVertex(cubeContext, points[3]);

                    SetNormal(cubeContext, normals[4]);     // Top
                    SetVertex(cubeContext, points[6]);
                    SetVertex(cubeContext, points[5]);
                    SetVertex(cubeContext, points[7]);
                    SetVertex(cubeContext, points[5]);
                    SetVertex(cubeContext, points[6]);
                    SetVertex(cubeContext, points[4]);

                    SetNormal(cubeContext, normals[0]);     // Bottom
                    SetVertex(cubeContext, points[0]);
                    SetVertex(cubeContext, points[2]);
                    SetVertex(cubeContext, points[3]);
                    SetVertex(cubeContext, points[0]);
                    SetVertex(cubeContext, points[3]);
                    SetVertex(cubeContext, points[1]);
                }

                SCRTImmediateDraw.PopRasterizerState();
                SCRTImmediateDraw.PushRasterizerState(RasterizerStates.WireframeState.TSRRasterizerState);

                DrawSquareLine(new Vector3[] { points[0], points[1], points[3], points[2] });
                DrawSquareLine(new Vector3[] { points[0], points[1], points[5], points[4] });
                DrawSquareLine(new Vector3[] { points[0], points[2], points[6], points[4] });
                DrawSquareLine(new Vector3[] { points[2], points[3], points[7], points[6] });
                DrawSquareLine(new Vector3[] { points[1], points[3], points[7], points[5] });
                DrawSquareLine(new Vector3[] { points[4], points[6], points[7], points[5] });

                SCRTImmediateDraw.PopRasterizerState();
                break;

            case CheckShape.Circle_2P:
                points = new Vector3[] {
                    new Vector3(firstPos.X, firstPos.Y, firstPos.Z),
                    new Vector3(secondPos.X, secondPos.Y, secondPos.Z)
                };

                circlePos.Add(points[0]);

                using (var circleContext = base.BeginLitMesh(TSRRenderMode.TRIANGLEFAN))
                {
                    SCRTImmediateDraw.PushRasterizerState(RasterizerStates.CullBackFacesState.TSRRasterizerState);
                    circleContext.SetVertexColor(faceColor);

                    SetNormal(circleContext, normals[4]);
                    Vector3 prev = points[1];
                    Vector3 post = points[1];

                    circlePos.Add(prev);
                    circlePos.Add(post);

                    for (int i = 0; i < 180; i++)
                    {
                        SetVertex(circleContext, points[0]);
                        SetVertex(circleContext, prev);
                        SetVertex(circleContext, post);
                        prev = post;

                        post.x += 1.536f;
                        post.z += 0.2865f;

                        circlePos.Add(prev);
                        circlePos.Add(post);
                    }

                    SCRTImmediateDraw.PopRasterizerState();
                    SCRTImmediateDraw.PushRasterizerState(RasterizerStates.WireframeState.TSRRasterizerState);

                    using (var lineContext = base.BeginLineStrips(2.0f, true))
                    {
                        lineContext.SetVertexColor(faceColor);

                        foreach (var v in points)
                        {
                            SetVertex(lineContext, v);
                        }
                        SetVertex(lineContext, points.First());
                        lineContext.Freeze();
                        lineContext.Draw();
                    }

                    SCRTImmediateDraw.PopRasterizerState();
                }
                break;

            case CheckShape.Circle_3P:
                break;
            }
        }
예제 #5
0
        /// <summary>
        ///     Called when the 3D Engine wishes to render this element. This is where geometry must be drawn to the 3D scene
        /// </summary>
        /// <param name="rpi">The <see cref="IRenderPassInfo3D" /> containing parameters for the current render pass.</param>
        public override void RenderScene(IRenderPassInfo3D rpi)
        {
            float fStartCoordX = (float)rpi.XCalc.GetCoordinate(m_startX) - rpi.WorldDimensions.X / 2.0f;
            float fStartCoordY = (float)rpi.YCalc.GetCoordinate(m_startY);
            float fStartCoordZ = (float)rpi.ZCalc.GetCoordinate(m_startZ) - rpi.WorldDimensions.Z / 2.0f;

            float fEndCoordX = (float)rpi.XCalc.GetCoordinate(m_endX) - rpi.WorldDimensions.X / 2.0f;
            float fEndCoordY = (float)rpi.YCalc.GetCoordinate(m_endY);
            float fEndCoordZ = (float)rpi.ZCalc.GetCoordinate(m_endZ) - rpi.WorldDimensions.Z / 2.0f;

            float fHalfHeightCoord = (float)((rpi.YCalc.GetCoordinate(m_height) - rpi.YCalc.GetCoordinate(0.0)) / 2.0);

            Vector3[] corners =
            {
                new Vector3(fStartCoordX, fStartCoordY - fHalfHeightCoord, fStartCoordZ),   // bottom start
                new Vector3(fEndCoordX,   fEndCoordY - fHalfHeightCoord, fEndCoordZ),       // bottom end
                new Vector3(fStartCoordX, fStartCoordY + fHalfHeightCoord, fStartCoordZ),   // top start
                new Vector3(fEndCoordX,   fEndCoordY + fHalfHeightCoord, fEndCoordZ),       // top end
            };

            Plane plane = new Plane(corners[0], corners[1], corners[2]);

            Vector3[] normals =
            {
                new Vector3(plane.NormalX,  plane.NormalY, plane.NormalZ),  // front
                new Vector3(-plane.NormalX, -plane.NormalY, -plane.NormalZ) // back
            };

            // We create a mesh context. There are various mesh render modes. The simplest is Triangles
            // For this mode we have to draw a couple of triangles (three vertices) for each side of the plane
            // You can see
            using (var meshContext = BeginLitMesh(TSRRenderMode.TRIANGLES))
            {
                // Set the Rasterizer State for this entity
                SCRTImmediateDraw.PushRasterizerState(RasterizerStates.CullBackFacesState.TSRRasterizerState);

                // Set the color before drawing vertices
                meshContext.SetVertexColor(m_color);

                // Now draw the triangles. Each face of the plane is made up of two triangles
                // Front face
                SetNormal(meshContext, normals[1]);
                SetVertex(meshContext, corners[0]);
                SetVertex(meshContext, corners[2]);
                SetVertex(meshContext, corners[1]);
                SetVertex(meshContext, corners[1]);
                SetVertex(meshContext, corners[2]);
                SetVertex(meshContext, corners[3]);

                // Back face
                SetNormal(meshContext, normals[0]);
                SetVertex(meshContext, corners[0]);
                SetVertex(meshContext, corners[1]);
                SetVertex(meshContext, corners[2]);
                SetVertex(meshContext, corners[1]);
                SetVertex(meshContext, corners[3]);
                SetVertex(meshContext, corners[2]);
            }

            // Revert raster state
            SCRTImmediateDraw.PopRasterizerState();

            if (m_drawWireframe)
            {
                // Set the Rasterizer State for wireframe
                SCRTImmediateDraw.PushRasterizerState(RasterizerStates.WireframeState.TSRRasterizerState);

                // Create a Line Context for a continuous line and draw the outline of the cube
                var lineColor = Color.FromArgb(0xFF, m_color.R, m_color.G, m_color.B);

                CreateSquare(2.0f, true, lineColor, new[] { corners[0], corners[1], corners[3], corners[2] });

                // Revert raster state
                SCRTImmediateDraw.PopRasterizerState();
            }
        }