Targeting 3D objects with a mouse

Hi. What I’m trying to do is to see if I clicked on on object. The problem is that after transforming, then projecting the 3D model with shaders I then need to retrieve the vertices and find the edge ones. Now it’s probably my lack of knowledge but I can’t seem to find a function or a variable to retrieve the processed information form a GLSL shader. To me it also seems incredibly performance heavy.

From my experience in gaming I know that at least some years ago they used a simple shapes like rectangles probably transforming and projecting them without using shaders and checking if the mouse if over them that way. Have I guessed it correctly?

You can use some bounding shape (like a rectangle, or a box in 3D) to quickly determine if an object could
be hit or not, which is of course much faster than processing each potentially visible object and testing entire
objects. That way, you only need to perform intersection testing on objects actually intersecting the region under
the mouse cursor.

Some time ago I wrote a small animation program for a University assignment that required mouse picking of vertices.
I thought “screw it, lets do it the simple way” and wrote a functon that simply runs through the vertices of a potentially
hit object, multiplies the coordinates with transformation and projection matrices, does persepective divide and checks if it
is under the mouse cursor by some boundary.

The test objects had between 20k and and 50k vertices and there was no noticable hitch whatsoever when clicking on
something (tested on University machine with some not-that-expensive Intel Core 2 Duo processor). I didn’t measure
the time it took, but selecting a vertex of an object once every couple seconds performed instantanous with no noticable
impact on realtime rendering.