I am using Monogame 3.5
and i have simple model of cube. I use BasicEffect
to draw it. I want it transparent so i use effect.Alpha = 0.5f
. Is it possible to show all edges something like on picture?
1 Answers
There's two ways to do this depending on what you're looking for. You can either set the rendering rastersizer state to show wireframe, or you can get a list of your edges and draw a set of VertexPositionColor
using GraphicsDevice.DrawIndexedPrimitives
.
Raster Sizer State
You can draw the cube transparent, and then, assuming you're using the BasicEffect
, you can turn off all of the shading and set the colour to white.
You can then redraw the cube with the new rastersizer state set to FillMode.Wireframe
. here's some pseudo code.
//Draw the Cube Transparent
DrawCubeTransparent();
//Now save the Rastersizer state for later
RasterizerState originalRasterizerState = GraphicsDevice.RasterizerState;
//Now set the RasterizerState too WireFrame
RasterizerState newRasterizerState = new RasterizerState();
newRasterizerState.FillMode = FillMode.WireFrame;
GraphicsDevice.RasterizerState = newRasterizerState;
//Now redraw the cube as wireframe with the shading off and colour set to white
DrawCubeWireFrame();
//Now reset the Rastersizer fill state
raphicsDevice.RasterizerState = originalRasterizerState;
DrawIndexedPrimitives
The previous method might not be ideal, because it will draw all triangular faces, so there wil be a diagonal line through your cube faces.
The other way is to find out which edges you want to draw and then use DrawIndexedPrimitives to draw an array of Vertices which contain all of your edges.
A simple google search will give you a ton of examples in using this.

- 106
- 7