Jump to content
  • Advertisement
Sign in to follow this  
Freshmaker

XNA - Z axis backwards?

This topic is 4133 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

Been messing around with XNA and looking at some online tutorials and noticed something odd. This one in particular: http://www.riemers.net/eng/Tutorials/XNA/Csharp/Series1/World_space.php He defines a triangle with vertices: Red = (0,0,0) Yellow = (5, 10, 0) Green = (10, 0, -5) Now, if I positioned the camera at say 0,0,-40, and look at the origin, I would expect the Green vertex to be on the right. However, he positions the camera at positive 40 to make the Green be on the right. Is there something about the coordinate space in this XNA framework backwards? Thanks!

Share this post


Link to post
Share on other sites
Advertisement
XNA is by default right handed, which is no doubt confusing since most direct X examples are left handed, although the functions exist in both LH and RH versions. RH coordinates have the Z axis pointing in the opposite direction from LH coordinates (positive Z is out of the screen in RH, and into the screen in LH). Also the winding order of the vertices is CCW instead of clockwise.

see the math entry here:
http://msdn2.microsoft.com/en-us/directx/aa937797.aspx

You are stuck with it since they took away all of the LH functions. Of course if you have old code, its not that hard to invert the Z axis on the matrices or flip the winding order of the vertices or the cull mode.

Share this post


Link to post
Share on other sites
Thanks, that was a great article. The next odd thing, back to that example tutorial link, is he sets up the index buffer with CW vertex order and does so in several of his other tutorials also. He did stick in a CullMode = none, but taking that out, as he states, doesn't make a difference.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!