# D3DXVec3Unproject problem

This topic is 4966 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 on other sites
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 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 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.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 10
• 11
• 13
• 9
• 11
• ### Forum Statistics

• Total Topics
634090
• Total Posts
3015430
×

## Important Information

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!