This project has moved. For the latest updates, please go here.

Cutting peices out of Geometry

Nov 13, 2009 at 7:08 AM
Edited Nov 13, 2009 at 7:15 AM

I'm trying to figure out the best way to create some geometry to represent my 'level'. What I basically want to do is to define a shape, then to define another shape to 'cut' out of the first shape.

Pictures of what I'd like to do:

Just imagine the game taking place inside those areas, boxes flying around etc. Basically, the gray area is the bounding area.

Whats the best way to achieve this? Thanks

Nov 13, 2009 at 7:52 AM

Hi James.

If the shapes are going to be simple like that you can easily write your own code to generate them, because Polygon clipping can be quite expensive. If you need to use clipping though the "Union", "Subtract" and "CutHoleInShape" functions from the Vertices class will do what you want, and if I remember correctly theres even an example on how to use them in AdvancedSamples.

Also have a look at the GPC Polygon Clipping Library, which I use in my game Boxycraft for both the clipping and triangulation.

But still, if they are going to be that simple (boxes and circles), you can write your own code to generate them, or even use the clipping functions and save the result.