Example #1
0
    //NOTE: Used to check for movement keys
    bool frameStarted(const Ogre::FrameEvent &evt)
    {
        // Tell OIS to handle all input events
        input.capture();

        // Update windows/gui as a result of input events
        // For instance this could mean opening a new window/dialog,
        // by doing this after the input events are handled we
        // ensure that window/gui changes appear quickly while
        // avoiding that window/gui changes does not happen in
        // event callbacks (which may crash)
        windows.update();

        // Disable movement in Gui mode
        if (windows.isGuiMode()) return true;

        // Configure player movement according to keyboard input. Actual movement will
        // be done in the physics system.
        if (poller.isDown(A_MoveLeft))
        {
            player.setAutoMove (false);
            player.setLeftRight (1);
        }
        else if (poller.isDown(A_MoveRight))
        {
            player.setAutoMove (false);
            player.setLeftRight (-1);
        }
        else
            player.setLeftRight (0);

        if (poller.isDown(A_MoveForward))
        {
            player.setAutoMove (false);
            player.setForwardBackward (1);
        }
        else if (poller.isDown(A_MoveBackward))
        {
            player.setAutoMove (false);
            player.setForwardBackward (-1);
        }
        else
            player.setForwardBackward (0);

        return true;
    }
Example #2
0
    // Used to check for movement keys
    bool frameStarted(const Ogre::FrameEvent &evt)
    {
        // Tell OIS to handle all input events
        input.capture();

        // Disable movement in Gui mode
        if(windows.isGuiMode()) return true;

        float speed = 300 * evt.timeSinceLastFrame;
        float moveX = 0, moveY = 0, moveZ = 0;

        if(poller.isDown(A_MoveLeft)) moveX -= speed;
        if(poller.isDown(A_MoveRight)) moveX += speed;
        if(poller.isDown(A_MoveForward)) moveZ -= speed;
        if(poller.isDown(A_MoveBackward)) moveZ += speed;

        // TODO: These should be enabled for floating modes (like
        // swimming and levitation) and disabled for everything else.
        if(poller.isDown(A_MoveUp)) moveY += speed;
        if(poller.isDown(A_MoveDown)) moveY -= speed;

        if(moveX != 0 || moveY != 0 || moveZ != 0)
            player.moveRel(moveX, moveY, moveZ);

        return true;
    }
Example #3
0
    // Used to check for movement keys
    bool frameStarted(const Ogre::FrameEvent &evt)
    {
      // Tell OIS to handle all input events
      input.capture();

      // Update windows/gui as a result of input events
      // For instance this could mean opening a new window/dialog,
      // by doing this after the input events are handled we
      // ensure that window/gui changes appear quickly while
      // avoiding that window/gui changes does not happen in
      // event callbacks (which may crash)
      windows.update();

      // Disable movement in Gui mode
      if(windows.isGuiMode()) return true;

      float speed = 300 * evt.timeSinceLastFrame;
      float moveX = 0, moveY = 0, moveZ = 0;

      if(poller.isDown(A_MoveLeft)) moveX -= speed;
      if(poller.isDown(A_MoveRight)) moveX += speed;
      if(poller.isDown(A_MoveForward)) moveZ -= speed;
      if(poller.isDown(A_MoveBackward)) moveZ += speed;

      // TODO: These should be enabled for floating modes (like
      // swimming and levitation) and disabled for everything else.
      if(poller.isDown(A_MoveUp)) moveY += speed;
      if(poller.isDown(A_MoveDown)) moveY -= speed;

      if(moveX != 0 || moveY != 0 || moveZ != 0)
        player.moveRel(moveX, moveY, moveZ);


      return true;
    }
Example #4
0
    //NOTE: Used to check for movement keys
    void update (float duration)
    {
        // Tell OIS to handle all input events
        input.capture();

        // Update windows/gui as a result of input events
        // For instance this could mean opening a new window/dialog,
        // by doing this after the input events are handled we
        // ensure that window/gui changes appear quickly while
        // avoiding that window/gui changes does not happen in
        // event callbacks (which may crash)
        windows.update();

        // Disable movement in Gui mode

        if (windows.isGuiMode()) return;

        // Configure player movement according to keyboard input. Actual movement will
        // be done in the physics system.
        if (mControlSwitch["playercontrols"]) {
            if (poller.isDown(A_MoveLeft))
            {
                player.setAutoMove (false);
                player.setLeftRight (1);
            }
            else if (poller.isDown(A_MoveRight))
            {
                player.setAutoMove (false);
                player.setLeftRight (-1);
            }
            else
                player.setLeftRight (0);

            if (poller.isDown(A_MoveForward))
            {
                player.setAutoMove (false);
                player.setForwardBackward (1);
            }
            else if (poller.isDown(A_MoveBackward))
            {
                player.setAutoMove (false);
                player.setForwardBackward (-1);
            }
            else
                player.setForwardBackward (0);

            if (poller.isDown(A_Jump) && mControlSwitch["playerjumping"])
                player.setUpDown (1);
            else if (poller.isDown(A_Crouch))
                player.setUpDown (-1);
            else
                player.setUpDown (0);

            if (mControlSwitch["playerviewswitch"]) {
                if (poller.isDown(A_TogglePOV)) {
                    if (mPreviewPOVDelay <= 0.5 &&
                        (mPreviewPOVDelay += duration) > 0.5)
                    {
                        mPreviewPOVDelay = 1.f;
                        MWBase::Environment::get().getWorld()->togglePreviewMode(true);
                    }
                } else {
                    if (mPreviewPOVDelay > 0.5) {
                        //disable preview mode
                        MWBase::Environment::get().getWorld()->togglePreviewMode(false);
                    } else if (mPreviewPOVDelay > 0.f) {
                        togglePOV();
                    }
                    mPreviewPOVDelay = 0.f;
                }
            }
        }
        // Idle time update despite of control switches
        if (poller.isDown(A_MoveLeft) ||
            poller.isDown(A_MoveRight) ||
            poller.isDown(A_MoveForward) ||
            poller.isDown(A_MoveBackward) ||
            poller.isDown(A_Jump) ||
            poller.isDown(A_Crouch) ||
            poller.isDown(A_TogglePOV))
        {
            resetIdleTime();
        } else {
            updateIdleTime(duration);
        }
    }