Sign in to follow this  
dxdotnet1

picking problem

Recommended Posts

guys help me see i have a 3d terrain composed of tiles and my tile picking works well. my only problem is when i add a 3d model in my terrain i cant pick the model properly. well i draw all the terrain first using 3d tile then drawn all visible 3d models. See the problem is when i drawn the model lets say for example at 16,0,-128 and pick at the model it doesnt picked. but when i click on the first tile ( tile 0 located at 0,0,0) my message box says that i picked the model. whats wrong? when do i need to reset my world matrix? or do i really need to reset my world matrix when drawing someting?

Share this post


Link to post
Share on other sites
Could you post your code?
A good solution for ray picking is the use of D3DXIntersect and D3DXVec3Unproject function.
With the second, you transform a screen point to the space coordinates (remember that the input coordinates should be in viewport coordinates): notes that the pWorld matrix must the trasformation matrix of the mesh.
Using D3DXVec3Unproject you obtain the first D3DXVECTOR for D3DXIntersect: with the second you will "create" a ray and if it's intersect the mesh, last function return true value.

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