Using our FrameListener
we are going to add a user controlled camera.
To control the camera we need a mouse interface, a pointer to the camera, and a variable defining the speed at which our camera should move as a member variable of our
FrameListener:
OIS::Mouse* _Mouse; Ogre::Camera* _Cam; float _movementspeed;
Adjust the constructor and add the camera pointer as the new parameter and set the movement speed to
50:
MyFrameListener(Ogre::RenderWindow* win,Ogre::Camera* cam) { _Cam = cam; _movementspeed = 50.0f;
Init the mouse using the
InputManager:
_Mouse = static_cast<OIS::Mouse*>(_InputManager->createInputObject( OIS::OISMouse, false ));
And remember to destroy it in the destructor:
_InputManager->destroyInputObject(_Mouse);
Add the code to move the camera using the W, A, S, D keys and the movement speed to the
frameStarted
event handler:Ogre::Vector3 translate(0,0,0); if(_Keyboard->isKeyDown(OIS::KC_W)) { translate += Ogre::Vector3...