PDA

View Full Version : picking: don't want to pick hidden objects



08-14-2003, 03:01 AM
hi
i got one problem: when i pick, i get also hit's from objects that are hidden by other objects and thus not visible. how do i stop openGL from returning hits for invisible objects?


thanks for help
_________________
-- hENON

PanzerSchreck
08-14-2003, 03:19 AM
You can't stop GL from also picking "hidden" objects unless you remove them by yourself.
But I see no problem in this, as you also get the Z-Values of the hits in your hit-buffer, which you can use to determine the nearest objects.

08-14-2003, 04:41 AM
thank's that's what i need.
is there even more information in the hit results i dont know of?

PanzerSchreck
08-14-2003, 05:08 AM
Every hit in your selectionbuffer consits of a total of four values in this order, where n is the hit you process :

SelectBuffer[(n*4)] = Number of objects on the stack when the hit occured
SelectBuffer[(n*4)+1] = Smallest Z-Value of all vertices of the hit object
SelectBuffer[(n*4)+2] = Biggest Z-Value of that object
SelectBuffer[(n*4)+3] = Name of the hit object

Hope this answers your question!

08-14-2003, 05:45 AM
yeah, thats great.

i suppose the order in the hit record depends directly on the order i am drawing the objects.

Rob The Bloke
08-14-2003, 09:03 PM
You could always use the hacky colour buffer trick where you draw the objects to the backbuffer only. Each object has it's own ID specified in the colour (use glColor3ub or glColor4ub) read the pixel back from the backbuffer.

The benefit of this is that if you enable depth buffering it will auotmatically do what you want.....