Model perspective issue in XNA

Started by
3 comments, last by xchimera 11 years, 1 month ago

I have recently been playing around with XNA for the first time. I have some experience with DirectX 10 and 11, and have also gone through some modeling tutorials for Blender. But this is the first time I've tried to import a model created in Blender.

In the project I'm experimenting with, I am drawing a jet model provided in a Microsoft example, and a simple house model I created in Blender and exported to a .x file. The problem I'm having is the perspective of the house is opposite as it should be, relative to the camera. If the house model is in the center of the viewing area, it looks fine - all I see is the front surface of the model. As the model moves to the right of the camera (translation only, no rotation applied), I should begin to see some of the side of the model that is closest to the camera. Instead the opposite side becomes visible. The same happens with up and down movement.

The jet model behaves correctly, but I'm using the same view and projection matrix for both models.

Here are some screenshots to demonstrate what I'm talking about. Hard to tell with the jet, but the issue with the house is pretty clear. Just looking for some tips as to why this might happen? Hard for me to understand how the model could be the problem, but since I'm using the same matrices for both models, I feel like there must be something wrong with the way I exported the model or something. Thanks in advance for any time given to help me out!

[attachment=14031:1.png][attachment=14032:2.png][attachment=14033:3.png][attachment=14034:4.png][attachment=14035:5.png][attachment=14036:6.png]

Advertisement

My guess is that the vertex windings are backwards, so it's being drawn inside-out. You can test that with the following line.


GraphicsDevice.RasterizerState = RasterizerState.CullClockwise;

The default behavior is to cull counter-clockwise.

My guess is that the vertex windings are backwards

You were right! That line appeared to do the trick. Any idea if there is a way to take care of this on the export from Blender so I don't have to modify the cull mode?

Unfortunately I'm not familiar with Blender, so I can't really help you there. You could try flipping all the normals before you export, which isn't great, but it might work.

It is most likely because the faces are pointing the wrong way in blender, this can be quite hard to spot unless you go into texture mode. Try a google search to find out how to fix it as the only way i know this is because the same thing happened to me.

This topic is closed to new replies.

Advertisement