Jump to content
  • Advertisement
Sign in to follow this  
Frozen

D3DXVec3Unproject problem

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

Well, let's imagine I have some vertices, and all have z = 0; If I have a point, let's say A(100, 200), how do I find what point in model space was transformed and became A? I know I must use D3DXVec3Unproject, but I don't really know how.

Share this post


Link to post
Share on other sites
Advertisement
it's important to realise that, unless you also have Z information (which isn't necessarily accurate enough) a 2D coordinate converts to a 3D ray - that is, you can't know what model space coordinate became that rasterized 2D coordinate.

What you probably want to do is using D3DXVec3Unproject() determine the ray, and then use inverse transforms to find your coordinate/ray in a particular space...

Mathematically speaking

START Model -> View -> Projection -> Viewport FINISH

That would be World*View*Proj*Vport; simply using the inverse matrices you should be able to go back the other way -> Vport-1*Proj-1*View-1*World-1

it's all a bit confusing at times - sometimes only a good mathematics book can help you out [headshake]

hth though,
Jack

Share this post


Link to post
Share on other sites
Hey Frozen,

To unproject a point you would use the function like this

D3DXVECTOR3 pointInModelSpace;
D3DXVECTOR3 pointInScreenSpace(100,200,0);
D3DXVec3Unproject( &pointInModelSpace, &pointInScreenSpace, &myViewPort, &myProjection, &myView, &myWorld );

You should have access to the projection, viewport, world matrix and camera matrix to make this work.

Share this post


Link to post
Share on other sites
jollyjeffers,

I thought that is what unproject did, it multiplied the coordinate by the inverse concatanated matrix. He gave us the z information that all his vertices z value are zero. Maybe I'm a little confused though.

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!