moving (momentun and force using problem)

deshan

30-09-2009 20:19:57

Hi all
I have a little question with using momentum and forces. I have tried both but momentum makes undesired effects.

Following is my code of controlling the game character
FPCamera class

void FPCamera::updateFPCamera()
{
{ //-------------------- movements ------------------------------
NxOgre::Vec3 forceMain(0,0,0); // this is to apply force to move forward and backward
NxOgre::Vec3 forceSide(0,0,0); // this is to apply force to move left and right
Ogre::Real mass = cam_body->getMass();

Ogre::Vector3 direction = (cam_node->getOrientation()* Vector3::NEGATIVE_UNIT_Z);
Ogre::Vector3 angularDirection = (cam_node->getOrientation()* Vector3::NEGATIVE_UNIT_X);

Ogre::Vector3 V0 = cam_body->getLinearVelocity().as<Ogre::Vector3>(); // type conversion Nxogre::Vec3 to Ogre:Vector3
Ogre::Vector3 V1(direction * this->fpVelocity_forwardBackward);
Ogre::Vector3 V2 (angularDirection * this->fpVelocity_leftRight);

Ogre::Vector3 velocityDifference_forwardBackward = (V1 - V0);
Ogre::Vector3 velocityDifference_leftright = (V2 - V0);

forceMain.x = velocityDifference_forwardBackward.x;
forceMain.z = velocityDifference_forwardBackward.z;

forceSide.x = velocityDifference_leftright.x;
forceSide.z = velocityDifference_leftright.z;

//cam_body->setLinearMomentum(forceMain*mass);
//cam_body->setLinearMomentum(forceSide*mass);

cam_body->addForce(forceMain, NxOgre::Enums::ForceMode_Force);
cam_body->addForce(forceSide, NxOgre::Enums::ForceMode_Force);
}
}


When I use setLinearMomentum, it effect to gravity. This means the body does not fall any more. I have tried the setLinearVelocity but ended up with the same problem.
SetForce works fine. But visual effect looks like a movement of a vehicle. This means after release the control still it's move and stop after some time because of friction. I wan't make it stop instantly.

Please help me to make use of real physics