PDA

View Full Version : Physically correct destructible objects



3_of_8
15-03-2008, 12:22 AM
Hey there,

I'm currently playing some Half Life 2 and I realized that boxes do not just spawn some random pieces of wood when destroyed, as in most other games, but break very realistically. It's the same with windows, when I hit them, they break exactly at the point where I hit them and pieces of glass fall out of it at that point. Or cardboard boxes kinda fold when they are hit with a crowbar.

How does this work technically? Is this scripted or is this some very special physics technique, where some information about the object is stored in a separate file?

I am perfectly aware of the fact that the Source engine is not Open Source and nobody except its developers (and those guys who stole the code once :D ) probably knows how this works in detail, but I don't need details, I just want to have a rough idea how it works, as I (and my colleague) would love to have something like that in a game of ours.

User137
15-03-2008, 09:14 AM
I haven't played Halflife 2, but i can think of ideas how to make it. First objects are just what they are in every other game. When hit occurs, the game finds out which face(s) were involved on collision and then subdivides the face into more triangles. Depending on what hits the surface i think there must be hard coded behaviours for different cases.

Now.. all objects consists of triangles, so if bullet hits a glass which is rectangle or a cube as a whole, it gets tricky finding out which faces are with the subdivide. They could either have a common group index variable or material variable which stores info on how hard they are to bend/destroy. Either case, it is easy to find out which face it hit and then spread the effect on other same group triangles.

3_of_8
15-03-2008, 09:27 AM
You think that's true for those boxes? Because they always break where the nails should be, so you really have the single boards it's made of. One possibility how they did this could be that they have several connection types (as you can use yourself in Garry's Mod) like welds (which break after a certain amount of damage done to them, which you can adjust), sliders, ropes and hinges. Maybe they do that to the objects, too: Each object is divided into "subobjects" which are connected in one of these ways, and when hit, break.

This doesn't explain how they do it for the glass, but maybe it's like you say, or maybe... maybe it's even scripted or the Source engine has something especially for breaking glass effects...

JernejL
15-03-2008, 11:01 AM
New beta versions of newton support deforming and breaking of convex hull objects, you might be interested into that.

Robert Kosek
15-03-2008, 02:25 PM
Personally, I think you'd need two things:
1) The ability to treat specific faces as quads or as non-polygonal surfaces.
2) Some amount of molecular knowledge of the substance making the object, IE how glass fragments.

I would treat the glass as one quad surface and from there make jagged fractures (perhaps based off a fractal pattern) in the glass surface and then tessellate it based off that. It would then be simple to shatter the pieces once broken apart like that.

For a box you'd have to know something about how the material behaves. A metal box would simply "smush" into itself when given enough pressure, but a cardboard box could split, crack, or deform oddly because of the pressure and irregularity of the striking angle.

If you are good with math all this stuff should be a relative cakewalk.