Skip to main content
gamedev.net
🔒 Locked

picking problem

Started by dxdotnet1 Nov 23, 2004 at 11:34 PM 3 replies 850+ views
Original Post
dxdotnet1
dxdotnet1
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?
dxdotnet1
dxdotnet1
I cant pick my mesh properly after a series of transform :(
pls help! it picks right when the mesh is untransformed.
Phillip Hamlyn
Phillip Hamlyn
This is covered in an MVP article here

http://www.mvps.org/directx/articles/improved_ray_picking.htm

mrwinch
mrwinch
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.
dxdotnet1
dxdotnet1
thanks but i already found the solution, i transform my ray from world to model and test it against model coordinate of my mesh. :)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.