PDA

View Full Version : Selection Mode, selecting front poly only



redarrow
06-04-2005, 07:05 AM
Hi all,

Anyone know how to pick only the front most poly using selection mode?

I know there's got to be an easy answer, but it's slipping me now..

Thanks

dorbie
06-04-2005, 04:35 PM
When you finish selection the glRenderMode call returns the number of hits.

Each hit record includes the minimum & maximum depth, so look at the values written to your selection buffer & compare to get the nearest, the granularity will depend on the names you have, the bufefr includes the name stack.

So each hit gives:

int number_of_names
int depth_min_of_primitives
int depth_max_of_primitives
int name_stack[number_of_names]

The usefulness of the depth information depends on how you've grouped your geometry and names. It cannot be perfect, but it will help you narrow the field and allow further refinement.

redarrow
06-04-2005, 09:32 PM
Thanks,

I never quite did get how those min/max depth values worked..

If I get you right, depth_min_of_primitives is the distance of the nearest primitive to the viewpoint that recieved a selection hit?

So I find each "shape" (I use the winged-edge data structure by the way) in the name stack,
and compare the distance from it to the viewpoint with depth_min_of_primitives,
The closest one is the one I select..

Is that about right?