Picking and selection buffer - simple?

Hi,

I am wanting to do hierarchical picking. I’m not too sure (by looking at FAQs), what the arrangement of the selection buffer output should be in any given circumstance.

Say for example, I do the following (after correct setup of selection):

glPushName ( AXIS );

glPushName ( MARKER );

glPopName ();
glPopName ();

glPushName ( OTHERTHING );

glPopName ();

…ok and I click on `marker’ - I want to know (a) that AXIS was clicked and (b) that MARKER on AXIS was clicked. What is the bytewise\format of the selection buffer in this case? Also, if OTHERTHING is behind MARKER and I click MARKER - OTHERTHING will be returned in the buffer. I have to depth sort to get MARKER (or is it AXIS?).

Anyway, please explain this to me in slow, painful and laborious detail.

Thanks.

Hi,

If I understand it correctly, The selection buffer should look like this in your case.

Selection buffer
[0] -> 2
[1] -> min z value
[2] -> max z value
[3] -> AXIS
[4] -> MARKER

If OTHERTHING is also in the hit, the selection buffer might look two ways:
[0] -> 2
[1] -> min z value
[2] -> max z value
[3] -> AXIS
[4] -> MARKER
[5] -> 1
[6] -> min z value
[7] -> max z value
[8] -> OTHERTHING

or

[0] -> 1
[1] -> min z value
[2] -> max z value
[3] -> OTHERTHING
[4] -> 2
[5] -> min z value
[6] -> max z value
[7] -> AXIS
[8] -> MARKER

So, to answer your question:
If you click on MARKER, AXIS will always be on the namestack, thus you’d know that AXIS is also selected.

If you click on AXIS but not MARKER, then only AXIS will be on the namestack.

Also note that AXIS geometries and MARKER geometries need not be physically in the same location for them to be selected. Even if the geometries is apart, when you click on MARKER, AXIS will always be selected (i.e. on the namestack).

Also, if OTHERTHING is behind MARKER, you just need to find the hit record with the minimum z to find out which object you have actually selected. Your depth sort will nab you the hit record which contain MARKER and AXIS together.

Also note that when you do the
glRenderMode( GL_RENDER )
from GL_SELECT,
this function will return the total number of hits in the selection buffer. It is very important to get this number.

Hope this will help.

Zu

Perfect. Thankyou very much (ended my confusion today) - I can now go home from work a happy chappy.

Maybe you can help me with my problem? So that I can go home and have a good night sleep… nightmare

Originally posted by Robbo:
[b]
Perfect. Thankyou very much (ended my confusion today) - I can now go home from work a happy chappy.

[/b]