[ODE] RE: more questions on physical movement...

Jon Watte hplus-ode at mindcontrol.org
Fri May 21 23:48:23 MST 2004


> Can you explain the look ahead extrapolation?   I dont understand how I can 
> look ahead in time to know where I want to be. For example, at t= 3.0 
> seconds I'm pressing the left arrow key, and should be strafing left. If I 
> look ahead to t=3.1 seconds I dont know where I should be because its 
> possible that at time t=3.02 I release all keys, which means I should stop 
> moving. So I'm not really sure how I can look ahead.

That doesn't matter. You should look ahead based on the state of the current 
controllers. When the user releases the key, the look-ahead will say that you 
should be standing still, so force is applied to make you stand still. In 
reality, you'll spend a little bit of time slowing down and coming to a stop.

> If I could look ahead, how do I get the difference in force? I have the 
> current velocity and position, but how do I use this to calculate the change 
> in force for the time slice and apply it properly in ode?

My code looks something like:

#define LOOKAHEAD_TIME 0.1

Vec3 whereIReallyWantToBe = currentPosition + desiredRunSpeedDirection * 
        LOOKAHEAD_TIME;
Vec3 whereIWillBe = currentPosition + currentSpeed * LOOKAHEAD_TIME;
Vec3 forceToApply = (whereIReallWantToBe - whereIWillBe) * 
        SPEED_TO_FORCE_MULTIPLIER / LOOKAHEAD_TIME;
LimitRunForceBasedOnRunSpeed( &forceToApply, currentSpeed );
dBodyAddForce( m_body, forceToApply.x forceToApply.y, forceToApply.z );


The function "LimitRunForceBasedOnRunSpeed" as well as the constant 
SPEED_TO_FORCE_MULTIPLIER determine how the controls "feel" and the 
LOOKAHEAD_TIME determines how aggressive you are in acceleration/stopping 
within the force limits -- I find that 0.1 is quite aggressive.

Perhaps this is worthy of inclusion on some Wiki or FAQ, if it isn't already?

Cheers,

			/ h+




More information about the ODE mailing list