Using Farseer 3.3.1 I want to create a rectangular BreakableBody with many pieces. Right now here is my code:

Vertices polygon = PolygonTools.CreateRectangle( 2.5f , 1.25f );
List<Vertices> triangulated = FlipcodeDecomposer.ConvexPartition(polygon);
BreakableBody breakableBody = new BreakableBody(triangulated, World, 1);
breakableBody.MainBody.Position = Vector2.Zero;
breakableBody.Strength = 5;

This code turns the rectangle into two pieces (cut from corner to corner). I have tried four of the five decomposing methods (Flipcode, Bayazit, CDT and Earclip). I also haven't been able to find any good examples of a rectangle being divided into multiple pieces.

Preferably, I am looking for a way to create random sized pieces, but cutting it into 32 cubes ( 8 x 4 ) would be fine also.


Farseer breaks apart the bodies along existing polygons, it will not create new ones for you.

You seem to misunderstand what decomposing is. It breaks apart complex polygons into the triangles necessary to represent it. It always takes 2 triangles to represent a polygon so that is why your body keeps breaking to 2 triangles.

Try something along the lines of the below (Note this is just of the top of my head)

List<Vertices> pieces = new List<Vertices>();
for (int x = -4; x < 4; x++)
  for (int y = -1; y < 1; y++)
    pieces.add(PolygonTools.CreateRectangle(1, 1, new Vector2(x,y)));
_breakablebody = new BreakableBody(pieces, World, 1);
  • \$\begingroup\$ Yes, I learned this in between when I asked and now (but forgot to come back to address my question :p). But this is the solution I used, so thank you for your answer. \$\endgroup\$ – Andrew Jackman Feb 19 '12 at 8:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.