PDA

View Full Version : picking 2D object (with rotation, translation)



codetale
08-13-2010, 02:35 AM
My apologize if wrong forum to ask my question.
And sorry about my poor English.

I am new to opengl,
I draw some objects on screen, all objects are form with 4 vertices and map a texture to it.

my problem is how I select the object after apply rotation and translation (glTranslatef, glRotatef)?

is there any way to know the translated or rotated location of the vertices?

thank you very much

Rosario Leonardi
08-13-2010, 05:17 AM
There are different technique to pick object.

One is to draw the object in a flat color in a separate buffer and associate a color to each object. Then read the pixel of the buffer to know witch object you have selected. Multisampling must be disabled cause multisampling can change the final color of the object the edge. The bad news is that the user can FORCE the multisampling to be enabled.

Another solution is to aproximate the object with a simple object, a sphere, a box a capsule.

You should usually know the position and the rotation (cause you are the one that set them). If you don't know them you can retrieve the current matrix with glGet