How can I select an object from screen?

5 views
Skip to first unread message

Hanyu Liu

unread,
Nov 7, 2009, 4:44:06 PM11/7/09
to G3D Users
Hi, all
How can I select an object I drawn from the screen? For example, I
draw 4 cubes in different locations, with different names, like A, B,
C and D, without occlusions. If I click one cube, I could know which
cube is selected. Can some one tell me which classes should be used
and the main process to implement this?
Thank you!

Morgan McGuire

unread,
Nov 7, 2009, 4:55:14 PM11/7/09
to g3d-...@googlegroups.com
I'd use GCamera's world ray function to get a ray from the mouse position and CollisionDetection's ray-box intersection to find which box it hit.

-m

Prof. Morgan McGuire
Computer Science Department
Williams College
http://cs.williams.edu/~morgan

Hanyu Liu

unread,
Nov 7, 2009, 5:54:39 PM11/7/09
to g3d-...@googlegroups.com
Thank you very much, Morgan.
Ray-box intersection is not a defined function of CollisionDetection,
right? I need to use Ray::intersection or Ray::distance to determine
which box is hit by the ray.

Morgan McGuire

unread,
Nov 7, 2009, 8:39:45 PM11/7/09
to g3d-...@googlegroups.com
See collisionTimeForMovingPointFixedAABox

-m

Prof. Morgan McGuire
Computer Science Department
Williams College
http://cs.williams.edu/~morgan


Hanyu Liu

unread,
Nov 9, 2009, 11:14:55 AM11/9/09
to G3D Users
Thank you, Morgan!
It works well!
Reply all
Reply to author
Forward
0 new messages