View Full Version : Region Selection Opengl
03-03-2004, 07:20 AM
Does anybody have any ideas how I could go about doing region selections. That is given a selection region defined by something like a lasso tool, select all polygons that lie in region. The region would be extruded along the z direction for infinity. The I would apply regular modelview transform to geometry. Any methods to do this efficiently?
Precision is not critical, ie few dozen polygon extra. Also, it is okay if I select several object's polygons if they overlap.
Could I stencil buffer for this approach?
03-03-2004, 06:52 PM
Sorry to bump my own thread, but I was really hoping someone would have an answer. I have searched online and found very little on this. Thanks.
I had to do some kind of selection too lately. There are several way to do it. One is trying to figure out a way to project your mouse position in Object Space with an increasing depth value, but it would turn out to be complex and expensive.
The redbook itselfs explains a method using a specific openGL state ( the SELECTION state ) that does all the dirty work for you and returns a name for each polygon that is selected. This might be more simple, though you'll have to name each primtive in the scene, and it sounds to me like it's still quite expensive.
What I finally decided to do was to take a different approach that works quite well and that's not so expensive. All you have to do is render your scene twice :
1) First you render the scene with only depth testing enabled, you give each object a unique color so that you can use it to identify the object. You read the resulting framebuffer in system memory with glReadPixel and keep it to detect selection
2) You render your scene as usual
When you need to know what's selected, you just check the pixel from the selection pass that stand in the selected area, and if you find a color that corresponds to a specific object you now that object has been picked.
Of course you can balance performance/precision by modifing the resolution when you render the first pass, I personally found out that a 64*64 area is sufficent for selecting objects at a reasonable distance.
Hope I helped you somehow, I don't know if you are able to use multipass, in case you need help I'll be checking this post for a while!
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.