View Full Version : Selecting objects completely inside a region
I am writing an editor in which geometry may be selected via sweeping/rubber banding using the opengl selection mechanism. gluPickMatrix is used to setup a selection projection that corresponds to the area of the sweep.
My question is: how can i restrict the selection to those objects that lie fully inside the selection region?
At present any objects that intersect this region(either fully or partially) are registered as a hit due to the nature of the OpenGL selection mechanism
any help would be much appreciated.
06-28-2002, 12:08 AM
Perhaps not the best way...
Use the selection buffer to get all the objects inside the selection, then use gluProject to reject objects with vertices outside the selection.
06-28-2002, 01:24 AM
Again not fast, but you could try redrawing the geometry you get a 'pick' on to another 4 selection regions. Left, right, bottom and top. This isn't so bad because you have less stuff to draw and can eliminate even more on each of the surrounding selections.
Anything selected both inside and outside the pick region is obviously not entirely enclosed within the selection region.
| 2 |
| | | |
| 4 | 1 | 5 |
| 3 |
1 = first selection region
2-5 = anti-selection regions
You test the hit results of 1 against 2-5 and subtract those hits as you proceed.
| ___________ |
| |_____2_____| |
| | | | | |
| |4| 1 |5| |
| |_|_______|_| |
| |_____3_____| |
Something like this would do the same thing but it might be slower. I'd test both.
Make sure you are able to support a tiny frustum just outside your visible frustum incase of a drag from the edge. You may have to calculate the picking frusta yourself for this, it realy is easy with glFrustum. I don't use glu* that's cheating :-).
If you're looking down on a scene and considering that you want to eliminate as much geometry as possible early on the best clip order for typical scenes is probably something like this (unless the top of 1 breaks the horizon):
| __________________ |
| | | |
| | 2 | |
| | | |
| | 1 | |
| |_______| |
| 3 | | 4 |
| | 5 | |
Extending all selection regions well beyond the frustum as I have done with region 2 would probably make no difference except to cull more geometry early on and speed you up. It might even be faster in raw test speed depending on performance under clipped conditions.
[This message has been edited by dorbie (edited 06-28-2002).]
I have come across the method of cutting up the screen before but this seemed a bit like overkill. i might give the gluProject thing a try.
While we're on the subject of rubber banding, does anyone know if there are any problems with using the glLogicOp(GL_XOR) stuff under windows 2000 - because it just doesnt seem to work. Is there an alternative - without doing a complete redraw every time?
07-02-2002, 04:10 AM
Worst case you can readpixels from the frontbuffer when you start the drag and drawpixels to keep it clean during. Do the whole thing or just bits depending on performance. Drawing the whole thing should be pretty fast so long as you don't have to simultaneously animate by drawing to the backbuffer.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.