rendering the overlapped geometry of objects

Hello Everyone,
I have a requirement to render the result of two objects added together. For instance, if two spheres touch each other I want to only see the object formed by the intersection of the two spheres. I think some people call this “Mutual Exclusive” volume. Other objects include cones and cubes. I also need to view sphere #1 with the sphere #2 cut out of it. The origin of all of these are arbitrary.

Do any of you know how to render these objects?

Also, I tried to copy and paste some C code into a this message and I got an error stating that the parenthesis were not allowed in the text. Can anyone explain this?

Thanks,
Tim

You need CSG (Constructive Solid Geometry).

There are two ways to do it:

  1. Calculate the Intersection/Union/Difference of the two objects on your own. The result is a polyhedra which you only have to display.

  2. Calculate the Intersection/Union/Difference of the two objects with the help of OpenGL. The result is only present in the frame buffer.

For the 2nd I have a link for you: http://www.sgi.com/software/opengl/advanced97/notes/node11.html .

The 1st one is really hard to accomplish with all special cases. But it has a big advantage: The resulting model can be drawn very fast. The 2nd solution will calculate the result new for each frame which makes it slow.

I know, there is a demo with sourcecode out there, but I didn’t find it at the moment.

Keywords: CSG, Boolean Operations, Set Operations.

Kilam.