Skip to main content
gamedev.net
🔒 Locked

Help picking

Started by SFSpoto 0 replies 300+ views
Original Post
SFSpoto
SFSpoto
Hi. I have studied the opengl system for pick an object in 3d space. It is collegated to the name stack of objects. For example, if i wont to get a single vertex of a mesh, i must to save a name on stack for each vertex? If there is a complex mesh, or several different complex meshes, this system is not too expesive? What is the system that is used in this case? tnx.
Zipster
Zipster
Unfortunately, the OpenGL selection system isn't all that advanced. You pretty much need a name for each entity that will potentially be selected, and if you have thousands of entities then you need thousands of names, not to mention a rather large selection buffer. The alternative is to write your own selection code, which isn't that bad. You just have to be able to convert a point on your screen to a ray in world-space, and then manually find out which objects intersect. Thus the selection code is in your own hands and you can perform any optimizations you want. Not to mention it's API-independent. As for the actual transformation from screen-space into world-space/object-space, and performing the ray-point intersection you'd need, there's standard formulas for doing that. Look up gluUnProject for the transformation, it provides some insight on the formulas it uses. And for the the ray-point intersection, it's basically finding the distance from a point to a line and if it's less than some threshold, you intersect.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.