attaching camera to character <edit>

capture

29-05-2008 01:22:44

I've been working on a first person camera system, but I don't seem to be making much progress.

So far I envision the player moving about using the arrows for forward and such and the mouse will control left and right orientation of the character and the camera. To do this I set the camera to the position of a childnode of the characters body, which gets the forward backward motion good.

But how do i sync the left and right orientation of the character and the camera, using the mouse?

I've been doing something like this:
Characters part
Ogre::Quaternion quat = camHandler->getCameraOrientation();

mPlayer->getNode()->yaw(quat.getYaw());
mPlayer->setDirection(mPlayer->getNode()->getOrientation());

Cameras part

mCamera->yaw(mPlayer->getNode()->getOrientation().getYaw());
mCamera->pitch(mRotY);


My code does not seem to work, and causes the camera seems to continue spinning after the mouse has stopped moving.

Any help with this?

capture

02-06-2008 01:51:58

Okay I have almost got it all working except this last bug.


/***BUG*** The code here presents a bug, in that with this
the character continues to rotate after the mouse has stopped moving*/
mRotX = inputHandler->getMouseRotX();
mPlayer->getNode()->yaw(mRotX);
mPlayer->setDirection(mPlayer->getNode()->getOrientation().getYaw());
mRotX = 0;
/*End of bug*/


The bug causes the mPlayer to continue to setDirection after it has reached the direction desired. I am not exactly sure how to fix this. Any one else got any ideas?