Page 1 of 1
Models visible when under an object
Posted: Sat Jun 18, 2011 11:26 pm
by finaiized
I think the best way to explain this is through pictures:
(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;
Re: Models visible when under an object
Posted: Sat Jun 18, 2011 11:36 pm
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.
Re: Models visible when under an object
Posted: Sun Jun 19, 2011 12:07 am
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.
Re: Models visible when under an object
Posted: Sun Jun 19, 2011 12:10 am
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).
Re: Models visible when under an object
Posted: Sun Jun 19, 2011 12:24 am
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!