max0180's picture

object space -> screen space

hi,

Ive a couple of 3d objects(in object space). when my mouse is over one object, i want to know which one.
how can i do it?

my thought: from my mouse position, i construct an orthogonal vector into the object screen and then i want to know which object touches my vector.

but dont know how?

markus


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
objarni's picture

This is the "picking problem". There are several solutions.

The most simple solution (in my point of view) is the one you are outlining: build some collision routines (triangle-ray, sphere-ray) and check which object in your scene collides with the "ray" going through your screen from your "eye" (0,0,0). If several objects collide, choose the object which is closest.

Another technique is discussed here:

http://www.opentk.com/node/213