15

I'm using a game physics library (Box2D) which only supports convex polygon shapes. However, I'd like the level builder to be able to just specify concave polygons without having to worry about that.

So, how can I automatically break apart a concave polygon into convex ones (or even all triangles). Speed would be cool, but ease of implementation is more important. The breaking apart will only be done on game initialization.

(My language is Flash/ActionScript 3, but that shouldn't matter)

Bart van Heukelom
  • 43,244
  • 59
  • 186
  • 301

3 Answers3

5

Bernard Chazelle and David P. Dobkin presented an algorithm for that in 1985: Optimal Convex Decompositions.

Other approaches can be found on Wikipedia.

Joey
  • 344,408
  • 85
  • 689
  • 683
3

you probabaly need triangulation

Joey
  • 344,408
  • 85
  • 689
  • 683
Drakosha
  • 11,925
  • 4
  • 39
  • 52
2

This page explains how to convert polygons into non-complex shapes using ActionScript 3. The code is large so I wont copy paste here.

http://www.emanueleferonato.com/2011/09/12/create-non-convex-complex-shapes-with-box2d/

benathon
  • 7,455
  • 2
  • 41
  • 70