3d math tutorials up

Printable View

Show 80 post(s) from this thread on one page
Page 2 of 3 First 123 Last
• 09-02-2003
Silvercord
I don't entirely understand what you mean, but if you are talking about having it move in a sine wave and actually calculate its speed per second then I think it's a waste of calculations. The doom3 engine actually does something like this though, not the sine wave part, but the bullet is treated as a real particle and can reflect off of hard surfaces...when bullets go through smoke, the smoke actually spirals, pretty neat eh?
• 09-02-2003
confuted
Quote:

Originally posted by Thantos
Here is a challange for ya since I've seen very few games that do it well.

Accurately move a bullet in a normal flight path. And of course optionally include the bullet spread.

Mathematically, that's not horribly difficult (anyone with a bit of physics should be able to describe the motion using parabolics). However, computationally, it's a lot more intensive than straight line bullets, and would likely just confuse the player. Anyway, perhaps it would be possible (read: feasible) to approximate realistic motion through the use of lookup tables or something. But, as you probably know since you were in the army, there are a number of ways of sighting in a weapon. You can sight it so that it will hit consistently at a certain distance - at shorter distances it will be high and longer distances, low. You could also have the sights completely parallel to the barrel (not for real world use), so that the bullet begins dropping as soon as it leaves the barrel (no initial vertical velocity). Anyway, look at the difference in computations:
Code:

