Sign in to follow this  
Dhaos

D3DXVec3Project & D3DXVec3Unproject

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
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

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