2
\$\begingroup\$

I am currently render my geometry using "Modern OpenGL" approach (with shaders and buffers). I have already implemented picking of single primitives using glReadPixels. Now I am faced with problem how to implement selection of multiple objects. I cannot use glReadPixels because maximum (and it seems meaningful for me) number of objects that I could select with 10x10 box is 100. But it is really necessary for my purposes to have ability to select thousands of objects in small selection area.

I already read answer to similar question where was recommended to test each point against selection rectangle. But it gives new problems: all my vertices are already stored in buffers and it looks like huge performance to test each point on CPU.

Could someone help with such issue?

\$\endgroup\$
  • \$\begingroup\$ What do you mean with "I have already implemented picking of single primitives using glReadPixels"? Are you using colorPicking? Is it acceptable for you get this selection only in top(side) view, or you need fully 3D selecting? \$\endgroup\$ – wondra Sep 10 '14 at 16:36
  • \$\begingroup\$ Yes, I am using color picking. I also need fully 3D selection. Problem is color picking is not acceptable solution because I may have more then 100 elements on 1 pixel which need to be selected. \$\endgroup\$ – frankie Sep 10 '14 at 18:26
  • \$\begingroup\$ Why is it limited to 100 elements? There is over 16mil colors. \$\endgroup\$ – wondra Sep 10 '14 at 19:03
  • \$\begingroup\$ @wondra okay, but I guess that color picking would not work when there is to much elements at one square unit. \$\endgroup\$ – frankie Sep 11 '14 at 9:26
  • \$\begingroup\$ you can always render the selected area in (much)higher resolution. Colorpicking cannot work if there are elements hiding behind each other and you want get all of them(picking regardless depth), in other cases, it will work with little tweaking. \$\endgroup\$ – wondra Sep 11 '14 at 12:25
1
\$\begingroup\$

One option is to take the screen coordinates for the rectangles corner points, convert them to rays in world space and then use these to define a box to do 3D collision detection with. The maximum length of the box should be the distance between the camera's near and far clipping plane.

\$\endgroup\$
  • \$\begingroup\$ can you provide references where full approach is described, or post here some code? \$\endgroup\$ – frankie Sep 10 '14 at 11:47
  • \$\begingroup\$ share please, how to perform selecting of objects with collision detection \$\endgroup\$ – frankie Sep 12 '14 at 8:48
  • \$\begingroup\$ Collision detection is a big topic and is going to largely depend on your needs and any system you currently/plan to have, so I can't really outline it here. There are numerous ways to perform object picking with rays, and this method is simply an expansion to build a box from 4 rays instead. Looking up frustum culling may be useful to you here as well as it's similar. \$\endgroup\$ – OriginalDaemon Sep 12 '14 at 9:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.