Sign in to follow this  

XNA: Models drawn last visible from certain angles?

This topic is 1964 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have been challenging myself to make a basic port of Minecraft to XNA just for the fun of it, but have ran into this very confusing problem. When looking at a 3x3x3 grid of cube models, randomly textured, I find that at any time my camera is in a negative coordinate, some of the blocks which should not be visible are showing through. I think it's a view or projection problem, but it's all right by the offline samples I've seen. (I don't have Internet much ATM.) Here are my view and projection lines:
View = Matrix.CreateLookat(cameraPosition, cameraLookat, Vector3.Up);
Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, GraphicsDevice.Viewport.AspectRatio, 1f, 1000f);

Each block is its own class. View and Projection are passed every Draw call.

Let me know if anyone needs more information to solve this dilemma.

Share this post


Link to post
Share on other sites
If depth buffer writing or testing are disabled, the objects you render last will draw over any other objects. This seems most likely given the symptoms, and will be the easiest thing to check first. Edited by Nypyren

Share this post


Link to post
Share on other sites
Sometimes XNA is so dumb. You would expect a library that makes things easier would have depth testing enabled by default... Also, my "Steve" model that I made is having problems: XNA is culling the outside head faces! I know how to turn cull mode off, but I'd rather have all models cull correctly. I made him with Blender 2.6 and exported to fbx. Should I just export as obj to Max and export there?

EDIT: My Steve model's head face normals were somehow wrong in Blender, so I got them flipped and solved. And the depth buffer is not the problem. Could it be my model files being exported all screwy by Blender? Edited by Drakken255

Share this post


Link to post
Share on other sites
Ladies and Gentlemen: I have solved the problem. SpriteBatch screws up a bunch of graphics settings when Begin is called, namely the DepthStencilState. I thought setting the state to Default didn't work because I did that in LoadContent, when SpriteBatch changes it every frame. I now realize that I must change it back every frame.

Share this post


Link to post
Share on other sites

This topic is 1964 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this