Skip to main content
gamedev.net
🔒 Locked

breaking an object

Started by V-man 8 replies 2.6k views
Original Post
V-man
V-man
Has anyone implemented "breaking an object". I guess the choices are to predefine the geometry. In other words, perhaps I can store the borken peices in my file format. I need to figure out if I can use Blender to help break an object offline. The other option is to have some kind of a math. This would be difficult since there is a need to texture the broken surfaces. How did you tackle this problem?
bzroom
bzroom
Pre-broken geometry is often used. With one state of the mesh representing the whole object, and another state representing hte many states. You can either simulate the debris pieces with physics by spawning a physical object associated to each sub mesh. Or you can run an animation, either artist created or procedural to give the appearance of physical simulation but with a lot less cost.

Those methods are for pre-broken geometry.

For procedurally broken geometry it would be difficult to artist animate it since it doesnt exist until it breaks. But likely you would create a submesh by breaking and capping the mesh based on some split plane. That new submesh would be controlled with either procedural or physical animation.

Havok has some demos for the latter (procedural break), and the first set of solutions would be covered by the demo when the procedurally broken pieces are spawned into the world.
PreBreak   ProceduralBreak     \       /     _\|   |/_         O spawn pieces       /   \         |/_   _\|Physics     Precedural animation

*crappy ascii arrows :P
grhodes_at_work
grhodes_at_work
John Ratcliff wrote some code, CreateDynamics (open source) that can take a generic mesh and preprocess it for "pre-fracture," which is an industry term used to describe pre-broken geometry. nVIDIA has announced their APEX tool, which helps create pre-fracture geometry for PhysX. It's in beta, not yet available to the public. Havok has a destruction capability, with a good toolset, but I'm not sure if its available with their free use license. The Bullet open source physics library has convex decomposition functionality (based on Ratcliff's code), which can be used to generate prefracture models. In (I think) the Bullet 2.5 SDK, there was an example of this.

Most engines support "breakable" constraints, which are joints that will break if the joint force exceeds some maximum limit. Using prefracture with the pieces initially connected with breakable 6DOF joints is a way to have the physics engine automatically break things for you. Now...keep in mind, it is breaking the physics model. You have to also have your visual/render model break. I think Ratcliff's CreateDynamics code deals with this, e.g., it imports an art model, decomposes it into convex chunks...which can be your visualization model chunks, then for each chunk creates a corresponding physics body.

Pixelux Entertainment has a product called Digital Molecular Matter (DMM) that focuses on destruction physics for games. They use finite element methods instead of rigid body dynamics with breakable constraints. It's a bit fancy. Check it out.

Your observation that texturing the broken surfaces is tricky is a good observation. But it is not at all unachieveable, even for a single developer as long as they are strong in geometry and math. Here's an outline of how you could do it. Let's say that you model a piece of wood as a 3D surface model to be rendered...you are modeling the exterior surface, not the interior volume. If you break the exterior in half, what are you left with? Two meshes, each with an open hole on one side revealing that the model was nothing but a shell. To fill the hole, you have to do something like:

1) Find the boundary edges of the hole. [This is easy enough...just look for triangles edges with no neighbor. Those edges are on the boundary of the hole. If you represented your mesh using the winged-edge data structure---WEDS---it will be fast to search since you just traverse the edges and look for edges that have a face on only the left or the right but not both, an O(n) search.]
2) Create a (potentially nonplanar) closed polygon by connecting those found edges together. A closed polygon is a loop, when you circle back around and come back to the edge you started with. There may be more than one polygon depending on how the thing breaks. The WEDS data structure again helps with this, since every edge already points towards the next edge, enabling you to traverse without searching for the next edge in the loop.
3) Triangulate the polygon(s) to generate triangles to fill the gap, using, for example, an ear-clipping algorithm or a constrained Delaunay triangulation. (The polygons are likely concave, so an unconstrained Delaunay triangulation will fail to generate the correct results. Ear-clipping can handle concave polygons, as can a constrained Delaunay triangulation.) The trick here is to project the (potentially nonplanar) polygon(s) into some plane to do the triangulation. If the triangle is twisted out of plane (as it likely is with fracture), then if you choose your projection plane poorly you may get a folded or degenerate polygon that fails in the triangulation...so some extra work may be needed to deal with non-planar polygons.
4) Map some texture onto the triangulated hole-filling polygons. You cannot merely use the same texture coordinates from the original vertices, as this will create ugly stripes across the closed face where the hole used to be. But you would like to minimize discontinuity between the texture as applied to the hole filler and the original boundary mesh. Applying the texture in some radial fashion that matches the boundary but is different in the center is a possibility (think of the growth circles of trees). This would require adding a new vertex or vertices to the interior of the hole filler polygons to give something to be at the center of the radial map. If you do this, then you would perhaps add a point at the average location of all the points on the fill polygon and use the constrained Delaunay triangulation in step 3 above. OR, do the ear-clipping triangulation then run the result through a subdivision algorithm...but disallow subdivision of boundary edges since you want to match up with the exterior surface mesh.

Hope all the trivia and thoughts help!
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net
V-man
V-man
Thanks for the replies. I will have a look at those libraries.
Yes, I would like to prefracture and save the broken pieces in my file format.
I will do the physics and animation myself (no artists involved).
bzroom
bzroom
I found it helpful to include a "spawn vector" with each debris piece. So that you can control the velocity and direction of each piece at is leaves. There were other semantics such as WorldRelative, ObjectRelative, and Randomization.

This came in handy during cut scenes and stuff where we wanted a very specific behavior from the debris, for ex: want a wheel from a car to fly by the camera.. that's a world relative velocity. No matter what way the car is it'll shoot at the camera.

The windows how ever, you want the glass to always break "out" so they had an object relative vector pointing outward.

Ground impacts always go up + some random, etc.

Good luck!
grhodes_at_work
grhodes_at_work
bzroom, your spawn vector concept is a good one, especially when it is desirable to have an artist composed look to the effect. Some libraries also use callbacks when joints are broken, to allow things like spawning particle system such as a dust cloud to further enhance the visual.
Graham Rhodes Moderator, Math & Physics forum @ gamedev.net
V-man
V-man
For CreateDynamics, I downloaded some installer from that guy but the documentation doesnt match what the program has. I didn't "get it" just by playing around with his program.

APEX : should I ask for the beta? I just want to break 1 or 2 objects. I'm not really into beta testing all the features of that product.

I will check Bullet engine soon.
grhodes_at_work
grhodes_at_work
I'm not surprised there was a disconnect between CreateDynamics and the presentation...there isn't any true software documentation for CreateDynamics that I've seen, so there's a discovery process on how to use it. I don't know if nVIDIA would let you into the APEX beta. I think it's a closed beta, but if you're in their developer network it may be possible. It may be that there aren't any good open source or freely available tools for authoring prefracture yet. I wish there were, but all I could offer what what I know.

Graham Rhodes Moderator, Math & Physics forum @ gamedev.net
PolyVox
PolyVox
At GDC 09 there was a talk by Volition about how they do the destructible environments in the next Red Faction game. They are basically doing pre-defined breaking as you describe. You can read Gamedev's summary of the talk here:

http://www.gamedev.net/columns/events/gdc2009/article.asp?id=1435

And you can see a movie of the technique in action here:

http://cmpmedia.vo.llnwd.net/o1/vault/gdc09/slides/bldg_collapse.wmv

I have the actual slides at work but I don't suppose I am allowed to distribute them :-( Maybe if you search you can find them online.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.