Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5981


Ignore:
Timestamp:
Oct 21, 2009, 5:17:05 PM (15 years ago)
Author:
wirthmi
Message:

Made NewHumanController an InputHandler so we can control the crosshair.

Location:
code/branches/steering/src/orxonox
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/steering/src/orxonox/controllers/Controller.h

    r5781 r5981  
    5757                { return this->controllableEntity_; }
    5858            virtual void changedControllableEntity() {}
     59            virtual void startControl() {}
     60            virtual void stopControl() {}
    5961
    6062        protected:
  • code/branches/steering/src/orxonox/controllers/NewHumanController.cc

    r5979 r5981  
    2121 *
    2222 *   Author:
    23  *      Fabian 'x3n' Landau
     23 *      Michael Wirth
    2424 *   Co-authors:
    2525 *      ...
     
    2828
    2929#include "NewHumanController.h"
     30
     31#include "core/input/InputManager.h"
     32#include "core/input/InputState.h"
    3033
    3134#include "core/CoreIncludes.h"
     
    7275
    7376        NewHumanController::localController_s = this;
     77
     78        gameInputState_ = InputManager::getInstance().createInputState("humansteering", true, true);
     79        gameInputState_->setMouseHandler(this);
     80        gameInputState_->setMouseMode(MouseMode::Exclusive);
    7481    }
    7582
     
    7784    {
    7885        NewHumanController::localController_s = 0;
     86
     87        if( this->isInitialized() )
     88        {
     89            gameInputState_->setHandler(0);
     90            InputManager::getInstance().destroyState("humansteering");
     91        }
    7992    }
    8093
     
    95108    }
    96109
     110    void NewHumanController::startControl() {
     111        //gameInputState_->setHandler(KeyBinderManager::getInstance().getDefaultAsHandler());
     112        //KeyBinderManager::getInstance().setToDefault();
     113
     114        InputManager::getInstance().enterState("humansteering");
     115        std::cout << "started control" << endl;
     116    }
     117
     118    void NewHumanController::stopControl() {
     119        InputManager::getInstance().leaveState("humansteering");
     120        std::cout << "stopped control" << endl;
     121    }
     122
     123    void NewHumanController::mouseMoved(IntVector2 abs, IntVector2 rel, IntVector2 clippingSize)
     124    {
     125        std::cout << "X: " << static_cast<float>(abs.x) << " Y: " << static_cast<float>(abs.y) << endl;
     126    }
     127
    97128}
  • code/branches/steering/src/orxonox/controllers/NewHumanController.h

    r5979 r5981  
    2121 *
    2222 *   Author:
    23  *      Fabian 'x3n' Landau
     23 *      Michael Wirth
    2424 *   Co-authors:
    2525 *      ...
     
    3232#include "OrxonoxPrereqs.h"
    3333
    34 #include "tools/interfaces/Tickable.h"
     34//#include "tools/interfaces/Tickable.h"
    3535#include "HumanController.h"
     36#include "core/input/InputHandler.h"
     37#include "core/input/InputState.h"
    3638
    3739namespace orxonox
    3840{
    39     class _OrxonoxExport NewHumanController : public HumanController
     41    class _OrxonoxExport NewHumanController : public HumanController, public InputHandler
    4042    {
    4143        public:
     
    4547            virtual void tick(float dt);
    4648
     49            void startControl();
     50            void stopControl();
     51
    4752        private:
    4853            static NewHumanController* localController_s;
     54            InputState* gameInputState_;
     55
     56            //mouse handler functions
     57            void mouseMoved    (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize);
    4958    };
    5059}
  • code/branches/steering/src/orxonox/infos/PlayerInfo.cc

    r5929 r5981  
    158158        this->bReadyToSpawn_ &= (!this->bSetUnreadyAfterSpawn_);
    159159
    160         if (this->controller_)
     160        if (this->controller_) {
    161161            this->controller_->setControllableEntity(entity);
     162            this->controller_->startControl();
     163        }
    162164
    163165        this->changedControllableEntity();
     
    174176        this->controllableEntityID_ = OBJECTID_UNKNOWN;
    175177
    176         if (this->controller_)
     178        if (this->controller_) {
    177179            this->controller_->setControllableEntity(0);
     180            this->controller_->stopControl();
     181        }
    178182
    179183        entity->removePlayer();
Note: See TracChangeset for help on using the changeset viewer.