Is there any way for the programmer to know which plane is in front of another one if there are two planes in the view? OpenGL knows that with Z Buffer, however, how can I know this?
Our project: we need to retrieve some information from planes in the view. We only try to get information from the front most plane. So we need to know which plane is the front most one. Is there any way to do that?
Just make your own state variable that keeps track of it.
there is an extremelly fast way to do what you want. Please dont use any gl command to do that (like rendering the planes with different colors or using the stencil buffer). If you choose that method you will have to draw a lot of overlapping geometry what will cost a lot of rendering time and will speed down your scene. To find the nearest plane at the mouse point use 3d math.
Follow these steps:
- convert the mouse screen coordinates to a camera space segment starting at the near view plane and ending at the far view plane;
- transform that segment to view space (multiply it by the inverted view matrix);
- uses a segment-plane intersection routine to find which planes are intersected and the intersection distance;
- get the smallest distance.
Althought that seems to be computationally expensive it isn’t and will run thousands of times faster than any rendering approach.
If you aren’t able to do the involved computation tasks i can send you a demo of mouse picking.