Sign in to follow this  

Explosions and physics

This topic is 4806 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
"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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
I think I saw this posted on the Newton website, and after reading the answer I think I like the second idea better.

Essentially you use the physics engine internal data structures to do all the setup for you. You only need to apply the explosion physics with impulses to the objects collected by the sphere.

I think also that the expansion wave and occlusion can be incorporated easily be just casting rays from the extents of the object box to the explosion origin.

Oliii said
"idea 2 is to be avoided. This looks like a hack, and does not have any physical meaning."

I do not understand why this should be avoided: perhaps you can clarify what you mean by no physical meaning, your answer does not seems to have any physical meaning either, and it sound way of a lot more complex.

Roberto

Share this post


Link to post
Share on other sites
Well ODE for example separates the Physics Simulator from the collision detection system.

So for the collision detection system you creat a sphere that changes in size. And in your sphere collision CALLBACK FUNCTION (thats how ODE does collision response) you just set the velocity (that results from the impulse) to the objects that collided with your sphere with out actually passing the collision joints to the physics simulator.

Just my 5 cents.

P.S. You set a velocity (center of mass and rotational) for the object instead of a force. Because explosion wave that hits an object is an impulse(it creates an instantaneus "discontunuous" change in velocity for the object). Just like an object collding with a wall, the physics simulator does not add a force to change the direction of the object as it collides with a wall it adds an impulse, because the velocity changes instantenuously. Well not really, but the time displacement is so small because forces happen on atomic level that physisists came up with an idea of impulse. Sorry if i am borring you. =(

[Edited by - snisarenko on October 14, 2004 9:25:28 PM]

Share this post


Link to post
Share on other sites
Quote:
Oliii said
"idea 2 is to be avoided. This looks like a hack, and does not have any physical meaning."

I do not understand why this should be avoided: perhaps you can clarify what you mean by no physical meaning, your answer does not seems to have any physical meaning either, and it sound way of a lot more complex.


I don't think you are talking about the same thing Roberto.

Idea nr 2 was that the sphere would reject all bodies that was inside the sphere and it would all be handled by the collision-system.

If I understood you correctly you mean that the sphere should be used only to detect which bodies are inside it and then apply all impulses yourself.
A combination of Idea nr 1 and Idea nr 2.
And I think that is actually a good idea.

That way you won't have to cast a ray to every object in the scene, just the ones intersecting the sphere.(If you want objects to be protected by fixed objects, that is)

Share this post


Link to post
Share on other sites

This topic is 4806 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this