Archived

This topic is now archived and is closed to further replies.

d1820

Ray picking

Recommended Posts

In using ray picking in directx 8.1 is the only way it works correctly is if the world matrix is set as an identity? It seems that when i try to set a ratation, scale or translation on my mesh object for the world the ray picking no longer returns the correct results? Any ideas how to check if a mesh object was selected by the mouse when each mesh object has its own world settings (rotation, scale, translation)?

Share this post


Link to post
Share on other sites
quote:
Original post by d1820
In using ray picking in directx 8.1 is the only way it works correctly is if the world matrix is set as an identity?

It seems that when i try to set a ratation, scale or translation on my mesh object for the world the ray picking no longer returns the correct results?

Any ideas how to check if a mesh object was selected by the mouse when each mesh object has its own world settings (rotation, scale, translation)?


You have to convert the ray to be in the mesh''s local coordinate space. Each mesh has it''s own "world" matrix, right? So what you do is take the inverse of the object''s world matrix (by using D3DXMatrixInverse or your own matrix inversion routine) and use this matrix to tranform your ray to the object''s local coordinate space. You then use this transformed ray to do your picking.

Hope this helps,
neneboricua

Share this post


Link to post
Share on other sites