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?



I think that has nothing to do with maths but in opengl you can achieve the intersection of two objects if you use the stencil buffer.

Maybe this page could be helpful for you.