yuriythebest
23-09-2008 22:49:32
right, an important lesson that I learnt from my previous experiments in ogre is to always test your app on different types of pc's as early as possible. This proved to be very wise in this case as the character speed and jumping ability is very different on the two that I tested:
Quad core + 8600Gts + 4gb ram = character barely jumps, moves slowly
pentium 4 + 6600Gts + 1Gb ram = character runs fast and jumps high
I always assumed as long as I multiply all the speeds in frameStarted by evt.timeSinceLastFrame that I would get consistent results since when you create the mOgreNewtListener you input the ogreNewt frame rate- I was proved wrong.
my character callback:
and here is how I move the character (I've only included the code that moves him left for brevity:
// move ivan left
I use a Vector3 called spd which is then used by the callback
Quad core + 8600Gts + 4gb ram = character barely jumps, moves slowly
pentium 4 + 6600Gts + 1Gb ram = character runs fast and jumps high
I always assumed as long as I multiply all the speeds in frameStarted by evt.timeSinceLastFrame that I would get consistent results since when you create the mOgreNewtListener you input the ogreNewt frame rate- I was proved wrong.
my character callback:
void mainApp1App::ivanCallback (OgreNewt::Body* me)
{
//prevent falling asleep
me->unFreeze();
//control actual motion velocity based on keys pressed
if (isJumping){
me->setVelocity(Vector3(spd.x, spd.y, spd.z));
}else{
me->setVelocity(Vector3(spd.x, me->getVelocity().y, spd.z));
spd.y=0;
}
//add gravity
me->addForce(Vector3(0,-9.8,0));
//so the cube doesn't rotate
me->setOmega(Vector3(0,0,0));
//might be redundant- also to top rotation
me->getPositionOrientation(bodyPos, bodyOrient);
me->setPositionOrientation(bodyPos , bodyOrientOriginal );
}
and here is how I move the character (I've only included the code that moves him left for brevity:
// move ivan left
}else if(mKeyboard->isKeyDown(OIS::KC_M)){
spd=Vector3(ivanSpeed*evt.timeSinceLastFrame,spd.y*evt.timeSinceLastFrame,0);
charNode->setOrientation(Quaternion(0.707107,0,0.707107,0));
}
I use a Vector3 called spd which is then used by the callback