Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1293


Ignore:
Timestamp:
May 15, 2008, 5:44:55 PM (16 years ago)
Author:
scheusso
Message:

merged changes from input & camera & network branch into trunk

Location:
code/trunk
Files:
57 edited
41 copied

Legend:

Unmodified
Added
Removed
  • code/trunk/CMakeLists.txt

    r1219 r1293  
    2222
    2323OPTION(NETWORK_TESTING_ENABLED "Do you want to build network testing tools: i.e. chatclient chatserver and alike")
     24OPTION(NETWORKTRAFFIC_TESTING_ENABLED "Do you want to build dummyserver4 and dummyclient4")
    2425
    2526
     
    4243
    4344# global compiler/linker flags. force -O2!
    44 SET(CMAKE_C_FLAGS "$ENV{CFLAGS} -O2 -Wall -g -ggdb")
    45 SET(CMAKE_CXX_FLAGS "$ENV{CXXFLAGS} -O2 -Wall -g -ggdb")
     45SET(CMAKE_C_FLAGS "$ENV{CFLAGS} -O0 -Wall -g -ggdb")
     46SET(CMAKE_CXX_FLAGS "$ENV{CXXFLAGS} -O0 -Wall -g -ggdb")
    4647SET(CMAKE_LD_FLAGS "$ENV{LDFLAGS}")
    4748SET(CMAKE_EXE_LINKER_FLAGS " --no-undefined")
  • code/trunk/bin/keybindings.ini

    r1219 r1293  
    2424R_6=
    2525H_6=
    26 P_7=
     26P_7="exec disco.txt"
    2727R_7=
    2828H_7=
     
    3030R_8=
    3131H_8=
    32 P_9=
     32P_9="disco.txt"
    3333R_9=
    3434H_9=
  • code/trunk/bin/levels/sample.oxw

    r1102 r1293  
    99  </audio-->
    1010
    11 <Ambient colourvalue="1,1,1" />
     11<!--Ambient colourvalue="1,1,1" /-->
    1212<Skybox src="Orxonox/StarSkyBox" />
    13 
    14 <SpaceShip camera="true" position="0,0,0" scale="10" yawpitchroll="-90,-90,0" mesh="assf3.mesh" maxSpeed="500" maxSideAndBackSpeed="50" maxRotation="1.0" transAcc="200" rotAcc="3.0" transDamp="75" rotDamp="1.0" />
     13<SpaceShip camera="true" position="0,0,0" scale="10" yawpitchroll="-90,-90,0" mesh="assff.mesh" maxSpeed="500" maxSideAndBackSpeed="50" maxRotation="1.0" transAcc="200" rotAcc="3.0" transDamp="75" rotDamp="1.0" />
    1514
    1615<NPC position="0,100,400" scale="1" mesh="razor.mesh"/>
     
    3130</Model-->
    3231
    33 <Model position="-200,1000,500" scale="10" mesh="hoover_body.mesh" yawpitchroll="-90,-90,0" />
     32<!--Model position="-200,1000,500" scale="10" mesh="hoover_body.mesh" yawpitchroll="-90,-90,0" />
    3433<Model position="-200,1000,500" scale="10" mesh="hoover_gear0.mesh" yawpitchroll="-90,-90,0" />
    3534<Model position="-200,1000,500" scale="10" mesh="hoover_gear1.mesh" yawpitchroll="-90,-90,0" />
    3635<Model position="-200,1000,500" scale="10" mesh="hoover_gear2.mesh" yawpitchroll="-90,-90,0" />
    37 <Model position="-200,1000,500" scale="10" mesh="hoover_turbine.mesh" yawpitchroll="-90,-90,0" />
     36<Model position="-200,1000,500" scale="10" mesh="hoover_turbine.mesh" yawpitchroll="-90,-90,0" /-->
    3837
    3938
  • code/trunk/bin/ogre.cfg-init

    r790 r1293  
    44FSAA=0
    55Full Screen=No
    6 RTT Preferred Mode=PBuffer
     6RTT Preferred Mode=FBO
    77Video Mode=1024 x 768
  • code/trunk/bin/run-script

    r790 r1293  
    2222        fi
    2323fi
     24trap "xset r" EXIT HUP INT TERM ABRT KILL
    2425exec ./orxonox $@
  • code/trunk/cmake/FindBoost.cmake

    r790 r1293  
    101101# Add in some path suffixes. These will have to be updated whenever a new Boost version comes out.
    102102SET(SUFFIX_FOR_PATH
     103 boost
    103104 boost-1_34_1
    104105 boost-1_34_0
  • code/trunk/src/core/BaseObject.cc

    r1209 r1293  
    4545        @brief Constructor: Registers the object in the BaseObject-list.
    4646    */
    47     BaseObject::BaseObject()
     47    BaseObject::BaseObject() :
     48      bActive_(true),
     49      bVisible_(true),
     50      level_(0),
     51      namespace_(0)
    4852    {
    4953        RegisterRootObject(BaseObject);
    50 
    51         this->bActive_ = true;
    52         this->bVisible_ = true;
    53         this->level_ = 0;
    54         this->namespace_ = 0;
    5554    }
    5655
  • code/trunk/src/core/CommandExecutor.h

    r1214 r1293  
    8989            inline std::string getAdditionalParameter() const
    9090                { return (this->additionalParameter_ != "") ? (" " + this->additionalParameter_) : ""; }
     91            inline std::string getCommandString() const { return this->processedCommand_; }
    9192
    9293            void setEvaluatedParameter(unsigned int index, MultiTypeMath param);
  • code/trunk/src/core/CoreIncludes.h

    r1062 r1293  
    5959    if (orxonox::Identifier::isCreatingHierarchy() && this->getParents()) \
    6060        this->getParents()->insert(this->getParents()->end(), this->getIdentifier()); \
    61     orxonox::ClassManager<ClassName>::getIdentifier()->addObject(this)
     61    orxonox::ClassManager<ClassName>::getIdentifier()->addObject(this); \
     62    if (orxonox::Identifier::isCreatingHierarchy()) \
     63      return
    6264
    6365/**
  • code/trunk/src/core/CorePrereqs.h

    r1219 r1293  
    144144
    145145  // input
     146  //class GUIInputHandler;
    146147  class InputBuffer;
    147148  class InputBufferListener;
    148149  class InputManager;
     150  class JoyStickHandler;
    149151  class KeyBinder;
    150   class GUIInputHandler;
    151152  class KeyHandler;
    152153  class MouseHandler;
    153   class JoyStickHandler;
    154154
    155155}
  • code/trunk/src/core/Debug.h

    r1219 r1293  
    273273#define CCOUT_EXEC(x) \
    274274  orxonox::OutputHandler::getOutStream().setOutputLevel(x) \
    275   << "*** " << this->getIdentifier()->getName() << ": "
     275  << this->getIdentifier()->getName() << ": "
    276276
    277277#ifndef CCOUT
  • code/trunk/src/core/Error.cc

    r1062 r1293  
    3737namespace orxonox
    3838{
    39         Error::Error()
    40         {
    41                 Error(0,"");
    42         }
    43 
    4439        Error::Error(std::string errorMsg, int errorCode)
    45         {
    46                 Error(errorCode, errorMsg);
    47         }
    48 
    49         Error::Error(int errorCode, std::string errorMsg)
    5040        {
    5141                COUT(1) << "############################ "<< std::endl
  • code/trunk/src/core/Error.h

    r1062 r1293  
    4444        {
    4545        public:
    46                 Error();
    47                 Error(std::string errorMsg, int errorCode = 0);
    48                 Error(int errorCode, std::string errorMsg = "");
     46                Error(std::string errorMsg = "", int errorCode = 0);
    4947        private:
    5048
  • code/trunk/src/core/InputBuffer.cc

    r1220 r1293  
    2323 *      Fabian 'x3n' Landau
    2424 *   Co-authors:
    25  *      ...
     25 *      Reto Grieder
    2626 *
    2727 */
     
    3232
    3333#include "util/Clipboard.h"
    34 #include "InputManager.h"
     34#include "CoreIncludes.h"
     35#include "ConfigValueIncludes.h"
    3536
    3637namespace orxonox
    3738{
    38     InputBuffer::InputBuffer()
    39     {
    40         //this->bActivated_ = false;
    41         this->allowedChars_ = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZäöüÄÖÜ0123456789 \\\"(){}[]<>.:,;_-+*/=!?|$&%^";
    42         this->keyboard_ = InputManager::getKeyboard();
    43         this->buffer_ = "";
    44 
    45         //this->keyboard_->setEventCallback(this);
    46     }
    47 
    48     InputBuffer::InputBuffer(const std::string allowedChars)
    49     {
    50         //this->bActivated_ = false;
    51         this->allowedChars_ = allowedChars;
    52         this->keyboard_ = InputManager::getKeyboard();
    53         this->buffer_ = "";
    54     }
    55 /*
    56     void InputBuffer::registerListener(InputBufferListener* listener, void (InputBufferListener::*function)(), bool bOnlySingleInput)
    57     {
    58         struct InputBufferListenerTuple newListener = {listener, function, true, bOnlySingleInput, ' '};
    59         this->listeners_.insert(this->listeners_.end(), newListener);
    60     }
    61 
    62     void InputBuffer::registerListener(InputBufferListener* listener, void (InputBufferListener::*function)(), char char_, bool bOnlySingleInput)
    63     {
    64         struct InputBufferListenerTuple newListener = {listener, function, false, bOnlySingleInput, char_};
    65         this->listeners_.insert(this->listeners_.end(), newListener);
    66     }
    67 */
    68     void InputBuffer::set(const std::string& input)
    69     {
    70         this->buffer_ = "";
    71         this->append(input);
    72     }
    73 
    74     void InputBuffer::append(const std::string& input)
    75     {
    76         for (unsigned int i = 0; i < input.size(); i++)
    77         {
    78             if (this->charIsAllowed(input[i]))
    79                 this->buffer_ += input[i];
    80 
    81             this->updated(input[i], false);
    82         }
    83         this->updated();
    84     }
    85 
    86     void InputBuffer::append(const char& input)
    87     {
    88         if (this->charIsAllowed(input))
    89             this->buffer_ += input;
    90 
    91         this->updated(input, true);
    92     }
    93 
    94     void InputBuffer::clear()
    95     {
    96         this->buffer_ = "";
    97         this->updated();
    98     }
    99 
    100     void InputBuffer::removeLast()
    101     {
    102         this->buffer_ = this->buffer_.substr(0, this->buffer_.size() - 1);
    103         this->updated();
    104     }
    105 
    106     void InputBuffer::updated()
    107     {
    108         for (std::list<InputBufferListenerTuple>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
    109         {
    110             if ((*it).bListenToAllChanges_)
    111                 (*(*it).listener_.*(*it).function_)();
    112         }
    113     }
    114 
    115     void InputBuffer::updated(const char& update, bool bSingleInput)
    116     {
    117         for (std::list<InputBufferListenerTuple>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
    118         {
    119             if (((*it).bListenToAllChanges_ || ((*it).char_ == update)) && (!(*it).bOnlySingleInput_ || bSingleInput))
    120                 (*(*it).listener_.*(*it).function_)();
    121         }
    122     }
    123 
    124     /*void InputBuffer::activityChanged() const
    125     {
    126     }*/
    127 
    128     bool InputBuffer::charIsAllowed(const char& input)
    129     {
    130         if (this->allowedChars_ == "")
    131             return true;
    132         else
    133             return (this->allowedChars_.find(input) != std::string::npos);
    134     }
    135 
    136     bool InputBuffer::keyPressed(const OIS::KeyEvent &e)
    137     {
    138         /*if (e.key == OIS::KC_NUMPADENTER)
    139         {
    140             this->setActivated(!this->isActivated());
    141             this->clear();
    142             return true;
    143         }*/
    144 
    145         if (this->keyboard_->isModifierDown(OIS::Keyboard::Ctrl))
    146         {
    147             if (e.key == OIS::KC_V)
    148             {
    149                 this->append(fromClipboard());
    150                 return true;
    151             }
    152             else if (e.key == OIS::KC_C)
    153             {
    154                 toClipboard(this->buffer_);
    155                 return true;
    156             }
    157             else if (e.key == OIS::KC_X)
    158             {
    159                 toClipboard(this->buffer_);
    160                 this->clear();
    161                 return true;
    162             }
    163         }
    164         else if (this->keyboard_->isModifierDown(OIS::Keyboard::Shift))
    165         {
    166             if (e.key == OIS::KC_INSERT)
    167             {
    168                 this->append(fromClipboard());
    169                 return true;
    170             }
    171             else if (e.key == OIS::KC_DELETE)
    172             {
    173                 toClipboard(this->buffer_);
    174                 this->clear();
    175                 return true;
    176             }
    177         }
    178 
    179         //std::cout << this->keyboard_->getAsString(e.key) << " / " << (char)e.text << std::endl;
    180 
    181         std::string input = this->keyboard_->getAsString(e.key);
    182         /*if (input.size() >= 1)
    183             this->append(input[0]);*/
    184 
    185         this->append((char)e.text);
    186         return true;
    187     }
    188 
    189     bool InputBuffer::keyReleased(const OIS::KeyEvent &e)
    190     {
    191         return true;
    192     }
     39  InputBuffer::InputBuffer(const std::string allowedChars) :
     40    buffer_(""),
     41    allowedChars_(allowedChars),
     42    lastKey_(KeyCode::Unassigned),
     43    timeSinceKeyPressed_(0.0f),
     44    timeSinceKeyRepeated_(0.0f),
     45    keysToRepeat_(0)
     46  {
     47    RegisterObject(InputBuffer);
     48    setConfigValues();
     49  }
     50
     51  void InputBuffer::setConfigValues()
     52  {
     53    SetConfigValue(keyRepeatDeleay_, 0.4).description("Key repeat deleay of the input buffer");
     54    SetConfigValue(keyRepeatTime_, 0.022).description("Key repeat time of the input buffer");
     55    if (keyRepeatDeleay_ < 0.0)
     56    {
     57      ResetConfigValue(keyRepeatDeleay_);
     58    }
     59    if (keyRepeatTime_ < 0.0)
     60    {
     61      ResetConfigValue(keyRepeatTime_);
     62    }
     63  }
     64  /*
     65  void InputBuffer::registerListener(InputBufferListener* listener, void (InputBufferListener::*function)(), bool bOnlySingleInput)
     66  {
     67    struct InputBufferListenerTuple newListener = {listener, function, true, bOnlySingleInput, ' '};
     68    listeners_.insert(listeners_.end(), newListener);
     69  }
     70
     71  void InputBuffer::registerListener(InputBufferListener* listener, void (InputBufferListener::*function)(), char char_, bool bOnlySingleInput)
     72  {
     73    struct InputBufferListenerTuple newListener = {listener, function, false, bOnlySingleInput, char_};
     74    listeners_.insert(listeners_.end(), newListener);
     75  }
     76  */
     77  void InputBuffer::set(const std::string& input)
     78  {
     79    buffer_ = "";
     80    append(input);
     81  }
     82
     83  void InputBuffer::append(const std::string& input)
     84  {
     85    for (unsigned int i = 0; i < input.size(); i++)
     86    {
     87      if (charIsAllowed(input[i]))
     88        buffer_ += input[i];
     89
     90      updated(input[i], false);
     91    }
     92    updated();
     93  }
     94
     95  void InputBuffer::append(const char& input)
     96  {
     97    if (charIsAllowed(input))
     98      buffer_ += input;
     99
     100    updated(input, true);
     101  }
     102
     103  void InputBuffer::clear()
     104  {
     105    buffer_ = "";
     106    updated();
     107  }
     108
     109  void InputBuffer::removeLast()
     110  {
     111    buffer_ = buffer_.substr(0, buffer_.size() - 1);
     112    updated();
     113  }
     114
     115  void InputBuffer::updated()
     116  {
     117    for (std::list<InputBufferListenerTuple>::iterator it = listeners_.begin(); it != listeners_.end(); ++it)
     118    {
     119      if ((*it).bListenToAllChanges_)
     120        (*(*it).listener_.*(*it).function_)();
     121    }
     122  }
     123
     124  void InputBuffer::updated(const char& update, bool bSingleInput)
     125  {
     126    for (std::list<InputBufferListenerTuple>::iterator it = listeners_.begin(); it != listeners_.end(); ++it)
     127    {
     128      if (((*it).bListenToAllChanges_ || ((*it).char_ == update)) && (!(*it).bOnlySingleInput_ || bSingleInput))
     129        (*(*it).listener_.*(*it).function_)();
     130    }
     131  }
     132
     133  bool InputBuffer::charIsAllowed(const char& input)
     134  {
     135    if (allowedChars_ == "")
     136      return true;
     137    else
     138      return (allowedChars_.find(input) != std::string::npos);
     139  }
     140
     141
     142  void InputBuffer::processKey(const KeyEvent &evt)
     143  {
     144    if (evt.isModifierDown(KeyboardModifier::Ctrl))
     145    {
     146      if (evt.key == KeyCode::V)
     147        append(fromClipboard());
     148      else if (evt.key == KeyCode::C)
     149        toClipboard(buffer_);
     150      else if (evt.key == KeyCode::X)
     151      {
     152        toClipboard(buffer_);
     153        clear();
     154      }
     155    }
     156    else if (evt.isModifierDown(KeyboardModifier::Shift))
     157    {
     158      if (evt.key == KeyCode::Insert)
     159      {
     160        append(fromClipboard());
     161      }
     162      else if (evt.key == KeyCode::Delete)
     163      {
     164        toClipboard(buffer_);
     165        clear();
     166      }
     167    }
     168    //std::string input = keyboard_->getAsString(e.key);
     169    /*if (input.size() >= 1)
     170    append(input[0]);*/
     171
     172    append((char)evt.text);
     173  }
     174
     175  void InputBuffer::tick(float dt)
     176  {
     177    timeSinceKeyPressed_ += dt;
     178    if (keysToRepeat_ < 10 && timeSinceKeyPressed_ > keyRepeatDeleay_)
     179    {
     180      // initial time out has gone by, start repeating keys
     181      while (timeSinceKeyPressed_ - timeSinceKeyRepeated_ > keyRepeatTime_)
     182      {
     183        timeSinceKeyRepeated_ += keyRepeatTime_;
     184        keysToRepeat_++;
     185      }
     186    }
     187  }
     188
     189  bool InputBuffer::keyPressed(const KeyEvent &evt)
     190  {
     191    lastKey_ = evt.key;
     192    timeSinceKeyPressed_ = 0.0;
     193    timeSinceKeyRepeated_ = keyRepeatDeleay_;
     194    keysToRepeat_ = 0;
     195
     196    processKey(evt);
     197    return true;
     198  }
     199
     200  bool InputBuffer::keyHeld(const KeyEvent& evt)
     201  {
     202    if (evt.key == lastKey_)
     203    {
     204      while (keysToRepeat_)
     205      {
     206        processKey(evt);
     207        keysToRepeat_--;
     208      }
     209    }
     210    return true;
     211  }
     212
    193213}
  • code/trunk/src/core/InputBuffer.h

    r1219 r1293  
    2323 *      Fabian 'x3n' Landau
    2424 *   Co-authors:
    25  *      ...
     25 *      Reto Grieder
    2626 *
    2727 */
     
    3535#include <list>
    3636
    37 #include "ois/OISKeyboard.h"
    38 #include "InputHandler.h"
     37#include "InputInterfaces.h"
     38#include "Tickable.h"
    3939
    4040namespace orxonox
    4141{
    42     class _CoreExport InputBufferListener
    43     {};
     42  class _CoreExport InputBufferListener
     43  {};
    4444
    45     class _CoreExport InputBuffer : public KeyHandler
     45  class _CoreExport InputBuffer : public KeyHandler, public TickableReal
     46  {
     47    struct InputBufferListenerTuple
    4648    {
    47         struct InputBufferListenerTuple
    48         {
    49             InputBufferListener* listener_;
    50             void (InputBufferListener::*function_)();
    51             bool bListenToAllChanges_;
    52             bool bOnlySingleInput_;
    53             char char_;
    54         };
     49      InputBufferListener* listener_;
     50      void (InputBufferListener::*function_)();
     51      bool bListenToAllChanges_;
     52      bool bOnlySingleInput_;
     53      char char_;
     54    };
    5555
    56         public:
    57             InputBuffer();
    58             InputBuffer(const std::string allowedChars);
     56  public:
     57    InputBuffer(const std::string allowedChars =
     58      "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZäöüÄÖÜ0123456789 \\\"(){}[]<>.:,;_-+*/=!?|$&%^");
    5959
    60             template <class T>
    61             void registerListener(T* listener, void (T::*function)(), bool bOnlySingleInput)
    62             {
    63                 struct InputBufferListenerTuple newListener = {listener, (void (InputBufferListener::*)())function, true, bOnlySingleInput, ' '};
    64                 this->listeners_.insert(this->listeners_.end(), newListener);
    65             }
    66             template <class T>
    67             void registerListener(T* listener, void (T::*function)() const, bool bOnlySingleInput)
    68             {
    69                 struct InputBufferListenerTuple newListener = {listener, (void (InputBufferListener::*)())function, true, bOnlySingleInput, ' '};
    70                 this->listeners_.insert(this->listeners_.end(), newListener);
    71             }
     60    void setConfigValues();
    7261
    73             template <class T>
    74             void registerListener(T* listener, void (T::*function)(), char char_, bool bOnlySingleInput)
    75             {
    76                 struct InputBufferListenerTuple newListener = {listener, (void (InputBufferListener::*)())function, false, bOnlySingleInput, char_};
    77                 this->listeners_.insert(this->listeners_.end(), newListener);
    78             }
    79             template <class T>
    80             void registerListener(T* listener, void (T::*function)() const, char char_, bool bOnlySingleInput)
    81             {
    82                 struct InputBufferListenerTuple newListener = {listener, (void (InputBufferListener::*)())function, false, bOnlySingleInput, char_};
    83                 this->listeners_.insert(this->listeners_.end(), newListener);
    84             }
     62    template <class T>
     63    void registerListener(T* listener, void (T::*function)(), bool bOnlySingleInput)
     64    {
     65      struct InputBufferListenerTuple newListener = {listener, (void (InputBufferListener::*)())function, true, bOnlySingleInput, ' '};
     66      this->listeners_.insert(this->listeners_.end(), newListener);
     67    }
     68    template <class T>
     69    void registerListener(T* listener, void (T::*function)() const, bool bOnlySingleInput)
     70    {
     71      struct InputBufferListenerTuple newListener = {listener, (void (InputBufferListener::*)())function, true, bOnlySingleInput, ' '};
     72      this->listeners_.insert(this->listeners_.end(), newListener);
     73    }
    8574
    86             void set(const std::string& input);
    87             void append(const std::string& input);
    88             void append(const char& input);
    89             void removeLast();
    90             void clear();
     75    template <class T>
     76    void registerListener(T* listener, void (T::*function)(), char char_, bool bOnlySingleInput)
     77    {
     78      struct InputBufferListenerTuple newListener = {listener, (void (InputBufferListener::*)())function, false, bOnlySingleInput, char_};
     79      this->listeners_.insert(this->listeners_.end(), newListener);
     80    }
     81    template <class T>
     82    void registerListener(T* listener, void (T::*function)() const, char char_, bool bOnlySingleInput)
     83    {
     84      struct InputBufferListenerTuple newListener = {listener, (void (InputBufferListener::*)())function, false, bOnlySingleInput, char_};
     85      this->listeners_.insert(this->listeners_.end(), newListener);
     86    }
    9187
    92             void updated();
    93             void updated(const char& update, bool bSingleInput);
     88    void set(const std::string& input);
     89    void append(const std::string& input);
     90    void append(const char& input);
     91    void removeLast();
     92    void clear();
    9493
    95             inline std::string get() const
    96                 { return this->buffer_; }
     94    void updated();
     95    void updated(const char& update, bool bSingleInput);
    9796
    98             /*inline void activate()
    99                 { this->setActivated(true); }
    100             inline void deactivate()
    101                 { this->setActivated(false); }
    102             inline void setActivated(bool bActivated)
    103                 { if (this->bActivated_ != bActivated) { this->bActivated_ = bActivated; this->activityChanged(); } else { this->bActivated_ = bActivated; } }
    104             inline bool isActivated() const
    105                 { return this->bActivated_; }
     97    inline std::string get() const
     98    { return this->buffer_; }
    10699
    107             void activityChanged() const;*/
     100  private:  // functions
     101    bool charIsAllowed(const char& input);
    108102
    109         private:
    110             bool charIsAllowed(const char& input);
     103    bool keyPressed (const KeyEvent& evt);
     104    bool keyReleased(const KeyEvent& evt) { return true; }
     105    bool keyHeld    (const KeyEvent& evt);
     106    void processKey (const KeyEvent &e);
    111107
    112             bool keyPressed(const OIS::KeyEvent &e);
    113             bool keyReleased(const OIS::KeyEvent &e);
    114             bool keyHeld(const OIS::KeyEvent &e) { return true; }
     108    void tick(float dt);
    115109
    116             OIS::Keyboard* keyboard_;
    117             //bool bActivated_;
    118             std::string buffer_;
    119             std::list<InputBufferListenerTuple> listeners_;
    120             std::string allowedChars_;
    121     };
     110  private: // variables
     111    std::string buffer_;
     112    std::list<InputBufferListenerTuple> listeners_;
     113    std::string allowedChars_;
     114
     115    KeyCode::Enum lastKey_;
     116    float timeSinceKeyPressed_;
     117    float timeSinceKeyRepeated_;
     118    int keysToRepeat_;
     119
     120    // configured values
     121    float keyRepeatDeleay_;
     122    float keyRepeatTime_;
     123  };
    122124}
    123125
  • code/trunk/src/core/InputHandler.cc

    r1219 r1293  
    3333
    3434#include "InputHandler.h"
     35#include "util/Convert.h"
    3536#include "Debug.h"
    3637#include "ConfigValueIncludes.h"
    3738#include "CoreIncludes.h"
    38 #include "util/Convert.h"
    39 #include "core/CommandExecutor.h"
     39#include "CommandExecutor.h"
    4040
    4141namespace orxonox
     
    5555    std::string keyNames[] = {
    5656    "UNASSIGNED",
    57                 "ESCAPE",
    58                 "1",
    59                 "2",
    60                 "3",
    61                 "4",
    62                 "5",
    63                 "6",
    64                 "7",
    65                 "8",
    66                 "9",
    67                 "0",
    68                 "MINUS",
    69                 "EQUALS",
    70                 "BACK",
    71                 "TAB",
    72                 "Q",
    73                 "W",
    74                 "E",
    75                 "R",
    76                 "T",
    77                 "Y",
    78                 "U",
    79                 "I",
    80                 "O",
    81                 "P",
    82                 "LBRACKET",
    83                 "RBRACKET",
    84                 "RETURN",
    85                 "LCONTROL",
    86                 "A",
    87                 "S",
    88                 "D",
    89                 "F",
    90                 "G",
    91                 "H",
    92                 "J",
    93                 "K",
    94                 "L",
    95                 "SEMICOLON",
    96                 "APOSTROPHE",
    97                 "GRAVE",
    98                 "LSHIFT",
    99                 "BACKSLASH",
    100                 "Z",
    101                 "X",
    102                 "C",
    103                 "V",
    104                 "B",
    105                 "N",
    106                 "M",
    107                 "COMMA",
    108                 "PERIOD",
    109                 "SLASH",
    110                 "RSHIFT",
    111                 "MULTIPLY",
    112                 "LMENU",
    113                 "SPACE",
    114                 "CAPITAL",
    115                 "F1",
    116                 "F2",
    117                 "F3",
    118                 "F4",
    119                 "F5",
    120                 "F6",
    121                 "F7",
    122                 "F8",
    123                 "F9",
    124                 "F10",
    125                 "NUMLOCK",
    126                 "SCROLL",
    127                 "NUMPAD7",
    128                 "NUMPAD8",
    129                 "NUMPAD9",
    130                 "SUBTRACT",
    131                 "NUMPAD4",
    132                 "NUMPAD5",
    133                 "NUMPAD6",
    134                 "ADD",
    135                 "NUMPAD1",
    136                 "NUMPAD2",
    137                 "NUMPAD3",
    138                 "NUMPAD0",
    139                 "DECIMAL",
     57    "ESCAPE",
     58    "1",
     59    "2",
     60    "3",
     61    "4",
     62    "5",
     63    "6",
     64    "7",
     65    "8",
     66    "9",
     67    "0",
     68    "MINUS",
     69    "EQUALS",
     70    "BACK",
     71    "TAB",
     72    "Q",
     73    "W",
     74    "E",
     75    "R",
     76    "T",
     77    "Y",
     78    "U",
     79    "I",
     80    "O",
     81    "P",
     82    "LBRACKET",
     83    "RBRACKET",
     84    "RETURN",
     85    "LCONTROL",
     86    "A",
     87    "S",
     88    "D",
     89    "F",
     90    "G",
     91    "H",
     92    "J",
     93    "K",
     94    "L",
     95    "SEMICOLON",
     96    "APOSTROPHE",
     97    "GRAVE",
     98    "LSHIFT",
     99    "BACKSLASH",
     100    "Z",
     101    "X",
     102    "C",
     103    "V",
     104    "B",
     105    "N",
     106    "M",
     107    "COMMA",
     108    "PERIOD",
     109    "SLASH",
     110    "RSHIFT",
     111    "MULTIPLY",
     112    "LMENU",
     113    "SPACE",
     114    "CAPITAL",
     115    "F1",
     116    "F2",
     117    "F3",
     118    "F4",
     119    "F5",
     120    "F6",
     121    "F7",
     122    "F8",
     123    "F9",
     124    "F10",
     125    "NUMLOCK",
     126    "SCROLL",
     127    "NUMPAD7",
     128    "NUMPAD8",
     129    "NUMPAD9",
     130    "SUBTRACT",
     131    "NUMPAD4",
     132    "NUMPAD5",
     133    "NUMPAD6",
     134    "ADD",
     135    "NUMPAD1",
     136    "NUMPAD2",
     137    "NUMPAD3",
     138    "NUMPAD0",
     139    "DECIMAL",
    140140    "","",
    141                 "OEM_102",
    142                 "F11",
    143                 "F12",
     141    "OEM_102",
     142    "F11",
     143    "F12",
    144144    "","","","","","","","","","","",
    145                 "F13",
    146                 "F14",
    147                 "F15",
     145    "F13",
     146    "F14",
     147    "F15",
    148148    "","","","","","","","","","",
    149                 "KANA",
     149    "KANA",
    150150    "","",
    151                 "ABNT_C1",
     151    "ABNT_C1",
    152152    "","","","","",
    153                 "CONVERT",
    154     "",
    155                 "NOCONVERT",
    156     "",
    157                 "YEN",
    158                 "ABNT_C2",
     153    "CONVERT",
     154    "",
     155    "NOCONVERT",
     156    "",
     157    "YEN",
     158    "ABNT_C2",
    159159    "","","","","","","","","","","","","","",
    160                 "NUMPADEQUALS",
     160    "NUMPADEQUALS",
    161161    "","",
    162                 "PREVTRACK",
    163                 "AT",
    164                 "COLON",
    165                 "UNDERLINE",
    166                 "KANJI",
    167                 "STOP",
    168                 "AX",
    169                 "UNLABELED",
    170                 "NEXTTRACK",
     162    "PREVTRACK",
     163    "AT",
     164    "COLON",
     165    "UNDERLINE",
     166    "KANJI",
     167    "STOP",
     168    "AX",
     169    "UNLABELED",
     170    "NEXTTRACK",
    171171    "","",
    172                 "NUMPADENTER",
    173                 "RCONTROL",
     172    "NUMPADENTER",
     173    "RCONTROL",
    174174    "","",
    175                 "MUTE",
    176                 "CALCULATOR",
    177                 "PLAYPAUSE",
    178     "",
    179                 "MEDIASTOP",
     175    "MUTE",
     176    "CALCULATOR",
     177    "PLAYPAUSE",
     178    "",
     179    "MEDIASTOP",
    180180    "","","","","","","","","",
    181                 "VOLUMEDOWN",
    182     "",
    183                 "VOLUMEUP",
    184     "",
    185                 "WEBHOME",
    186                 "NUMPADCOMMA",
    187     "",
    188                 "DIVIDE",
    189     "",
    190                 "SYSRQ",
    191                 "RMENU",
     181    "VOLUMEDOWN",
     182    "",
     183    "VOLUMEUP",
     184    "",
     185    "WEBHOME",
     186    "NUMPADCOMMA",
     187    "",
     188    "DIVIDE",
     189    "",
     190    "SYSRQ",
     191    "RMENU",
    192192    "","","","","","","","","","","","",
    193                 "PAUSE",
    194     "",
    195                 "HOME",
    196                 "UP",
    197                 "PGUP",
    198     "",
    199                 "LEFT",
    200     "",
    201                 "RIGHT",
    202     "",
    203                 "END",
    204                 "DOWN",
    205                 "PGDOWN",
    206                 "INSERT",
    207                 "DELETE",
     193    "PAUSE",
     194    "",
     195    "HOME",
     196    "UP",
     197    "PGUP",
     198    "",
     199    "LEFT",
     200    "",
     201    "RIGHT",
     202    "",
     203    "END",
     204    "DOWN",
     205    "PGDOWN",
     206    "INSERT",
     207    "DELETE",
    208208    "","","","","","","",
    209                 "LWIN",
    210                 "RWIN",
    211                 "APPS",
    212                 "POWER",
    213                 "SLEEP",
     209    "LWIN",
     210    "RWIN",
     211    "APPS",
     212    "POWER",
     213    "SLEEP",
    214214    "","","",
    215                 "WAKE",
    216     "",
    217                 "WEBSEARCH",
    218                 "WEBFAVORITES",
    219                 "WEBREFRESH",
    220                 "WEBSTOP",
    221                 "WEBFORWARD",
    222                 "WEBBACK",
    223                 "MYCOMPUTER",
    224                 "MAIL",
    225                 "MEDIASELECT"
     215    "WAKE",
     216    "",
     217    "WEBSEARCH",
     218    "WEBFAVORITES",
     219    "WEBREFRESH",
     220    "WEBSTOP",
     221    "WEBFORWARD",
     222    "WEBBACK",
     223    "MYCOMPUTER",
     224    "MAIL",
     225    "MEDIASELECT"
    226226    };
    227227    for (int i = 0; i < numberOfKeys_s; i++)
     
    229229
    230230    std::string mouseButtonNames[] = {
    231     "MouseLeft", "MouseRight", "MouseMiddle",
    232     "MouseButton3", "MouseButton4", "MouseButton5",
    233     "MouseButton6", "MouseButton7" };
     231      "MouseLeft", "MouseRight", "MouseMiddle",
     232      "MouseButton3", "MouseButton4", "MouseButton5",
     233      "MouseButton6", "MouseButton7" };
    234234    for (int i = 0; i < numberOfMouseButtons_s; i++)
    235235      mouseButtonNames_[i] = mouseButtonNames[i];
     
    267267        switch (j)
    268268        {
    269           // note: the first element in the struct is the string, so the following pointer
    270           //       arithmetic works.
    271269          case 0:
    272270            cont->getValue(&bindingsKeyPress_[i].commandStr);
    273271            break;
    274272          case 1:
    275             cont->getValue(bindingsKeyRelease_ + i);
     273            cont->getValue(&bindingsKeyRelease_[i].commandStr);
    276274            break;
    277275          case 2:
    278             cont->getValue(bindingsKeyHold_ + i);
     276            cont->getValue(&bindingsKeyHold_[i].commandStr);
    279277        }
    280278      }
     
    295293        {
    296294          case 0:
    297             cont->getValue(bindingsMouseButtonPress_ + i);
     295            cont->getValue(&bindingsMouseButtonPress_[i].commandStr);
    298296            break;
    299297          case 1:
    300             cont->getValue(bindingsMouseButtonRelease_ + i);
     298            cont->getValue(&bindingsMouseButtonRelease_[i].commandStr);
    301299            break;
    302300          case 2:
    303             cont->getValue(bindingsMouseButtonHold_ + i);
     301            cont->getValue(&bindingsMouseButtonHold_[i].commandStr);
    304302        }
    305303      }
     
    320318        {
    321319          case 0:
    322             cont->getValue(bindingsJoyStickButtonPress_ + i);
     320            cont->getValue(&bindingsJoyStickButtonPress_[i].commandStr);
    323321            break;
    324322          case 1:
    325             cont->getValue(bindingsJoyStickButtonRelease_ + i);
     323            cont->getValue(&bindingsJoyStickButtonRelease_[i].commandStr);
    326324            break;
    327325          case 2:
    328             cont->getValue(bindingsJoyStickButtonHold_ + i);
     326            cont->getValue(&bindingsJoyStickButtonHold_[i].commandStr);
    329327        }
    330328      }
     
    345343    for (int i = 0; i < numberOfMouseButtons_s; i++)
    346344    {
    347       bindingsMouseButtonPress_  [i] = "";
    348       bindingsMouseButtonRelease_[i] = "";
    349       bindingsMouseButtonHold_   [i] = "";
     345      bindingsMouseButtonPress_  [i].commandStr = "";
     346      bindingsMouseButtonRelease_[i].commandStr = "";
     347      bindingsMouseButtonHold_   [i].commandStr = "";
    350348    }
    351349    for (int i = 0; i < numberOfJoyStickButtons_s; i++)
    352350    {
    353       bindingsJoyStickButtonPress_  [i] = "";
    354       bindingsJoyStickButtonRelease_[i] = "";
    355       bindingsJoyStickButtonHold_   [i] = "";
     351      bindingsJoyStickButtonPress_  [i].commandStr = "";
     352      bindingsJoyStickButtonRelease_[i].commandStr = "";
     353      bindingsJoyStickButtonHold_   [i].commandStr = "";
    356354    }
    357355  }
     
    370368    // evaluate the key bindings
    371369    // TODO: what if binding is invalid?
    372     //for (int i = 0; i < numberOfKeys_s; i++)
    373     //{
    374     //  if (bindingsKeyPress_[i].commandStr != "")
    375     //  {
    376     //    bindingsKeyPress_[i].evaluation = CommandExecutor::evaluate(bindingsKeyPress_[i].commandStr);
    377     //    bindingsKeyPress_[i].commandStr = bindingsKeyPress_[i].evaluation.getCommandString();
    378     //  }
    379     //}
     370    for (int i = 0; i < numberOfKeys_s; i++)
     371    {
     372      if (bindingsKeyPress_[i].commandStr != "")
     373      {
     374        bindingsKeyPress_[i].evaluation = CommandExecutor::evaluate(bindingsKeyPress_[i].commandStr);
     375        bindingsKeyPress_[i].commandStr = bindingsKeyPress_[i].evaluation.getCommandString();
     376      }
     377    }
    380378
    381379    COUT(ORX_DEBUG) << "KeyBinder: Loading key bindings done." << std::endl;
     
    383381  }
    384382
    385   bool KeyBinder::executeBinding(KeyBinding& binding)
     383  bool KeyBinder::executeSimpleBinding(KeyBinding& binding)
    386384  {
    387385    if (binding.commandStr != "")
    388386    {
    389       //if (binding.commandStr != binding.evaluation.getCommandString())
    390       //{
    391       //  // key binding has changed, reevaluate the command string.
    392       //  binding.evaluation = CommandExecutor::evaluate(binding.commandStr);
    393       //  binding.commandStr = binding.evaluation.getCommandString();
    394       //}
    395       COUT(3) << "Executing command: " << binding.commandStr << std::endl;
     387      if (binding.commandStr != binding.evaluation.getCommandString())
     388      {
     389        // key binding has changed, reevaluate the command string.
     390        binding.evaluation = CommandExecutor::evaluate(binding.commandStr);
     391        binding.commandStr = binding.evaluation.getCommandString();
     392      }
     393      COUT(ORX_DEBUG) << "Keybinding: Executing command: " << binding.commandStr << std::endl;
    396394      CommandExecutor::execute(binding.commandStr);
    397395    }
     
    405403    @param e Event information
    406404  */
    407   bool KeyBinder::keyPressed(const OIS::KeyEvent &e)
    408   {
    409     COUT(3) << "Key: " << e.key << std::endl;
    410     // find the appropriate key binding
    411     executeBinding(bindingsKeyPress_[int(e.key)]);
    412      
     405  bool KeyBinder::keyPressed(const KeyEvent& evt)
     406  {
     407    // find the appropriate key binding
     408    executeSimpleBinding(bindingsKeyPress_[int(evt.key)]);
     409
    413410    return true;
    414411  }
     
    418415    @param e Event information
    419416  */
    420   bool KeyBinder::keyReleased(const OIS::KeyEvent &e)
    421   {
    422     // find the appropriate key binding
    423     executeBinding(bindingsKeyRelease_[int(e.key)]);
     417  bool KeyBinder::keyReleased(const KeyEvent& evt)
     418  {
     419    // find the appropriate key binding
     420    executeSimpleBinding(bindingsKeyRelease_[int(evt.key)]);
    424421
    425422    return true;
     
    428425  /**
    429426    @brief Event handler for the keyHeld Event.
    430     @param e Event information
    431   */
    432   bool KeyBinder::keyHeld(const OIS::KeyEvent &e)
    433   {
    434     // find the appropriate key binding
    435     executeBinding(bindingsKeyHold_[int(e.key)]);
     427    @param e Mouse state information
     428  */
     429  bool KeyBinder::keyHeld(const KeyEvent& evt)
     430  {
     431    // find the appropriate key binding
     432    executeSimpleBinding(bindingsKeyHold_[int(evt.key)]);
    436433
    437434    return true;
     
    440437  /**
    441438    @brief Event handler for the mouseMoved Event.
    442     @param e Event information
    443   */
    444   bool KeyBinder::mouseMoved(const OIS::MouseEvent &e)
     439    @param e Mouse state information
     440  */
     441  bool KeyBinder::mouseMoved(const MouseState &evt)
     442  {
     443    /*if (bindingMouseMoved_.commandStr != "")
     444    {
     445      if (bindingMouseMoved_.commandStr != bindingMouseMoved_.evaluation.getCommandString())
     446      {
     447        // key binding has changed, reevaluate the command string.
     448        bindingMouseMoved_.evaluation = CommandExecutor::evaluate(bindingMouseMoved_.commandStr);
     449        bindingMouseMoved_.commandStr = bindingMouseMoved_.evaluation.getCommandString();
     450      }
     451      COUT(3) << "Executing command: " << bindingMouseMoved_.commandStr << std::endl;
     452
     453      bindingMouseMoved_.evaluation.setEvaluatedParameter(
     454      CommandExecutor::execute(bindingMouseMoved_.commandStr);
     455    }*/
     456
     457    return true;
     458  }
     459
     460  /**
     461    @brief Event handler for the mouseScrolled Event.
     462    @param e Mouse state information
     463  */
     464  bool KeyBinder::mouseScrolled(const MouseState &evt)
    445465  {
    446466    return true;
     
    452472    @param id The ID of the mouse button
    453473  */
    454   bool KeyBinder::mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id)
    455   {
    456     // find the appropriate key binding
    457     std::string cmdStr = bindingsMouseButtonPress_[int(id)];
    458     if (cmdStr != "")
    459     {
    460       CommandExecutor::execute(cmdStr);
    461       COUT(3) << "Executing command: " << cmdStr << std::endl;
    462     }
     474  bool KeyBinder::mouseButtonPressed(const MouseState& state, MouseButton::Enum id)
     475  {
     476    // find the appropriate key binding
     477    executeSimpleBinding(bindingsMouseButtonPress_[int(id)]);
    463478
    464479    return true;
     
    470485    @param id The ID of the mouse button
    471486  */
    472   bool KeyBinder::mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id)
    473   {
    474     // find the appropriate key binding
    475     std::string cmdStr = bindingsMouseButtonRelease_[int(id)];
    476     if (cmdStr != "")
    477     {
    478       CommandExecutor::execute(cmdStr);
    479       COUT(3) << "Executing command: " << cmdStr << std::endl;
    480     }
     487  bool KeyBinder::mouseButtonReleased(const MouseState& state, MouseButton::Enum id)
     488  {
     489    // find the appropriate key binding
     490    executeSimpleBinding(bindingsMouseButtonRelease_[int(id)]);
    481491
    482492    return true;
     
    488498    @param id The ID of the mouse button
    489499  */
    490   bool KeyBinder::mouseHeld(const OIS::MouseEvent &e, OIS::MouseButtonID id)
    491   {
    492     // find the appropriate key binding
    493     std::string cmdStr = bindingsMouseButtonHold_[int(id)];
    494     if (cmdStr != "")
    495     {
    496       CommandExecutor::execute(cmdStr);
    497       COUT(3) << "Executing command: " << cmdStr << std::endl;
    498     }
    499 
    500     return true;
    501   }
    502 
    503   bool KeyBinder::buttonPressed(int joyStickID, const OIS::JoyStickEvent &arg, int button)
    504   {
    505     // find the appropriate key binding
    506     std::string cmdStr = bindingsJoyStickButtonPress_[button];
    507     if (cmdStr != "")
    508     {
    509       CommandExecutor::execute(cmdStr);
    510       COUT(3) << "Executing command: " << cmdStr << std::endl;
    511     }
    512 
    513     return true;
    514   }
    515 
    516   bool KeyBinder::buttonReleased(int joyStickID, const OIS::JoyStickEvent &arg, int button)
    517   {
    518     // find the appropriate key binding
    519     std::string cmdStr = bindingsJoyStickButtonRelease_[button];
    520     if (cmdStr != "")
    521     {
    522       CommandExecutor::execute(cmdStr);
    523       COUT(3) << "Executing command: " << cmdStr << std::endl;
    524     }
    525 
    526     return true;
    527   }
    528 
    529   bool KeyBinder::buttonHeld(int joyStickID, const OIS::JoyStickEvent &arg, int button)
    530   {
    531     // find the appropriate key binding
    532     std::string cmdStr = bindingsJoyStickButtonHold_[button];
    533     if (cmdStr != "")
    534     {
    535       CommandExecutor::execute(cmdStr);
    536       COUT(3) << "Executing command: " << cmdStr << std::endl;
    537     }
    538 
    539     return true;
    540   }
    541 
    542   bool KeyBinder::axisMoved(int joyStickID, const OIS::JoyStickEvent &arg, int axis)
    543   {
    544     return true;
    545   }
    546 
    547   bool KeyBinder::sliderMoved(int joyStickID, const OIS::JoyStickEvent &arg, int id)
    548   {
    549     return true;
    550   }
    551 
    552   bool KeyBinder::povMoved(int joyStickID, const OIS::JoyStickEvent &arg, int id)
    553   {
    554     return true;
    555   }
    556 
    557   bool KeyBinder::vector3Moved(int joyStickID, const OIS::JoyStickEvent &arg, int id)
     500  bool KeyBinder::mouseButtonHeld(const MouseState& state, MouseButton::Enum id)
     501  {
     502    // find the appropriate key binding
     503    executeSimpleBinding(bindingsMouseButtonHold_[int(id)]);
     504
     505    return true;
     506  }
     507
     508  bool KeyBinder::joyStickButtonPressed(const JoyStickState& state, int button)
     509  {
     510    // find the appropriate key binding
     511    executeSimpleBinding(bindingsJoyStickButtonPress_[button]);
     512
     513    return true;
     514  }
     515
     516  bool KeyBinder::joyStickButtonReleased(const JoyStickState& state, int button)
     517  {
     518    // find the appropriate key binding
     519    executeSimpleBinding(bindingsJoyStickButtonRelease_[button]);
     520
     521    return true;
     522  }
     523
     524  bool KeyBinder::joyStickButtonHeld(const JoyStickState& state, int button)
     525  {
     526    // find the appropriate key binding
     527    executeSimpleBinding(bindingsJoyStickButtonHold_[button]);
     528
     529    return true;
     530  }
     531
     532  bool KeyBinder::joyStickAxisMoved(const JoyStickState& state, int axis)
     533  {
     534    return true;
     535  }
     536
     537  bool KeyBinder::joyStickSliderMoved(const JoyStickState& state, int index)
     538  {
     539    return true;
     540  }
     541
     542  bool KeyBinder::joyStickPovMoved(const JoyStickState& state, int index)
     543  {
     544    return true;
     545  }
     546
     547  bool KeyBinder::joyStickVector3Moved(const JoyStickState& state, int index)
    558548  {
    559549    return true;
     
    586576  //bool GUIInputHandler::keyPressed(const OIS::KeyEvent &e)
    587577  //{
    588                 ////CEGUI::System::getSingleton().injectKeyDown( arg.key );
    589                 ////CEGUI::System::getSingleton().injectChar( arg.text );
     578    ////CEGUI::System::getSingleton().injectKeyDown( arg.key );
     579    ////CEGUI::System::getSingleton().injectChar( arg.text );
    590580  //  return true;
    591581  //}
     
    597587  //bool GUIInputHandler::keyReleased(const OIS::KeyEvent &e)
    598588  //{
    599                 ////CEGUI::System::getSingleton().injectKeyUp( arg.key );
     589    ////CEGUI::System::getSingleton().injectKeyUp( arg.key );
    600590  //  return true;
    601591  //}
     
    607597  //bool GUIInputHandler::mouseMoved(const OIS::MouseEvent &e)
    608598  //{
    609                 ////CEGUI::System::getSingleton().injectMouseMove( arg.state.X.rel, arg.state.Y.rel );
     599    ////CEGUI::System::getSingleton().injectMouseMove( arg.state.X.rel, arg.state.Y.rel );
    610600  //  return true;
    611601  //}
     
    616606  //  @param id The ID of the mouse button
    617607  //*/
    618   //bool GUIInputHandler::mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id)
     608  //bool GUIInputHandler::mousePressed(const OIS::MouseEvent &e, OIS::MouseButton id)
    619609  //{
    620                 ////CEGUI::System::getSingleton().injectMouseButtonDown(convertOISMouseButtonToCegui(id));
     610    ////CEGUI::System::getSingleton().injectMouseButtonDown(convertOISMouseButtonToCegui(id));
    621611  //  return true;
    622612  //}
     
    627617  //  @param id The ID of the mouse button
    628618  //*/
    629   //bool GUIInputHandler::mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id)
     619  //bool GUIInputHandler::mouseReleased(const OIS::MouseEvent &e, OIS::MouseButton id)
    630620  //{
    631                 ////CEGUI::System::getSingleton().injectMouseButtonUp(convertOISMouseButtonToCegui(id));
     621    ////CEGUI::System::getSingleton().injectMouseButtonUp(convertOISMouseButtonToCegui(id));
    632622  //  return true;
    633623  //}
  • code/trunk/src/core/InputHandler.h

    r1219 r1293  
    3838
    3939#include <string>
     40
    4041#include "ois/OIS.h"
    4142#include "OrxonoxClass.h"
    4243#include "CommandExecutor.h"
     44#include "InputInterfaces.h"
    4345
    4446namespace orxonox
     
    5456    };
    5557  }
    56 
    57   /**
    58     @brief Interface class used for key input listeners.
    59   */
    60   class _CoreExport KeyHandler : public OIS::KeyListener
    61   {
    62   public:
    63     virtual ~KeyHandler() { }
    64     virtual bool keyHeld(const OIS::KeyEvent &arg) = 0;
    65   };
    66 
    67   /**
    68     @brief Interface class used for mouse input listeners.
    69   */
    70   class _CoreExport MouseHandler : public OIS::MouseListener
    71   {
    72   public:
    73     virtual ~MouseHandler() { }
    74     virtual bool mouseHeld(const OIS::MouseEvent &arg, OIS::MouseButtonID id) = 0;
    75   };
    76 
    77   /**
    78     @brief Interface class used for joy stick input listeners.
    79   */
    80   class _CoreExport JoyStickHandler
    81   {
    82   public:
    83     virtual ~JoyStickHandler() { }
    84                 virtual bool buttonPressed (int joyStickID, const OIS::JoyStickEvent &arg, int button) = 0;
    85                 virtual bool buttonReleased(int joyStickID, const OIS::JoyStickEvent &arg, int button) = 0;
    86     virtual bool buttonHeld    (int joyStickID, const OIS::JoyStickEvent &arg, int button) = 0;
    87                 virtual bool axisMoved     (int joyStickID, const OIS::JoyStickEvent &arg, int axis)   = 0;
    88                 virtual bool sliderMoved   (int joyStickID, const OIS::JoyStickEvent &arg, int index) {return true;}
    89                 virtual bool povMoved      (int joyStickID, const OIS::JoyStickEvent &arg, int index) {return true;}
    90                 virtual bool vector3Moved  (int joyStickID, const OIS::JoyStickEvent &arg, int index) {return true;}
    91   };
    9258
    9359  struct _CoreExport KeyBinding
     
    11379    void setConfigValues();
    11480
    115     std::string testtest;
    116 
    11781  private: // functions
    11882
    119     bool executeBinding(KeyBinding &binding);
     83    bool executeSimpleBinding(KeyBinding &binding);
    12084
    121                 bool keyPressed   (const OIS::KeyEvent   &arg);
    122                 bool keyReleased  (const OIS::KeyEvent   &arg);
    123                 bool keyHeld      (const OIS::KeyEvent   &arg);
     85    bool keyPressed (const KeyEvent& evt);
     86    bool keyReleased(const KeyEvent& evt);
     87    bool keyHeld    (const KeyEvent& evt);
    12488
    125     bool mousePressed (const OIS::MouseEvent &arg, OIS::MouseButtonID id);
    126                 bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id);
    127                 bool mouseHeld    (const OIS::MouseEvent &arg, OIS::MouseButtonID id);
    128     bool mouseMoved   (const OIS::MouseEvent &arg);
     89    bool mouseButtonPressed (const MouseState& state, MouseButton::Enum id);
     90    bool mouseButtonReleased(const MouseState& state, MouseButton::Enum id);
     91    bool mouseButtonHeld    (const MouseState& state, MouseButton::Enum id);
     92    bool mouseMoved         (const MouseState& state);
     93    bool mouseScrolled      (const MouseState& state);
    12994
    130                 bool buttonPressed (int joyStickID, const OIS::JoyStickEvent &arg, int button);
    131                 bool buttonReleased(int joyStickID, const OIS::JoyStickEvent &arg, int button);
    132                 bool buttonHeld    (int joyStickID, const OIS::JoyStickEvent &arg, int button);
    133                 bool axisMoved     (int joyStickID, const OIS::JoyStickEvent &arg, int axis);
    134                 bool sliderMoved   (int joyStickID, const OIS::JoyStickEvent &arg, int id);
    135                 bool povMoved      (int joyStickID, const OIS::JoyStickEvent &arg, int id);
    136                 bool vector3Moved  (int joyStickID, const OIS::JoyStickEvent &arg, int id);
     95    bool joyStickButtonPressed (const JoyStickState& state, int button);
     96    bool joyStickButtonReleased(const JoyStickState& state, int button);
     97    bool joyStickButtonHeld    (const JoyStickState& state, int button);
     98    bool joyStickAxisMoved     (const JoyStickState& state, int axis)  ;
     99    bool joyStickSliderMoved   (const JoyStickState& state, int index) ;
     100    bool joyStickPovMoved      (const JoyStickState& state, int index) ;
     101    bool joyStickVector3Moved  (const JoyStickState& state, int index) ;
    137102
    138103  private: // variables
     
    152117    static const int numberOfMouseButtons_s = 8;
    153118    //! Array of input events for every pressed mouse button
    154     std::string bindingsMouseButtonPress_  [numberOfMouseButtons_s];
     119    KeyBinding bindingsMouseButtonPress_  [numberOfMouseButtons_s];
    155120    //! Array of input events for every released mouse button
    156     std::string bindingsMouseButtonRelease_[numberOfMouseButtons_s];
     121    KeyBinding bindingsMouseButtonRelease_[numberOfMouseButtons_s];
    157122    //! Array of input events for every held mouse button
    158     std::string bindingsMouseButtonHold_   [numberOfMouseButtons_s];
     123    KeyBinding bindingsMouseButtonHold_   [numberOfMouseButtons_s];
     124    //! Key binding for mouse moved event
     125    KeyBinding bindingMouseMoved_;
     126    //! Key binding for mouse scrolled event
     127    KeyBinding bindingMouseScrolled_;
    159128    //! Names of the mouse buttons as strings
    160129    std::string mouseButtonNames_[numberOfMouseButtons_s];
     
    163132    static const int numberOfJoyStickButtons_s = 32;
    164133    //! Array of input events for every pressed joy stick button
    165     std::string bindingsJoyStickButtonPress_  [numberOfJoyStickButtons_s];
     134    KeyBinding bindingsJoyStickButtonPress_  [numberOfJoyStickButtons_s];
    166135    //! Array of input events for every released joy stick button
    167     std::string bindingsJoyStickButtonRelease_[numberOfJoyStickButtons_s];
     136    KeyBinding bindingsJoyStickButtonRelease_[numberOfJoyStickButtons_s];
    168137    //! Array of input events for every held joy stick button
    169     std::string bindingsJoyStickButtonHold_   [numberOfJoyStickButtons_s];
     138    KeyBinding bindingsJoyStickButtonHold_   [numberOfJoyStickButtons_s];
    170139    //! Names of the joy stick buttons as strings
    171140    std::string joyStickButtonNames_[numberOfJoyStickButtons_s];
     
    186155  //private:
    187156  //  // input events
    188                 //bool keyPressed   (const OIS::KeyEvent   &arg);
    189                 //bool keyReleased  (const OIS::KeyEvent   &arg);
    190                 //bool keyHeld      (const OIS::KeyEvent   &arg);
     157    //bool keyPressed   (const OIS::KeyEvent   &arg);
     158    //bool keyReleased  (const OIS::KeyEvent   &arg);
     159    //bool keyHeld      (const OIS::KeyEvent   &arg);
    191160
    192   //  bool mousePressed (const OIS::MouseEvent &arg, OIS::MouseButtonID id);
    193                 //bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButtonID id);
    194                 //bool mouseHeld    (const OIS::MouseEvent &arg, OIS::MouseButtonID id);
     161  //  bool mousePressed (const OIS::MouseEvent &arg, OIS::MouseButton id);
     162    //bool mouseReleased(const OIS::MouseEvent &arg, OIS::MouseButton id);
     163    //bool mouseHeld    (const OIS::MouseEvent &arg, OIS::MouseButton id);
    195164  //  bool mouseMoved   (const OIS::MouseEvent &arg);
    196165
    197                 //bool buttonPressed (const OIS::JoyStickEvent &arg, int button);
    198                 //bool buttonReleased(const OIS::JoyStickEvent &arg, int button);
    199                 //bool buttonHeld    (const OIS::JoyStickEvent &arg, int button);
    200                 //bool axisMoved     (const OIS::JoyStickEvent &arg, int axis);
    201                 //bool sliderMoved   (const OIS::JoyStickEvent &arg, int id);
    202                 //bool povMoved      (const OIS::JoyStickEvent &arg, int id);
     166    //bool buttonPressed (const OIS::JoyStickEvent &arg, int button);
     167    //bool buttonReleased(const OIS::JoyStickEvent &arg, int button);
     168    //bool buttonHeld    (const OIS::JoyStickEvent &arg, int button);
     169    //bool axisMoved     (const OIS::JoyStickEvent &arg, int axis);
     170    //bool sliderMoved   (const OIS::JoyStickEvent &arg, int id);
     171    //bool povMoved      (const OIS::JoyStickEvent &arg, int id);
    203172  //};
    204173
  • code/trunk/src/core/InputManager.cc

    r1219 r1293  
    3030  @file
    3131  @brief Implementation of the InputManager that captures all the input from OIS
    32          and redirects it to handlers if necessary.
     32         and redirects it to handlers.
    3333 */
    3434
     
    5252  InputManager::InputManager() :
    5353      inputSystem_(0), keyboard_(0), mouse_(0),
    54       state_(IS_UNINIT), stateRequest_(IS_UNINIT)
     54      joySticksSize_(0),
     55      state_(IS_UNINIT), stateRequest_(IS_UNINIT),
     56      keyboardModifiers_(0)
    5557  {
    5658    RegisterObject(InputManager);
    57 
    58     this->joySticks_.reserve(5);
    59     //this->activeJoyStickHandlers_.reserve(10);
    60     this->activeKeyHandlers_.reserve(10);
    61     this->activeMouseHandlers_.reserve(10);
    6259  }
    6360
     
    8784    @param windowHeight The height of the render window
    8885  */
    89   bool InputManager::_initialise(const size_t windowHnd, const int windowWidth, const int windowHeight,
    90         const bool createKeyboard, const bool createMouse, const bool createJoySticks)
     86  bool InputManager::_initialise(const size_t windowHnd, int windowWidth, int windowHeight,
     87        bool createKeyboard, bool createMouse, bool createJoySticks)
    9188  {
    9289    if (state_ == IS_UNINIT)
    9390    {
     91      CCOUT(3) << "Initialising Input System..." << std::endl;
    9492      CCOUT(ORX_DEBUG) << "Initialising OIS components..." << std::endl;
    9593
     
    145143    addKeyHandler(binder, "keybinder");
    146144    addMouseHandler(binder, "keybinder");
     145    addJoyStickHandler(binder, "keybinder");
    147146
    148147    // Read all the key bindings and assign them
     
    234233  bool InputManager::_initialiseJoySticks()
    235234  {
    236     if (joySticks_.size() > 0)
     235    if (joySticksSize_ > 0)
    237236    {
    238237      CCOUT(2) << "Warning: Joy sticks already initialised, skipping." << std::endl;
     
    265264      return false;
    266265    }
     266    joySticksSize_ = joySticks_.size();
     267    activeJoyStickHandlers_.resize(joySticksSize_);
     268    joyStickButtonsDown_.resize(joySticksSize_);
    267269    return success;
    268270  }
     
    273275  void InputManager::_destroy()
    274276  {
    275     CCOUT(ORX_DEBUG) << "Destroying ..." << std::endl;
    276 
    277277    if (state_ != IS_UNINIT)
    278278    {
     279      CCOUT(ORX_DEBUG) << "Destroying ..." << std::endl;
     280
    279281      if (keyHandlers_.find("buffer") != keyHandlers_.end())
    280282        delete keyHandlers_["buffer"];
     
    296298
    297299      state_ = IS_UNINIT;
    298     }
    299     else
    300       CCOUT(ORX_WARNING) << "Warning: Cannot be destroyed, since not initialised." << std::endl;
    301 
    302     CCOUT(ORX_DEBUG) << "Destroying done." << std::endl;
     300      CCOUT(ORX_DEBUG) << "Destroying done." << std::endl;
     301    }
    303302  }
    304303
     
    336335  void InputManager::_destroyJoySticks()
    337336  {
    338     if (joySticks_.size() > 0)
     337    if (joySticksSize_ > 0)
    339338    {
    340339      // note: inputSystem_ can never be 0, or else the code is mistaken
    341       for (unsigned int i = 0; i < joySticks_.size(); i++)
     340      for (unsigned int i = 0; i < joySticksSize_; i++)
    342341        if (joySticks_[i] != 0)
    343342          inputSystem_->destroyInputObject(joySticks_[i]);
    344343
    345344      joySticks_.clear();
     345      joySticksSize_ = 0;
    346346      activeJoyStickHandlers_.clear();
    347347      joyStickButtonsDown_.clear();
     
    372372        activeKeyHandlers_.clear();
    373373        activeMouseHandlers_.clear();
    374         activeJoyStickHandlers_.clear();
     374        for (unsigned int i = 0; i < joySticksSize_; i++)
     375          activeJoyStickHandlers_[i].clear();
    375376
    376377        switch (stateRequest_)
     
    381382          activeKeyHandlers_.push_back(keyHandlers_["keybinder"]);
    382383          activeMouseHandlers_.push_back(mouseHandlers_["keybinder"]);
    383           activeMouseHandlers_.push_back(mouseHandlers_["SpaceShip"]);
    384           for (std::vector<OIS::JoyStick*>::const_iterator it = joySticks_.begin();
    385                 it != joySticks_.end(); it++)
    386             activeJoyStickHandlers_[*it].push_back(joyStickHandlers_["keybinder"]);
     384          if (getMouseHandler("SpaceShip"))
     385            activeMouseHandlers_.push_back(mouseHandlers_["SpaceShip"]);
     386          for (unsigned int i = 0; i < joySticksSize_; i++)
     387            activeJoyStickHandlers_[i].push_back(joyStickHandlers_["keybinder"]);
    387388          break;
    388389
     
    393394        case IS_CONSOLE:
    394395          activeMouseHandlers_.push_back(mouseHandlers_["keybinder"]);
    395           for (std::vector<OIS::JoyStick*>::const_iterator it = joySticks_.begin();
    396                 it != joySticks_.end(); it++)
    397             activeJoyStickHandlers_[*it].push_back(joyStickHandlers_["keybinder"]);
     396          if (getMouseHandler("SpaceShip"))
     397            activeMouseHandlers_.push_back(mouseHandlers_["SpaceShip"]);
     398          for (unsigned int i = 0; i < joySticksSize_; i++)
     399            activeJoyStickHandlers_[i].push_back(joyStickHandlers_["keybinder"]);
    398400
    399401          activeKeyHandlers_.push_back(keyHandlers_["buffer"]);
     
    412414    if (keyboard_)
    413415      keyboard_->capture();
     416    for (unsigned  int i = 0; i < joySticksSize_; i++)
     417      joySticks_[i]->capture();
    414418
    415419
    416420    // call all the handlers for the held key events
    417     for (std::list<OIS::KeyCode>::const_iterator itKey = keysDown_.begin();
    418           itKey != keysDown_.end(); itKey++)
    419     {
    420       OIS::KeyEvent keyArg(keyboard_, *itKey, 0);
    421       for (unsigned int i = 0; i < activeKeyHandlers_.size(); i++)
    422         activeKeyHandlers_[i]->keyHeld(keyArg);
    423     }
     421    for (unsigned int iKey = 0; iKey < keysDown_.size(); iKey++)
     422      for (unsigned int iHandler = 0; iHandler < activeKeyHandlers_.size(); iHandler++)
     423        activeKeyHandlers_[iHandler]->keyHeld(KeyEvent(keysDown_[iKey], keyboardModifiers_));
    424424
    425425    // call all the handlers for the held mouse button events
    426     for (std::list<OIS::MouseButtonID>::const_iterator itMouseButton = mouseButtonsDown_.begin();
    427           itMouseButton != mouseButtonsDown_.end(); itMouseButton++)
    428     {
    429       OIS::MouseEvent mouseButtonArg(mouse_, mouse_->getMouseState());
    430       for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
    431         activeMouseHandlers_[i]->mouseHeld(mouseButtonArg, *itMouseButton);
    432     }
     426    for (unsigned int iButton = 0; iButton < mouseButtonsDown_.size(); iButton++)
     427      for (unsigned int iHandler = 0; iHandler < activeMouseHandlers_.size(); iHandler++)
     428        activeMouseHandlers_[iHandler]->mouseButtonHeld(mouse_->getMouseState(), mouseButtonsDown_[iButton]);
    433429
    434430    // call all the handlers for the held joy stick button events
    435     for (std::map< OIS::JoyStick*, std::list <int> >::const_iterator itJoyStick = joyStickButtonsDown_.begin();
    436           itJoyStick != joyStickButtonsDown_.end(); itJoyStick++)
    437     {
    438       OIS::JoyStick* joyStick = (*itJoyStick).first;
    439       for (std::list<int>::const_iterator itJoyStickButton = (*itJoyStick).second.begin();
    440             itJoyStickButton != (*itJoyStick).second.end(); itJoyStickButton++)
    441       {
    442         OIS::JoyStickEvent joyStickButtonArg(joyStick, joyStick->getJoyStickState());
    443         for (unsigned int i = 0; i < activeJoyStickHandlers_[joyStick].size(); i++)
    444           activeJoyStickHandlers_[joyStick][i]->buttonHeld(i, joyStickButtonArg, *itJoyStickButton);
    445       }
    446     }
    447   }
    448 
     431    for (unsigned int iJoyStick  = 0; iJoyStick < joySticksSize_; iJoyStick++)
     432      for (unsigned int iButton   = 0; iButton   < joyStickButtonsDown_[iJoyStick].size(); iButton++)
     433        for (unsigned int iHandler = 0; iHandler  < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
     434          activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickButtonHeld(
     435              JoyStickState(joySticks_[iJoyStick]->getJoyStickState(), iJoyStick), joyStickButtonsDown_[iJoyStick][iButton]);
     436  }
    449437
    450438  // ###### Key Events ######
     
    457445  {
    458446    // check whether the key already is in the list (can happen when focus was lost)
    459     for (std::list<OIS::KeyCode>::iterator it = keysDown_.begin(); it != keysDown_.end(); it++)
    460     {
    461       if (*it == e.key)
    462       {
    463         keysDown_.erase(it);
    464         break;
    465       }
    466     }
    467     keysDown_.push_back(e.key);
     447    unsigned int iKey = 0;
     448    while (iKey < keysDown_.size() && keysDown_[iKey].key != (KeyCode::Enum)e.key)
     449      iKey++;
     450    if (iKey == keysDown_.size())
     451      keysDown_.push_back(Key(e));
     452
     453    // update modifiers
     454    if(e.key == OIS::KC_RMENU    || e.key == OIS::KC_LMENU)
     455      keyboardModifiers_ |= KeyboardModifier::Alt;   // alt key
     456    if(e.key == OIS::KC_RCONTROL || e.key == OIS::KC_LCONTROL)
     457      keyboardModifiers_ |= KeyboardModifier::Ctrl;  // ctrl key
     458    if(e.key == OIS::KC_RSHIFT   || e.key == OIS::KC_LSHIFT)
     459      keyboardModifiers_ |= KeyboardModifier::Shift; // shift key
    468460
    469461    for (unsigned int i = 0; i < activeKeyHandlers_.size(); i++)
    470       activeKeyHandlers_[i]->keyPressed(e);
     462      activeKeyHandlers_[i]->keyPressed(KeyEvent(e, keyboardModifiers_));
    471463
    472464    return true;
     
    480472  {
    481473    // remove the key from the keysDown_ list
    482     for (std::list<OIS::KeyCode>::iterator it = keysDown_.begin(); it != keysDown_.end(); it++)
    483     {
    484       if (*it == e.key)
    485       {
    486         keysDown_.erase(it);
     474    for (unsigned int iKey = 0; iKey < keysDown_.size(); iKey++)
     475    {
     476      if (keysDown_[iKey].key == (KeyCode::Enum)e.key)
     477      {
     478        keysDown_.erase(keysDown_.begin() + iKey);
    487479        break;
    488480      }
    489481    }
    490482
     483    // update modifiers
     484    if(e.key == OIS::KC_RMENU    || e.key == OIS::KC_LMENU)
     485      keyboardModifiers_ &= ~KeyboardModifier::Alt;   // alt key
     486    if(e.key == OIS::KC_RCONTROL || e.key == OIS::KC_LCONTROL)
     487      keyboardModifiers_ &= ~KeyboardModifier::Ctrl;  // ctrl key
     488    if(e.key == OIS::KC_RSHIFT   || e.key == OIS::KC_LSHIFT)
     489      keyboardModifiers_ &= ~KeyboardModifier::Shift; // shift key
     490
    491491    for (unsigned int i = 0; i < activeKeyHandlers_.size(); i++)
    492       activeKeyHandlers_[i]->keyReleased(e);
     492      activeKeyHandlers_[i]->keyReleased(KeyEvent(e, keyboardModifiers_));
    493493
    494494    return true;
     
    504504  bool InputManager::mouseMoved(const OIS::MouseEvent &e)
    505505  {
    506     for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
    507       activeMouseHandlers_[i]->mouseMoved(e);
     506    // check for actual moved event
     507    if (e.state.X.rel != 0 || e.state.Y.rel != 0)
     508    {
     509      for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
     510        activeMouseHandlers_[i]->mouseMoved(e.state);
     511    }
     512
     513    // check for mouse scrolled event
     514    if (e.state.Z.rel != 0)
     515    {
     516      for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
     517        activeMouseHandlers_[i]->mouseScrolled(e.state);
     518    }
    508519
    509520    return true;
     
    518529  {
    519530    // check whether the button already is in the list (can happen when focus was lost)
    520     for (std::list<OIS::MouseButtonID>::iterator it = mouseButtonsDown_.begin(); it != mouseButtonsDown_.end(); it++)
    521     {
    522       if (*it == id)
    523       {
    524         mouseButtonsDown_.erase(it);
    525         break;
    526       }
    527     }
    528     mouseButtonsDown_.push_back(id);
     531    unsigned int iButton = 0;
     532    while (iButton < mouseButtonsDown_.size() && mouseButtonsDown_[iButton] != (MouseButton::Enum)id)
     533      iButton++;
     534    if (iButton == mouseButtonsDown_.size())
     535      mouseButtonsDown_.push_back((MouseButton::Enum)id);
    529536
    530537    for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
    531       activeMouseHandlers_[i]->mousePressed(e, id);
     538      activeMouseHandlers_[i]->mouseButtonPressed(e.state, (MouseButton::Enum)id);
    532539
    533540    return true;
     
    542549  {
    543550    // remove the button from the keysDown_ list
    544     for (std::list<OIS::MouseButtonID>::iterator it = mouseButtonsDown_.begin(); it != mouseButtonsDown_.end(); it++)
    545     {
    546       if (*it == id)
    547       {
    548         mouseButtonsDown_.erase(it);
     551    for (unsigned int iButton = 0; iButton < mouseButtonsDown_.size(); iButton++)
     552    {
     553      if (mouseButtonsDown_[iButton] == (MouseButton::Enum)id)
     554      {
     555        mouseButtonsDown_.erase(mouseButtonsDown_.begin() + iButton);
    549556        break;
    550557      }
     
    552559
    553560    for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
    554       activeMouseHandlers_[i]->mouseReleased(e, id);
     561      activeMouseHandlers_[i]->mouseButtonReleased(e.state, (MouseButton::Enum)id);
    555562
    556563    return true;
     
    562569  bool InputManager::buttonPressed(const OIS::JoyStickEvent &arg, int button)
    563570  {
     571    // use the device to identify which one called the method
    564572    OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
     573    unsigned int iJoyStick = 0;
     574    while (joySticks_[iJoyStick] != joyStick)
     575      iJoyStick++;
    565576
    566577    // check whether the button already is in the list (can happen when focus was lost)
    567     std::list<int>& buttonsDownList = joyStickButtonsDown_[joyStick];
    568     for (std::list<int>::iterator it = buttonsDownList.begin(); it != buttonsDownList.end(); it++)
    569     {
    570       if (*it == button)
    571       {
    572         buttonsDownList.erase(it);
     578    std::vector<int> buttonsDown = joyStickButtonsDown_[iJoyStick];
     579    unsigned int iButton = 0;
     580    while (iButton < buttonsDown.size() && buttonsDown[iButton] != button)
     581      iButton++;
     582    if (iButton == buttonsDown.size())
     583      buttonsDown.push_back(button);
     584
     585    for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
     586      activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickButtonPressed(JoyStickState(arg.state, iJoyStick), button);
     587
     588    return true;
     589  }
     590
     591  bool InputManager::buttonReleased(const OIS::JoyStickEvent &arg, int button)
     592  {
     593    // use the device to identify which one called the method
     594    OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
     595    unsigned int iJoyStick = 0;
     596    while (joySticks_[iJoyStick] != joyStick)
     597      iJoyStick++;
     598
     599    // remove the button from the joyStickButtonsDown_ list
     600    std::vector<int> buttonsDown = joyStickButtonsDown_[iJoyStick];
     601    for (unsigned int iButton = 0; iButton < buttonsDown.size(); iButton++)
     602    {
     603      if (buttonsDown[iButton] == button)
     604      {
     605        buttonsDown.erase(buttonsDown.begin() + iButton);
    573606        break;
    574607      }
    575608    }
    576     joyStickButtonsDown_[joyStick].push_back(button);
    577 
    578     for (unsigned int i = 0; i < activeJoyStickHandlers_[joyStick].size(); i++)
    579       activeJoyStickHandlers_[joyStick][i]->buttonPressed(i, arg, button);
    580 
    581     return true;
    582   }
    583 
    584   bool InputManager::buttonReleased(const OIS::JoyStickEvent &arg, int button)
    585   {
     609
     610    for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
     611      activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickButtonReleased(JoyStickState(arg.state, iJoyStick), button);
     612
     613    return true;
     614  }
     615
     616  bool InputManager::axisMoved(const OIS::JoyStickEvent &arg, int axis)
     617  {
     618    // use the device to identify which one called the method
    586619    OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
    587 
    588     // remove the button from the joyStickButtonsDown_ list
    589     std::list<int>& buttonsDownList = joyStickButtonsDown_[joyStick];
    590     for (std::list<int>::iterator it = buttonsDownList.begin(); it != buttonsDownList.end(); it++)
    591     {
    592       if (*it == button)
    593       {
    594         buttonsDownList.erase(it);
    595         break;
    596       }
    597     }
    598 
    599     for (unsigned int i = 0; i < activeJoyStickHandlers_[joyStick].size(); i++)
    600       activeJoyStickHandlers_[joyStick][i]->buttonReleased(i, arg, button);
    601 
    602     return true;
    603   }
    604 
    605   bool InputManager::axisMoved(const OIS::JoyStickEvent &arg, int axis)
    606   {
     620    unsigned int iJoyStick = 0;
     621    while (joySticks_[iJoyStick] != joyStick)
     622      iJoyStick++;
     623
     624    for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
     625      activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickAxisMoved(JoyStickState(arg.state, iJoyStick), axis);
     626
     627    return true;
     628  }
     629
     630  bool InputManager::sliderMoved(const OIS::JoyStickEvent &arg, int id)
     631  {
     632    // use the device to identify which one called the method
    607633    OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
    608     for (unsigned int i = 0; i < activeJoyStickHandlers_[joyStick].size(); i++)
    609       activeJoyStickHandlers_[joyStick][i]->axisMoved(i, arg, axis);
    610 
    611     return true;
    612   }
    613 
    614   bool InputManager::sliderMoved(const OIS::JoyStickEvent &arg, int id)
    615   {
     634    unsigned int iJoyStick = 0;
     635    while (joySticks_[iJoyStick] != joyStick)
     636      iJoyStick++;
     637
     638    for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
     639      activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickSliderMoved(JoyStickState(arg.state, iJoyStick), id);
     640
     641    return true;
     642  }
     643
     644  bool InputManager::povMoved(const OIS::JoyStickEvent &arg, int id)
     645  {
     646    // use the device to identify which one called the method
    616647    OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
    617     for (unsigned int i = 0; i < activeJoyStickHandlers_[joyStick].size(); i++)
    618       activeJoyStickHandlers_[joyStick][i]->sliderMoved(i, arg, id);
    619 
    620     return true;
    621   }
    622 
    623   bool InputManager::povMoved(const OIS::JoyStickEvent &arg, int id)
    624   {
     648    unsigned int iJoyStick = 0;
     649    while (joySticks_[iJoyStick] != joyStick)
     650      iJoyStick++;
     651
     652    for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
     653      activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickPovMoved(JoyStickState(arg.state, iJoyStick), id);
     654
     655    return true;
     656  }
     657
     658  bool InputManager::vector3Moved(const OIS::JoyStickEvent &arg, int id)
     659  {
     660    // use the device to identify which one called the method
    625661    OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
    626     for (unsigned int i = 0; i < activeJoyStickHandlers_[joyStick].size(); i++)
    627       activeJoyStickHandlers_[joyStick][i]->povMoved(i, arg, id);
    628 
    629     return true;
    630   }
    631 
    632   bool InputManager::vector3Moved(const OIS::JoyStickEvent &arg, int id)
    633   {
    634     OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
    635     for (unsigned int i = 0; i < activeJoyStickHandlers_[joyStick].size(); i++)
    636       activeJoyStickHandlers_[joyStick][i]->vector3Moved(i, arg, id);
     662    unsigned int iJoyStick = 0;
     663    while (joySticks_[iJoyStick] != joyStick)
     664      iJoyStick++;
     665
     666    for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
     667      activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickVector3Moved(JoyStickState(arg.state, iJoyStick), id);
    637668
    638669    return true;
     
    645676  // ################################
    646677
    647   bool InputManager::initialise(const size_t windowHnd, const int windowWidth, const int windowHeight,
    648     const bool createKeyboard, const bool createMouse, const bool createJoySticks)
     678  bool InputManager::initialise(const size_t windowHnd, int windowWidth, int windowHeight,
     679    bool createKeyboard, bool createMouse, bool createJoySticks)
    649680  {
    650681    return _getSingleton()._initialise(windowHnd, windowWidth, windowHeight,
     
    685716  int InputManager::numberOfJoySticks()
    686717  {
    687     return _getSingleton().joySticks_.size();
     718    return _getSingleton().joySticksSize_;
     719  }
     720
     721  bool InputManager::isKeyDown(KeyCode::Enum key)
     722  {
     723    if (_getSingleton().keyboard_)
     724      return _getSingleton().keyboard_->isKeyDown((OIS::KeyCode)key);
     725    else
     726      return false;
     727  }
     728
     729  bool InputManager::isModifierDown(KeyboardModifier::Enum modifier)
     730  {
     731    if (_getSingleton().keyboard_)
     732      return isModifierDown(modifier);
     733    else
     734      return false;
     735  }
     736
     737  const MouseState InputManager::getMouseState()
     738  {
     739    if (_getSingleton().mouse_)
     740      return _getSingleton().mouse_->getMouseState();
     741    else
     742      return MouseState();
     743  }
     744
     745  const JoyStickState InputManager::getJoyStickState(unsigned int ID)
     746  {
     747    if (ID < _getSingleton().joySticksSize_)
     748      return JoyStickState(_getSingleton().joySticks_[ID]->getJoyStickState(), ID);
     749    else
     750      return JoyStickState();
    688751  }
    689752
     
    757820  bool InputManager::addKeyHandler(KeyHandler* handler, const std::string& name)
    758821  {
     822    if (!handler)
     823      return false;
    759824    if (_getSingleton().keyHandlers_.find(name) == _getSingleton().keyHandlers_.end())
    760825    {
     
    883948  bool InputManager::addMouseHandler(MouseHandler* handler, const std::string& name)
    884949  {
     950    if (!handler)
     951      return false;
    885952    if (_getSingleton().mouseHandlers_.find(name) == _getSingleton().mouseHandlers_.end())
    886953    {
     
    10101077  bool InputManager::addJoyStickHandler(JoyStickHandler* handler, const std::string& name)
    10111078  {
     1079    if (!handler)
     1080      return false;
    10121081    if (_getSingleton().joyStickHandlers_.find(name) == _getSingleton().joyStickHandlers_.end())
    10131082    {
     
    10611130    @return False if name or id was not found, true otherwise.
    10621131  */
    1063   bool InputManager::enableJoyStickHandler(const std::string& name, const int ID)
     1132  bool InputManager::enableJoyStickHandler(const std::string& name, unsigned int ID)
    10641133  {
    10651134    // get handler pointer from the map with all stored handlers
     
    10691138
    10701139    // check for existence of the ID
    1071     if ((unsigned int)ID >= _getSingleton().joySticks_.size())
    1072       return false;
    1073     OIS::JoyStick* joyStick = _getSingleton().joySticks_[ID];
     1140    if (ID >= _getSingleton().joySticksSize_)
     1141      return false;
    10741142
    10751143    // see whether the handler already is in the list
    1076     for (std::vector<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[joyStick].begin();
    1077           it != _getSingleton().activeJoyStickHandlers_[joyStick].end(); it++)
     1144    for (std::vector<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[ID].begin();
     1145          it != _getSingleton().activeJoyStickHandlers_[ID].end(); it++)
    10781146    {
    10791147      if ((*it) == (*handlerIt).second)
     
    10831151      }
    10841152    }
    1085     _getSingleton().activeJoyStickHandlers_[joyStick].push_back((*handlerIt).second);
     1153    _getSingleton().activeJoyStickHandlers_[ID].push_back((*handlerIt).second);
    10861154    _getSingleton().stateRequest_ = IS_CUSTOM;
    10871155    return true;
     
    10931161    @return False if name or id was not found, true otherwise.
    10941162  */
    1095   bool InputManager::disableJoyStickHandler(const std::string &name, int ID)
     1163  bool InputManager::disableJoyStickHandler(const std::string &name, unsigned int ID)
    10961164  {
    10971165    // get handler pointer from the map with all stored handlers
     
    11011169
    11021170    // check for existence of the ID
    1103     if ((unsigned int)ID >= _getSingleton().joySticks_.size())
    1104       return false;
    1105     OIS::JoyStick* joyStick = _getSingleton().joySticks_[ID];
     1171    if (ID >= _getSingleton().joySticksSize_)
     1172      return false;
    11061173
    11071174    // look for the handler in the list
    1108     for (std::vector<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[joyStick].begin();
    1109           it != _getSingleton().activeJoyStickHandlers_[joyStick].end(); it++)
     1175    for (std::vector<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[ID].begin();
     1176          it != _getSingleton().activeJoyStickHandlers_[ID].end(); it++)
    11101177    {
    11111178      if ((*it) == (*handlerIt).second)
    11121179      {
    1113         _getSingleton().activeJoyStickHandlers_[joyStick].erase(it);
     1180        _getSingleton().activeJoyStickHandlers_[ID].erase(it);
    11141181        _getSingleton().stateRequest_ = IS_CUSTOM;
    11151182        return true;
     
    11241191    @return False if key handler is not active or doesn't exist, true otherwise.
    11251192  */
    1126   bool InputManager::isJoyStickHandlerActive(const std::string& name, const int ID)
     1193  bool InputManager::isJoyStickHandlerActive(const std::string& name, unsigned int ID)
    11271194  {
    11281195    // get handler pointer from the map with all stored handlers
     
    11321199
    11331200    // check for existence of the ID
    1134     if ((unsigned int)ID >= _getSingleton().joySticks_.size())
    1135       return false;
    1136     OIS::JoyStick* joyStick = _getSingleton().joySticks_[ID];
     1201    if (ID >= _getSingleton().joySticksSize_)
     1202      return false;
    11371203
    11381204    // see whether the handler already is in the list
    1139     for (std::vector<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[joyStick].begin();
    1140           it != _getSingleton().activeJoyStickHandlers_[joyStick].end(); it++)
     1205    for (std::vector<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[ID].begin();
     1206          it != _getSingleton().activeJoyStickHandlers_[ID].end(); it++)
    11411207    {
    11421208      if ((*it) == (*handlerIt).second)
  • code/trunk/src/core/InputManager.h

    r1219 r1293  
    3939
    4040#include <map>
    41 #include <list>
     41#include <vector>
    4242
    4343#include "ois/OIS.h"
    4444#include "Tickable.h"
     45#include "InputInterfaces.h"
    4546
    4647namespace orxonox
    4748{
    48   class Mouse : public OIS::Mouse
    49   {
    50   };
    51 
    5249  /**
    5350    @brief Captures and distributes mouse and keyboard input.
    5451  */
    5552  class _CoreExport InputManager
    56         : public Tickable,
     53        : public TickableReal,
    5754          public OIS::KeyListener, public OIS::MouseListener, public OIS::JoyStickListener
    5855  {
     
    7269
    7370  public: // static functions
    74     static bool initialise(const size_t windowHnd, const int windowWidth, const int windowHeight,
    75           const bool createKeyboard = true, const bool createMouse = true, const bool createJoySticks = false);
     71    static bool initialise(const size_t windowHnd, int windowWidth, int windowHeight,
     72          bool createKeyboard = true, bool createMouse = true, bool createJoySticks = false);
    7673    static bool initialiseKeyboard();
    7774    static bool initialiseMouse();
     
    8582    static void destroyMouse();
    8683    static void destroyJoySticks();
     84
     85    static bool isModifierDown(KeyboardModifier::Enum modifier);
     86    static bool isKeyDown(KeyCode::Enum key);
     87    static const MouseState getMouseState();
     88    static const JoyStickState getJoyStickState(unsigned int ID);
    8789
    8890    static void setWindowExtents(const int width, const int height);
     
    108110    static bool removeJoyStickHandler         (const std::string& name);
    109111    static JoyStickHandler* getJoyStickHandler(const std::string& name);
    110     static bool enableJoyStickHandler         (const std::string& name, const int id);
    111     static bool disableJoyStickHandler        (const std::string& name, const int id);
    112     static bool isJoyStickHandlerActive       (const std::string& name, const int id);
    113 
    114     // Temporary solutions. Will be removed soon!
    115     static OIS::Mouse*    getMouse()    { return _getSingleton().mouse_   ; }
    116     static OIS::Keyboard* getKeyboard() { return _getSingleton().keyboard_; }
     112    static bool enableJoyStickHandler         (const std::string& name, unsigned int id);
     113    static bool disableJoyStickHandler        (const std::string& name, unsigned int id);
     114    static bool isJoyStickHandlerActive       (const std::string& name, unsigned int id);
    117115
    118116  private: // functions
     
    123121
    124122    // Intenal methods
    125     bool _initialise(const size_t, const int, const int, const bool, const bool, const bool);
     123    bool _initialise(const size_t, int, int, bool, bool, bool);
    126124    bool _initialiseKeyboard();
    127125    bool _initialiseMouse();
     
    133131    void _destroyJoySticks();
    134132
    135     //void _setNumberOfJoysticks(int size);
    136 
    137133    void tick(float dt);
    138134
    139135    // input events
    140                 bool mousePressed  (const OIS::MouseEvent    &arg, OIS::MouseButtonID id);
    141                 bool mouseReleased (const OIS::MouseEvent    &arg, OIS::MouseButtonID id);
     136    bool mousePressed  (const OIS::MouseEvent    &arg, OIS::MouseButtonID id);
     137    bool mouseReleased (const OIS::MouseEvent    &arg, OIS::MouseButtonID id);
    142138    bool mouseMoved    (const OIS::MouseEvent    &arg);
    143                 bool keyPressed    (const OIS::KeyEvent      &arg);
    144                 bool keyReleased   (const OIS::KeyEvent      &arg);
    145                 bool buttonPressed (const OIS::JoyStickEvent &arg, int button);
    146                 bool buttonReleased(const OIS::JoyStickEvent &arg, int button);
    147                 bool axisMoved     (const OIS::JoyStickEvent &arg, int axis);
    148                 bool sliderMoved   (const OIS::JoyStickEvent &arg, int id);
    149                 bool povMoved      (const OIS::JoyStickEvent &arg, int id);
    150                 bool vector3Moved  (const OIS::JoyStickEvent &arg, int id);
     139    bool keyPressed    (const OIS::KeyEvent      &arg);
     140    bool keyReleased   (const OIS::KeyEvent      &arg);
     141    bool buttonPressed (const OIS::JoyStickEvent &arg, int button);
     142    bool buttonReleased(const OIS::JoyStickEvent &arg, int button);
     143    bool axisMoved     (const OIS::JoyStickEvent &arg, int axis);
     144    bool sliderMoved   (const OIS::JoyStickEvent &arg, int id);
     145    bool povMoved      (const OIS::JoyStickEvent &arg, int id);
     146    bool vector3Moved  (const OIS::JoyStickEvent &arg, int id);
    151147
    152148    static InputManager& _getSingleton();
     
    158154    OIS::Mouse*                                 mouse_;       //!< OIS keyboard
    159155    std::vector<OIS::JoyStick*>                 joySticks_;   //!< OIS joy sticks
     156    unsigned int                                joySticksSize_;
    160157
    161158    InputState state_;
    162159    InputState stateRequest_;
     160    unsigned int keyboardModifiers_;
    163161
    164162    std::map<std::string, KeyHandler*>          keyHandlers_;
     
    168166    std::vector<KeyHandler*>                    activeKeyHandlers_;
    169167    std::vector<MouseHandler*>                  activeMouseHandlers_;
    170     std::map< OIS::JoyStick*, std::vector<JoyStickHandler*> > activeJoyStickHandlers_;
     168    std::vector<std::vector<JoyStickHandler*> > activeJoyStickHandlers_;
    171169
    172     std::list<OIS::KeyCode>                     keysDown_;
    173     std::list<OIS::MouseButtonID>               mouseButtonsDown_;
    174     std::map< OIS::JoyStick*, std::list<int> >  joyStickButtonsDown_;
     170    std::vector<Key>                            keysDown_;
     171    std::vector<MouseButton::Enum>              mouseButtonsDown_;
     172    std::vector<std::vector<int> >              joyStickButtonsDown_;
    175173
    176174  };
     175
    177176}
    178177
  • code/trunk/src/core/Namespace.cc

    r1062 r1293  
    3737    CreateFactory(Namespace);
    3838
    39     Namespace::Namespace()
     39    Namespace::Namespace() :
     40      bAutogeneratedFileRootNamespace_(false),
     41      bRoot_(false),
     42      operator_("or")
    4043    {
    4144        RegisterObject(Namespace);
    42 
    43         this->bAutogeneratedFileRootNamespace_ = false;
    44         this->bRoot_ = false;
    45         this->operator_ = "or";
    4645    }
    4746
  • code/trunk/src/core/OrxonoxClass.cc

    r1056 r1293  
    3737{
    3838    /** @brief Constructor: Sets the default values. */
    39     OrxonoxClass::OrxonoxClass()
     39    OrxonoxClass::OrxonoxClass() :
     40      identifier_(0),
     41      parents_(0)
    4042    {
    4143        this->setConfigValues();
    42 
    43         this->identifier_ = 0;
    44         this->parents_ = 0;
    4544    }
    4645
  • code/trunk/src/core/SignalHandler.cc

    r1062 r1293  
    3535
    3636#include <assert.h>
     37#include <iostream>
    3738
    3839#include "Debug.h"
     
    4344
    4445#include <wait.h>
     46#include <X11/Xlib.h>
     47#include <X11/Xutil.h>
     48#include <X11/keysym.h>
     49
     50bool SignalHandler::bXAutoKeyRepeatOn_ = false;
    4551
    4652SignalHandler::SignalHandler()
     
    5864  this->fileName = fileName;
    5965
     66  // prepare for restoring XAutoKeyRepeat
     67  Display* display;
     68  if ((display = XOpenDisplay(0)))
     69  {
     70    XKeyboardState oldState;
     71    XGetKeyboardControl(display, &oldState);
     72    if (oldState.global_auto_repeat == AutoRepeatModeOn)
     73      bXAutoKeyRepeatOn_ = true;
     74    else
     75      bXAutoKeyRepeatOn_ = false;
     76    XCloseDisplay(display);
     77  }
     78  else
     79  {
     80    std::cout << "Warning: couldn't open X display to restore XAutoKeyRepeat." << std::endl;
     81    bXAutoKeyRepeatOn_ = false;
     82  }
     83
     84
    6085  // make sure doCatch is only called once without calling dontCatch
    6186  assert( sigRecList.size() == 0 );
     
    120145      sigName = "SIGILL";
    121146      break;
     147  }
     148
     149  if (bXAutoKeyRepeatOn_)
     150  {
     151    std::cout << "Trying to restore XAutoKeyRepeat" << std::endl;
     152        Display* display;
     153          if ((display = XOpenDisplay(0)))
     154    {
     155                        XAutoRepeatOn(display);
     156                  XCloseDisplay(display);
     157    }
    122158  }
    123159
  • code/trunk/src/core/SignalHandler.h

    r1062 r1293  
    8686    std::string appName;
    8787    std::string fileName;
     88
     89    // used to turn on KeyAutoRepeat if OIS crashes
     90    static bool bXAutoKeyRepeatOn_;
    8891};
    8992
  • code/trunk/src/core/Tickable.cc

    r1062 r1293  
    4040        RegisterRootObject(Tickable);
    4141    }
     42
     43    /**
     44        @brief Constructor: Registers the object in the TickableReal-list
     45    */
     46    TickableReal::TickableReal()
     47    {
     48        RegisterRootObject(TickableReal);
     49    }
    4250}
  • code/trunk/src/core/Tickable.h

    r1062 r1293  
    6262    };
    6363
     64    //! The Tickable interface provides a tick(dt) function, that gets called every frame.
     65    class _CoreExport TickableReal : virtual public OrxonoxClass
     66    {
     67        public:
     68            /**
     69                @brief Gets called every frame.
     70                @param dt The time since the last frame in seconds
     71            */
     72            virtual void tick(float dt) = 0;
     73
     74        protected:
     75            TickableReal();
     76    };
     77
    6478}
    6579
  • code/trunk/src/orxonox/CMakeLists.txt

    r1224 r1293  
    1616  objects/Ambient.cc
    1717  objects/Camera.cc
     18  objects/CameraHandler.cc
    1819  objects/Explosion.cc
    1920  objects/Model.cc
     
    4243ADD_EXECUTABLE( orxonox ${ORXONOX_SRC_FILES} )
    4344
     45IF(NETWORKTRAFFIC_TESTING_ENABLED)
     46
     47  SET( ORXONOXS_SRC_FILES
     48    GraphicsEngine.cc
     49    objects/Ambient.cc
     50    objects/Camera.cc
     51    objects/CameraHandler.cc
     52    objects/Explosion.cc
     53    objects/Model.cc
     54    objects/NPC.cc
     55    objects/Projectile.cc
     56    objects/Skybox.cc
     57    objects/SpaceShip.cc
     58    objects/WorldEntity.cc
     59  )
     60
     61  ADD_LIBRARY(orxonoxs SHARED ${ORXONOX_SRC_FILES})
     62ENDIF(NETWORKTRAFFIC_TESTING_ENABLED)
     63
    4464TARGET_LINK_LIBRARIES( orxonox
    4565  ${OGRE_LIBRARIES}
  • code/trunk/src/orxonox/GraphicsEngine.cc

    r1220 r1293  
    99 *   modify it under the terms of the GNU General Public License
    1010 *   as published by the Free Software Foundation; either version 2
    11  *   of the License, or (at your option) any later version.
    12  *
     11 *   of the License, or (atl your option) any later version.
     12 *lo
    1313 *   This program is distributed in the hope that it will be useful,
    1414 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     
    4444#include "core/ConfigValueIncludes.h"
    4545#include "core/Debug.h"
    46 #include "core/TclBind.h"
     46#include "core/CommandExecutor.h"
    4747
    4848
     
    5353    @return The only instance of GraphicsEngine.
    5454  */
    55   GraphicsEngine& GraphicsEngine::getSingleton()
     55  /*static*/ GraphicsEngine& GraphicsEngine::getSingleton()
    5656  {
    5757    static GraphicsEngine theOnlyInstance;
     
    6262    @brief Only use constructor to initialise variables and pointers!
    6363  */
    64   GraphicsEngine::GraphicsEngine()
     64  GraphicsEngine::GraphicsEngine() :
     65    root_(0),
     66    scene_(0),
     67    renderWindow_(0),
     68    //configPath_(""),
     69    dataPath_(""),
     70    ogreLogfile_("")
    6571  {
    6672    RegisterObject(GraphicsEngine);
    67     //this->bOverwritePath_ = false;
     73
    6874    this->setConfigValues();
    69     // set to standard values
    70     this->configPath_ = "";
    71     this->root_ = 0;
    72     this->scene_ = 0;
    73     this->renderWindow_ = 0;
    74     COUT(4) << "*** GraphicsEngine: Constructed" << std::endl;
     75    CCOUT(4) << "Constructed" << std::endl;
     76  }
     77
     78  void GraphicsEngine::setConfigValues()
     79  {
     80    SetConfigValue(dataPath_, "../../Media/").description("relative path to media data");
     81    SetConfigValue(ogreLogfile_, "ogre.log").description("Logfile for messages from Ogre. Use \"\" to suppress log file creation.");
     82    SetConfigValue(ogreLogLevelTrivial_ , 5).description("Corresponding orxonox debug level for ogre Trivial");
     83    SetConfigValue(ogreLogLevelNormal_  , 4).description("Corresponding orxonox debug level for ogre Normal");
     84    SetConfigValue(ogreLogLevelCritical_, 2).description("Corresponding orxonox debug level for ogre Critical");
    7585  }
    7686
     
    8999  void GraphicsEngine::destroy()
    90100  {
    91     COUT(4) << "*** GraphicsEngine: Destroying objects..." << std::endl;
     101    CCOUT(4) << "Destroying objects..." << std::endl;
    92102    Ogre::WindowEventUtilities::removeWindowEventListener(this->renderWindow_, this);
    93103    if (this->root_)
     
    103113      delete Ogre::LogManager::getSingletonPtr();
    104114    }
    105     COUT(4) << "*** GraphicsEngine: Destroying objects done" << std::endl;
    106   }
    107 
    108   void GraphicsEngine::setConfigValues()
    109   {
    110     SetConfigValue(dataPath_, "../../Media/").description("relative path to media data");
    111     SetConfigValue(ogreLogfile_, "ogre.log").description("Logfile for messages from Ogre. Use \"\" to suppress log file creation.");
    112     SetConfigValue(ogreLogLevelTrivial_ , 5).description("Corresponding orxonox debug level for ogre Trivial");
    113     SetConfigValue(ogreLogLevelNormal_  , 4).description("Corresponding orxonox debug level for ogre Normal");
    114     SetConfigValue(ogreLogLevelCritical_, 2).description("Corresponding orxonox debug level for ogre Critical");
    115 
    116     TclBind::getInstance().setDataPath(this->dataPath_);
     115    CCOUT(4) << "Destroying objects done" << std::endl;
    117116  }
    118117
     
    120119    @brief Creates the Ogre Root object and sets up the ogre log.
    121120  */
    122   void GraphicsEngine::setup()
    123   {
     121  bool GraphicsEngine::setup(std::string& dataPath)
     122  {
     123    CCOUT(3) << "Setting up..." << std::endl;
     124    // temporary overwrite of dataPath, change ini file for permanent change
     125    if (dataPath != "")
     126      dataPath_ = dataPath;
     127    if (dataPath_ == "")
     128      return false;
     129    if (dataPath_[dataPath_.size() - 1] != '/')
     130      dataPath_ += "/";
     131
    124132    //TODO: Check if file exists (maybe not here)
    125 /*#ifndef OGRE_STATIC_LIB
    126     root_ = new Ogre::Root(configPath_ + "plugins.cfg", configPath_ + "ogre.cfg",
    127                      configPath_ + "Ogre.log");
    128 #else
    129     root_ = new Ogre::Root(NULL, configPath_ + "ogre.cfg", configPath_ + "Ogre.log");
    130 #endif*/
    131133#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC && defined(_DEBUG)
    132134    std::string plugin_filename = "plugins_d.cfg";
     
    135137#endif
    136138
    137     // create a logManager
    138     Ogre::LogManager *logger;
    139                 if (Ogre::LogManager::getSingletonPtr() == 0)
    140                         logger = new Ogre::LogManager();
    141     else
    142       logger = Ogre::LogManager::getSingletonPtr();
    143     COUT(4) << "*** GraphicsEngine: Ogre LogManager created/assigned" << std::endl;
     139/*    // create a logManager
     140    // note: If there's already a logManager, Ogre will complain by a failed assertation.
     141    // but that shouldn't happen, since this is the first time to create a logManager..
     142    Ogre::LogManager* logger = new Ogre::LogManager();
     143    CCOUT(4) << "Ogre LogManager created" << std::endl;
    144144
    145145    // create our own log that we can listen to
     
    148148      myLog = logger->createLog("ogre.log", true, false, true);
    149149    else
    150       myLog = logger->createLog(this->ogreLogfile_, true, false, false);
    151     COUT(4) << "*** GraphicsEngine: Ogre Log created" << std::endl;
     150          myLog = logger->createLog(this->ogreLogfile_, true, false, false);
     151    CCOUT(4) << "Ogre Log created" << std::endl;
    152152
    153153    myLog->setLogDetail(Ogre::LL_BOREME);
    154     myLog->addListener(this);
     154    myLog->addListener(this);*/
    155155
    156156    // Root will detect that we've already created a Log
    157     COUT(4) << "*** GraphicsEngine: Creating Ogre Root..." << std::endl;
     157    CCOUT(4) << "Creating Ogre Root..." << std::endl;
    158158    root_ = new Ogre::Root(plugin_filename);
    159     COUT(4) << "*** GraphicsEngine: Creating Ogre Root done" << std::endl;
    160   }
    161 
    162   /**
    163    * @return scene manager
    164    */
    165   Ogre::SceneManager* GraphicsEngine::getSceneManager()
    166   {
    167     if(!scene_)
    168     {
    169       scene_ = root_->createSceneManager(Ogre::ST_GENERIC, "Default SceneManager");
    170       COUT(3) << "Info: Created SceneMan: " << scene_ << std::endl;
    171     }
    172     return scene_;
    173   }
    174 
    175   bool GraphicsEngine::load(std::string dataPath)
    176   {
    177     // temporary overwrite of dataPath, change ini file for permanent change
    178     if( dataPath != "" )
    179       dataPath_ = dataPath + "/";
    180     loadRessourceLocations(this->dataPath_);
    181     if (!root_->restoreConfig() && !root_->showConfigDialog())
    182       return false;
     159    CCOUT(4) << "Creating Ogre Root done" << std::endl;
     160
     161    // specify where Ogre has to look for resources. This call doesn't parse anything yet!
     162    declareRessourceLocations();
     163
     164    CCOUT(3) << "Set up done." << std::endl;
    183165    return true;
    184166  }
    185167
    186   void GraphicsEngine::initialise()
    187   {
    188     this->renderWindow_ = root_->initialise(true, "OrxonoxV2");
    189     Ogre::WindowEventUtilities::addWindowEventListener(this->renderWindow_, this);
    190     Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
    191     //TODO: Do NOT load all the groups, why are we doing that? And do we really do that? initialise != load...
    192     Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
    193   }
    194 
    195   void GraphicsEngine::loadRessourceLocations(std::string dataPath)
    196   {
     168  void GraphicsEngine::declareRessourceLocations()
     169  {
     170    CCOUT(4) << "Declaring Resources" << std::endl;
    197171    //TODO: Specify layout of data file and maybe use xml-loader
    198172    //TODO: Work with ressource groups (should be generated by a special loader)
    199173    // Load resource paths from data file using configfile ressource type
    200174    Ogre::ConfigFile cf;
    201     cf.load(dataPath + "resources.cfg");
     175    cf.load(dataPath_ + "resources.cfg");
    202176
    203177    // Go through all sections & settings in the file
     
    216190
    217191        Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
    218                                            std::string(dataPath + archName),
     192                                           std::string(dataPath_ + archName),
    219193                                           typeName, secName);
    220194      }
    221195    }
     196  }
     197
     198  bool GraphicsEngine::loadRenderer()
     199  {
     200    CCOUT(4) << "Configuring Renderer" << std::endl;
     201    if (!root_->restoreConfig() && !root_->showConfigDialog())
     202      return false;
     203
     204    CCOUT(4) << "Creating render window" << std::endl;
     205    this->renderWindow_ = root_->initialise(true, "OrxonoxV2");
     206    if (!root_->isInitialised())
     207    {
     208      CCOUT(2) << "Error: Creating Ogre root object failed" << std::endl;
     209      return false;
     210    }
     211    Ogre::WindowEventUtilities::addWindowEventListener(this->renderWindow_, this);
     212    Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
     213    return true;
     214  }
     215
     216  bool GraphicsEngine::initialiseResources()
     217  {
     218    CCOUT(4) << "Initialising resources" << std::endl;
     219    //TODO: Do NOT load all the groups, why are we doing that? And do we really do that? initialise != load...
     220    try
     221    {
     222      Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
     223      /*Ogre::StringVector str = Ogre::ResourceGroupManager::getSingleton().getResourceGroups();
     224      for (unsigned int i = 0; i < str.size(); i++)
     225      {
     226        Ogre::ResourceGroupManager::getSingleton().loadResourceGroup(str[i]);
     227      }*/
     228    }
     229    catch (Ogre::Exception e)
     230    {
     231      CCOUT(2) << "Error: There was an Error when initialising the resources." << std::endl;
     232      CCOUT(2) << "ErrorMessage: " << e.getFullDescription() << std::endl;
     233      return false;
     234    }
     235    return true;
     236  }
     237
     238  /**
     239   * @brief Creates the SceneManager
     240   */
     241  bool GraphicsEngine::createNewScene()
     242  {
     243    CCOUT(4) << "Creating new SceneManager" << std::endl;
     244    if (scene_)
     245    {
     246      CCOUT(2) << "SceneManager already exists! Skipping." << std::endl;
     247      return false;
     248    }
     249    scene_ = root_->createSceneManager(Ogre::ST_GENERIC, "Default SceneManager");
     250    CCOUT(3) << "Created SceneManager: " << scene_ << std::endl;
     251    return true;
    222252  }
    223253
     
    291321    }
    292322    OutputHandler::getOutStream().setOutputLevel(orxonoxLevel)
    293         << "*** Ogre: " << message << std::endl;
    294   }
    295 
    296     void GraphicsEngine::windowMoved(Ogre::RenderWindow *rw){
    297         int w = rw->getWidth();
    298         int h = rw->getHeight();
    299         InputManager::setWindowExtents(w, h);
    300     }
    301 
    302     void GraphicsEngine::windowResized(Ogre::RenderWindow *rw){
    303         int w = rw->getWidth();
    304         int h = rw->getHeight();
    305         InputManager::setWindowExtents(w, h);
    306     }
    307 
    308     void GraphicsEngine::windowFocusChanged(Ogre::RenderWindow *rw){
    309         int w = rw->getWidth();
    310         int h = rw->getHeight();
    311         InputManager::setWindowExtents(w, h);
    312     }
     323        << "Ogre: " << message << std::endl;
     324  }
     325
     326  /**
     327  * Window has resized.
     328  * @param rw The render window it occured in
     329  */
     330  void GraphicsEngine::windowMoved(Ogre::RenderWindow *rw)
     331  {
     332    // note: this doesn't change the window extents
     333  }
     334
     335  /**
     336  * Window has resized.
     337  * @param rw The render window it occured in
     338  * @note GraphicsEngine has a render window stored itself. This is the same
     339  *       as rw. But we have to be careful when using multiple render windows!
     340  */
     341  void GraphicsEngine::windowResized(Ogre::RenderWindow *rw)
     342  {
     343    // change the mouse clipping size for absolute mouse movements
     344    int w = rw->getWidth();
     345    int h = rw->getHeight();
     346    InputManager::setWindowExtents(w, h);
     347  }
     348
     349  /**
     350  * Window has resized.
     351  * @param rw The render window it occured in
     352  */
     353  void GraphicsEngine::windowFocusChanged(Ogre::RenderWindow *rw)
     354  {
     355    // note: this doesn't change the window extents
     356  }
     357
     358  /**
     359  * Window has resized.
     360  * @param rw The render window it occured in
     361  */
     362  void GraphicsEngine::windowClosed(Ogre::RenderWindow *rw)
     363  {
     364    // using CommandExecutor in order to avoid depending on Orxonox class.
     365    CommandExecutor::execute("exit", false);
     366  }
    313367}
  • code/trunk/src/orxonox/GraphicsEngine.h

    r1214 r1293  
    5252    @brief Graphics engine manager class
    5353    */
    54     class _OrxonoxExport GraphicsEngine : public Ogre::WindowEventListener, public OrxonoxClass, public Ogre::LogListener
     54    class _OrxonoxExport GraphicsEngine : public Ogre::WindowEventListener, public Ogre::LogListener, public OrxonoxClass
    5555    {
    56         friend class ClassIdentifier<GraphicsEngine>;
    5756        public:
    58             void setConfigPath(std::string path) { this->configPath_ = path; };
    5957            void setConfigValues();
    60             void setup();
    61             bool load(std::string path);
    62             void loadRessourceLocations(std::string path);
    63             Ogre::SceneManager* getSceneManager();
    64             void initialise();
     58            bool setup(std::string& dataPath);
     59            void declareRessourceLocations();
     60            bool loadRenderer();
     61            bool initialiseResources();
     62            bool createNewScene();
     63
    6564            void destroy();
     65
     66            Ogre::SceneManager* getSceneManager() { return scene_; }
     67            std::string& getDataPath() { return dataPath_; }
    6668
    6769            // several window properties
     
    7173            int getWindowHeight() const;
    7274
     75            void windowMoved       (Ogre::RenderWindow* rw);
     76            void windowResized     (Ogre::RenderWindow* rw);
     77            void windowFocusChanged(Ogre::RenderWindow* rw);
     78            void windowClosed      (Ogre::RenderWindow* rw);
     79
    7380            static GraphicsEngine& getSingleton();
    7481            static GraphicsEngine* getSingletonPtr() { return &getSingleton(); }
    75 
    76             void windowMoved(Ogre::RenderWindow* rw);
    77             void windowResized(Ogre::RenderWindow* rw);
    78             void windowFocusChanged(Ogre::RenderWindow* rw);
    7982
    8083        private:
     
    9295            Ogre::RenderWindow* renderWindow_;//!< the current render window
    9396            //bool               bOverwritePath_; //!< overwrites path
    94             std::string         configPath_;  //!< path to config file
     97            //std::string         configPath_;  //!< path to config file
    9598            std::string         dataPath_;    //!< path to data file
    9699            std::string         ogreLogfile_; //!< log file name for Ogre log messages
  • code/trunk/src/orxonox/Main.cc

    r1214 r1293  
    7878    Orxonox* orx = Orxonox::getSingleton();
    7979
     80    bool res = false;
    8081#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE
    81     orx->init(argc, argv, macBundlePath());
     82    res = orx->init(argc, argv, macBundlePath());
    8283#else
    83     orx->init(argc, argv, "");
     84    res = orx->init(argc, argv, "");
    8485#endif
    8586
    86     orx->start();
     87    if (res)
     88      orx->start();
    8789    orx->destroySingleton();
    8890  /*}
  • code/trunk/src/orxonox/Orxonox.cc

    r1219 r1293  
    3737
    3838//****** STD *******
    39 //#include <iostream>
    40 //#include <exception>
    4139#include <deque>
    4240
    4341//****** OGRE ******
    44 //#include <OgreException.h>
    4542#include <OgreFrameListener.h>
    4643#include <OgreOverlay.h>
     
    6562#include "core/InputBuffer.h"
    6663#include "core/InputManager.h"
     64#include "core/TclBind.h"
    6765
    6866// audio
     
    158156
    159157  /**
    160    * create a new instance of Orxonox
    161    */
    162   Orxonox::Orxonox()
    163   {
    164     this->mode_ = STANDALONE;
    165     this->serverIp_ = "";
    166     this->ogre_ = &GraphicsEngine::getSingleton();
    167     this->timer_ = 0;
    168     this->dataPath_ = "";
    169     this->auMan_ = 0;
    170     this->orxonoxHUD_ = 0;
    171     this->inputHandler_ = 0;
     158   * Create a new instance of Orxonox. Avoid doing any actual work here.
     159   */
     160  Orxonox::Orxonox() :
     161    ogre_(0),
     162    //auMan_(0),
     163    timer_(0),
    172164    // turn on frame smoothing by setting a value different from 0
    173     this->frameSmoothingTime_ = 0.0f;
    174     this->bAbort_ = false;
    175     this->timefactor_ = 1.0f;
    176   }
    177 
    178   /**
    179    * destruct Orxonox
     165    frameSmoothingTime_(0.0f),
     166    orxonoxConsole_(0),
     167    orxonoxHUD_(0),
     168    bAbort_(false),
     169    timefactor_(1.0f),
     170    mode_(STANDALONE),
     171    serverIp_("")
     172  {
     173  }
     174
     175  /**
     176   * Destruct Orxonox.
    180177   */
    181178  Orxonox::~Orxonox()
     
    186183    Loader::close();
    187184    InputManager::destroy();
    188     if (this->auMan_)
    189       delete this->auMan_;
     185    //if (this->auMan_)
     186    //  delete this->auMan_;
    190187    if (this->timer_)
    191188      delete this->timer_;
    192189    GraphicsEngine::getSingleton().destroy();
    193190
    194     if (client_g)
    195       delete client_g;
     191    if (network::Client::getSingleton())
     192      network::Client::destroySingleton();
    196193    if (server_g)
    197194      delete server_g;
    198195  }
    199196
    200   /**
    201     @brief Immediately deletes the orxonox object.
    202     Never use if you can help it while rendering!
    203   */
    204   void Orxonox::abortImmediateForce()
    205   {
    206     COUT(1) << "*** Orxonox Error: Orxonox object was unexpectedly destroyed." << std::endl;
    207     delete this;
    208   }
    209197
    210198  /**
     
    213201  void Orxonox::abortRequest()
    214202  {
    215     COUT(3) << "*** Orxonox: Abort requested." << std::endl;
     203    COUT(3) << "Orxonox: Abort requested." << std::endl;
    216204    bAbort_ = true;
    217205  }
    218206
    219207  /**
    220    * @return singleton object
     208   * @return singleton reference
    221209   */
    222210  Orxonox* Orxonox::getSingleton()
     
    243231   * @param path path to config (in home dir or something)
    244232   */
    245   void Orxonox::init(int argc, char **argv, std::string path)
     233  bool Orxonox::init(int argc, char **argv, std::string path)
    246234  {
    247235    //TODO: find config file (assuming executable directory)
     
    249237    //TODO: give config file to Ogre
    250238    std::string mode;
     239    std::string dataPath;
    251240
    252241    ArgReader ar(argc, argv);
    253242    ar.checkArgument("mode", mode, false);
    254     ar.checkArgument("data", this->dataPath_, false);
     243    ar.checkArgument("data", dataPath, false);
    255244    ar.checkArgument("ip", serverIp_, false);
    256     if(ar.errorHandling()) abortImmediateForce();
    257     if(mode == std::string("client"))
     245    if(ar.errorHandling())
     246      return false;
     247
     248    if (mode == "client")
     249      mode_ = CLIENT;
     250    else if (mode == "server")
     251      mode_ = SERVER;
     252    else
    258253    {
    259       mode_ = CLIENT;
    260       clientInit(path);
     254      mode = "standalone";
     255      mode_ = STANDALONE;
    261256    }
    262     else if(mode== std::string("server")){
    263       mode_ = SERVER;
    264       serverInit(path);
    265     }
    266     else{
    267       mode_ = STANDALONE;
    268       standaloneInit(path);
    269     }
    270   }
    271 
    272   void Orxonox::serverInit(std::string path)
    273   {
    274     COUT(2) << "initialising server" << std::endl;
    275 
    276     ogre_->setConfigPath(path);
    277     ogre_->setup();
    278     //root_ = ogre_->getRoot();
    279     if(!ogre_->load(this->dataPath_)) abortImmediateForce(/* unable to load */);
    280 
    281     server_g = new network::Server();
    282   }
    283 
    284   void Orxonox::clientInit(std::string path)
    285   {
    286     COUT(2) << "initialising client" << std::endl;\
    287 
    288     ogre_->setConfigPath(path);
    289     ogre_->setup();
    290     if(serverIp_.compare("")==0)
    291       client_g = new network::Client();
    292     else
    293       client_g = new network::Client(serverIp_, NETWORK_PORT);
    294     if(!ogre_->load(this->dataPath_)) abortImmediateForce(/* unable to load */);
    295   }
    296 
    297   void Orxonox::standaloneInit(std::string path)
    298   {
    299     COUT(2) << "initialising standalone mode" << std::endl;
    300 
    301     ogre_->setConfigPath(path);
    302     ogre_->setup();
    303     if(!ogre_->load(this->dataPath_)) abortImmediateForce(/* unable to load */);
     257    COUT(3) << "Orxonox: Mode is " << mode << "." << std::endl;
     258
     259    //if (mode_ == DEDICATED)
     260      // TODO: decide what to do here
     261    //else
     262
     263    // for playable server, client and standalone, the startup
     264    // procedure until the GUI is identical
     265
     266    TclBind::getInstance().setDataPath(dataPath);
     267    ConfigFileManager::getSingleton()->setFile(CFT_Settings, "orxonox.ini");
     268    Factory::createClassHierarchy();
     269
     270    ogre_ = &GraphicsEngine::getSingleton();
     271    if (!ogre_->setup(path))       // creates ogre root and other essentials
     272      return false;
     273
     274    return true;
    304275  }
    305276
     
    307278   * start modules
    308279   */
    309   void Orxonox::start()
    310   {
    311     switch(mode_){
     280  bool Orxonox::start()
     281  {
     282    //if (mode == DEDICATED)
     283    // do something else
     284    //else
     285
     286    if (!ogre_->loadRenderer())    // creates the render window
     287      return false;
     288
     289    // Calls the InputManager which sets up the input devices.
     290    // The render window width and height are used to set up the mouse movement.
     291    if (!InputManager::initialise(ogre_->getWindowHandle(),
     292          ogre_->getWindowWidth(), ogre_->getWindowHeight(), true, true, true))
     293      return false;
     294
     295    // TODO: Spread this so that this call only initialises things needed for the GUI
     296    if (!ogre_->initialiseResources())
     297      return false;
     298
     299    // TOOD: load the GUI here
     300    // set InputManager to GUI mode
     301    InputManager::setInputState(InputManager::IS_GUI);
     302    // TODO: run GUI here
     303
     304    // The following lines depend very much on the GUI output, so they're probably misplaced here..
     305
     306    InputManager::setInputState(InputManager::IS_NONE);
     307
     308    if (!loadPlayground())
     309      return false;
     310
     311    switch (mode_)
     312    {
     313    case SERVER:
     314      if (!serverLoad())
     315        return false;
     316      break;
    312317    case CLIENT:
    313       clientStart();
    314       break;
    315     case SERVER:
    316       serverStart();
     318      if (!clientLoad())
     319        return false;
    317320      break;
    318321    default:
    319       standaloneStart();
     322      if (!standaloneLoad())
     323        return false;
    320324    }
    321   }
    322 
    323   void Orxonox::clientStart(){
    324     ogre_->initialise();
    325     ConfigFileManager::getSingleton()->setFile(CFT_Settings, "orxonox.ini");
    326     Factory::createClassHierarchy();
    327 
    328 
    329     auMan_ = new audio::AudioManager();
    330 
     325
     326    InputManager::setInputState(InputManager::IS_NORMAL);
     327
     328    return startRenderLoop();
     329  }
     330
     331  /**
     332   * Loads everything in the scene except for the actual objects.
     333   * This includes HUD, Console..
     334   */
     335  bool Orxonox::loadPlayground()
     336  {
     337    ogre_->createNewScene();
     338
     339          // Init audio
     340    //auMan_ = new audio::AudioManager();
     341    //auMan_->ambientAdd("a1");
     342    //auMan_->ambientAdd("a2");
     343    //auMan_->ambientAdd("a3");
     344    //auMan->ambientAdd("ambient1");
     345    //auMan_->ambientStart();
     346
     347    // Load the HUD
     348    COUT(3) << "Orxonox: Loading HUD..." << std::endl;
    331349    Ogre::Overlay* hudOverlay = Ogre::OverlayManager::getSingleton().getByName("Orxonox/HUD1.2");
    332350    orxonoxHUD_ = new HUD();
     
    335353    hudOverlay->show();
    336354
    337     client_g->establishConnection();
    338     client_g->tick(0);
    339 
    340 
    341     //setupInputSystem();
    342 
    343     startRenderLoop();
    344   }
    345 
    346   void Orxonox::serverStart(){
    347     //TODO: start modules
    348     ogre_->initialise();
    349     //TODO: run engine
    350     ConfigFileManager::getSingleton()->setFile(CFT_Settings, "orxonox.ini");
    351     Factory::createClassHierarchy();
    352     createScene();
    353     setupInputSystem();
    354 
    355     server_g->open();
    356 
    357     startRenderLoop();
    358   }
    359 
    360   void Orxonox::standaloneStart(){
    361     //TODO: start modules
    362     ogre_->initialise();
    363     //TODO: run engine
    364     ConfigFileManager::getSingleton()->setFile(CFT_Settings, "orxonox.ini");
    365     Factory::createClassHierarchy();
    366     createScene();
    367     setupInputSystem();
    368 
    369     startRenderLoop();
    370   }
    371 
    372   void Orxonox::createScene(void)
    373   {
    374           // Init audio
    375     auMan_ = new audio::AudioManager();
    376 
    377     // load this file from config
    378     Level* startlevel = new Level("levels/sample.oxw");
    379     Loader::open(startlevel);
    380 
    381     Ogre::Overlay* hudOverlay = Ogre::OverlayManager::getSingleton().getByName("Orxonox/HUD1.2");
    382     orxonoxHUD_ = new HUD();
    383     orxonoxHUD_->setEnergyValue(20);
    384     orxonoxHUD_->setEnergyDistr(20,20,60);
    385     hudOverlay->show();
    386 
    387         /*
    388     auMan_->ambientAdd("a1");
    389     auMan_->ambientAdd("a2");
    390     auMan_->ambientAdd("a3");
    391     //auMan->ambientAdd("ambient1");
    392     auMan_->ambientStart();
    393   */
    394   }
    395 
    396   /**
    397     @brief Calls the InputHandler which sets up the input devices.
    398     The render window width and height are used to set up the mouse movement.
    399   */
    400   void Orxonox::setupInputSystem()
    401   {
    402     if (!InputManager::initialise(ogre_->getWindowHandle(),
    403           ogre_->getWindowWidth(), ogre_->getWindowHeight()))
    404       abortImmediateForce();
    405     InputManager::setInputState(InputManager::IS_NORMAL);
    406   }
    407 
    408   /**
    409     Main loop of the orxonox game.
    410     This is a new solution, using the ogre engine instead of being used by it.
    411     An alternative solution would be to simply use the timer of the Root object,
    412     but that implies using Ogre in any case. There would be no way to test
    413     our code without the help of the root object.
    414     There's even a chance that we can dispose of the root object entirely
    415     in server mode.
    416     About the loop: The design is almost exactly like the one in ogre, so that
    417     if any part of ogre registers a framelisteners, it will still behave
    418     correctly. Furthermore the time smoothing feature from ogre has been
    419     implemented too. If turned on (see orxonox constructor), it will calculate
    420     the dt_n by means of the recent most dt_n-1, dt_n-2, etc.
    421   */
    422   void Orxonox::startRenderLoop()
    423   {
     355    COUT(3) << "Orxonox: Loading Console..." << std::endl;
    424356    InputBuffer* ib = dynamic_cast<InputBuffer*>(InputManager::getKeyHandler("buffer"));
    425357    /*
     
    432364    ib->registerListener(console, &Testconsole::exit, (char)0x1B, true);
    433365    */
    434 
    435366    orxonoxConsole_ = new InGameConsole(ib);
    436367    ib->registerListener(orxonoxConsole_, &InGameConsole::listen, true);
     
    441372    ib->registerListener(orxonoxConsole_, &InGameConsole::exit, (char)0x1B, true);
    442373
     374    return true;
     375  }
     376
     377  /**
     378   * Level loading method for server mode.
     379   */
     380  bool Orxonox::serverLoad()
     381  {
     382    COUT(2) << "Loading level in server mode" << std::endl;
     383
     384    server_g = new network::Server();
     385
     386    if (!loadScene())
     387      return false;
     388
     389    server_g->open();
     390
     391    return true;
     392  }
     393
     394  /**
     395   * Level loading method for client mode.
     396   */
     397  bool Orxonox::clientLoad()
     398  {
     399    COUT(2) << "Loading level in client mode" << std::endl;\
     400
     401    if (serverIp_.compare("") == 0)
     402      client_g = network::Client::createSingleton();
     403    else
     404      client_g = network::Client::createSingleton(serverIp_, NETWORK_PORT);
     405
     406    client_g->establishConnection();
     407    client_g->tick(0);
     408
     409    return true;
     410  }
     411
     412  /**
     413   * Level loading method for standalone mode.
     414   */
     415  bool Orxonox::standaloneLoad()
     416  {
     417    COUT(2) << "Loading level in standalone mode" << std::endl;
     418
     419    if (!loadScene())
     420      return false;
     421
     422    return true;
     423  }
     424
     425  /**
     426   * Helper method to load a level.
     427   */
     428  bool Orxonox::loadScene()
     429  {
     430    Level* startlevel = new Level("levels/sample.oxw");
     431    Loader::open(startlevel);
     432
     433    return true;
     434  }
     435
     436
     437  /**
     438    Main loop of the orxonox game.
     439    About the loop: The design is almost exactly like the one in ogre, so that
     440    if any part of ogre registers a framelisteners, it will still behave
     441    correctly. Furthermore the time smoothing feature from ogre has been
     442    implemented too. If turned on (see orxonox constructor), it will calculate
     443    the dt_n by means of the recent most dt_n-1, dt_n-2, etc.
     444  */
     445  bool Orxonox::startRenderLoop()
     446  {
    443447    // first check whether ogre root object has been created
    444448    if (Ogre::Root::getSingletonPtr() == 0)
    445449    {
    446       COUT(2) << "*** Orxonox Error: Could not start rendering. No Ogre root object found" << std::endl;
    447       return;
     450      COUT(2) << "Orxonox Error: Could not start rendering. No Ogre root object found" << std::endl;
     451      return false;
    448452    }
    449453    Ogre::Root& ogreRoot = Ogre::Root::getSingleton();
     
    465469    timer_->reset();
    466470
     471    COUT(3) << "Orxonox: Starting the main loop." << std::endl;
    467472          while (!bAbort_)
    468473          {
     
    490495      for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it)
    491496        it->tick((float)evt.timeSinceLastFrame * this->timefactor_);
    492       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);
    493501
    494502      // don't forget to call _fireFrameStarted in ogre to make sure
     
    510518      ogreRoot._fireFrameEnded(evt);
    511519          }
     520
     521    if(mode_==CLIENT)
     522      network::Client::getSingleton()->closeConnection();
     523    else if(mode_==SERVER)
     524      server_g->close();
     525    return true;
    512526  }
    513527
     
    550564  }
    551565
     566  /**
     567   * Static function that shows the console in game mode.
     568   */
    552569  void Orxonox::activateConsole()
    553570  {
     571    // currently, the console shows itself when feeded with input.
    554572    InputManager::setInputState(InputManager::IS_CONSOLE);
    555573  }
  • code/trunk/src/orxonox/Orxonox.h

    r1219 r1293  
    5757  {
    5858    public:
    59       void init(int argc, char **argv, std::string path);
    60       void start();
    61       void abortImmediateForce();
     59      bool init(int argc, char **argv, std::string path);
     60      bool start();
     61
    6262      void abortRequest();
    63       inline audio::AudioManager* getAudioManagerPointer() { return auMan_; };
     63      //inline audio::AudioManager* getAudioManagerPointer() { return auMan_; };
    6464
    6565      static Orxonox* getSingleton();
     
    7979      ~Orxonox();
    8080
    81       // init functions
    82       void serverInit(std::string path);
    83       void clientInit(std::string path);
    84       void standaloneInit(std::string path);
     81      bool loadPlayground();
    8582
    86       // run functions
    87       void serverStart();
    88       void clientStart();
    89       void standaloneStart();
     83      bool serverLoad();
     84      bool clientLoad();
     85      bool standaloneLoad();
    9086
    91       void createScene();
    92       void setupInputSystem();
    93       void startRenderLoop();
     87      bool loadScene();
     88
     89      bool startRenderLoop();
     90
    9491      float calculateEventTime(unsigned long, std::deque<unsigned long>&);
    9592
    9693    private:
    9794      GraphicsEngine*       ogre_;          //!< our dearest graphics engine <3
    98       std::string           dataPath_;      //!< path to data
    99       audio::AudioManager*  auMan_;         //!< audio manager
    100       InputManager*         inputHandler_;  //!< Handles input with key bindings
     95      //audio::AudioManager*  auMan_;         //!< audio manager
    10196      Ogre::Timer*          timer_;         //!< Main loop timer
    10297      // TODO: make this a config-value by creating a config class for orxonox
  • code/trunk/src/orxonox/OrxonoxPlatform.h

    r1064 r1293  
    2121 *
    2222 *   Author:
    23  *      An unknown man from the Ogre development crew
     23 *      ...
    2424 *   Co-authors:
    2525 *      Reto Grieder
  • code/trunk/src/orxonox/console/InGameConsole.cc

    r1223 r1293  
    5454    const float BLINK = 0.25;
    5555
    56     InGameConsole::InGameConsole(InputBuffer* ib){
     56    InGameConsole::InGameConsole(InputBuffer* ib) :
     57        windowW(0), windowH(0),
     58        scroll(0), scrollTimer(0.0f),
     59        cursor(0.0f),
     60        active(false),
     61        ib_(ib),
     62        om(0),
     63        consoleOverlay(0),
     64        consoleOverlayContainer(0),
     65        consoleOverlayNoise(0),
     66        consoleOverlayBorder(0),
     67        consoleOverlayTextAreas(0)
     68    {
    5769        //RegisterObject(InGameConsole);
    58         ib_ = ib;
    59         active = false;
    60         cursor = 0.0;
    6170        init();
    6271    }
  • code/trunk/src/orxonox/objects/Ambient.cc

    r1209 r1293  
    5757        RegisterObject(Ambient);
    5858        Ambient::instance_s = this;
     59        registerAllVariables();
    5960    }
    6061
     
    6364    }
    6465
     66    bool Ambient::create(){
     67      GraphicsEngine::getSingleton().getSceneManager()->setAmbientLight(ambientLight_);
     68      return true;
     69    }
     70   
     71    void Ambient::registerAllVariables(){
     72      registerVar(&ambientLight_, sizeof(ColourValue), network::DATA);
     73     
     74    }
     75   
    6576    void Ambient::loadParams(TiXmlElement* xmlElem)
    6677    {
     
    8394   {
    8495        GraphicsEngine::getSingleton().getSceneManager()->setAmbientLight(colour);
     96      ambientLight_=colour;     
    8597   }
    8698
     
    96108
    97109        XMLPortParamLoadOnly(Ambient, "colourvalue", setAmbientLight, xmlelement, mode);
     110        create();
    98111    }
    99112}
  • code/trunk/src/orxonox/objects/Ambient.h

    r1056 r1293  
    3434#include "util/Math.h"
    3535#include "core/BaseObject.h"
     36#include "network/Synchronisable.h"
    3637
    3738namespace orxonox
    3839{
    39     class _OrxonoxExport Ambient : public BaseObject
     40    class _OrxonoxExport Ambient : public BaseObject, network::Synchronisable
    4041    {
    4142        public:
     
    4647            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    4748            void setAmbientLight(const ColourValue& colour);
     49            bool create();
     50            void registerAllVariables();
    4851
    4952            static void setAmbientLightTest(const ColourValue& colour)
     
    5255        private:
    5356            static Ambient* instance_s;
     57            ColourValue ambientLight_;
    5458
    5559    };
  • code/trunk/src/orxonox/objects/Camera.cc

    r1209 r1293  
    2323 *      Fabian 'x3n' Landau
    2424 *   Co-authors:
    25  *      ...
     25 *      Benjamin Knecht
    2626 *
    2727 */
     
    2929#include "OrxonoxStableHeaders.h"
    3030#include "Camera.h"
     31#include "CameraHandler.h"
    3132
    3233#include <string>
     
    4748namespace orxonox
    4849{
    49     CreateFactory(Camera);
    5050
    51     Camera::Camera()
     51  Camera::Camera(Ogre::SceneNode* node)
     52  {
     53    this->bHasFocus_ = false;
     54    this->cameraNode_ = GraphicsEngine::getSingleton().getSceneManager()->getRootSceneNode()->createChildSceneNode(node->getName() + "Camera");
     55    if( node != NULL )
     56      this->setPositionNode(node);
     57  }
     58
     59  Camera::~Camera()
     60  {
     61    CameraHandler::getInstance()->releaseFocus(this);
     62  }
     63
     64  void Camera::setPositionNode(Ogre::SceneNode* node)
     65  {
     66    this->positionNode_ = node;
     67    // set camera to node values according to camera mode
     68  }
     69
     70  void Camera::setTargetNode(Ogre::SceneNode* obj)
     71  {
     72    this->targetNode_ = obj;
     73  }
     74
     75  void Camera::tick(float dt)
     76  {
     77    if(this->positionNode_ != NULL) {
     78      // this stuff here may need some adjustments
     79      Vector3 offset = this->positionNode_->getWorldPosition() - this->cameraNode_->getPosition();
     80      this->cameraNode_->translate(15*dt*offset);
     81
     82      this->cameraNode_->setOrientation(Quaternion::Slerp(0.7, this->positionNode_->getWorldOrientation(), this->cameraNode_->getWorldOrientation(), false));
     83    }
     84  }
     85
     86  /**
     87    don't move anything before here! here the Ogre camera is set to values of this camera
     88    always call update after changes
     89  */
     90  void Camera::update()
     91  {
     92    if(this->positionNode_ != NULL)
    5293    {
    53         RegisterObject(Camera);
     94      this->cameraNode_->setPosition(this->positionNode_->getWorldPosition());
     95      this->cameraNode_->setOrientation(this->positionNode_->getWorldOrientation());
    5496    }
     97  }
    5598
    56     Camera::~Camera()
    57     {
    58     }
     99  /**
     100    what to do when camera loses focus (do not request focus in this function!!)
     101    this is called by the CameraHandler singleton class to notify the camera
     102  */
     103  void Camera::removeFocus()
     104  {
     105    this->bHasFocus_ = false;
     106    this->cameraNode_->detachObject(this->cam_);
     107  }
    59108
    60     void Camera::loadParams(TiXmlElement* xmlElem)
    61     {
    62       Ogre::SceneManager* mgr = GraphicsEngine::getSingleton().getSceneManager();
    63 
    64       if (xmlElem->Attribute("name") && xmlElem->Attribute("pos") && xmlElem->Attribute("lookat") && xmlElem->Attribute("node"))
    65       {
    66         //    <Camera name="Camera" pos="0,0,-250" lookat="0,0,0" />
    67 
    68         std::string name = xmlElem->Attribute("name");
    69         std::string pos = xmlElem->Attribute("pos");
    70         std::string lookat = xmlElem->Attribute("lookat");
    71 
    72         Ogre::Camera *cam = mgr->createCamera(name);
    73 
    74         float x, y, z;
    75         SubString posVec(xmlElem->Attribute("pos"), ',');
    76         convertValue<std::string, float>(&x, posVec[0]);
    77         convertValue<std::string, float>(&y, posVec[1]);
    78         convertValue<std::string, float>(&z, posVec[2]);
    79 
    80         cam->setPosition(Vector3(x,y,z));
    81 
    82         posVec = SubString(xmlElem->Attribute("lookat"), ',');
    83         convertValue<std::string, float>(&x, posVec[0]);
    84         convertValue<std::string, float>(&y, posVec[1]);
    85         convertValue<std::string, float>(&z, posVec[2]);
    86 
    87         cam->lookAt(Vector3(x,y,z));
    88 
    89         std::string node = xmlElem->Attribute("node");
    90 
    91         Ogre::SceneNode* sceneNode = (Ogre::SceneNode*)mgr->getRootSceneNode()->createChildSceneNode(node); //getChild(node);
    92         sceneNode->attachObject((Ogre::MovableObject*)cam);
    93 
    94         // FIXME: unused var
    95         //Ogre::Viewport* vp =
    96         GraphicsEngine::getSingleton().getRenderWindow()->addViewport(cam);
    97 
    98 
    99         COUT(4) << "Loader: Created camera "<< name  << std::endl << std::endl;
    100       }
    101    }
     109  void Camera::setFocus(Ogre::Camera* ogreCam)
     110  {
     111    this->bHasFocus_ = true;
     112    this->cam_ = ogreCam;
     113    this->cam_->setOrientation(this->cameraNode_->getWorldOrientation());
     114    this->cameraNode_->attachObject(this->cam_);
     115  }
    102116}
  • code/trunk/src/orxonox/objects/Camera.h

    r1056 r1293  
    2323 *      Fabian 'x3n' Landau
    2424 *   Co-authors:
    25  *      ...
     25 *      Benjamin Knecht
    2626 *
    2727 */
     
    3030#define _Camera_H__
    3131
     32#include <OgrePrerequisites.h>
     33#include <OgreSceneNode.h>
     34#include <OgreCamera.h>
     35
    3236#include "OrxonoxPrereqs.h"
    33 
    34 #include "core/BaseObject.h"
    3537
    3638namespace orxonox
    3739{
    38     class _OrxonoxExport Camera : public BaseObject
     40    class _OrxonoxExport Camera
    3941    {
    40         public:
    41             Camera();
    42             virtual ~Camera();
     42      friend class CameraHandler;
     43      public:
     44        Camera(Ogre::SceneNode* node = NULL);
     45        virtual ~Camera();
    4346
     47        void setPositionNode(Ogre::SceneNode* node);
     48        inline Ogre::SceneNode* getCameraNode() { return this->positionNode_; }
     49        // maybe also BaseObject
     50        void setTargetNode(Ogre::SceneNode* obj);
    4451
    45             void loadParams(TiXmlElement* xmlElem);
     52        void tick(float dt);
     53        void update();
     54        inline bool hasFocus() { return this->bHasFocus_; }
    4655
    47         private:
     56      private:
     57        void removeFocus();
     58        void setFocus(Ogre::Camera* ogreCam);
    4859
    49 
     60      private:
     61        Ogre::SceneNode* targetNode_;
     62        Ogre::SceneNode* positionNode_;
     63        Ogre::SceneNode* cameraNode_;
     64        Ogre::Vector3 oldPos;
     65        Ogre::Camera* cam_;
     66        bool bHasFocus_;
    5067    };
    5168}
  • code/trunk/src/orxonox/objects/Explosion.cc

    r1056 r1293  
    4545    CreateFactory(Explosion);
    4646
    47     Explosion::Explosion(WorldEntity* owner)
     47    Explosion::Explosion(WorldEntity* owner) :
     48      lifetime_(0.4),
     49      particle_(0)
    4850    {
    4951        RegisterObject(Explosion);
    50 
    51         this->particle_ = 0;
    52         this->lifetime_ = 0.4;
    5352
    5453        if (owner)
  • code/trunk/src/orxonox/objects/Model.cc

    r1209 r1293  
    4949    }
    5050
    51     void Model::loadParams(TiXmlElement* xmlElem)
    52     {
    53         WorldEntity::loadParams(xmlElem);
    54 
    55         if (xmlElem->Attribute("mesh"))
    56         {
    57             meshSrc_ = xmlElem->Attribute("mesh");
    58         }
    59         create();
    60     }
    61 
    6251    /**
    6352        @brief XML loading and saving.
     
    7362        XMLPortParamLoadOnly(Model, "mesh", setMesh, xmlelement, mode);
    7463
    75         create();
     64        Model::create();
    7665    }
    7766
     
    8271
    8372    bool Model::create(){
    84       WorldEntity::create();
     73      if(!WorldEntity::create())
     74        return false;
    8575      if ((this->meshSrc_ != "") && (this->meshSrc_.size() > 0))
    8676      {
    8777        this->mesh_.setMesh(meshSrc_);
    8878        this->attachObject(this->mesh_.getEntity());
    89         COUT(4) << "Loader: Created model" << std::endl;
     79        COUT(4) << "Loader (Model.cc): Created model" << std::endl;
    9080      }
    9181      return true;
     
    9383
    9484    void Model::registerAllVariables(){
    95       WorldEntity::registerAllVariables();
     85//       WorldEntity::registerAllVariables();
     86      COUT(5) << "Model.cc:registering new meshsrc with size: " << meshSrc_.length()+1 << " this: " << this << std::endl;
    9687      registerVar(&meshSrc_, meshSrc_.length() + 1, network::STRING);
    9788    }
  • code/trunk/src/orxonox/objects/Model.h

    r1056 r1293  
    4343            Model();
    4444            virtual ~Model();
    45             virtual void loadParams(TiXmlElement* xmlElem);
    4645            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    4746            void setMesh(const std::string& meshname);
  • code/trunk/src/orxonox/objects/NPC.cc

    r1056 r1293  
    3636  CreateFactory(NPC);
    3737
    38   NPC::NPC()
     38  NPC::NPC() :
     39    movable_(true)
    3940  {
    4041    RegisterObject(NPC);
    41     movable_ = true;
     42    registerAllVariables();
    4243  }
    4344
     
    5960    this->translate(location);
    6061    movable_ = movable;
     62  }
     63 
     64  void NPC::registerAllVariables(){
     65    Model::registerAllVariables();
     66    registerVar(&movable_, sizeof(movable_), network::DATA);
     67  }
     68 
     69  bool NPC::create(){
     70    Model::create();
     71    return true;
    6172  }
    6273
  • code/trunk/src/orxonox/objects/NPC.h

    r1056 r1293  
    5252      void update();
    5353      void setValues(Vector3 location, Vector3 speed, Vector3 acceleration, bool movable);
     54      void registerAllVariables();
     55      bool create();
    5456
    5557    private:
  • code/trunk/src/orxonox/objects/Projectile.cc

    r1056 r1293  
    4242    CreateFactory(Projectile);
    4343
    44     Projectile::Projectile(SpaceShip* owner)
     44    Projectile::Projectile(SpaceShip* owner) :
     45      owner_(owner)
    4546    {
    4647        RegisterObject(Projectile);
    4748
    4849        this->setConfigValues();
    49 
    50         this->owner_ = owner;
    5150
    5251        this->billboard_.setBillboardSet("Examples/Flare", ColourValue(1.0, 1.0, 0.5), 1);
  • code/trunk/src/orxonox/objects/Skybox.cc

    r1209 r1293  
    4747    {
    4848        RegisterObject(Skybox);
     49        registerAllVariables();
    4950    }
    5051
     
    5758        if (xmlElem->Attribute("src"))
    5859        {
    59                 std::string skyboxSrc = xmlElem->Attribute("src");
    60                 this->setSkybox(skyboxSrc);
     60                skyboxSrc_ = xmlElem->Attribute("src");
     61        this->create();
    6162
    62                 COUT(4) << "Loader: Set skybox: "<< skyboxSrc << std::endl << std::endl;
     63                COUT(4) << "Loader: Set skybox: "<< skyboxSrc_ << std::endl << std::endl;
    6364        }
    6465   }
     
    6970   }
    7071
     72   void Skybox::setSkyboxSrc(const std::string& src){
     73     skyboxSrc_ = src;
     74   }
     75   
    7176    /**
    7277        @brief XML loading and saving.
     
    7984        BaseObject::XMLPort(xmlelement, mode);
    8085
    81         XMLPortParamLoadOnly(Skybox, "src", setSkybox, xmlelement, mode);
     86        XMLPortParamLoadOnly(Skybox, "src", setSkyboxSrc, xmlelement, mode);
     87        create();
    8288    }
     89   
     90    bool Skybox::create(){
     91      this->setSkybox(skyboxSrc_);
     92      return true;
     93    }
     94   
     95    void Skybox::registerAllVariables(){
     96      registerVar(&skyboxSrc_, skyboxSrc_.length()+1 ,network::STRING);
     97    }
     98   
    8399}
  • code/trunk/src/orxonox/objects/Skybox.h

    r1056 r1293  
    3333
    3434#include "core/BaseObject.h"
     35#include "network/Synchronisable.h"
    3536
    3637namespace orxonox
    3738{
    38     class _OrxonoxExport Skybox : public BaseObject
     39    class _OrxonoxExport Skybox : public BaseObject, public network::Synchronisable
    3940    {
    4041        public:
     
    4546            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    4647            void setSkybox(const std::string& skyboxname);
     48           
     49            bool create();
     50            void registerAllVariables();
     51            void setSkyboxSrc(const std::string &src);
    4752
    4853        private:
     54            std::string skyboxSrc_;
    4955
    5056
  • code/trunk/src/orxonox/objects/SpaceShip.cc

    r1219 r1293  
    2323 *      Fabian 'x3n' Landau
    2424 *   Co-authors:
    25  *      ...
     25 *      Benjamin Knecht
    2626 *
    2727 */
     
    3737#include <OgreSceneNode.h>
    3838
     39#include "CameraHandler.h"
    3940#include "tinyxml/tinyxml.h"
    4041#include "ois/OIS.h"
     
    5051#include "core/XMLPort.h"
    5152#include "core/ConsoleCommand.h"
     53#include "network/Client.h"
    5254
    5355namespace orxonox
     
    6264    SpaceShip* SpaceShip::instance_s;
    6365
    64     SpaceShip::SpaceShip()
     66    SpaceShip::SpaceShip() :
     67      //testvector_(0,0,0),
     68      //bInvertYAxis_(false),
     69      setMouseEventCallback_(false),
     70      bLMousePressed_(false),
     71      bRMousePressed_(false),
     72      camNode_(0),
     73      cam_(0),
     74      camName_("CamNode"),
     75      tt_(0),
     76      redNode_(0),
     77      greenNode_(0),
     78      blinkTime_(0.0f),
     79      chNearNode_(0),
     80      chFarNode_(0),
     81      timeToReload_(0.0f),
     82      //reloadTime_(0.0f),
     83      maxSideAndBackSpeed_(0.0f),
     84      maxSpeed_(0.0f),
     85      maxRotation_(0.0f),
     86      translationAcceleration_(0.0f),
     87      rotationAcceleration_(0.0f),
     88      translationDamping_(0.0f),
     89      rotationDamping_(0.0f),
     90      maxRotationRadian_(0),
     91      rotationAccelerationRadian_(0),
     92      rotationDampingRadian_(0),
     93      zeroRadian_(0),
     94      mouseXRotation_(0),
     95      mouseYRotation_(0),
     96      mouseX_(0.0f),
     97      mouseY_(0.0f),
     98      emitterRate_(0.0f),
     99      server_(false)
    65100    {
    66101        RegisterObject(SpaceShip);
     
    71106        this->setConfigValues();
    72107
    73         this->setMouseEventCallback_ = false;
    74         this->bLMousePressed_ = false;
    75         this->bRMousePressed_ = false;
    76         this->mouseX_ = 0;
    77         this->mouseY_ = 0;
    78 
    79         this->camNode_ = 0;
    80 
    81         this->tt_ = 0;
    82         this->redNode_ = 0;
    83         this->greenNode_ = 0;
    84         this->blinkTime_ = 0;
    85 
    86         this->timeToReload_ = 0;
    87 
    88         this->maxSpeed_ = 0;
    89         this->maxSideAndBackSpeed_ = 0;
    90         this->maxRotation_ = 0;
    91         this->translationAcceleration_ = 0;
    92         this->rotationAcceleration_ = 0;
    93         this->translationDamping_ = 0;
    94         this->rotationDamping_ = 0;
    95 
    96         this->maxRotationRadian_ = 0;
    97         this->rotationAccelerationRadian_ = 0;
    98         this->rotationDampingRadian_ = 0;
    99         this->zeroRadian_ = Radian(0);
    100108
    101109        this->setRotationAxis(1, 0, 0);
    102110        this->setStatic(false);
    103 /*
    104         this->moveForward_ = 0;
    105         this->rotateUp_ = 0;
    106         this->rotateDown_ = 0;
    107         this->rotateRight_ = 0;
    108         this->rotateLeft_ = 0;
    109         this->loopRight_ = 0;
    110         this->loopLeft_ = 0;
    111         this->brakeForward_ = 0;
    112         this->brakeRotate_ = 0;
    113         this->brakeLoop_ = 0;
    114         this->speedForward_ = 0;
    115         this->speedRotateUpDown_ = 0;
    116         this->speedRotateRightLeft_ = 0;
    117         this->speedLoopRightLeft_ = 0;
    118         this->maxSpeedForward_ = 0;
    119         this->maxSpeedRotateUpDown_ = 0;
    120         this->maxSpeedRotateRightLeft_ = 0;
    121         this->maxSpeedLoopRightLeft_ = 0;
    122         this->accelerationForward_ = 0;
    123         this->accelerationRotateUpDown_ = 0;
    124         this->accelerationRotateRightLeft_ = 0;
    125         this->accelerationLoopRightLeft_ = 0;
    126 
    127         this->speed = 250;
    128         this->loop = 100;
    129         this->rotate = 10;
    130         this->mouseX = 0;
    131         this->mouseY = 0;
    132         this->maxMouseX = 0;
    133         this->minMouseX = 0;
    134         this->moved = false;
    135 
    136         this->brakeRotate(rotate*10);
    137         this->brakeLoop(loop);
    138 */
    139 //         this->create();
    140 
    141111
    142112        COUT(3) << "Info: SpaceShip was loaded" << std::endl;
     
    147117        if (this->tt_)
    148118            delete this->tt_;
     119        if(setMouseEventCallback_)
     120          InputManager::removeMouseHandler("SpaceShip");
     121        if (this->cam_)
     122          delete this->cam_;
    149123    }
    150124
     
    158132
    159133    void SpaceShip::registerAllVariables(){
    160       Model::registerAllVariables();
    161 
    162 
     134      registerVar( &camName_, camName_.length()+1, network::STRING, 0x1);
     135      registerVar( &maxSpeed_, sizeof(maxSpeed_), network::DATA, 0x1);
     136      registerVar( &maxSideAndBackSpeed_, sizeof(maxSideAndBackSpeed_), network::DATA, 0x1);
     137      registerVar( &maxRotation_, sizeof(maxRotation_), network::DATA, 0x1);
     138      registerVar( &translationAcceleration_, sizeof(translationAcceleration_), network::DATA, 0x1);
     139      registerVar( &rotationAcceleration_, sizeof(rotationAcceleration_), network::DATA, 0x1);
     140      registerVar( &rotationAccelerationRadian_, sizeof(rotationAccelerationRadian_), network::DATA, 0x1);
     141      registerVar( &translationDamping_, sizeof(translationDamping_), network::DATA, 0x1);
     142      registerVar( &rotationDamping_, sizeof(rotationDamping_), network::DATA, 0x1);
     143      registerVar( &rotationDampingRadian_, sizeof(rotationDampingRadian_), network::DATA, 0x1);
    163144
    164145    }
     
    166147    void SpaceShip::init()
    167148    {
     149    if ((server_ || ( network::Client::getSingleton() && network::Client::getSingleton()->getShipID()==objectID ) ))
     150    {
     151          if (!setMouseEventCallback_)
     152          {
     153              InputManager::addMouseHandler(this, "SpaceShip");
     154              setMouseEventCallback_ = true;
     155          }
     156    }
     157
    168158        // START CREATING THRUSTER
    169159        this->tt_ = new ParticleInterface(GraphicsEngine::getSingleton().getSceneManager(),"twinthruster" + this->getName(),"Orxonox/engineglow");
     
    191181        this->greenBillboard_.setBillboardSet("Examples/Flare", ColourValue(0.0, 1.0, 0.0), 1);
    192182
    193         this->redNode_ = this->getNode()->createChildSceneNode(this->getName() + "red", Vector3(0.3, 4.7, -0.3));
     183        this->redNode_ = this->getNode()->createChildSceneNode(this->getName() + "red", Vector3(0.3, 4.0, -0.3));
    194184        this->redNode_->setInheritScale(false);
    195         this->greenNode_ = this->getNode()->createChildSceneNode(this->getName() + "green", Vector3(0.3, -4.7, -0.3));
     185        this->greenNode_ = this->getNode()->createChildSceneNode(this->getName() + "green", Vector3(0.3, -4.0, -0.3));
    196186        this->greenNode_->setInheritScale(false);
    197187
     
    218208        this->chFarNode_->setScale(0.4, 0.4, 0.4);
    219209
     210        createCamera();
    220211        // END of testing crosshair
    221212    }
     
    232223        Model::loadParams(xmlElem);
    233224        this->create();
     225        this->getFocus();
    234226/*
    235227        if (xmlElem->Attribute("forward") && xmlElem->Attribute("rotateupdown") && xmlElem->Attribute("rotaterightleft") && xmlElem->Attribute("looprightleft"))
     
    246238
    247239            COUT(4) << "Loader: Initialized spaceship steering with values " << maxSpeedForward_ << " " << maxSpeedRotateUpDown_ << " " << maxSpeedRotateRightLeft_ << " " << maxSpeedLoopRightLeft_ << " " << std::endl;
    248         }
     240      }
    249241*/
    250242        if (xmlElem->Attribute("maxSpeed") && xmlElem->Attribute("maxSideAndBackSpeed") && xmlElem->Attribute("maxRotation") && xmlElem->Attribute("transAcc") && xmlElem->Attribute("rotAcc") && xmlElem->Attribute("transDamp") && xmlElem->Attribute("rotDamp"))
     
    272264
    273265            COUT(4) << "Loader: Initialized SpaceShip" << std::endl;
    274         }
    275 
    276         if (xmlElem->Attribute("camera"))
    277         {
    278             this->setCamera();
    279         }
     266        }
     267
     268        if (xmlElem->Attribute("camera"))
     269        {
     270            this->setCamera();
     271        }
    280272    }
    281273
    282274    void SpaceShip::setCamera(const std::string& camera)
    283275    {
    284         Ogre::Camera *cam = GraphicsEngine::getSingleton().getSceneManager()->createCamera("ShipCam");
    285         this->camNode_ = this->getNode()->createChildSceneNode("CamNode");
    286 /*
    287 //        node->setInheritOrientation(false);
    288         cam->setPosition(Vector3(0,50,-150));
    289         cam->lookAt(Vector3(0,20,0));
    290         cam->roll(Degree(0));
    291 */
    292 
    293         cam->setPosition(Vector3(-200,0,35));
     276      camName_=camera;
     277      // change camera attributes here, if you want to ;)
     278    }
     279   
     280    void SpaceShip::getFocus(){
     281      COUT(4) << "requesting focus" << std::endl;
     282      if(network::Client::getSingleton()==0 || network::Client::getSingleton()->getShipID()==objectID)
     283        CameraHandler::getInstance()->requestFocus(cam_);
     284     
     285    }
     286   
     287    void SpaceShip::createCamera(){
     288//       COUT(4) << "begin camera creation" << std::endl;
     289      this->camNode_ = this->getNode()->createChildSceneNode(camName_);
     290      COUT(4) << "position: (this)" << this->getNode()->getPosition() << std::endl;
     291      this->camNode_->setPosition(Vector3(-50,0,10));
     292      Quaternion q1 = Quaternion(Radian(Degree(90)),Vector3(0,-1,0));
     293      Quaternion q2 = Quaternion(Radian(Degree(90)),Vector3(0,0,-1));
     294      camNode_->setOrientation(q1*q2);
     295      COUT(4) << "position: (cam)" << this->camNode_->getPosition() << std::endl;
     296      cam_ = new Camera(this->camNode_);
     297
     298      cam_->setTargetNode(this->getNode());
    294299//        cam->setPosition(Vector3(0,-350,0));
    295         cam->lookAt(Vector3(0,0,35));
    296         cam->roll(Degree(-90));
    297 
    298         this->camNode_->attachObject(cam);
    299         GraphicsEngine::getSingleton().getRenderWindow()->addViewport(cam);
     300      if(network::Client::getSingleton()!=0 && network::Client::getSingleton()->getShipID()==objectID){
     301        this->setBacksync(true);
     302        CameraHandler::getInstance()->requestFocus(cam_);
     303      }
     304
    300305    }
    301306
     
    333338        XMLPortParamLoadOnly(SpaceShip, "transDamp", setTransDamp, xmlelement, mode);
    334339        XMLPortParamLoadOnly(SpaceShip, "rotDamp", setRotDamp, xmlelement, mode);
     340        server_=true; // TODO: this is only a hack
     341        SpaceShip::create();
     342        getFocus();
    335343    }
    336344
     
    343351    }
    344352
    345     bool SpaceShip::mouseMoved(const OIS::MouseEvent &e)
     353    bool SpaceShip::mouseMoved(const MouseState& state)
    346354    {
    347355/*
     
    360368        if (this->bRMousePressed_)
    361369        {
    362             this->camNode_->roll(Degree(-e.state.X.rel * 0.10));
    363             this->camNode_->yaw(Degree(e.state.Y.rel * 0.10));
    364         }
    365         else
    366         {
    367             float minDimension = e.state.height;
    368             if (e.state.width < minDimension)
    369                 minDimension = e.state.width;
    370 
    371             this->mouseX_ += e.state.X.rel;
     370            this->camNode_->roll(Degree(-state.X.rel * 0.10));
     371            this->camNode_->yaw(Degree(state.Y.rel * 0.10));
     372        }
     373        else
     374        {
     375            float minDimension = state.height;
     376            if (state.width < minDimension)
     377                minDimension = state.width;
     378
     379            this->mouseX_ += state.X.rel;
    372380            if (this->mouseX_ < -minDimension)
    373381                this->mouseX_ = -minDimension;
     
    375383                this->mouseX_ = minDimension;
    376384
    377             this->mouseY_ += e.state.Y.rel;
     385            this->mouseY_ += state.Y.rel;
    378386            if (this->mouseY_ < -minDimension)
    379387                this->mouseY_ = -minDimension;
     
    403411    }
    404412
    405     bool SpaceShip::mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id)
    406     {
    407         if (id == OIS::MB_Left)
     413    bool SpaceShip::mouseButtonPressed(const MouseState& state, MouseButton::Enum id)
     414    {
     415        if (id == MouseButton::Left)
    408416            this->bLMousePressed_ = true;
    409         else if (id == OIS::MB_Right)
     417        else if (id == MouseButton::Right)
    410418            this->bRMousePressed_ = true;
    411419
     
    413421    }
    414422
    415     bool SpaceShip::mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id)
    416     {
    417         if (id == OIS::MB_Left)
     423    bool SpaceShip::mouseButtonReleased(const MouseState& state, MouseButton::Enum id)
     424    {
     425        if (id == MouseButton::Left)
    418426            this->bLMousePressed_ = false;
    419         else if (id == OIS::MB_Right)
     427        else if (id == MouseButton::Right)
    420428        {
    421429            this->bRMousePressed_ = false;
     
    428436    void SpaceShip::tick(float dt)
    429437    {
    430         if (!setMouseEventCallback_)
    431         {
    432           InputManager::addMouseHandler(this, "SpaceShip");
    433           setMouseEventCallback_ = true;
    434         }
     438        if (this->cam_)
     439            this->cam_->tick(dt);
    435440
    436441        if (this->redNode_ && this->greenNode_)
     
    450455        if (this->bLMousePressed_ && this->timeToReload_ <= 0)
    451456        {
    452             new Projectile(this);
     457            Projectile *p = new Projectile(this);
     458            p->setBacksync(true);
    453459            this->timeToReload_ = this->reloadTime_;
    454460        }
    455 
    456         OIS::Keyboard* mKeyboard = InputManager::getKeyboard();
    457461
    458462
     
    522526        }
    523527
    524         if (mKeyboard->isKeyDown(OIS::KC_UP) || mKeyboard->isKeyDown(OIS::KC_W))
     528        if( (network::Client::getSingleton() &&  network::Client::getSingleton()->getShipID() == objectID) || server_ )
     529        {
     530          COUT(4) << "steering our ship: " << objectID << std::endl;
     531          if (InputManager::isKeyDown(KeyCode::Up) || InputManager::isKeyDown(KeyCode::W))
    525532            this->acceleration_.x = this->translationAcceleration_;
    526         else if(mKeyboard->isKeyDown(OIS::KC_DOWN) || mKeyboard->isKeyDown(OIS::KC_S))
     533          else if(InputManager::isKeyDown(KeyCode::Down) || InputManager::isKeyDown(KeyCode::S))
    527534            this->acceleration_.x = -this->translationAcceleration_;
    528         else
     535          else
    529536            this->acceleration_.x = 0;
    530537
    531         if (mKeyboard->isKeyDown(OIS::KC_RIGHT) || mKeyboard->isKeyDown(OIS::KC_D))
     538          if (InputManager::isKeyDown(KeyCode::Right) || InputManager::isKeyDown(KeyCode::D))
    532539            this->acceleration_.y = -this->translationAcceleration_;
    533         else if (mKeyboard->isKeyDown(OIS::KC_LEFT) || mKeyboard->isKeyDown(OIS::KC_A))
     540          else if (InputManager::isKeyDown(KeyCode::Left) || InputManager::isKeyDown(KeyCode::A))
    534541            this->acceleration_.y = this->translationAcceleration_;
    535         else
     542          else
    536543            this->acceleration_.y = 0;
    537544
    538         if (mKeyboard->isKeyDown(OIS::KC_DELETE) || mKeyboard->isKeyDown(OIS::KC_Q))
     545          if (InputManager::isKeyDown(KeyCode::Delete) || InputManager::isKeyDown(KeyCode::Q))
    539546            this->momentum_ = Radian(-this->rotationAccelerationRadian_);
    540         else if (mKeyboard->isKeyDown(OIS::KC_PGDOWN) || mKeyboard->isKeyDown(OIS::KC_E))
     547          else if (InputManager::isKeyDown(KeyCode::PageDown) || InputManager::isKeyDown(KeyCode::E))
    541548            this->momentum_ = Radian(this->rotationAccelerationRadian_);
    542         else
     549          else
    543550            this->momentum_ = 0;
     551        }/*else
     552          COUT(4) << "not steering ship: " << objectID << " our ship: " << network::Client::getSingleton()->getShipID() << std::endl;*/
    544553
    545554        WorldEntity::tick(dt);
  • code/trunk/src/orxonox/objects/SpaceShip.h

    r1219 r1293  
    2323 *      Fabian 'x3n' Landau
    2424 *   Co-authors:
    25  *      ...
     25 *      Benjamin Knecht
    2626 *
    2727 */
     
    3434#include <OgrePrerequisites.h>
    3535
    36 #include "core/InputHandler.h"
     36#include "core/InputInterfaces.h"
     37#include "Camera.h"
    3738#include "Model.h"
    3839#include "../tools/BillboardSet.h"
     
    6263            void setRotDamp(float value);
    6364
     65            void getFocus();
     66
    6467            static void setMaxSpeedTest(float value)
    6568                { SpaceShip::instance_s->setMaxSpeed(value); }
    6669
    67             bool mouseMoved(const OIS::MouseEvent &e);
    68             bool mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id);
    69             bool mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id);
    70             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; }
    7175
    7276
    7377        private:
     78            void createCamera();
    7479            static SpaceShip* instance_s;
    7580
     
    8186
    8287            Ogre::SceneNode* camNode_;
     88            Camera* cam_; 
     89            std::string camName_;
     90
    8391
    8492            ParticleInterface* tt_;
     
    117125
    118126            float emitterRate_;
     127            bool server_;
    119128    };
    120129}
  • code/trunk/src/orxonox/objects/WorldEntity.cc

    r1209 r1293  
    4545    unsigned int WorldEntity::worldEntityCounter_s = 0;
    4646
    47     WorldEntity::WorldEntity()
     47    WorldEntity::WorldEntity() :
     48      velocity_    (0, 0, 0),
     49      acceleration_(0, 0, 0),
     50      rotationAxis_(0, 1, 0),
     51      rotationRate_(0),
     52      momentum_    (0),
     53      node_        (0),
     54      bStatic_     (true)
    4855    {
    4956        RegisterObject(WorldEntity);
    50 
    51         //create();
    52 
    53         this->bStatic_ = true;
    54         this->velocity_ = Vector3(0, 0, 0);
    55         this->acceleration_ = Vector3(0, 0, 0);
    56         this->rotationAxis_ = Vector3(0, 1, 0);
    57         this->rotationRate_ = 0;
    58         this->momentum_ = 0;
    5957
    6058        if (GraphicsEngine::getSingleton().getSceneManager())
     
    6765          registerAllVariables();
    6866        }
    69         else
    70         {
    71           this->node_ = 0;
    72         }
    7367    }
     68   
    7469
    7570    WorldEntity::~WorldEntity()
    7671    {
     72      // just to make sure we clean out all scene nodes
     73      if(this->getNode())
     74        this->getNode()->removeAndDestroyAllChildren();
    7775    }
    7876
     
    8179        if (!this->bStatic_)
    8280        {
     81//             COUT(4) << "acceleration: " << this->acceleration_ << " velocity: " << this->velocity_ << std::endl;
    8382            this->velocity_ += (dt * this->acceleration_);
    8483            this->translate(dt * this->velocity_, Ogre::Node::TS_LOCAL);
     
    9493        BaseObject::loadParams(xmlElem);
    9594        create();
    96 /*
    97         if (xmlElem->Attribute("position"))
    98         {
    99             std::vector<std::string> pos = tokenize(xmlElem->Attribute("position"),",");
    100             float x, y, z;
    101             String2Number<float>(x, pos[0]);
    102             String2Number<float>(y, pos[1]);
    103             String2Number<float>(z, pos[2]);
    104             this->setPosition(x, y, z);
    105         }
    106 
    107         if (xmlElem->Attribute("direction"))
    108         {
    109             std::vector<std::string> pos = tokenize(xmlElem->Attribute("direction"),",");
    110             float x, y, z;
    111             String2Number<float>(x, pos[0]);
    112             String2Number<float>(y, pos[1]);
    113             String2Number<float>(z, pos[2]);
    114             this->setDirection(x, y, z);
    115         }
    116 
    117         if (xmlElem->Attribute("yaw") || xmlElem->Attribute("pitch") || xmlElem->Attribute("roll"))
    118         {
    119             float yaw = 0.0, pitch = 0.0, roll = 0.0;
    120             if (xmlElem->Attribute("yaw"))
    121                 String2Number<float>(yaw,xmlElem->Attribute("yaw"));
    122 
    123             if (xmlElem->Attribute("pitch"))
    124                 String2Number<float>(pitch,xmlElem->Attribute("pitch"));
    125 
    126             if (xmlElem->Attribute("roll"))
    127                 String2Number<float>(roll,xmlElem->Attribute("roll"));
    128 
    129             this->yaw(Degree(yaw));
    130             this->pitch(Degree(pitch));
    131             this->roll(Degree(roll));
    132         }
    133 
    134         if (xmlElem->Attribute("scale"))
    135         {
    136             std::string scaleStr = xmlElem->Attribute("scale");
    137             float scale;
    138             String2Number<float>(scale, scaleStr);
    139             this->setScale(scale);
    140         }
    141 
    142         if (xmlElem->Attribute("rotationAxis"))
    143         {
    144             std::vector<std::string> pos = tokenize(xmlElem->Attribute("rotationAxis"),",");
    145             float x, y, z;
    146             String2Number<float>(x, pos[0]);
    147             String2Number<float>(y, pos[1]);
    148             String2Number<float>(z, pos[2]);
    149             this->setRotationAxis(x, y, z);
    150         }
    151 
    152         if (xmlElem->Attribute("rotationRate"))
    153         {
    154             float rotationRate;
    155             String2Number<float>(rotationRate, xmlElem->Attribute("rotationRate"));
    156             this->setRotationRate(Degree(rotationRate));
    157             if (rotationRate != 0)
    158                 this->setStatic(false);
    159         }
    160 
    161         create();
    162 */
    16395    }
     96   
    16497
    16598    void WorldEntity::setYawPitchRoll(const Degree& yaw, const Degree& pitch, const Degree& roll)
     
    188121
    189122        XMLPortObject(WorldEntity, WorldEntity, "attached", attachWorldEntity, getAttachedWorldEntity, xmlelement, mode, false, true);
     123       
     124        WorldEntity::create();
    190125    }
    191126
     
    194129    {
    195130      // register coordinates
    196       registerVar( (void*) &(this->getPosition().x), sizeof(this->getPosition().x), network::DATA);
    197       registerVar( (void*) &(this->getPosition().y), sizeof(this->getPosition().y), network::DATA);
    198       registerVar( (void*) &(this->getPosition().z), sizeof(this->getPosition().z), network::DATA);
     131      registerVar( (void*) &(this->getPosition().x), sizeof(this->getPosition().x), network::DATA, 0x3);
     132      registerVar( (void*) &(this->getPosition().y), sizeof(this->getPosition().y), network::DATA, 0x3);
     133      registerVar( (void*) &(this->getPosition().z), sizeof(this->getPosition().z), network::DATA, 0x3);
    199134      // register orientation
    200       registerVar( (void*) &(this->getOrientation().w), sizeof(this->getOrientation().w), network::DATA);
    201       registerVar( (void*) &(this->getOrientation().x), sizeof(this->getOrientation().x), network::DATA);
    202       registerVar( (void*) &(this->getOrientation().y), sizeof(this->getOrientation().y), network::DATA);
    203       registerVar( (void*) &(this->getOrientation().z), sizeof(this->getOrientation().z), network::DATA);
    204       // not needed at the moment, because we don't have prediction yet
     135      registerVar( (void*) &(this->getOrientation().w), sizeof(this->getOrientation().w), network::DATA, 0x3);
     136      registerVar( (void*) &(this->getOrientation().x), sizeof(this->getOrientation().x), network::DATA, 0x3);
     137      registerVar( (void*) &(this->getOrientation().y), sizeof(this->getOrientation().y), network::DATA, 0x3);
     138      registerVar( (void*) &(this->getOrientation().z), sizeof(this->getOrientation().z), network::DATA, 0x3);
    205139      // register velocity_
    206       registerVar( (void*) &(this->getVelocity().x), sizeof(this->getVelocity().x), network::DATA);
    207       registerVar( (void*) &(this->getVelocity().y), sizeof(this->getVelocity().y), network::DATA);
    208       registerVar( (void*) &(this->getVelocity().z), sizeof(this->getVelocity().z), network::DATA);
    209       // register rotationAxis/rate
    210       registerVar( (void*) &(this->getRotationRate()), sizeof(this->getRotationRate()), network::DATA);
    211       registerVar( (void*) &(this->getRotationAxis().x), sizeof(this->getRotationAxis().x), network::DATA);
    212       registerVar( (void*) &(this->getRotationAxis().y), sizeof(this->getRotationAxis().y), network::DATA);
    213       registerVar( (void*) &(this->getRotationAxis().z), sizeof(this->getRotationAxis().z), network::DATA);
     140//       registerVar( (void*) &(this->getVelocity().x), sizeof(this->getVelocity().x), network::DATA, 0x3);
     141//       registerVar( (void*) &(this->getVelocity().y), sizeof(this->getVelocity().y), network::DATA, 0x3);
     142//       registerVar( (void*) &(this->getVelocity().z), sizeof(this->getVelocity().z), network::DATA, 0x3);
     143//       // register rotationAxis/rate
     144//       registerVar( (void*) &(this->getRotationRate()), sizeof(this->getRotationRate()), network::DATA, 0x3);
     145//       registerVar( (void*) &(this->getRotationAxis().x), sizeof(this->getRotationAxis().x), network::DATA, 0x3);
     146//       registerVar( (void*) &(this->getRotationAxis().y), sizeof(this->getRotationAxis().y), network::DATA, 0x3);
     147//       registerVar( (void*) &(this->getRotationAxis().z), sizeof(this->getRotationAxis().z), network::DATA, 0x3);
     148      // register scale of node
     149      registerVar( (void*) &(this->getScale().x), sizeof(this->getScale().x), network::DATA, 0x3);
     150      registerVar( (void*) &(this->getScale().y), sizeof(this->getScale().y), network::DATA, 0x3);
     151      registerVar( (void*) &(this->getScale().z), sizeof(this->getScale().z), network::DATA, 0x3);
     152      //register staticity
     153      registerVar( (void*) &(this->bStatic_), sizeof(this->bStatic_), network::DATA, 0x3);
     154      //register acceleration
     155      // register velocity_
     156//       registerVar( (void*) &(this->getAcceleration().x), sizeof(this->getAcceleration().x), network::DATA, 0x3);
     157//       registerVar( (void*) &(this->getAcceleration().y), sizeof(this->getAcceleration().y), network::DATA, 0x3);
     158//       registerVar( (void*) &(this->getAcceleration().z), sizeof(this->getAcceleration().z), network::DATA, 0x3);
    214159    }
    215160
  • code/trunk/src/orxonox/particle/ParticleInterface.cc

    r1039 r1293  
    6363  ParticleInterface::~ParticleInterface(void)
    6464  {
     65    while(particleSystem_->getNumEmitters()>0)
     66      particleSystem_->removeEmitter(particleSystem_->getNumEmitters()-1);
    6567    sceneManager_->destroyParticleSystem(particleSystem_);
    6668  }
  • code/trunk/src/orxonox/tools/Timer.cc

    r1063 r1293  
    6868    TimerBase::TimerBase()
    6969    {
    70         RegisterRootObject(TimerBase);
    71 
    7270        this->executor_ = 0;
    7371        this->interval_ = 0;
     
    7674
    7775        this->time_ = 0;
     76
     77        RegisterRootObject(TimerBase);
    7878    }
    7979
     
    8383    TimerBase::~TimerBase()
    8484    {
    85         delete this->executor_;
     85      if (this->executor_)
     86          delete this->executor_;
    8687    }
    8788
  • code/trunk/visual_studio/base_properties_debug.vsprops

    r1089 r1293  
    1313                BasicRuntimeChecks="3"
    1414                RuntimeLibrary="3"
    15                 DebugInformationFormat="4"
     15                DebugInformationFormat="3"
    1616        />
    1717        <Tool
  • code/trunk/visual_studio/network_properties.vsprops

    r1084 r1293  
    88        <Tool
    99                Name="VCCLCompilerTool"
    10                 PreprocessorDefinitions="NETWORK_SHARED_BUILD;WIN32_LEAN_AND_MEAN"
     10                PreprocessorDefinitions="ORXONOX_NO_EXPORTS;NETWORK_STATIC_BUILD;WIN32_LEAN_AND_MEAN"
    1111        />
    1212        <Tool
  • code/trunk/visual_studio/orxonox_properties.vsprops

    r1223 r1293  
    88        <Tool
    99                Name="VCCLCompilerTool"
    10                 PreprocessorDefinitions="ORXONOX_SHARED_BUILD"
     10                PreprocessorDefinitions="ORXONOX_NO_EXPORTS;NETWORK_STATIC_BUILD"
    1111                UsePrecompiledHeader="2"
    1212                PrecompiledHeaderThrough="OrxonoxStableHeaders.h"
     
    1414        <Tool
    1515                Name="VCLinkerTool"
    16                 AdditionalDependencies="OgreMain$(CSS).lib tcl85t.lib"
     16                AdditionalDependencies="OgreMain$(CSS).lib tcl85t.lib enet$(CS).lib zlib$(CS).lib"
    1717                OutputFile="$(OutDir)$(ProjectName)$(CS).exe"
    18                 IgnoreDefaultLibraryNames=""
     18                IgnoreDefaultLibraryNames="LIBCMT;LIBCMTD"
    1919        />
    2020</VisualStudioPropertySheet>
  • code/trunk/visual_studio/vc8/core.vcproj

    r1223 r1293  
    351351                        </File>
    352352                        <File
     353                                RelativePath="..\..\src\core\InputInterfaces.h"
     354                                >
     355                        </File>
     356                        <File
    353357                                RelativePath="..\..\src\core\InputManager.h"
    354358                                >
  • code/trunk/visual_studio/vc8/network.vcproj

    r1064 r1293  
    1818                <Configuration
    1919                        Name="Debug|Win32"
    20                         ConfigurationType="2"
     20                        ConfigurationType="4"
    2121                        InheritedPropertySheets="$(SolutionDir)base_properties_debug.vsprops;..\network_properties.vsprops"
    2222                        CharacterSet="1"
     
    5050                        />
    5151                        <Tool
    52                                 Name="VCLinkerTool"
     52                                Name="VCLibrarianTool"
    5353                        />
    5454                        <Tool
     
    5656                        />
    5757                        <Tool
    58                                 Name="VCManifestTool"
    59                         />
    60                         <Tool
    6158                                Name="VCXDCMakeTool"
    6259                        />
     
    6663                        <Tool
    6764                                Name="VCFxCopTool"
    68                         />
    69                         <Tool
    70                                 Name="VCAppVerifierTool"
    71                         />
    72                         <Tool
    73                                 Name="VCWebDeploymentTool"
    7465                        />
    7566                        <Tool
  • code/trunk/visual_studio/vc8/ois.vcproj

    r1219 r1293  
    560560                                </File>
    561561                        </Filter>
     562                        <Filter
     563                                Name="linux"
     564                                >
     565                                <File
     566                                        RelativePath="..\..\src\ois\linux\EventHelpers.cpp"
     567                                        >
     568                                        <FileConfiguration
     569                                                Name="Release|Win32"
     570                                                ExcludedFromBuild="true"
     571                                                >
     572                                                <Tool
     573                                                        Name="VCCLCompilerTool"
     574                                                />
     575                                        </FileConfiguration>
     576                                        <FileConfiguration
     577                                                Name="Debug|Win32"
     578                                                ExcludedFromBuild="true"
     579                                                >
     580                                                <Tool
     581                                                        Name="VCCLCompilerTool"
     582                                                />
     583                                        </FileConfiguration>
     584                                </File>
     585                                <File
     586                                        RelativePath="..\..\src\ois\linux\LinuxForceFeedback.cpp"
     587                                        >
     588                                        <FileConfiguration
     589                                                Name="Release|Win32"
     590                                                ExcludedFromBuild="true"
     591                                                >
     592                                                <Tool
     593                                                        Name="VCCLCompilerTool"
     594                                                />
     595                                        </FileConfiguration>
     596                                        <FileConfiguration
     597                                                Name="Debug|Win32"
     598                                                ExcludedFromBuild="true"
     599                                                >
     600                                                <Tool
     601                                                        Name="VCCLCompilerTool"
     602                                                />
     603                                        </FileConfiguration>
     604                                </File>
     605                                <File
     606                                        RelativePath="..\..\src\ois\linux\LinuxInputManager.cpp"
     607                                        >
     608                                        <FileConfiguration
     609                                                Name="Release|Win32"
     610                                                ExcludedFromBuild="true"
     611                                                >
     612                                                <Tool
     613                                                        Name="VCCLCompilerTool"
     614                                                />
     615                                        </FileConfiguration>
     616                                        <FileConfiguration
     617                                                Name="Debug|Win32"
     618                                                ExcludedFromBuild="true"
     619                                                >
     620                                                <Tool
     621                                                        Name="VCCLCompilerTool"
     622                                                />
     623                                        </FileConfiguration>
     624                                </File>
     625                                <File
     626                                        RelativePath="..\..\src\ois\linux\LinuxJoyStickEvents.cpp"
     627                                        >
     628                                        <FileConfiguration
     629                                                Name="Release|Win32"
     630                                                ExcludedFromBuild="true"
     631                                                >
     632                                                <Tool
     633                                                        Name="VCCLCompilerTool"
     634                                                />
     635                                        </FileConfiguration>
     636                                        <FileConfiguration
     637                                                Name="Debug|Win32"
     638                                                ExcludedFromBuild="true"
     639                                                >
     640                                                <Tool
     641                                                        Name="VCCLCompilerTool"
     642                                                />
     643                                        </FileConfiguration>
     644                                </File>
     645                                <File
     646                                        RelativePath="..\..\src\ois\linux\LinuxKeyboard.cpp"
     647                                        >
     648                                        <FileConfiguration
     649                                                Name="Release|Win32"
     650                                                ExcludedFromBuild="true"
     651                                                >
     652                                                <Tool
     653                                                        Name="VCCLCompilerTool"
     654                                                />
     655                                        </FileConfiguration>
     656                                        <FileConfiguration
     657                                                Name="Debug|Win32"
     658                                                ExcludedFromBuild="true"
     659                                                >
     660                                                <Tool
     661                                                        Name="VCCLCompilerTool"
     662                                                />
     663                                        </FileConfiguration>
     664                                </File>
     665                                <File
     666                                        RelativePath="..\..\src\ois\linux\LinuxMouse.cpp"
     667                                        >
     668                                        <FileConfiguration
     669                                                Name="Release|Win32"
     670                                                ExcludedFromBuild="true"
     671                                                >
     672                                                <Tool
     673                                                        Name="VCCLCompilerTool"
     674                                                />
     675                                        </FileConfiguration>
     676                                        <FileConfiguration
     677                                                Name="Debug|Win32"
     678                                                ExcludedFromBuild="true"
     679                                                >
     680                                                <Tool
     681                                                        Name="VCCLCompilerTool"
     682                                                />
     683                                        </FileConfiguration>
     684                                </File>
     685                        </Filter>
    562686                </Filter>
    563687                <Filter
     
    650774                                <File
    651775                                        RelativePath="..\..\src\ois\OISInterface.h"
     776                                        >
     777                                </File>
     778                        </Filter>
     779                        <Filter
     780                                Name="linux"
     781                                >
     782                                <File
     783                                        RelativePath="..\..\src\ois\linux\EventHelpers.h"
     784                                        >
     785                                </File>
     786                                <File
     787                                        RelativePath="..\..\src\ois\linux\LinuxForceFeedback.h"
     788                                        >
     789                                </File>
     790                                <File
     791                                        RelativePath="..\..\src\ois\linux\LinuxInputManager.h"
     792                                        >
     793                                </File>
     794                                <File
     795                                        RelativePath="..\..\src\ois\linux\LinuxJoyStickEvents.h"
     796                                        >
     797                                </File>
     798                                <File
     799                                        RelativePath="..\..\src\ois\linux\LinuxKeyboard.h"
     800                                        >
     801                                </File>
     802                                <File
     803                                        RelativePath="..\..\src\ois\linux\LinuxMouse.h"
     804                                        >
     805                                </File>
     806                                <File
     807                                        RelativePath="..\..\src\ois\linux\LinuxPrereqs.h"
    652808                                        >
    653809                                </File>
  • code/trunk/visual_studio/vc8/orxonox.vcproj

    r1219 r1293  
    204204                                </File>
    205205                                <File
     206                                        RelativePath="..\..\src\orxonox\objects\CameraHandler.cc"
     207                                        >
     208                                </File>
     209                                <File
    206210                                        RelativePath="..\..\src\orxonox\objects\Explosion.cc"
    207211                                        >
     
    459463                                <File
    460464                                        RelativePath="..\..\src\orxonox\objects\Camera.h"
     465                                        >
     466                                </File>
     467                                <File
     468                                        RelativePath="..\..\src\orxonox\objects\CameraHandler.h"
    461469                                        >
    462470                                </File>
Note: See TracChangeset for help on using the changeset viewer.