Picking

Started by
14 comments, last by Rectangle 11 years, 7 months ago

The Color picking would that be?

http://content.gpwik...nique_Color_IDs

Yes, the principles are right, but implemented using deprecated legacy OpenGL.
[size=2]Current project: Ephenation.
[size=2]Sharing OpenGL experiences: http://ephenationopengl.blogspot.com/
Advertisement

[quote name='VitaliBR' timestamp='1345737964' post='4972620']
The Color picking would that be?

http://content.gpwik...nique_Color_IDs

Yes, the principles are right, but implemented using deprecated legacy OpenGL.
[/quote]

What is deprecated? glReadPixels?
http://mateusvitali.wordpress.com/

I was also wondering about this. For a game with a lot of selectable objects on screen and where you dont need to know wich triangle is under the cursor only wich object (lets say World of Warcraft) would it be best to use colour picking or ray tracing?

Usually you can get away with ray tracing against a simplified geometry (circles, ellipses, boxes...).

[quote name='larspensjo' timestamp='1345738643' post='4972630']
[quote name='VitaliBR' timestamp='1345737964' post='4972620']
The Color picking would that be?

http://content.gpwik...nique_Color_IDs

Yes, the principles are right, but implemented using deprecated legacy OpenGL.
[/quote]

What is deprecated? glReadPixels?
[/quote]
No, that is valid. The old ways are the use of glBegin(), glTranslatef(), glColor(), etc. It called "immediate mode", as you define the geometry on-the-fly. The correct way is to use Vertex Buffer Objects (VBO) and Vertex Array Objects (VAO). You will also have to define your own shader. At first glance, it looks much harder. And it is harder, to begin with.

For a general tutorial about OpenGL 3+, see Learning Modern 3D Graphics Programming or http://www.opengl-tutorial.org/.
[size=2]Current project: Ephenation.
[size=2]Sharing OpenGL experiences: http://ephenationopengl.blogspot.com/
http://www.opengl.org/wiki/Common_Mistakes#Selection_and_Picking_and_Feedback_Mode
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
For the ray tracing method, here is a decent tutorial: http://schabby.de/picking-opengl-ray-tracing/

This topic is closed to new replies.

Advertisement