Oct 3, 2011 at 11:04 AM

is there a shatter demo for farseer or box2d somewhere? like in castle crushers or games like that. example:

(first one is like breakable body and the second one is how i need it)

Thanks everyone

Nov 8, 2011 at 2:23 PM


Nov 8, 2011 at 3:16 PM

There is no demo that I have seen, but you could accomplish this effect using laser cutting and proper usage of joints.  With the joints, when the reaction force/torque breaks a certain threshold, remove the joint and the pieces will fly apart.  that would be a good place to start with getting the "wood" to splinter using the laser.

I don't really know how you are going to make this effect really nice though as you have the problem of farseer being a 2d physics engine and you are trying to simulate a 3d effect.

Nov 9, 2011 at 12:02 PM

thats like the breakable bodys.

i'm thinking about voroni shatter...

Nov 9, 2011 at 8:24 PM

There are three things that you have said you wanted it to be like now.  Castle Crushers, the wood in the Star Wars video, and now Voronoi.  Maybe you could be specific.

Nov 10, 2011 at 11:49 AM

Castle Crushers and the Star Wars video are examples to show what kind of shatter i'm searching. Voronoi is an idea how to get this shatter working (place most of the points near the impact point and cut the polygon at the edges of the voronoi diagramm.

Nov 10, 2011 at 1:38 PM

It seems that you are going to have to code this yourself as I can't find anything googling.

Voronoi is a good place to start to get an object to shatter.  A quick google of "farseer voronoi" has this as its second link:

You could also try googling box2d stuff as this engine is very similar.  A quick google of "box2d voronoi" has this on its first page:

I still don't know exactly what you want.  Splintery wood?  Do you want the pieces to stick together?  What is Castle Crushers?  Did you mean Castle Crashers?  What shattering is there in Castle Crashers?  Did you google anything?


Nov 10, 2011 at 4:44 PM

the 2nd link is exactly what i need. (i found that before but i found no sample or something) (to keep the vornoi in the shape)

Nov 10, 2011 at 6:19 PM
Edited Nov 10, 2011 at 6:22 PM

That is the voronoi diagram library that the second link uses.  It is in actionscript, but it should not be too troublesome to port over to c#.  And if you do port it, open source it! :p  And credit Alan Shaw of course.

Now, actually breaking up a Body in farseer using the voronoi diagram will take a little bit of work as well.  Check out the CuttingTools.cs file in the Common/PolygonManipulation folder of the farseer source.  It will cut the polygons, but will only work right if the cut you are making goes all the way across the polygon.  You should be able to modify that to your needs as well.  I am imagining it wouldn't be too difficult to get working, but I haven't actually looked at how the cutting is done.  I just know what the documentation says.

And actually, you may consider just creating new bodies in the shape of the voronoi regions and removing the old body.  I have no idea what kind of performance hit either of my proposed methods would have.

If one of the dev's or someone who knows better could chime in with what would be a good method to pursue this I would be interested to know as well.

Nov 10, 2011 at 10:37 PM

Fortune's algorithm creates a Voronoi diagram that sort of looks like rock chunks. We already have some algorithms in that category such as the delaunay algorithm and I would love to have furtune's algorithm in the engine too. But remember, the main purpose of FPE is to be a physics engine ;) so it won't be high on the todo list.

As MaskedPixel proposed, the best way is to take the polygon vertices, break them up using Fortune's algorithm into a Voronoi diagram and use each individual part as a new polygon. Don't worry about performance in creating new fixtures - in the end, profile it if it does not run as you expected, then change it. Premature optimization is not something I would recommend.

Nov 11, 2011 at 7:25 AM

i'll give my best :)

and ofc it will be open source.

thanks for the help :D