XNA - Z axis backwards?

Started by
1 comment, last by Freshmaker 17 years, 2 months ago
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!
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.
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.

This topic is closed to new replies.

Advertisement