edge detection for several rects

I drew several 3D rects one on top of another and wish to detect the topmost rect so that i can make a part of that rect transparent, how do i proceed to do that? Also, is it necessary to convert objects to 2D for edge detection?

Hi,

If by edge detection you mean silhouettes, you can detect them by finding edges with the other face facing towards camera and the other one away. This you can check with a dot product between the face’s normal and a vector from one of it’s vertices to the camera.

The topmost quad is most robustly found by a bsp tree, but you can get approximate results by finding which quad’s center is closest to the camera. What’s the effect you’re trying to achieve?

-Ilkka

Ok… Having read your posts on the beginners forum:

So you only need to know which quad the mouse is on, right? I’m sure there would’ve been an easier way to ask this, but anyways. Your options are:

-OpenGL selection buffer
-Cast a ray from eye to mouse in software, see which quad it intersects closest
-Draw quads into backbuffer with different colors or stencil values, read back the pixel under the mouse (using glReadPixels) and choose the quad based on the color of the pixel.

-Ilkka