Models visible when under an object

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
finaiized
Posts: 3
Joined: Sat Jun 18, 2011 11:20 pm

Models visible when under an object

Post by finaiized »

I think the best way to explain this is through pictures:

Image

Image

(These images are taken from the GettingStartedDemo).

In the first, I'm looking under the platform. There are indeed boxes on it, but you can't see them, which is correct.
In the second, I'm looking under the Playground Model included with the demo. As you can see, you can see the cubes underneath - and no, those are not falling, but at rest on the model. This seems to only happen when you construct a model using TriangleMesh and it's GetVerticesAndIndicesFromModel method passed into a StaticMesh.

What is the problem here? I've experienced a similar problem when using SpriteBatch, but it was resolved by resetting the state:

Code: Select all

GraphicsDevice.BlendState = BlendState.Opaque;
GraphicsDevice.DepthStencilState = DepthStencilState.Default;
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Models visible when under an object

Post by Norbo »

The models are being drawn with back-face culling. Based on the winding of the triangles and the perspective of the camera, the device has decided that you shouldn't be able to see those triangles. You can change the cull mode to none instead of clockwise/counterclockwise to 'fix' this, though it is normal behavior.

This is just a graphical issue though; you'll have better luck finding information about rendering on the XNA forums and other specialized places.
finaiized
Posts: 3
Joined: Sat Jun 18, 2011 11:20 pm

Re: Models visible when under an object

Post by finaiized »

Norbo wrote:The models are being drawn with back-face culling. Based on the winding of the triangles and the perspective of the camera, the device has decided that you shouldn't be able to see those triangles. You can change the cull mode to none instead of clockwise/counterclockwise to 'fix' this, though it is normal behavior.

This is just a graphical issue though; you'll have better luck finding information about rendering on the XNA forums and other specialized places.
Thanks. I guess I was just wondering why the platform did not have this issue, though I'm assuming it's other double sided or it's just some cube property.

For reference, you can use the following code (place this in Initialize() or similar method) to set CullMode to None:

Code: Select all

var rs = new RasterizerState { CullMode = CullMode.None };
GraphicsDevice.RasterizerState = rs;
As this wasn't for gameplay, and just for testing, I'm assuming it's usually unnecessary.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Models visible when under an object

Post by Norbo »

I guess I was just wondering why the platform did not have this issue, though I'm assuming it's other double sided or it's just some cube property.
The platform is a cube model, which has 12 triangles, 2 on each face. Since the surface is closed and the winding is consistent, you only see the front faces. If you fly inside any of the cubes, you'll notice that you can't see any of the cube's triangles anymore (if back-face culling is enabled).
finaiized
Posts: 3
Joined: Sat Jun 18, 2011 11:20 pm

Re: Models visible when under an object

Post by finaiized »

Norbo wrote:
I guess I was just wondering why the platform did not have this issue, though I'm assuming it's other double sided or it's just some cube property.
The platform is a cube model, which has 12 triangles, 2 on each face. Since the surface is closed and the winding is consistent, you only see the front faces. If you fly inside any of the cubes, you'll notice that you can't see any of the cube's triangles anymore (if back-face culling is enabled).
Oh, I get it now. Thanks for the explanation!
Post Reply