A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by Neo » Fri May 11, 2012 12:41 pm
I'm new to newton game dynamics, and i'm now using irrlicht for rendering and newton for physics calculating to write a war game.
The problem is,i have no idea about how to create an explosion.. well, not the visual effect, i mean.., um.. for example, assume that an explosion
happened at point(x, y, z), how can i get to know which object around this point would be influenced by it? ALso, i dont know how to deal damage....
i had considered making a sphere that expands,hit the objects and apply force/damage,but it would go through the walls...
Can anyone help me? Thx

-
Neo
-
- Posts: 127
- Joined: Fri May 11, 2012 12:29 pm
- Location: China,Sichuan
by Sweenie » Fri May 11, 2012 5:20 pm
Well, first you could call the function NewtonForEachBodyInAABBDo to fetch all bodies close to the blast area.
Then check the distance to each body returned by the above function. Apply force or impulse based on that distance.
Now, to prevent bodies behind walls from being affected you could cast a ray and check if that hits the body. If it doesn't there is something in the way.
This won't be perfect in all cases though, for example if a body is partially behind a wall so that the ray don't hit it but in real life the blastwave would have pushed it away due to some parts of the body is exposed. Also if the ray hits another light object infront of another light object, but that could be avoided by making sure the raycast only detects static or very heavy objects. I guess it depends on how realistic you need it to be.
-
Sweenie
-
- Posts: 503
- Joined: Mon Jan 24, 2005 7:59 am
- Location: Sweden
by Neo » Sat May 12, 2012 6:03 am
Sweenie wrote:Well, first you could call the function NewtonForEachBodyInAABBDo to fetch all bodies close to the blast area.
Then check the distance to each body returned by the above function. Apply force or impulse based on that distance.
Now, to prevent bodies behind walls from being affected you could cast a ray and check if that hits the body. If it doesn't there is something in the way.
This won't be perfect in all cases though, for example if a body is partially behind a wall so that the ray don't hit it but in real life the blastwave would have pushed it away due to some parts of the body is exposed. Also if the ray hits another light object infront of another light object, but that could be avoided by making sure the raycast only detects static or very heavy objects. I guess it depends on how realistic you need it to be.
Fetch every object? Is it an efficient method when there are plenty of objects and multiple explosion occuring at the same time?
well...ray casting is a good idea, i'd like to use this to detect walls.
-
Neo
-
- Posts: 127
- Joined: Fri May 11, 2012 12:29 pm
- Location: China,Sichuan
by Sweenie » Sat May 12, 2012 7:07 am
That's why you should use the function NewtonForEachBodyInAABBDo, to fetch only the closest bodies that could possibly be affected instead of checking all bodies in the entire level. Just set the AABB to be large enough to encapsulate the extents of the blast radius.
-
Sweenie
-
- Posts: 503
- Joined: Mon Jan 24, 2005 7:59 am
- Location: Sweden
by Julio Jerez » Sat May 12, 2012 8:12 am
to help on parcially hidden objects you couild do something liek this.
after you call object in aabb, for each object cast a numbe of ray proportinal to the prejection of oject size over the distance to teh cente of teh explosion.
for exampl say teh aabb colect 10 objects.
for each object you get the size of it aabb, and divide by distance to teh origin of the explosion.
if the objec is small but it is close, then the above number will be large which means the object will be affected more than if the objec was far away.
to represent that you cast a number of rays, one the center, and few on concentric discs.
the explsoion can be represenet by a presure value that decae wi teh ditance to teh ray hit. theneth force genertate bu teh explasion of teh object is teh product of the
presure at the hit distance by teh number of hits.
large object get more force than smaller objects, and object farther away get less force because the explosion presure wave difusse over the distance.
also the number of ray hit represent if an object is totally or partially hidden.
you can experiment
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by Neo » Sat May 12, 2012 1:30 pm
Sweenie wrote:That's why you should use the function NewtonForEachBodyInAABBDo, to fetch only the closest bodies that could possibly be affected instead of checking all bodies in the entire level. Just set the AABB to be large enough to encapsulate the extents of the blast radius.
my complie said there is no such function called NewtonForEachBodyInAABBDo...my newton version is 2.35,does it really include that function?(newton wiki doesn't have the discription of this function, and i cant google it too

)
-
Neo
-
- Posts: 127
- Joined: Fri May 11, 2012 12:29 pm
- Location: China,Sichuan
by Neo » Sat May 12, 2012 2:02 pm
Julio Jerez wrote:to help on parcially hidden objects you couild do something liek this.
after you call object in aabb, for each object cast a numbe of ray proportinal to the prejection of oject size over the distance to teh cente of teh explosion.
for exampl say teh aabb colect 10 objects.
for each object you get the size of it aabb, and divide by distance to teh origin of the explosion.
if the objec is small but it is close, then the above number will be large which means the object will be affected more than if the objec was far away.
to represent that you cast a number of rays, one the center, and few on concentric discs.
the explsoion can be represenet by a presure value that decae wi teh ditance to teh ray hit. theneth force genertate bu teh explasion of teh object is teh product of the
presure at the hit distance by teh number of hits.
large object get more force than smaller objects, and object farther away get less force because the explosion presure wave difusse over the distance.
also the number of ray hit represent if an object is totally or partially hidden.
you can experiment
im not really get your meaning.."cast a number of rays, one the center, and few on concentric discs",does it mean cast multiple rays from center with defferent directions to the target oject?
-
Neo
-
- Posts: 127
- Joined: Fri May 11, 2012 12:29 pm
- Location: China,Sichuan
by Sweenie » Sat May 12, 2012 2:18 pm
my complie said there is no such function called NewtonForEachBodyInAABBDo...my newton version is 2.35,does it really include that function?(newton wiki doesn't have the discription of this function, and i cant google it too

)
Ah, sorry... meant NewtonWorldForEachBodyInAABBDo (missed the World part)
im not really get your meaning.."cast a number of rays, one the center, and few on concentric discs",does it mean cast multiple rays from center with defferent directions to the target oject?
Yep, try casting a bunch of rays towards different parts of the body, for example the center and perhaps close to the corners of the body's AABB.
If all rays hit it means the body is fully visible, if only some of them hit it would mean it's partially visible.
Though if the body is spherical, shooting rays at it's AABB's corners may miss the actual object so I guess you'll have to experiment a bit to get the results you want.
Perhaps reversing the raycast could work better, that is, shoot rays from the body towards the center of the blast instead.
-
Sweenie
-
- Posts: 503
- Joined: Mon Jan 24, 2005 7:59 am
- Location: Sweden
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 1 guest