View Full Version : Volume Intersection Problem

11-13-2008, 11:27 AM
I would like to be able to show which parts of a polygonal model lie within an ellipsoidal volume. I'm hoping this can be done with a multi-pass rendering involving stencil operations. Can anyone point me to a tutorial similar to what I'm trying to do? Reading the documentation on stencil planes and stencil operations is not good enough (for me). I need to see code or pseudo-code that does something similar to the problem I'm trying to solve. Thanks.

11-13-2008, 11:37 AM

11-13-2008, 05:31 PM
In the case you don't want to link again a third party library, see this source code (http://www.cosc.brocku.ca/Offerings/3P98/course/OpenGL/glut-3.7/progs/advanced/csg.c).The functions that may interest you in the file are firstInsideSecond,fixDepth,and.

11-14-2008, 09:49 AM
Thanks for posting that code. It is better for me than using a library of canned routines because I may actually learn how to use stencil operations to accomplish my goal. I'll play with the code this weekend to see if I can figure out how to accomplish my objective.

11-14-2008, 11:58 PM
I have brought that sample code onto my home PC, compiled, and run it successfully. It's an excellent demo. Next I have to try and figure out how it works :)

11-17-2008, 10:06 AM
Draw a closed ellipsoid, toggling a stencil bit for each fragment that is in front of the z-buffer.
The stencil bits that are one have an odd number of ellipsoid surfaces in front of it, and therefore are inside the ellipsoid volume.

See also: