   [Help] Ray picking
  I have load a mesh and then i draw a AABB bounding box for the mesh. the bounding box will move and rotation with mesh. Now i want to create a ray to detect that if ray hit the mesh, bounding box or not hit any thing. Anyone got the idea how to do that or example?in my guess, i have to use getcursorpos() to get the mouse position and compute vector origin and direction and then translate those into view space -> project space -> world space -> model's local space then check if it hit the mesh or bounding box. is this theory correct?Buy the way, when i load a mesh what space it is?[Edited by - tomneo2004 on June 22, 2009 7:19:15 AM]
  The general idea is that you cast a ray:- origin is the image plane pixel where the mouse pointer is- through a point on the near clip plane (creating a ray)- intersect that ray with stuffGoogle "language" + "API" + "picking example" (e.g. C# XNA picking) and you should get a ton of examples.   ;  If using OpenGL google for gluUnproject and its source code which is, for example, to be found in the Mesa implementation. If using Direct3D google for D3DXUnproject. Both should yield enough results to get you the idea of how its done. Your approach is already the correct way to do it.When loading a mesh its considered to be in local coordinate space with its own origin and axis system. If you render it as is without any additional transformation except for the camera space then this local space equals the world space.   ;  thanks guys   