Members - Reputation: 623
Posted 11 January 2007 - 08:48 PM
Members - Reputation: 382
Posted 12 January 2007 - 06:56 AM
It comes highly recommended (planning to use it in my game - not using it yet)
He recommends fixing your timestep (locking it to a certain times per second) then interpolating the values (giving a very slight delay: ~1 timestep)
p.s. He addresses several approaches, including the one you suggest :)
GDNet+ - Reputation: 8193
Posted 12 January 2007 - 07:33 AM
If you want to go with the fixed-timestep route, which is a good one, I'd set the simulation rate at 30-50 hz. when you've got your frame-time, just chose the last simulation and the next, then interpolate between the two. Linear is easiest and would give accurate enough results, but you could probably do even better by taking the previous 2 or 3 simulations into account, as some cost to performance.
Members - Reputation: 654
Posted 12 January 2007 - 11:10 PM
G = Gravity vector, typically (0, -9.82, 0)
For each spawned particle, keep the following:
t0 = Birth time of particle
P0 = Position vector at birth
V0 = Initital velocity
Analytically getting the position of the particle at the given time t:
P(t) = P0 + V0 * dt + (G * dt * dt / 2) where dt = t - t0
Or more optimized:
P(t) = P0 + dt * (V0 + G * dt) where GH = G / 2 (Calculated when gravity changes, typically just once).
I typically use this in vertex shader code etc, that way you can let the gpu worry about the particles, all the CPU need to do is to spawn them etc.