```"simple" y=(initial vertical velocity)*t + initial_height "realistic" y=initial_vertical_velocity*t + (1/2)(-gravity)t^2 + initial_height```
The difference between "simple" and "realistic" is the term (1/2)(-gravity)t^2, which can be simplified to (k)t^2 where t represents (1/2)(-gravity) (constant, can be precalculated and #defined unless you deal with variable gravity) However, that's still three multiplications PER bullet, PER frame. That can get expensive, and the player probably either wouldn't notice or would think the aiming system was off. Especially since most FPS rely on fairly short distance shots, meaning there would be a short flight duration and hence only a slight bullet drop. Conclusion: not hard to do, but why?

Quote:

think of something that hasn't been done. I was thinking about realistic speed in a game, because that was one of the problems I've had trouble with, and with instantaneous velocity we could get into some calculus with derivatives, that'd be kind of neat.
We could do that. I'm not 100% positive what you mean (it would require clarification) but it sounds workable. We could also throw in momentum, and perhaps rotational momentum (hmmm... does anyone have a use for rotational momentum in a game?)

Oh, and for emphasis since we haven't gotten an answer...
Quote:

has anybody actually read it yet?
• 09-02-2003
Thantos
Actually what I mean is that a bullet does not travel straight. Looking at the side it makes an arc. Example: The M16A2 with its sights adjusted to 300, when it fires a bullet the bullet will cross the same horizontal plane at 33 and 300 (I can't remember if it was meters or yards since they were always interchanged).

The arc is based off many factors including: rifling, amount of gun power, muzzle velocity, air temperature, and to a smaller degree wind (it effects horizontal movement more then arc).

It always annoys me in a game when you can shoot a pistol just as accurately as a rifle over 100 yards.
• 09-02-2003
Silvercord
for the second time it is because bullets travel in waves

EDIT: everything travels in waves just it is only noticable when there is a lot of energy for a given amount of mass
• 09-02-2003
confuted
Quote:

Originally posted by Silvercord
I don't entirely understand what you mean, but if you are talking about having it move in a sine wave and actually calculate its speed per second then I think it's a waste of calculations. The doom3 engine actually does something like this though, not the sine wave part, but the bullet is treated as a real particle and can reflect off of hard surfaces...when bullets go through smoke, the smoke actually spirals, pretty neat eh?
Bullets don't move in a sine wave. Sine waves are periodic. They move in a parabola :) See above. However, calculating the speed every frame due to speed reduction due to air resistance would be an even bigger waste of calculation than what I just said :) That formula isn't easy. (Well, it's easy, but not on the processor). The thing with the smoke though... that's cool. Although I'm not sure if it really does it much in real life... I may have to try :)
• 09-02-2003
Silvercord
that's not ture, it's a sine wave

EDIT: the origin of the wave bends because of gravity, but it is still ultimately a sine wave

EDIT1: everything moves in waves
• 09-02-2003
confuted
Quote:

The arc is based off many factors including: rifling, amount of gun power, muzzle velocity, air temperature, and to a smaller degree wind (it effects horizontal movement more then arc).
This is what we call wasting more clock cycles than your computer has. The cause for the arc, as I said, is the sighting. When you're looking through your scope at something 300 yards away, the barrel is actually pointed up a bit. Not horizontally. vertical velocity becomes 0 due to the effects of gravity half-way to the target (when the gun is sighted to the target distance). Oh, and you forgot bullet weight. Momentum plays a large part when overcoming air resistance.
• 09-02-2003
confuted
Quote:

Originally posted by Silvercord
that's not ture, it's a sine wave

EDIT: the origin of the wave bends because of gravity, but it is still ultimately a sine wave

WHAT THE HECK ARE YOU TALKING ABOUT?!?!?

You shoot a bullet in real life. It flies a long distance, and drops to the ground. It does not go back up after that (discounting richochet). A sine wave goes back up. Plus, it's simple newtonian physics. You know this Silvercord.
d=v_i*t + (1/2)a*t^2
apply that to vertical velocity/acceleration (gravity) and distance above the ground (or relative to the muzzle)
• 09-02-2003
Silvercord
and you wouldn't ever actually use parabolics in a game...ever...the only useful thing is the instantaneous velocity of all forces on an object...the derivative of the parabolic equations

i.e for gravity i use 32x as the speed

but if i wanted to graph the height you use -16x^2 + initialvelocityx + initialheight;

EDIT: i know im right about the sine waves, im not giving up so easily, im drawing a picture, I didn't ever say the wave is huge, but it is definitely there
• 09-02-2003
Thantos
Quote:

were in the army
BLASHMEY!!!

Take a look at my avatar again.

As I said the speed reduction due to wind speed is minor. When firing at 500 meters if we had a head or tail wind there would be no sight adjustments.

Edit: Yea your right I forgot about bullet weight.

And I know that the barrel is pointed upwards. Most things are a constant ( or close enought to be used as such)
• 09-02-2003
confuted
Quote:

Originally posted by Silvercord
and you wouldn't ever actually use parabolics in a game...ever...the only useful thing is the instantaneous velocity of all forces on an object...the derivative of the parabolic equations

i.e for gravity i use 32x as the speed

but if i wanted to graph the height you use -16x^2 + initialvelocityx + initialheight;

EDIT: i know im right about the sine waves, im not giving up so easily, im drawing a picture, I didn't ever say the wave is huge, but it is definitely there

Yeah, if your X axis is vertical...... :rolleyes:

The motion could be modelled by a sine wave, but it is in NO WAY accurate. And the trig calculation is more expensive than squaring a number anyway. If you were going to do this in a game, parabolics is the way you would do it. Seperate the X and Y (and Z) values, and have them vary according to T. That's the only (good) way to do it, and it's a lot cheaper than doing anything else.
• 09-02-2003
confuted
Quote:

Originally posted by Thantos
BLASHMEY!!!

Take a look at my avatar again.

As I said the speed reduction due to wind speed is minor. When firing at 500 meters if we had a head or tail wind there would be no sight adjustments.

Edit: Yea your right I forgot about bullet weight.

And I know that the barrel is pointed upwards. Most things are a constant ( or close enought to be used as such)

Wind speed may be minor, but air resistance is not. Try firing your pistol on the moon and you'll see what I mean. :rolleyes:
• 09-02-2003
Thantos
On the moon you'd also have to factor in the reduction in gravity which would probabily have more effect then the air resistance.
• 09-02-2003
confuted
Ok, I guess I have to explain the air resistance to you. Air resistance slows down an object as it travels through the air. It can be looked at as many collisions with air molecules, each of which take some of the object's momentum. This accumulates. Without air resistance, horizontal velocity is completely constant for a bullet. With air restance, the bullet will slow down and stop short of where it was expected to be when calculations were performed without accounting for air resistance. In a game, it would be pretty safe to just make the estimation that the decrease in speed is linear, although in actuality it is not. But here's a true story for you: In an evacuated tube (read: no air), a penny and a feather fall at EXACTLY the same rate. This is because there is no air resistance slowing either one down. I've seen it myself.
• 09-02-2003
Thantos
I know how air resistance works. It is also consistant enough to assign a value for it.
Show 80 post(s) from this thread on one page
Page 2 of 3 First 123 Last