Tranforming body in frame listner

deshan

18-05-2009 19:40:12

Hi all
My requirement is transforming a newton body in framelistner as I wish. Up to now I know how to apply custom forces and velocity for a body. After that I do not know what to do when I need to change these forces and directions of the velocity.
Initially in the application createScene method I make the body and bind a callback function like following.

body->setCustomForceAndTorqueCallback<GameApplication>(&GameApplication::myCallBackFunction,this);

void GameApplication::myCallBackFunction(OgreNewt::Body* body)
{
Ogre::Real mass;
Ogre::Vector3 inertia;

body->getMassMatrix(mass, inertia);

Ogre::Vector3 force(0,-9.8,0);

force *= mass;
body->addForce( force );

body->setVelocity(Vector3(0, 0, -100));
}


Now if I want to change the velocity size and direction in the framelistner what should I do?

Zero23

24-05-2009 01:00:08

Use your body pointer in the framelistener?