body::getVelocity returning 1/8th real velocity? [solved]

Scorch

11-03-2007 05:28:16

I have a ball that i'm pushing along the ground.
Its moving way slower than it should.
So I decided to see how fast it is really moving.


Vector3 vel = b->getVelocity(); // balls velocity
Vector3 hVel = Vector3( vel.x, 0, vel.z ); // balls horizontal velocity (ignoring climb and fall)

Real current_velocity = hVel.length();
cout << "Current Velocity is " << current_velocity << std::endl;


Problem is, the result says the velocity is 6 (which I assume is units per second).

But if I move another object (like the camera) at a rate of 3/second. The camera out-runs the ball at 2x the speed
by doing the following:


Vector3 moveVec(0,0,3 * evt.timeSinceLastFrame);
mCamera->move( mCamera->getOrientation() * moveVec);


The camera out runs the ball every time.
I had to increase the velocity of the ball to 12, to match the camera speed of 3!?

oh, and I am calling

newtWorld->update(evt.timeSinceLastFrame);


every frame.

Any ideas why 6 units per second in ogreNewt doesn't match 6 units per second in Ogre3d?

Scorch

11-03-2007 05:39:48

n/m .. I hate when I find my answer after I finaly post.

It says, right in the docs:


this function is clamped between values representing fps [60,600]. if you pass a smaller value, it is internally clamped to 60fps. likewise a value higher than 600fps is treated as 600fs.


I bet this is related.

Scorch

11-03-2007 05:51:30

ok, yea I solved my own problem.
sorry to bother everyone ...



Solution:

static float timeElapsed = 0;
timeElapsed += evt.timeSinceLastFrame;
const float fps = 60;
while( timeElapsed > (1 / fps)) // frames per second
{
newtWorld->update((1 / fps));
timeElapsed -= (1 / fps);
}
std::cout << " Rendered " << evt.timeSinceLastFrame / (1 / fps) << " physics frames " << std::endl;