I’m really interested to know what is the “best” approach and then what are people actually using in real world projects (as they may not be the same) for picking
I have been looking at different ways to implement picking in my game engine.
Based on my research so far i have found the following techniques:
- Color Picking.
This basically involves quietly re-drawing your entire scene but using a different color for every artifact. Then use the GL pixel at approach to determine the color at X,Y. This color will only match one of your objects… (assuming you managed to keep them all unique colors)
A decent approach but it eats up noticeable FPS cycles.
- True ray casting
Calculate the normal and plane for each model and then determine the closest intersecting point.
Ok this sounds nice an generic … but the math on this still escapes me… Especially for my models that have lots of angles and faces… So unless im missing a trick on this approach it sounds good but hard to implement.
-
Camera depth picking
I tripped over this one… as it didnt seem like a popular approach but i found the strategy to be interesting. Using Opengl change the perspective to “zoom” really tightly into where the mouse is. Next call glRenderMode(GL11.GL_Render) and you get the count of artifacts draw to the screen. The closest one is your winner. -
GL pick list
You assign a name to each model and then ask OpenGl to tell you what you clicked on… which sounds great! only this feature appears to be dead in current releases…
So what are people actually using??
For my purposes im most interested in 3D applications
thanks!
j.
[edited] - corrected typo… grr typos…
[edited +1] - added type 4 OpenGL Pick List