关于C#:在XNA 4.0中绘制3D模型?

Draw 3d model in XNA 4.0?

我正在绘制几个模型,并使用以下代码来设置渲染状态:

1
2
3
4
GraphicsDevice.BlendState = BlendState.Opaque;
GraphicsDevice.DepthStencilState = DepthStencilState.Default;
GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise;
GraphicsDevice.SamplerStates[0] = SamplerState.LinearWrap;

某些模型渲染不正确。如果我更改一行代码:

1
GraphicsDevice.DepthStencilState = DepthStencilState.DepthRead;

现在,其他人无法正常工作。我在每个代码段中使用了2个代码,但仍然无法正常工作。

如何解决此渲染问题?

屏幕截图:

我先绘制地面,然后是"道路"模型。

顶部:http://i.stack.imgur.com/xH8qp.png

当我改变相机的angular时...:http://i.stack.imgur.com/Nbw3m.png


您的问题似乎是Z角战斗,此问题是由于尝试在距相机相同距离处渲染2个或更多多边形而引起的。

绘制模型时,可以禁用Z缓冲区。 DepthStencilState.None