Now we are going to add interactivity to the scene by adding the user control to the movements of the model.
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;
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)
Assign the node pointer to the member variable and set the walking speed to
50:
_WalkingSpeed = 50.0f; _node = node;
In the
frameStarted
function we need two new variables, which will hold the rotation and the translation the user wants to apply to the node:Ogre::Vector3 SinbadTranslate(0,0,0); float _rotation = 0.0f;
Then we need code to calculate the translation and rotation depending on which arrow key the user has pressed:
if(_Keyboard->isKeyDown(OIS::KC_UP)) { SinbadTranslate += Ogre...