Jump to content
  • Advertisement
Sign in to follow this  
KShots

OpenGL OpenGL selection buffer

This topic is 4401 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Has anyone ever worked with this before? Currently, I have it working - I can select things with a single click, and I can click and drag over an area to get an area full of things. The problem I'm encountering is that I'm getting all the objects behind the other objects I'm drawing as well... This is easy to solve if I'm just doing a single click, where the selection area is 9 pixels (1 to each side of the click - an area of 0 didn't seem to work) by simply comparing the depth of the hits... but when you're dragging over an area, it becomes more complex. By definition, you're trying to select more than one object when you're dragging, but you don't necessarily want every object in the world that's viewable in your "near" to "far" viewing frustum in the dragged area. Any idea how to approach that?

Share this post


Link to post
Share on other sites
Advertisement
You get, as you say, everything within the view volume defined by the selection area. If you don't want everything, then you have to limit the near and far clip planes, or manually pick the objects from the selection buffer you want. If you only want a subset of the selection volume, you have to tell OpenGL what subset you want, or you have to ask for everything and extract the proper subset yourself.

Share this post


Link to post
Share on other sites
Quote:
Original post by KShots
By definition, you're trying to select more than one object when you're dragging, but you don't necessarily want every object in the world that's viewable in your "near" to "far" viewing frustum in the dragged area.
I really should rephrase that. Of course you want everything you can see to be selected. What I'm looking for is a way to exclude objects that you can't see, but are contained within your viewing volume (they're obstructed by a closer object). On the other hand, if they are partially visible, I would want them to be selected also. The way I was previously phrasing my problem was implying that I didn't necessarily want to select everything I can see - that's not the case :).

A problem that could crop up if you're just "selecting it all" and deselecting what you don't want, is that you may miss something way out towards your far clipping plane that you can't see in a complex scene... I'm trying to avoid that sort of thing - I'm anticipating very complex scenes where I may be selecting any visible model, triangle, or vertex.

Share this post


Link to post
Share on other sites
Then I think a rasterization based solution would be better. Assign a unique color to each object and draw them to a non-visible frame buffer (the back buffer for example, or an off screen buffer), and read back the colors drawn. The stencil buffer could work aswell, but limits the number of unique objects a bit.

Share this post


Link to post
Share on other sites
Ah, you're absolutely right. I'd compared that and the selection buffer earlier, thought the selection buffer was a "neater" solution... but I can definately see the "unique color" solution solving my problem. Thanks!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!