View Full Version : edge detection for several rects

12-21-2003, 10:41 PM
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?

12-22-2003, 10:20 PM

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?


12-23-2003, 04:54 AM
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.