Time for action — controlling the model with the arrow keys

Now we are going to add interactivity to the scene by adding the user control to the movements of the model.

  1. The FrameListener needs two new members: one pointer to the node we want to move, and one float indicating the movement speed:
    float _WalkingSpeed;
    Ogre::SceneNode* _node;
    
  2. The pointer to the node is passed to us in the constructor:
    MyFrameListener(Ogre::RenderWindow* win,Ogre::Camera* cam,Ogre::Viewport* viewport,Ogre::SceneNode* node)
    
  3. Assign the node pointer to the member variable and set the walking speed to 50:
    _WalkingSpeed = 50.0f;
    _node = node;
    
  4. In the frameStarted function we need two new variables, which will hold the rotation and the translation the user wants to apply to the ...

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.