PDA

View Full Version : Picking



02-25-2001, 05:15 PM
Hi, I'm a novice/intermediate openGL programmer, and I'm having problems with picking (telling what 3d object the mouse is over). I've reached the point where I'm so frustrated, I've given up trying myself, and am asking for help from someone experienced :)

I'm using openGL in C/C++. I have the function to draw the objects (primitive objects). I have the x,y coordinate of the mouse, and this code reflects the current state of the camera:

glLoadIdentity();
glTranslatef(0.0f,0.0f,zoom);
glRotatef(overAngle,1.0f,0.0f,0.0f);
glRotatef(rotate,0,1,0);

Anything that I've tried has either failed to select the object, or has somehow thrown off my matrix/camera settings so I can not see the object drawn.

If anyone could, please tell me/explain to me/ (and/or) give the code to simply (given the information before):

-Write a function that takes the x,y of the mouse, and returns whether or not the mouse is over the object drawn in drawTop() at the camera settings noted above

Thank you.

-Akira

zed
02-25-2001, 06:52 PM
see my site (url in profile) for a demo that uses the selection buffer

02-25-2001, 07:49 PM
Thank you, your example helped me solve the problem.

-Akira