Tano_ITA
02-05-2008 10:27:15
Hi,
i need to know how i throw an object that i've picked with mouse. Like Half Life 2. I've writed this code:
So to determinate the direction:
But i can't understand how i can determinate the z directorion with position of mouse and camera.. Anyone can help me?
Thanks a lot and sorry for my bad english.. =)
i need to know how i throw an object that i've picked with mouse. Like Half Life 2. I've writed this code:
if((dragging)&&(mMouse->getMouseState().buttonDown(OIS::MB_Right)))
{
info.mBody->setCustomForceAndTorqueCallback<OgreNewtonFrameListener>(&OgreNewtonFrameListener::ThrowObjectCallBack, this);
}
So to determinate the direction:
void OgreNewtonFrameListener::ThrowObjectCallBack (OgreNewt::Body* me)
{
Ogre::Vector3 dir, vec;
Ogre::Quaternion camorient = msnCam->getWorldOrientation();
Ogre::Vector3 pos = msnCam->getWorldPosition();
vec = Ogre::Vector3(0,0,-1);
dir = camorient * vec;
Ogre::Real mass;
//Vector3 jumpForce(0, 15,-5), inertia;
Vector3 jumpForce(pos.x,pos.y,pos.z*(-1000)), inertia;
me->getMassMatrix(mass,inertia);
//jumpForce += Vector3(0.0,-9.8,0.0);
//jumpForce *= mass;
me->addForce(jumpForce);
}
But i can't understand how i can determinate the z directorion with position of mouse and camera.. Anyone can help me?
Thanks a lot and sorry for my bad english.. =)