PDA

View Full Version : rotated points selection



chenghuayan
04-22-2005, 05:11 AM
I drawn points in a window and used the select mode method shown in the "red book" to select them. But after I rotate those points, I am not able to select them again. I am new to opengl, so could someone teach me specificly how to do this?

plasmonster
04-23-2005, 01:49 PM
Selection should work with rotation. You have probably made a simple mistake somewhere.

Here's some code that works:
http://www.lighthouse3d.com/opengl/picking/

Maybe this will help you spot any mistakes, like not setting the pick matrix properly.

chenghuayan
04-24-2005, 12:08 PM
Yes, your seguession helps. I didn't multiply the rotation matrix before setting the pick matrix. It works fine now. Thanks for your reply.

plasmonster
04-24-2005, 12:23 PM
Hey Chenghuayan, glad that helped.

It sounds like you building the modelview on the projection matrix stack, or something. That can work, but you might run into trouble with lighting, among other things.

Just so you know, you can set up the camera and object transformations just as you would without picking. The trick is applying the pick matrix transform before the usual projection matrix setup.

// Begin frame
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPickMatrix(...);
glFrustum(...)/glOrtho(...);

glMatrixMode(GL_MODELVIEW);
... camera transforms as usual

... object transformations as usual
(Don't forget to push and pop the camera)