hellaeon
24-11-2008 11:21:53
Goodaye,
I have two classes at the moment, the application ad one is the frame listener. I managed to create a table and ball, and specific to the ball's body I used this call in my MainApplication->createScene() function
and then, in my MainListener class, I put the following:
mMove is set by pressing a key.
The problem is I cant seem to use any variable from the same Mainlistener class even though the function, I assume, belongs to the class. I cant even try to access a scene node using getSceneNode() despite doing it elsewhere in the same classes functions. All I want to do is see if I can apply the force using a key. Can someon please put me in the right direction?
SOLUTION : LEARN the Ogre startup sequence properly!
I have two classes at the moment, the application ad one is the frame listener. I managed to create a table and ball, and specific to the ball's body I used this call in my MainApplication->createScene() function
body->setCustomForceAndTorqueCallback<MainListener>(&MainListener::CueBallCallBack,(MainListener*) mFrameListener);
and then, in my MainListener class, I put the following:
void MainListener::CueBallCallBack(OgreNewt::Body* bod)
{
if (MainListener::mMove)
{
Ogre::Real mass;
Ogre::Vector3 inertia;
Ogre::Vector3 position;
Ogre::Vector3 force;
Ogre::Quaternion orientation;
bod->getMassMatrix(mass, inertia);
bod->getPositionOrientation(position,orientation);
Vector3 V0 = bod->getVelocity();
Vector3 V1=orientation*(-50*Vector3::UNIT_Z);
Ogre::Real deltatime = bod->getWorld()->getTimeStep();
Vector3 acel ((V1 - V0) / deltatime);
force = (Vector3(acel.x,-1,acel.z))*mass;
bod->addForce(force);
}
else bod->addForce(Vector3::ZERO);
}
mMove is set by pressing a key.
The problem is I cant seem to use any variable from the same Mainlistener class even though the function, I assume, belongs to the class. I cant even try to access a scene node using getSceneNode() despite doing it elsewhere in the same classes functions. All I want to do is see if I can apply the force using a key. Can someon please put me in the right direction?
SOLUTION : LEARN the Ogre startup sequence properly!