Making a multi-pieced rectangular breakable body with Farseer

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++)