【发布时间】:2016-06-01 14:16:30
【问题描述】:
【问题讨论】:
标签: c# 3d xna-4.0 monogame edge-detection
【问题讨论】:
标签: c# 3d xna-4.0 monogame edge-detection
有两种方法可以做到这一点,具体取决于您要查找的内容。您可以将渲染光栅化器状态设置为显示线框,也可以获取边缘列表并使用GraphicsDevice.DrawIndexedPrimitives 绘制一组VertexPositionColor。
光栅尺状态
您可以将立方体绘制成透明的,然后,假设您使用的是BasicEffect,您可以关闭所有阴影并将颜色设置为白色。
然后您可以重新绘制立方体,并将新的光栅化器状态设置为FillMode.Wireframe。这是一些伪代码。
//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
以前的方法可能不太理想,因为它会绘制所有三角形面,所以会有一条对角线穿过你的立方体面。
另一种方法是找出要绘制的边,然后使用 DrawIndexedPrimitives 绘制包含所有边的顶点数组。
一个简单的谷歌搜索将为您提供大量使用此功能的示例。
【讨论】: