fuzzy, yet accurate selection

Hi, I have a fairly complex scene in which I’m trying to make it easy for users to click thin lines. I’ve got it working with gluPickMatrix: width and height are both 17. Then I use glReadPixels to sample all the pixels in the depth buffer for the 17x17 square.

My problem is that I still need the picking to be accurate - I need to give a higher priority to objects which are found at the center of the square than on the periphery.

It seems like I should be able to correspond the depth buffer value of the closest, highest-priority, non-empty pixel with a z value returned from the selection buffer. But I can’t seem to convert the values to parallel ranges.

Am I going about this the right way? Any examples I can look at?

Thanks a lot.

You could perform multiple pick passes with different sizes, even making it addaptive.

If you start large then only draw picked items subsequently to smaller pick boxes and stop when you have only one or at some size limit.

for simple straight lines, you could just use gluProject to map the lines’ start-/endpoint onto the screen and by this calculate the mouse pointer’s distance to the line in screen coordinates.

what kind of application is it? some kind of model editor?

Dorbie - thanks. I followed your idea of multiple passes, and ended up making two passes.

The first pass has a large pick matrix and reads the entire depth buffer to determine the best pixel to use. The second pass uses a 1 pixel pick matrix at the chosen point and finds the highest pick buffer match at that point. Wish I could do all this in one pass.

RigidBody - unfortunately, these lines are quite curvy. I didn’t write the line generation code, but I’m assuming they’re just line strips with a lot of points. It’s a biology visualization tool. See http://spdc.sdsc.edu/iedb/epitopeViewer/viewer_jogl3.php, click ‘View’, and click on one of the “ribbons” in the 3d part to turn it to a thin line.