Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 14, 2008, 11:44:17 AM (17 years ago)
Author:
rgrieder
Message:

merged input branch into merge branch

Location:
code/branches/merge/src/orxonox
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/merge/src/orxonox/Orxonox.cc

    r1268 r1272  
    290290    // The render window width and height are used to set up the mouse movement.
    291291    if (!InputManager::initialise(ogre_->getWindowHandle(),
    292           ogre_->getWindowWidth(), ogre_->getWindowHeight()))
     292          ogre_->getWindowWidth(), ogre_->getWindowHeight(), true, true, true))
    293293      return false;
    294294
     
    495495      for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it)
    496496        it->tick((float)evt.timeSinceLastFrame * this->timefactor_);
    497       orxonoxConsole_->tick((float)evt.timeSinceLastFrame * this->timefactor_);
     497      // Iterate through all TickableReals and call their tick(dt) function
     498      for (Iterator<TickableReal> it = ObjectList<TickableReal>::start(); it; ++it)
     499        it->tick((float)evt.timeSinceLastFrame);
     500      orxonoxConsole_->tick((float)evt.timeSinceLastFrame);
    498501
    499502      // don't forget to call _fireFrameStarted in ogre to make sure
  • code/branches/merge/src/orxonox/objects/SpaceShip.cc

    r1265 r1272  
    142142    void SpaceShip::init()
    143143    {
    144                 if ((!network::Client::getSingleton() || network::Client::getSingleton()->getShipID()==objectID ))
    145                 {
    146                 if (!setMouseEventCallback_)
    147                 {
    148                         InputManager::addMouseHandler(this, "SpaceShip");
    149                         setMouseEventCallback_ = true;
    150                 }
    151                 }
     144    if ((!network::Client::getSingleton() || network::Client::getSingleton()->getShipID()==objectID ))
     145    {
     146          if (!setMouseEventCallback_)
     147          {
     148              InputManager::addMouseHandler(this, "SpaceShip");
     149              setMouseEventCallback_ = true;
     150          }
     151    }
    152152
    153153        // START CREATING THRUSTER
     
    233233
    234234            COUT(4) << "Loader: Initialized spaceship steering with values " << maxSpeedForward_ << " " << maxSpeedRotateUpDown_ << " " << maxSpeedRotateRightLeft_ << " " << maxSpeedLoopRightLeft_ << " " << std::endl;
    235         }
     235      }
    236236*/
    237237        if (xmlElem->Attribute("maxSpeed") && xmlElem->Attribute("maxSideAndBackSpeed") && xmlElem->Attribute("maxRotation") && xmlElem->Attribute("transAcc") && xmlElem->Attribute("rotAcc") && xmlElem->Attribute("transDamp") && xmlElem->Attribute("rotDamp"))
     
    259259
    260260            COUT(4) << "Loader: Initialized SpaceShip" << std::endl;
    261         }
    262 
    263         if (xmlElem->Attribute("camera"))
    264         {
    265             this->setCamera();
    266         }
     261        }
     262
     263        if (xmlElem->Attribute("camera"))
     264        {
     265            this->setCamera();
     266        }
    267267    }
    268268
     
    349349    }
    350350
    351     bool SpaceShip::mouseMoved(const OIS::MouseEvent &e)
     351    bool SpaceShip::mouseMoved(const MouseState& state)
    352352    {
    353353/*
     
    366366        if (this->bRMousePressed_)
    367367        {
    368             this->camNode_->roll(Degree(-e.state.X.rel * 0.10));
    369             this->camNode_->yaw(Degree(e.state.Y.rel * 0.10));
    370         }
    371         else
    372         {
    373             float minDimension = e.state.height;
    374             if (e.state.width < minDimension)
    375                 minDimension = e.state.width;
    376 
    377             this->mouseX_ += e.state.X.rel;
     368            this->camNode_->roll(Degree(-state.X.rel * 0.10));
     369            this->camNode_->yaw(Degree(state.Y.rel * 0.10));
     370        }
     371        else
     372        {
     373            float minDimension = state.height;
     374            if (state.width < minDimension)
     375                minDimension = state.width;
     376
     377            this->mouseX_ += state.X.rel;
    378378            if (this->mouseX_ < -minDimension)
    379379                this->mouseX_ = -minDimension;
     
    381381                this->mouseX_ = minDimension;
    382382
    383             this->mouseY_ += e.state.Y.rel;
     383            this->mouseY_ += state.Y.rel;
    384384            if (this->mouseY_ < -minDimension)
    385385                this->mouseY_ = -minDimension;
     
    409409    }
    410410
    411     bool SpaceShip::mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id)
    412     {
    413         if (id == OIS::MB_Left)
     411    bool SpaceShip::mouseButtonPressed(const MouseState& state, MouseButton::Enum id)
     412    {
     413        if (id == MouseButton::Left)
    414414            this->bLMousePressed_ = true;
    415         else if (id == OIS::MB_Right)
     415        else if (id == MouseButton::Right)
    416416            this->bRMousePressed_ = true;
    417417
     
    419419    }
    420420
    421     bool SpaceShip::mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id)
    422     {
    423         if (id == OIS::MB_Left)
     421    bool SpaceShip::mouseButtonReleased(const MouseState& state, MouseButton::Enum id)
     422    {
     423        if (id == MouseButton::Left)
    424424            this->bLMousePressed_ = false;
    425         else if (id == OIS::MB_Right)
     425        else if (id == MouseButton::Right)
    426426        {
    427427            this->bRMousePressed_ = false;
     
    454454            this->timeToReload_ = this->reloadTime_;
    455455        }
    456 
    457         OIS::Keyboard* mKeyboard = InputManager::getKeyboard();
    458456
    459457
     
    523521        }
    524522
    525         if( (network::Client::getSingleton() &&  network::Client::getSingleton()->getShipID() == objectID) || server_ ){
    526           COUT(4) << "steering our ship: " << objectID << " mkeyboard: " << mKeyboard << std::endl;
    527           if (mKeyboard->isKeyDown(OIS::KC_UP) || mKeyboard->isKeyDown(OIS::KC_W))
     523        if( (network::Client::getSingleton() &&  network::Client::getSingleton()->getShipID() == objectID) || server_ )
     524        {
     525          COUT(4) << "steering our ship: " << objectID << std::endl;
     526          if (InputManager::isKeyDown(KeyCode::Up) || InputManager::isKeyDown(KeyCode::W))
    528527            this->acceleration_.x = this->translationAcceleration_;
    529           else if(mKeyboard->isKeyDown(OIS::KC_DOWN) || mKeyboard->isKeyDown(OIS::KC_S))
     528          else if(InputManager::isKeyDown(KeyCode::Down) || InputManager::isKeyDown(KeyCode::S))
    530529            this->acceleration_.x = -this->translationAcceleration_;
    531530          else
    532531            this->acceleration_.x = 0;
    533532
    534           if (mKeyboard->isKeyDown(OIS::KC_RIGHT) || mKeyboard->isKeyDown(OIS::KC_D))
     533          if (InputManager::isKeyDown(KeyCode::Right) || InputManager::isKeyDown(KeyCode::D))
    535534            this->acceleration_.y = -this->translationAcceleration_;
    536           else if (mKeyboard->isKeyDown(OIS::KC_LEFT) || mKeyboard->isKeyDown(OIS::KC_A))
     535          else if (InputManager::isKeyDown(KeyCode::Left) || InputManager::isKeyDown(KeyCode::A))
    537536            this->acceleration_.y = this->translationAcceleration_;
    538537          else
    539538            this->acceleration_.y = 0;
    540539
    541           if (mKeyboard->isKeyDown(OIS::KC_DELETE) || mKeyboard->isKeyDown(OIS::KC_Q))
     540          if (InputManager::isKeyDown(KeyCode::Delete) || InputManager::isKeyDown(KeyCode::Q))
    542541            this->momentum_ = Radian(-this->rotationAccelerationRadian_);
    543           else if (mKeyboard->isKeyDown(OIS::KC_PGDOWN) || mKeyboard->isKeyDown(OIS::KC_E))
     542          else if (InputManager::isKeyDown(KeyCode::PageDown) || InputManager::isKeyDown(KeyCode::E))
    544543            this->momentum_ = Radian(this->rotationAccelerationRadian_);
    545544          else
  • code/branches/merge/src/orxonox/objects/SpaceShip.h

    r1264 r1272  
    3434#include <OgrePrerequisites.h>
    3535
    36 #include "core/InputHandler.h"
     36#include "core/InputInterfaces.h"
    3737#include "Camera.h"
    3838#include "Model.h"
     
    6868                { SpaceShip::instance_s->setMaxSpeed(value); }
    6969
    70             bool mouseMoved(const OIS::MouseEvent &e);
    71             bool mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id);
    72             bool mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id);
    73             bool mouseHeld(const OIS::MouseEvent &e, OIS::MouseButtonID id) { return true; }
     70            bool mouseButtonPressed (const MouseState& state, MouseButton::Enum id);
     71            bool mouseButtonReleased(const MouseState& state, MouseButton::Enum id);
     72            bool mouseButtonHeld    (const MouseState& state, MouseButton::Enum id) { return true; }
     73            bool mouseMoved         (const MouseState& state);
     74            bool mouseScrolled      (const MouseState& state) { return true; }
    7475
    7576
Note: See TracChangeset for help on using the changeset viewer.