Sign in to follow this  
Nauraushaun

How are X and Y defined in DirectX?

Recommended Posts

Nauraushaun    100
Hello there,
This is a bit of a beginner question, but it's so DirectX oriented that I decided to take it here.
I've spent some time making a game in DirectX. At the beginning I realized that DirectX or Direct3D or whichever by default has -X as right, and X as left. So, if you put a sprite at (5, 6), it ends up 5 spaces to the left, 6 spaces up. Why is this? Graphs aren't like this, why is DirectX? I actually tinkered so that my objects would respond the opposite, with +X being to the right of screen, but this is almost definitely a poor method of solving the problem.
Thanks for your help.

Share this post


Link to post
Share on other sites
mhagain    13430
X and Y aren't strictly defined in any particular way, and you can have them work any way you wish. It all depends on the projection matrix you set up, and that can use either left-handed coords (using the D3DX -LH functions, for example), right handed coords (-RH functions), or be any custom matrix you wish. The only exception to this is if you supply pretransformed coords (equivalent to D3DFVF_XYZRHW in the old fixed pipeline), in which case top-left is 0,0 and positions increase as you move towards bottom-right.

Share this post


Link to post
Share on other sites
Tom KQT    1704
mhagain is right.

But what makes me wonder is how did you come to the assumption that in Direct3D by default the +X goes left?
If we were to discuss the "default" axes orientation, then it would rather be +X pointing right, +Y up and +Z into the screen (or from the screen with RH), because this orientation is suggested also by the transformed vertices (view space, screen space etc). And last but not least, this: http://msdn.microsoft.com/en-us/library/bb204853%28v=vs.85%29.aspx

To sum it up: it all depends on you (on your definition of the view and proj matrices), as mhagain said.
But the somehow "default" orientation is +X right and -X left, not as you said.

Share this post


Link to post
Share on other sites
Nauraushaun    100
I've been using LH functions, evidently. I don't think I know enough about it to risk a change, this late in the project.
Thanks for the pointers guys. I didn't even know what to search for originally.

Share this post


Link to post
Share on other sites

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