PDA

View Full Version : subtracting polygons



Richard145
02-07-2007, 03:35 AM
I am not sure where to put this question, but since I am not an expert at OpenGL I will try here.

If I have two polygons, one Outer and one Inner, and I want to remove the area of the Inner polygon from that of the Outer polygon (create a "hole" in the Outer polygon) what is the easiest way? Does OpenGL have a library call that can do this automatically?

Thanks in advance for any help or hints.

jide
02-07-2007, 04:09 AM
You can use the stencil buffer to do that. Or you can use a CSG library. It's somewhat easy in both cases.

Richard145
02-07-2007, 07:02 AM
Thank you jide. I will give it a try.

Richard145
02-07-2007, 07:14 AM
Please excuse my ignorance, but will the stencil buffer remove everything in its defined region or only the polygon on which you have it placed?

I would like the user to still be able to see other polygons that may be behind the polygon that is being stenciled (such as an open-top box).

Once again, thank you.

RigidBody
02-08-2007, 04:52 AM
the simplest answer in that case would be "draw all other polygons without stencil test before the one with the hole"

Richard145
02-08-2007, 09:02 AM
Thank you RigidBody. I will give your suggestion a try.

Richard145
02-16-2007, 04:05 AM
Some of the general shapes of the polygons with the "holes" appear to be complex. I am unfamiliar but what about using tessellation?
Does anybody have a link or some simple code that uses tessellation I could look at?

Thanks in advance.

plasmonster
02-16-2007, 07:41 AM
Here's a nice tutorial:
http://www.flipcode.com/articles/article_tesselating.shtml

Some demos from the redbook (tesswind.c is in there):
http://www.sgi.com/products/software/opengl/examples/redbook/

I'm sure there are many other examples online (try a search for "opengl tesselation").

Hth