Dropping a not guided bomb

Started by
4 comments, last by Buckeye 9 years, 6 months ago

Hi there i am trying to make a bomb indicator that shows where the bomb will fall.

sth like this: (sorry for lowres pic)

dropindi.jpg

so when i drop a bomb it has some velocity from the beggining, the drag and gravity starts to act (sam efor the lift but i don't mind with it for now)

but before i show you my solution i want you to read the main movement code:


t3dpoint WeightForce 	= Normalize(-pos) * Q;
t3dpoint DragForce 		= Normalize(-vel) * (DragCoeff * ((1.250 * squareSpeed)/2.0f) * 0.760f);
t3dpoint Acceleration 	= (WeightForce + DragForce) / Weight;

pos = pos + (vel * dt);
vel = vel + (Acceleration * dt); //where dt is time between frames

so i thought i should make a fast iteration to the surface -


 while (bomb_didint_hit_the_surface)
{
set dt to 1 second 
calculate all forces
calculate new position 
make a ray from now position to new position and check if i hit the surface with this ray then i return;
}

it would look like this (every red line is one second interval i hope you get the point

dropme.jpg

Is there any easier way to determine the falling point?

Advertisement

I thought that (in the real world), non-guided bombs fall straight down. :)

I thought that (in the real world), non-guided bombs fall straight down. smile.png

They drop more like on a trajectory parabola (roughly, not considering air drag).

Is there any easier way to determine the falling point?

In general, yes -- in practice it may be hard. What you're looking for is a closed-form equation for a trajectory parabola with wind drag. The problem is that your ground level varies (at least that's how it is shown in your image). So either way, since your ground isn't even, you would have to do a few iterations with some kind of raymarching. All in all, that's probably nearly as much work as simply stepping in the simulation until you see that ground has been hit.

Depending on the level of realism that you want, it may be allowable to "cheat" and simply let the bomb drop on a quarter-circle path (which looks not very much unlike a bomb would realistically drop). That's very easy to calculate for the animation (instead of doing "proper" physics with forces, simply put the bomb on the circle where it would be at the given time), and it should be very easy find where your heightfield collides with a circle.

Or, just run the proper simulation quickly, as you have envisioned, that will certainly work fine and shouldn't be a problem. A few hundred iterations extra aren't really a problem for a modern computer.

Or, don't show the cross at all, and make the challenge of figuring the correct spot a part of the game happy.png

Your general approach (piece-wise integration) is the correct approach with variable ground-height because you can't otherwise determine the upper integral limit.

Just a comment, but your weight-force looks suspicious as it appears to be based on position (and you don't mention what "Q") is. If you're trying to account for the slight change of gravity due to height, you should base it only on height, not position.

EDIT: Also, 1 second integration times seems very long. You may want to experiment with shorter times.

ph34r.png by samoth

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

Just a comment, but your weight-force looks suspicious as it appears to be based on position (and you don't mention what "Q") is. If you're trying to account for the slight change of gravity due to height, you should base it only on height, not position.




float Q = eGForce * Weight; // gravity force val  eGForce is 9.81 gravity const     Q euals to m * g //in school they tought me that Q = mg 
(maybe you name it somehow differently)

float squareSpeed = VectorLength(vel); //speed squared ;p

t3dpoint WeightForce = Normalize(-pos) * Q; //since i have almost round globe (not just flat ground with heightmap) 
i Normalize reversed position to obtain a gravity direction vector and multiple it by weight force

t3dpoint DragForce = Normalize(-vel) * (DragCoeff * ((1.250 * squareSpeed)/2.0f) * 0.760f); bla bla bla 0.768 is an area for mk84 ;] and 1.250 is air dens 
(here constant but i have a function for determining the proper airdens)

t3dpoint Acceleration = (WeightForce + DragForce) / Weight; yep still no stabilizators, but it hink they will make bomb go further (checked it by shooting 
arrows with bow ;])

pos = pos + (vel * dt);
vel = vel + (Acceleration * dt); //where dt is time between frames

btw thanks for your replies i will iterate towards ground

I thought that (in the real world), non-guided bombs fall straight down. smile.png

Nope, they start off with the velocity the craft had when the bomb was released, then that initial velocity is influenced by gravity (and drag if you factor that in). Otherwise, dropping a cup whilst inside an aeroplane would mean it would shoot to the back of the plane with remarkable speed ;)

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley


i Normalize reversed position to obtain a gravity direction vector

Understood, and now obvious.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

This topic is closed to new replies.

Advertisement