View Full Version : how can i know .....????

01-03-2004, 01:41 AM
how can i know if a click in the screem is in 3d object .( i mean if i want to drag some object , i need to know at the fush if it was in the object i want to drag)

thanks u all?

01-03-2004, 04:11 AM
Read about selection buffer, this is what you need.

01-03-2004, 06:42 AM
You can cast a ray from mouse position to viewer's direction and check if it hits any object with the ray-plane collision technique

01-15-2004, 12:21 AM
Casting a ray and testing with all polygons (or all frontfacing polygons) can cost alot...

What I did was pre-compute the OBB Trees of the meshes (useful for collision detection as well) and use the intersection of a ray and OBB tree to determine which polygon (if any) was hit. It's pretty fast and accurate, and can be accelerated even more if you first test the ray with the bounding spheres of the objects before passing to the OBB trees.

This technique gives other information which can be useful, such as distance from the cast point (the mouse click on the front clipping plane) to the object selected.

Cheers !