camera can't move?

feng007lhf

31-08-2007 16:09:02

I create a floor and a camera, i want to camera can go on the floor. i set the friction between floorbody and camerabody is 0, but when i use anrow key to control it, it can't move ,

my code as follows:

bool OgreNewtonFrameListener::frameStarted(const FrameEvent &evt)
{
mKeyboard->capture();
mMouse->capture();

mCameraNode->yaw( Degree(mMouse->getMouseState().X.rel * -0.2), SceneNode::TS_WORLD );
//msnCam->pitch(Degree(mMouse->getMouseState().Y.rel * -0.2));
mCameraBody->setPositionOrientation(mCameraNode->getPosition(), mCameraNode->getOrientation());

mSpeed = 50;

Vector3 position;
Vector3 dir;
Quaternion orientation;
mCameraBody->getPositionOrientation(position,orientation);

if (mKeyboard->isKeyDown(OIS::KC_UP))
{
dir = orientation * Vector3::UNIT_Z;
mCameraBody->setVelocity(dir * mSpeed);
}
if (mKeyboard->isKeyDown(OIS::KC_DOWN))
{
dir = orientation * Vector3::NEGATIVE_UNIT_Z;
mCameraBody->setVelocity(dir * mSpeed);
}
if (mKeyboard->isKeyDown(OIS::KC_LEFT))
{
dir = orientation * Vector3::UNIT_X;
mCameraBody->setVelocity(dir * mSpeed);
}
if (mKeyboard->isKeyDown(OIS::KC_RIGHT))
{
dir = orientation * Vector3::NEGATIVE_UNIT_X;
mCameraBody->setVelocity(dir * mSpeed);
}
if (mKeyboard->isKeyDown(OIS::KC_ESCAPE))
return false;
return true;
}

feng007lhf

01-09-2007 09:13:19

I found the reason, because i haven't set the size of the world, so when camera move to some place , it can't move. sorry, maybe i don't descript the question so clearly, let you mistake the question.