Jump to content
  • Advertisement
Sign in to follow this  
Dhaos

D3DXVec3Project & D3DXVec3Unproject

This topic is 3543 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 am totally lost right now. I want to figure out what a point is, on the screen, given a world rotation. Everything I looked up pointed at two functions D3DXVec3Project & D3DXVec3Unproject. Each attempt at using these functions including any sort of rotation gave very weird numbers. However they worked perfectly as long as no rotation occurred. I know there is something funny going on when inputting the z value of the vector. I have no idea how one would determine what z to use. Visual Aid! +Y ^ | | | P | O--------> +X +Z is into the scene, -Z is out of the scene. I rotate via a world transform by some degrees. How do you determine what a point P is, considering the world rotation? I am *not* asking to apply a rotation to P, I want to know what P is given the world transformation. (normally P would be some value...but after a rotation P should be a much GREATER value since the axis that determines what each pixel is has been rotated). I am using an orthogonal projection so I don't have to deal with any perspective related calculations. I would expect that as you rotate an object by Y, the x value of each pixel would increase or decrease. Defaultly my viewport is 768 x 768, thus making each pixel worth 1/384 in 3D space. This again, works fine, so long as a rotation does not occur. Again I ask how do you determine a point on the screen given a world rotation. I know I am missing something silly, this can't be that hard, given how easy everything else about setting up directx is.

Share this post


Link to post
Share on other sites
Advertisement
If you want to determine what position the world transform is transforming too, multiply a Vec(0,0,0) by the matrix and then pass that in as the second parameter to D3DXVec3Project().

I might be wrong, but i think that is what i did.

Share this post


Link to post
Share on other sites
I might be misunderstanding you. You want me to rotate (0,0,0) by the world matrix and use that as the second parameter to D3DXVec3Project?

I might be unclear in what I am trying to accomplish, imagine clicking on the screen, and the computer outputting where you clicked using the axis that was rotated by the world transform.

When moving the mouse left or right, x would be adjusted much more massively.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!