# Mesh drawing?

## Recommended Posts

Hello all, I got a problem rendering my meshes. I got a screeny under with 2 samples, the left sample is rendering of DXViewer which shows it correctly and the right is my application which doesn't draw it like I want it. My application presents some triangles of the back in front of the mesh. What could be causing this rendering-behavior in my application, what settings might I forgot about? Thank you, Xeile

##### Share on other sites

i.e:

this.D3DDevice.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1, 0);

p.s. i don't think clearing a zbuffer could save that nasty looking mesh!

##### Share on other sites
Quote:
 Original post by vidalsasoonare you clearing your z-buffer?i.e:this.D3DDevice.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1, 0);p.s. i don't think clearing a zbuffer could save that nasty looking mesh!

Yep, I'm indeed clearing the target and ZBuffer every frame.

##### Share on other sites

Did you try using a mesh that was included with the SDK?

Maybe try running "Optimize" on the mesh...

i.e. mesh.OptimizeInPlace( MeshFlags.OptimizeCompact | MeshFlags.OptimizeAttributeSort, (GraphicsBuffer)null );

If those don't help, I don't know what could be wrong.

##### Share on other sites
Hmm... what are your backface triangles culling settings? I suggest:
pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW );

##### Share on other sites
This is a depth buffer problem.
What is your depth buffer set at?
you could try
presentParams.EnableAutoDepthStencil = true;presentParams.AutoDepthStencilFormat = DepthFormat.D24S8;

and then also making sure your near and far plane of your projection matrix is set correctly. Usually this works if it's set at 1.0f and 1000.0f respectively.

I hope this helps.
Take care.

##### Share on other sites
Quote:
 Original post by ArmadonAnd then also making sure your near and far plane of your projection matrix is set correctly. Usually this works if it's set at 1.0f and 1000.0f respectively.I hope this helps.Take care.

That was the problem, I had the nearplane set to 0.0f. On the moment you mentioned near plane, I slapped myself... Well making errors is human, I guess.

Thanks for all the help

## Create an account

Register a new account

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627638
• Total Posts
2978327

• 10
• 12
• 22
• 13
• 34