Time for action — adding a frame listener
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); ...
Get Ogre 3D 1.7 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.