the reasoning is the by not having them animated automatically the app gets best of both.
the application can always move the body in various ways:
1-It can place then on its own app container and loop over the bodies an update the before the newton update
2-it can moves then in a dedicate transform call back.
3-It can make a engine listener to group then to collect and update them in the listener call back
to animate the body you call the procedure stated by Joe, but you need to calculate velocity and omega from the delta position and delta orientation, this is very simple.
for the position:
- Code: Select all
let dt be the time step
Let p1 be the target position;
let p0 b the current position
veloc = (p1 - p0) / dt
for the angular velocity is more complex but there is function in the math library for assistance.
- Code: Select all
dQuaterion::CalcAverageOmega
- Code: Select all
let q0 be the current orination
let q1 be the target orientation
then
omega = q0.CalcAverageOmega (q1, dt);
with veloc and omega you set those in the body, (any body with no zero mass)
and you can call
- Code: Select all
NewtonBodySetVelocity(body, &velocity[0]);
NewtonBodySetOmega(body, &omega[0]);
NewtonBodyIntegrateVelocity (body, dt);
if the body was kinematic will only move when you call the function.
if the body is dynamics it moves and continue moving by its inertia as long as the velocity is not changed again.