Explosions and physics

Started by
11 comments, last by Sweenie 19 years, 6 months ago
Setup ===== I'm currently using 2 engines: one is to draw and the other takes care of the physics. I would like to simulate physical explosions. I did couple of searches but I din't get lots of releveant stuff. I came up with an idea couple of weeks ago and something new popped in my mind this morning. So I have 2 solutions: First idea ========== The first idea was to get the epicenter of the explosion. From there, trace a ray to the center of each and every physical object in the scene. Depending on the distance between the epicenter and the middle of the physical object, puch every physical object. New idea ======== In the scene, place an immense unmovable (fixed?) collision sphere that represent the radius of the explosion and then remove it a split second later. The physics engine should take care of the collisions and push everything out of the area o fthe sphere (as 2 physical objects can't be at the same place at the same time) Problem ======= The first idea is a work around the physics engine and is damn slow when come the time to check for every ray and start pushing everything. The second idea might do serious random effects: who the hell knows how the physical objects are going to be propulsed? Asking ====== I'd like to know what you think about it and how you're implementing your explosions.
Advertisement
I do idea #1. Get the ray between the explosion and the object, scale it and then add it to the objects velocity. The scaling is just linearly interpolated so that the closer you are the more your pushed. You could do quadratic or other types of interpolation but i've found linear to work fine and its very quick and simple so haven't needed anything more comples. This way is very quick ... you just get the two positions, minus explosion position from the objects position, scale the new vector and add to the objects velocity. If you want you can add a check to make sure there are no objects in the way (so you can't be hit through a wall) but thats relativly easy to add.

If you try idea #2 won't all your objects just move to the edge of the sphere and not get pushed? I guess if your phyics engine does bouncing off terrain that'd work but having everyone instantly zap to the the radius of the sphere and then suddenly fall straight down would look really weird! I'd stick with #1
idea 2 is to be avoided. This looks like a hack, and does not have any physical meaning.

idea 1 is usually performed.

The explosion radius, or range of influence, is usually small. Say, 10 meters. Basically, see which objects are within that range, if any, generate an impulse on the object from the epicentre towards roughly the centre of the object (that should make the object spin). Or find the ray intersection with the object, and generate a impulse/torque from there. If you have ragdolls, you can generate an impulse on each joints.

You can also check for occlusions, and should. If the bomb explodes behind a wall, it should not damage whatever is behind that wall (or damage slightly, ...). For that, there are a wide range of techniques. One is to cast rays from the explosion towards hot points on the object and see if any are occluded. Costly, but feasable if you don't have that many explosions. Another one can be based on PVS sets. Also fake renders (render with minimum LOD and details, with a very short range, onto a very small texture from the explosion viewpoint, and count pixels/triangles drawn using a fast query mechanism).

Everything is better with Metal.

Okey just made this up but I got a feeling it's the most realistic way to do it.

You could see an explosion like a growing sphere, it grows at a certain rate, which gets smaller as it grows, the bigger the grow rate at the beginning the harder the bang. Just adding a velocity to the hit objects won't suffice for realisctic physics, the objects have to rotate. So what you do is:

Detect object-to-explosion-sphere collision and get the exact hit point.

If there was a hit, apply a force on the hit point starting off from the explosions center, the force that you determine with the explosions grow rate.

Decrease the grow rate.

Run the test till there are no more objects to be hit or the rate is smaller than a certain number.

Good luck.
Why would the rate of growth of the explosion become smaller? The energy per area, certainly, but the wavefront should move at the speed of sound in whatever the medium is - usually air.
To win one hundred victories in one hundred battles is not the acme of skill. To subdue the enemy without fighting is the acme of skill.
I would go for the first idea.
Just as olii says, it would look much more realistic if box protected by a pillar wouldn't be affected by the explosion.

I'm not an expert at fluid dynamics but wouldn't the burst of air swoop over the objects and therefor drag them up in the air?
Therefor applying the impulseforces a little bit above the objects centers would make it look like they were dragged up and it would also add a little spin to them.

<-Sweenie->
"Why would the rate of growth of the explosion become smaller?"

Well the explosions has to end somewhere, if it kept increasing the exlosions would never end. And also it will give an explosion effect, like objects further away are less affected than objects close to the explosion.
Just multiply the impulse by the inverse square of the distance of the object from the explosion.

[Edited by - CodeMunkie on October 13, 2004 2:09:51 PM]
"When you die, if you get a choice between going to regular heaven or pie heaven, choose pie heaven. It might be a trick, but if it's not, mmmmmmm, boy."
How to Ask Questions the Smart Way.
Quote:Original post by Mussi
Well the explosions has to end somewhere, if it kept increasing the exlosions would never end. And also it will give an explosion effect, like objects further away are less affected than objects close to the explosion.


No. You are confusing the speed of propagation of a wave with the energy contained in the wave. The speed of propagation is constant. The energy per unit area goes as the inverse square of the distance.

To put it another way : The energy transferred to an object is inversely proportional to the square of the distance; the time at which this happens is linear in the distance.
To win one hundred victories in one hundred battles is not the acme of skill. To subdue the enemy without fighting is the acme of skill.
oh so you were talking about real physics ^^, I just tought that up to simulate the explosion effect.

This topic is closed to new replies.

Advertisement