Breakable objects

Started by
12 comments, last by capn_midnight 20 years, 2 months ago

was looking for Stan Melax''s vox demo, but can''t find it anywhere, so here is a guy who made an equivalent. Vox demo

There are also BSP trees, and doing CSG operations, of course

Everything is better with Metal.

Advertisement
okay, I didn''t want to search for a hex tessalation fractal algo, I wanted to come up with one on my own. Here is what I have:

#include <cmath>//define constants, extreme precision unnecessary#define PIo3 1.04719#define sqrt3 1.73205void hex(float r, float a, float x, float y){   if(r>5){      float tr = r/sqrt3;      hex(tr, a + PIo3, x, y);      for(int n=0; n<6; ++n){         float ta, tx, ty;         ta = a + n*PIo3;         tx = x + r*cos(ta);         ty = y + r*sin(ta);         hex(tr, ta, tx, ty);      }   }   else{      //pseudocode      pushPolyStack(createHexPoly(r, a, x, y));   }      }

[Formerly "capn_midnight". See some of my projects. Find me on twitter tumblr G+ Github.]

who knows, by the time I''m done with this, I might have an article in the making.

[Formerly "capn_midnight". See some of my projects. Find me on twitter tumblr G+ Github.]

Check out James O''brien''s paper on Brittle Fracture.

http://www.cs.berkeley.edu/~job/Papers/

It really is exactly what you want to do. His work is true 3D but 2D is much easier. Start with your base shape and then tesselate it into finite elements using something like constrained Delaunay triangulation. Then use a strain formula to calculate the strain forces at each of the connecting nodes. If the strain exceeds some threshold you set, a fracture has occurred.

It ends up being sort of a mass and spring mesh system where the stretch is the strain on the element. Since everyone here is so into the rod-constraint stuff, a simple 2D tinkertoy demo using the Jakobsen style contraints could be made to work in this way very easy.

Then you can either do it the fast and easy way or the hard and more accurate way. Fast is just allow the object to split along the tesselated edges of your object. The crack will follow the path but if you tesselate enough and in a sort of non-regular way, it will be fine.

The "right" thing to do is calculate how the crack would go through the object and then remesh. The paper covers that in detail.

I also did a talk with James on these issues at GDC last year so can go into more particulars if you find the papers confusing.

This topic is closed to new replies.

Advertisement