[ODE] Shockwave of an explosion
Roel van Dijk
roelvandijk at home.nl
Tue Dec 23 12:53:26 MST 2003
On Tuesday 23 December 2003 11:36, bernd129 at web.de wrote:
> Hello.
> How can I simulate the shockwave of an explosion?
Hmm. You first have to define the shockwave of the explosion. Let's say it's a
perfect sphere. The shockwave has a position and a radius. Everything within
the radius of the shockwave is propelled outwards. Away from the center of
the shockwave. The amount of force applied to objects depends on the distance
from the center. At the time of detonation the radius is 0. The radius of the
explosion should grow rapidly after detonation.
How much and for how long depends on the type of explosion. A handgrenade
could make an explosion of 2 meters for 0.5 seconds (just estimating) and a
huge napalm bomb could have an explosion of 100 meters for 5 seconds.
An explosion 'object' could look something like this:
class Explosion
{
public:
vector3D position; // position of the explosion
float maxSize; // maximum size of the explosion
float curSize; // current size, initially 0, increases over time
float duration; // duration in seconds
float elapsedTime; // how much time has elapsed since detonation
float force; // force of the explosion
void update(float time); // progress the explosion 'time' seconds
};
When there is an explosion you create an Explosion object with the appropriate
parameters. You call the update function every simulation loop. Then you do
collision detection. If an object is within the radius of the explosion you
apply a force on that object. The force vector runs from the center of the
explosion the the object. The size of the vector depends on the distance
between the object and the explosion and the force of the explosion.
I haven't really tried any of this. It's just what I came up with :-)
More information about the ODE
mailing list