Blog

Archive
| All posts |
  • Shatter

    published on 4/4/2011 6:28 PM

    On the morning of 26th of March I finally came up with an idea that I could use to join the [url:DBF Destruction competition 2011|http://www.dbfinteractive.com/forum/index.php?topic=4924.0]. The problem was that the deadline was the very same day. The idea I had was to simulate the shattering of glass and as such it was a fairly ambitious idea for the 8 hours that was left until the deadline but I though I might as well try. A while before the deadline I had a entry that I though was good enough to enter the compo with.

    The original entry [url:finished 3rd|http://www.dbfinteractive.com/display_comp.php?dl_id=24] but work continued on the effect and this is the end result of a few days of polishing.

    The process to do this effect is as follows.

    Create 4 points and add to a list

    Depending on the destruction done on the window

    ** For a explosion randomize a number of points inside the rectangle formed by the 4 points ** For a bullet hit pick a random point and generate rings with the initial point in the center

    Triangulate the point list. [url:Paul Bourkes triangulation|http://paulbourke.net/papers/triangulate] works fine for this

    From the triangle soup create one shard per triangle.

    Depending on the destruction done on the window

    ** For a explosion calculate the distance from ground zero and apply a force equal to that to each point in the shard list ** For a bullet hit calculate the distance from the ray and apply a force equal to that to each point in the shard list

    Use a [url:verlet integrator|http://en.wikipedia.org/wiki/Verlet_integration] to simulate the shards particles. The verlet integrator is very simple, fast and stable so perfect for shards.

    After the integrator has moved the shards forward a time step move all points out from any collision surfaces

    Let the effect run for a few seconds then apply a linear interpolation that takes the shard particles back to their original location to create the rebuild effect

    Apply an appropriate shader to the triangle list and the effect is complete

    Only one window is simulated and then cloned 3 more times to create the illusion of a fully simulated box. The first explosion in the video is about 2000 shards in each window the 2nd and 3rd explosions are closer to 30000 per window.

    No textures where used or harmed in the making of this entry. It's all procedural.

    You can try it [url:yourself|/shatterv2.zip]. Start it with the "run.bat" file. Most of the scene can be changed in the scenes/shatter.p9s file