PDA

View Full Version : boolean operation, quads and circle.



magnuse
07-29-2004, 11:55 PM
hi, I need some help with this kind of boolean problem. I have a square (GL_QUADS) built up with four vertices and want to make a hole in the middle of this one.
My idea is to make a circle and then take boolean between the square and the circle, to get a hole where I put the circle.
But I don't know how to do this. If someone can help me I will be very thankful...
I'm a beginner and using Microsoft Visual c++.

SeskaPeel
07-30-2004, 02:47 AM
Magnuse, this is called constructive geometry (CSG). To do that, you'll need to use the stencil buffer.

This is very simple :
1/ Disable frame buffer writing (glColorMask)
2/ Enable stencil writing
3/ Render your circle
4/ Disable stencil writing, enable stencil test
5/ Render your quad

The next step is to have a cube, and make a hole through it with a cylinder, or half it with a sphere. This uses the same technique, but I'll leave you think about it.

SeskaPeel.

magnuse
07-30-2004, 05:55 AM
thanx, I've done it now...

Eric
08-02-2004, 05:53 AM
As a side note, I'll add that if you're only interested in such boolean operations (i.e. making holes) with "flat surfaces", you may want to have a look at the Tesselator object available in the GLU library.

It won't work for proper CSG though!!! ;)