Set a body in front of camera..[SOLVED]

Tano_ITA

09-05-2008 18:09:57

Hi,
i've a problem. I need to know how i can setposition of a body i pick in front of camera. Just like Half Life 2.. Anyone have some idea? I can pick an object, but i want "freeze" it in front of my camera to shoot..

Thanks a lot!

pra

09-05-2008 18:48:39

Vector3 camPos = myCamOrPlayerOrWhatever->getPosition();
Quaternion camOrnt = myCamOrPlayerOrWhatever->getOrientation();
Vector3 relToCam = (camOrnt*Vector3(0,0,-5))+camPos;

this should generate a vector what represents a point 5 units in front of the cam

Tano_ITA

09-05-2008 19:40:02

Thanks a lot!


void OgreNewtonFrameListener::pickObjectCallback( OgreNewt::Body* me)
{
Vector3 camPos = msnCam->getPosition();
Quaternion camOrient = msnCam->getOrientation();
Vector3 relToCam = (camOrient*Vector3(0,-10,-10))+camPos;

me->setPositionOrientation(relToCam, camOrient);
}