Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2662


Ignore:
Timestamp:
Feb 14, 2009, 10:17:35 PM (16 years ago)
Author:
rgrieder
Message:

Merged presentation branch back to trunk.

Location:
code/trunk
Files:
6 deleted
281 edited
400 copied

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/TODO

    r2171 r2662  
    33        test network functionality with paketloss/delay: http://www.linuxfoundation.org/en/Net:Netem#Packet_loss
    44
    5         bidirectional
    6 
    75        minimize synchronisableHeader
    86
    97
    10         !!! check that enet does not cause a packet traffic jam when a reliable packet gets missed !!!
    118        !!! ensure that objects get synched, when newly created, even if not their tick
    129
  • code/trunk/bin/Plugins.cfg

    r1763 r2662  
    1010Plugin=Plugin_BSPSceneManager
    1111Plugin=Plugin_OctreeSceneManager
    12 #Plugin=Plugin_CgProgramManager
     12Plugin=Plugin_CgProgramManager
    1313
  • code/trunk/bin/def_keybindings.ini

    r2103 r2662  
    3232KeyF14=
    3333KeyF15=
    34 KeyF2=
     34KeyF2="OverlayGroup toggleVisibility Stats"
    3535KeyF3=
    3636KeyF4=
     
    5050KeyKana=
    5151KeyKanji=
    52 KeyL=
     52KeyL=dropItems
    5353KeyLeft=
    5454KeyLeftAlt=
    5555KeyLeftBracket=
    56 KeyLeftControl=
     56KeyLeftControl=mouseLook
    5757KeyLeftShift=
    5858KeyLeftWindows=
     
    100100KeyPageDown=
    101101KeyPageUp=
    102 KeyPause=
     102KeyPause=pause
    103103KeyPeriod=
    104104KeyPlayPause=
     
    119119KeySlash=
    120120KeySleep=
    121 KeySpace=
     121KeySpace=boost
    122122KeyStop=
    123123KeySystemRequest=
     
    145145KeyYen=
    146146KeyZ=
    147 Key_084=
    148 Key_085=
    149 Key_089=
    150 Key_090=
    151 Key_091=
    152 Key_092=
    153 Key_093=
    154 Key_094=
    155 Key_095=
    156 Key_096=
    157 Key_097=
    158 Key_098=
    159 Key_099=
    160 Key_103=
    161 Key_104=
    162 Key_105=
    163 Key_106=
    164 Key_107=
    165 Key_108=
    166 Key_109=
    167 Key_110=
    168 Key_111=
    169 Key_112=
    170 Key_114=
    171 Key_115=
    172 Key_117=
    173 Key_118=
    174 Key_119=
    175 Key_120=
    176 Key_121=
    177 Key_123=
    178 Key_125=
    179 Key_128=
    180 Key_129=
    181 Key_130=
    182 Key_131=
    183 Key_132=
    184 Key_133=
    185 Key_134=
    186 Key_135=
    187 Key_136=
    188 Key_137=
    189 Key_138=
    190 Key_139=
    191 Key_140=
    192 Key_141=
    193 Key_143=
    194 Key_144=
    195 Key_154=
    196 Key_155=
    197 Key_158=
    198 Key_159=
    199 Key_163=
    200 Key_165=
    201 Key_166=
    202 Key_167=
    203 Key_168=
    204 Key_169=
    205 Key_170=
    206 Key_171=
    207 Key_172=
    208 Key_173=
    209 Key_175=
    210 Key_177=
    211 Key_180=
    212 Key_182=
    213 Key_185=
    214 Key_186=
    215 Key_187=
    216 Key_188=
    217 Key_189=
    218 Key_190=
    219 Key_191=
    220 Key_192=
    221 Key_193=
    222 Key_194=
    223 Key_195=
    224 Key_196=
    225 Key_198=
    226 Key_202=
    227 Key_204=
    228 Key_206=
    229 Key_212=
    230 Key_213=
    231 Key_214=
    232 Key_215=
    233 Key_216=
    234 Key_217=
    235 Key_218=
    236 Key_224=
    237 Key_225=
    238 Key_226=
    239 Key_228=
    240147
    241148[MouseButtons]
     
    247154MouseLeft="fire"
    248155MouseMiddle=
    249 MouseRight=
     156MouseRight="altfire"
    250157MouseWheel1Down=
    251158MouseWheel1Up=
     
    256163MouseXNeg="scale -1 rotateYaw"
    257164MouseXPos="scale 1 rotateYaw"
    258 MouseYNeg="scale 1 rotatePitch"
    259 MouseYPos="scale -1 rotatePitch"
     165MouseYNeg="scale -1 rotatePitch"
     166MouseYPos="scale 1 rotatePitch"
    260167
  • code/trunk/bin/telnet_server.tcl

    r1505 r2662  
    8181         return
    8282     }
    83      if {[string equal $line "quit"] || [string equal $line "exit"]} {
     83     if {[string equal $line "logout"] || [string equal $line "quit"]} {
    8484         disconnect $client
     85         return
     86     }
     87     if {[string equal $line "exit"]} {
     88         set ::termination 1
    8589         return
    8690     }
  • code/trunk/src/CMakeLists.txt

    r2129 r2662  
    22INCLUDE_DIRECTORIES(..)
    33INCLUDE_DIRECTORIES(orxonox)
     4INCLUDE_DIRECTORIES(bullet)
    45
    56ADD_SUBDIRECTORY(cpptcl)
    67ADD_SUBDIRECTORY(ois)
    78ADD_SUBDIRECTORY(tinyxml)
     9ADD_SUBDIRECTORY(bullet)
    810ADD_SUBDIRECTORY(lua)
    911ADD_SUBDIRECTORY(tolua)
  • code/trunk/src/core/BaseObject.cc

    r2171 r2662  
    3636#include "CoreIncludes.h"
    3737#include "EventIncludes.h"
     38#include "Functor.h"
    3839#include "XMLPort.h"
    3940#include "XMLFile.h"
     
    6061        this->oldGametype_ = 0;
    6162
     63        this->lastLoadedXMLElement_ = 0;
     64
     65        this->functorSetMainState_ = 0;
     66        this->functorGetMainState_ = 0;
     67
    6268        this->setCreator(creator);
    6369        if (this->creator_)
     
    8288    BaseObject::~BaseObject()
    8389    {
    84         for (std::list<BaseObject*>::const_iterator it = this->events_.begin(); it != this->events_.end(); ++it)
    85             (*it)->unregisterEventListener(this);
    86 
    87         for (std::map<BaseObject*, std::string>::const_iterator it = this->eventListeners_.begin(); it != this->eventListeners_.end(); ++it)
    88             it->first->removeEvent(this);
     90        if (this->isInitialized())
     91        {
     92            for (std::list<BaseObject*>::const_iterator it = this->events_.begin(); it != this->events_.end(); ++it)
     93                (*it)->unregisterEventListener(this);
     94
     95            for (std::map<BaseObject*, std::string>::const_iterator it = this->eventListeners_.begin(); it != this->eventListeners_.end(); ++it)
     96                it->first->removeEvent(this);
     97
     98            if (this->functorSetMainState_)
     99                delete this->functorSetMainState_;
     100            if (this->functorGetMainState_)
     101                delete this->functorGetMainState_;
     102        }
    89103    }
    90104
     
    100114        XMLPortParam(BaseObject, "visible", setVisible, isVisible, xmlelement, mode);
    101115        XMLPortParam(BaseObject, "active", setActive, isActive, xmlelement, mode);
     116        XMLPortParam(BaseObject, "mainstate", setMainStateName, getMainStateName, xmlelement, mode);
    102117
    103118        XMLPortObjectTemplate(BaseObject, Template, "templates", addTemplate, getTemplate, xmlelement, mode, Template*);
     
    109124            std::list<std::string> eventnames;
    110125
    111             if (mode == XMLPort::LoadObject)
     126            if (mode == XMLPort::LoadObject || mode == XMLPort::ExpandObject)
    112127            {
    113128                for (ticpp::Iterator<ticpp::Element> child = events->FirstChildElement(false); child != child.end(); child++)
     
    279294        SetEvent(BaseObject, "visibility", setVisible, event);
    280295    }
     296
     297    void BaseObject::setMainStateName(const std::string& name)
     298    {
     299        if (this->mainStateName_ != name)
     300        {
     301            this->mainStateName_ = name;
     302            if (this->functorSetMainState_)
     303                delete this->functorSetMainState_;
     304            if (this->functorGetMainState_)
     305                delete this->functorGetMainState_;
     306            this->changedMainState();
     307            if (!this->functorSetMainState_)
     308                COUT(2) << "Warning: \"" << name << "\" is not a valid MainState." << std::endl;
     309        }
     310    }
     311
     312    void BaseObject::setMainState(bool state)
     313    {
     314        if (this->functorSetMainState_)
     315            (*this->functorSetMainState_)(state);
     316        else
     317            COUT(2) << "Warning: No MainState defined in object \"" << this->getName() << "\" (" << this->getIdentifier()->getName() << ")" << std::endl;
     318    }
     319
     320    bool BaseObject::getMainState() const
     321    {
     322        if (this->functorGetMainState_)
     323        {
     324            (*this->functorGetMainState_)();
     325            return this->functorGetMainState_->getReturnvalue();
     326        }
     327        else
     328        {
     329            COUT(2) << "Warning: No MainState defined in object \"" << this->getName() << "\" (" << this->getIdentifier()->getName() << ")" << std::endl;
     330            return false;
     331        }
     332    }
     333
     334    void BaseObject::changedMainState()
     335    {
     336        SetMainState(BaseObject, "activity",   setActive,  isActive);
     337        SetMainState(BaseObject, "visibility", setVisible, isVisible);
     338    }
    281339}
  • code/trunk/src/core/BaseObject.h

    r2171 r2662  
    3636#ifndef _BaseObject_H__
    3737#define _BaseObject_H__
     38
     39#define SetMainState(classname, statename, setfunction, getfunction) \
     40    if (this->getMainStateName() == statename) \
     41    { \
     42        this->functorSetMainState_ = createFunctor(&classname::setfunction)->setObject(this); \
     43        this->functorGetMainState_ = createFunctor(&classname::getfunction)->setObject(this); \
     44    }
    3845
    3946#include <map>
     
    5562    class _CoreExport BaseObject : virtual public OrxonoxClass
    5663    {
     64        template <class T> friend class XMLPortClassParamContainer;
     65
    5766        public:
    5867            BaseObject(BaseObject* creator);
     
    100109            virtual void changedVisibility() {}
    101110
     111            void setMainState(bool state);
     112            bool getMainState() const;
     113
     114            void setMainStateName(const std::string& name);
     115            inline const std::string& getMainStateName() const { return this->mainStateName_; }
     116            virtual void changedMainState();
     117
    102118            /** @brief Sets a pointer to the xml file that loaded this object. @param file The pointer to the XMLFile */
    103119            inline void setFile(const XMLFile* file) { this->file_ = file; }
     
    121137            inline Scene* getScene() const { return this->scene_; }
    122138
    123             inline void setGametype(Gametype* gametype) { this->oldGametype_ = this->gametype_; this->gametype_ = gametype; this->changedGametype(); }
     139            inline void setGametype(Gametype* gametype)
     140            {
     141                if (gametype != this->gametype_)
     142                {
     143                    this->oldGametype_ = this->gametype_;
     144                    this->gametype_ = gametype;
     145                    this->changedGametype();
     146                }
     147            }
    124148            inline Gametype* getGametype() const { return this->gametype_; }
    125149            inline Gametype* getOldGametype() const { return this->oldGametype_; }
    126             virtual inline void changedGametype() {}
     150            virtual void changedGametype() {}
    127151
    128152            void fireEvent();
     
    151175
    152176        protected:
    153             std::string name_;                          //!< The name of the object
    154             std::string oldName_;                       //!< The old name of the object
    155             mbool bActive_;                             //!< True = the object is active
    156             mbool bVisible_;                            //!< True = the object is visible
     177            std::string name_;                                 //!< The name of the object
     178            std::string oldName_;                              //!< The old name of the object
     179            mbool       bActive_;                              //!< True = the object is active
     180            mbool       bVisible_;                             //!< True = the object is visible
     181            std::string mainStateName_;
     182            Functor*    functorSetMainState_;
     183            Functor*    functorGetMainState_;
    157184
    158185        private:
     
    160187            Template* getTemplate(unsigned int index) const;
    161188
    162             bool                  bInitialized_;         //!< True if the object was initialized (passed the object registration)
    163             const XMLFile*        file_;                 //!< The XMLFile that loaded this object
    164             std::string           loaderIndentation_;    //!< Indentation of the debug output in the Loader
    165             Namespace*            namespace_;
    166             BaseObject*           creator_;
    167             Scene*                scene_;
    168             Gametype*             gametype_;
    169             Gametype*             oldGametype_;
    170             std::set<Template*>   templates_;
    171             std::map<BaseObject*, std::string> eventListeners_;
     189            bool                   bInitialized_;              //!< True if the object was initialized (passed the object registration)
     190            const XMLFile*         file_;                      //!< The XMLFile that loaded this object
     191            Element*               lastLoadedXMLElement_;      //!< Non 0 if the TinyXML attributes have already been copied to our own lowercase map
     192            std::map<std::string, std::string> xmlAttributes_; //!< Lowercase XML attributes
     193            std::string            loaderIndentation_;         //!< Indentation of the debug output in the Loader
     194            Namespace*             namespace_;
     195            BaseObject*            creator_;
     196            Scene*                 scene_;
     197            Gametype*              gametype_;
     198            Gametype*              oldGametype_;
     199            std::set<Template*>    templates_;
     200            std::map<BaseObject*,  std::string> eventListeners_;
    172201            std::list<BaseObject*> events_;
    173202            std::map<std::string, EventContainer*> eventContainers_;
     
    178207    SUPER_FUNCTION(3, BaseObject, changedVisibility, false);
    179208    SUPER_FUNCTION(4, BaseObject, processEvent, false);
     209    SUPER_FUNCTION(6, BaseObject, changedMainState, false);
     210    SUPER_FUNCTION(9, BaseObject, changedName, false);
     211    SUPER_FUNCTION(10, BaseObject, changedGametype, false);
    180212}
    181213
  • code/trunk/src/core/CommandExecutor.cc

    r1784 r2662  
    5353    }
    5454
    55     ConsoleCommand& CommandExecutor::addConsoleCommandShortcut(ConsoleCommand* command)
     55    ConsoleCommand& CommandExecutor::addConsoleCommandShortcut(ConsoleCommand* command, bool bDeleteAtExit)
    5656    {
    5757        std::map<std::string, ConsoleCommand*>::const_iterator it = CommandExecutor::getInstance().consoleCommandShortcuts_.find(command->getName());
     
    6161        }
    6262
     63        // Make sure we can also delete the external ConsoleCommands that don't belong to an Identifier
     64        if (command && bDeleteAtExit)
     65        {
     66            CommandExecutor::getInstance().consoleCommandExternals_.insert(command);
     67        }
    6368
    6469        CommandExecutor::getInstance().consoleCommandShortcuts_[command->getName()] = command;
     
    647652        }
    648653    }
     654
     655    void CommandExecutor::destroyExternalCommands()
     656    {
     657        for (std::set<ConsoleCommand*>::const_iterator it = CommandExecutor::getInstance().consoleCommandExternals_.begin();
     658            it != CommandExecutor::getInstance().consoleCommandExternals_.end(); ++it)
     659            delete *it;
     660    }
    649661}
  • code/trunk/src/core/CommandExecutor.h

    r1771 r2662  
    5151            static const CommandEvaluation& getLastEvaluation();
    5252
    53             static ConsoleCommand& addConsoleCommandShortcut(ConsoleCommand* command);
     53            static ConsoleCommand& addConsoleCommandShortcut(ConsoleCommand* command, bool bDeleteAtExit = false);
    5454            static ConsoleCommand* getConsoleCommandShortcut(const std::string& name);
    5555            static ConsoleCommand* getLowercaseConsoleCommandShortcut(const std::string& name);
     
    6868            /** @brief Returns a const_iterator to the end of the map that stores all console commands with their names in lowercase. @return The const_iterator */
    6969            static inline std::map<std::string, ConsoleCommand*>::const_iterator getLowercaseConsoleCommandShortcutMapEnd() { return CommandExecutor::getInstance().consoleCommandShortcuts_LC_.end(); }
     70
     71            static void destroyExternalCommands();
    7072
    7173        private:
     
    101103            std::map<std::string, ConsoleCommand*> consoleCommandShortcuts_;
    102104            std::map<std::string, ConsoleCommand*> consoleCommandShortcuts_LC_;
     105            std::set<ConsoleCommand*>              consoleCommandExternals_;
    103106    }; // tolua_export
    104107} // tolua_export
  • code/trunk/src/core/CommandLine.cc

    r2105 r2662  
    8383    CommandLine::~CommandLine()
    8484    {
    85         for (std::map<std::string, CommandLineArgument*>::const_iterator it = cmdLineArgs_.begin();
    86             it != cmdLineArgs_.end(); ++it)
    87         {
    88             delete it->second;
    89         }
     85        CommandLine::destroyAllArguments();
    9086    }
    9187
     
    9894        static CommandLine instance;
    9995        return instance;
     96    }
     97
     98    /**
     99    @brief
     100        Destroys all command line arguments. This should be called at the end
     101        of main. Do not use before that.
     102    */
     103    void CommandLine::destroyAllArguments()
     104    {
     105        for (std::map<std::string, CommandLineArgument*>::const_iterator it = _getInstance().cmdLineArgs_.begin();
     106            it != _getInstance().cmdLineArgs_.end(); ++it)
     107            delete it->second;
     108        _getInstance().cmdLineArgs_.clear();
    100109    }
    101110
  • code/trunk/src/core/CommandLine.h

    r2103 r2662  
    155155        }
    156156
     157        static void destroyAllArguments();
    157158
    158159    private:
     
    179180        //! Holds all pointers to the arguments and serves as a search map by name.
    180181        std::map<std::string, CommandLineArgument*> cmdLineArgs_;
    181         //! Search map by chortcut for the arguments.
     182        //! Search map by shortcut for the arguments.
    182183        std::map<std::string, CommandLineArgument*> cmdLineArgsShortcut_;
    183184    };
  • code/trunk/src/core/ConfigFileManager.cc

    r2103 r2662  
    160160                if ((*it)->getIndex() > size)
    161161                    size = (*it)->getIndex();
    162         return (size + 1);
     162        if (size == 0)
     163            return 0;
     164        else
     165            return (size + 1);
    163166    }
    164167
  • code/trunk/src/core/ConfigFileManager.h

    r2103 r2662  
    3838
    3939#include "util/Math.h"
     40#include "util/OrxEnum.h"
    4041
    4142namespace orxonox
    4243{
    43     // Use unsigned int as config file type to have an arbitrary number of files
    44     class ConfigFileType
    45     {
    46     public:
    47         ConfigFileType() { }
    48         ConfigFileType(unsigned int type)              { type_ = type; }
    49         ConfigFileType(const ConfigFileType& instance) { type_ = instance.type_; }
    50 
    51         operator unsigned int() { return type_; }
    52         ConfigFileType& operator =(unsigned int type) { type_ = type; return *this; }
    53         bool operator <(const ConfigFileType& right) const   { return (type_ < right.type_); }
    54 
    55         /* *** Put the different config file types here *** */
    56         static const unsigned int NoType              = 0;
    57         static const unsigned int Settings            = 1;
    58         static const unsigned int JoyStickCalibration = 2;
    59 
    60         static const unsigned int numberOfReservedTypes = 1024;
    61 
    62     private:
    63         unsigned int type_;
     44    // Use int as config file type to have an arbitrary number of files
     45    struct ConfigFileType : OrxEnum<ConfigFileType>
     46    {
     47        OrxEnumConstructors(ConfigFileType);
     48
     49        static const int NoType              = 0;
     50        static const int Settings            = 1;
     51        static const int JoyStickCalibration = 2;
     52
     53        static const int numberOfReservedTypes = 1024;
    6454    };
    6555
  • code/trunk/src/core/ConfigValueContainer.cc

    r2171 r2662  
    273273        {
    274274            this->valueVector_.clear();
    275             for (unsigned int i = 0; i < ConfigFileManager::getInstance().getVectorSize(this->type_, this->sectionname_, this->varname_); i++)
     275            unsigned int vectorSize = ConfigFileManager::getInstance().getVectorSize(this->type_, this->sectionname_, this->varname_);
     276            for (unsigned int i = 0; i < vectorSize; i++)
    276277            {
    277278                if (i < this->defvalueStringVector_.size())
  • code/trunk/src/core/ConfigValueContainer.h

    r2171 r2662  
    109109            {
    110110                this->init(type, identifier, sectionname, varname);
    111                 this->initValue((V)defvalue);
     111                this->initValue(static_cast<V>(defvalue));
    112112            }
    113113
     
    217217            inline const std::string& getName() const
    218218                { return this->varname_; }
     219            /** @brief Retuns the name of the section this config value is in. */
     220            inline const std::string& getSectionName() const
     221                { return this->sectionname_; }
    219222            /** @brief Returns true if this config-value is a vector */
    220223            inline bool isVector() const
  • code/trunk/src/core/ConsoleCommand.h

    r2087 r2662  
    6464
    6565#define SetConsoleCommandShortcutGeneric(fakevariable, command) \
    66     orxonox::ConsoleCommand& fakevariable = orxonox::CommandExecutor::addConsoleCommandShortcut(command)
     66    orxonox::ConsoleCommand& fakevariable = orxonox::CommandExecutor::addConsoleCommandShortcut(command, true)
    6767
    6868
  • code/trunk/src/core/Core.cc

    r2171 r2662  
    4646    bool Core::bIsMaster_s      = false;
    4747
     48    Core* Core::singletonRef_s = 0;
     49
    4850    /**
    4951        @brief Constructor: Registers the object and sets the config-values.
     
    5355    {
    5456        RegisterRootObject(Core);
     57
     58        assert(Core::singletonRef_s == 0);
     59        Core::singletonRef_s = this;
     60        this->bInitializeRandomNumberGenerator_ = false;
     61
    5562        this->setConfigValues();
    56         isCreatingCoreSettings() = false;
    5763    }
    5864
     
    6268    Core::~Core()
    6369    {
    64         isCreatingCoreSettings() = true;
    65     }
    66 
    67     /**
    68         @brief Returns true if the Core instance is not yet ready and the static functions have to return a default value.
    69     */
    70     bool& Core::isCreatingCoreSettings()
    71     {
    72         static bool bCreatingCoreSettings = true;
    73         return bCreatingCoreSettings;
    74     }
    75 
    76     /**
    77         @brief Returns a unique instance of Core.
    78         @return The instance
    79     */
    80     Core& Core::getInstance()
    81     {
    82         // If bCreatingSoftDebugLevelObject is true, we're just about to create an instance of the DebugLevel class
    83         //if (Core::isCreatingCoreSettings())
    84         //{
    85         //    isCreatingCoreSettings() = false;
    86         //    //instance.setConfigValues();
    87         //}
    88 
    89         static bool firstTime = true;
    90         if (firstTime)
    91             isCreatingCoreSettings() = true;
    92 
    93         static Core instance;
    94         return instance;
     70        assert(Core::singletonRef_s);
     71        Core::singletonRef_s = 0;
    9572    }
    9673
     
    10481        SetConfigValue(softDebugLevelShell_, 1).description("The maximal level of debug output shown in the ingame shell").callback(this, &Core::debugLevelChanged);
    10582        SetConfigValue(language_, Language::getLanguage().defaultLanguage_).description("The language of the ingame text").callback(this, &Core::languageChanged);
     83        SetConfigValue(bInitializeRandomNumberGenerator_, true).description("If true, all random actions are different each time you start the game").callback(this, &Core::initializeRandomNumberGenerator);
    10684    }
    10785
     
    140118    int Core::getSoftDebugLevel(OutputHandler::OutputDevice device)
    141119    {
    142         if (!Core::isCreatingCoreSettings())
     120        switch (device)
    143121        {
    144             switch (device)
    145             {
    146             case OutputHandler::LD_All:
    147                 return Core::getInstance().softDebugLevel_;
    148             case OutputHandler::LD_Console:
    149                 return Core::getInstance().softDebugLevelConsole_;
    150             case OutputHandler::LD_Logfile:
    151                 return Core::getInstance().softDebugLevelLogfile_;
    152             case OutputHandler::LD_Shell:
    153                 return Core::getInstance().softDebugLevelShell_;
    154             default:
    155                 assert(0);
    156             }
     122        case OutputHandler::LD_All:
     123            return Core::getInstance().softDebugLevel_;
     124        case OutputHandler::LD_Console:
     125            return Core::getInstance().softDebugLevelConsole_;
     126        case OutputHandler::LD_Logfile:
     127            return Core::getInstance().softDebugLevelLogfile_;
     128        case OutputHandler::LD_Shell:
     129            return Core::getInstance().softDebugLevelShell_;
     130        default:
     131            assert(0);
     132            return 2;
    157133        }
    158 
    159         // Return a constant value while we're creating the object
    160         return 2;
    161134    }
    162135
     
    168141     void Core::setSoftDebugLevel(OutputHandler::OutputDevice device, int level)
    169142     {
    170         if (!Core::isCreatingCoreSettings())
    171         {
    172             if (device == OutputHandler::LD_All)
    173                 Core::getInstance().softDebugLevel_ = level;
    174             else if (device == OutputHandler::LD_Console)
    175                 Core::getInstance().softDebugLevelConsole_ = level;
    176             else if (device == OutputHandler::LD_Logfile)
    177                 Core::getInstance().softDebugLevelLogfile_ = level;
    178             else if (device == OutputHandler::LD_Shell)
    179                 Core::getInstance().softDebugLevelShell_ = level;
     143        if (device == OutputHandler::LD_All)
     144            Core::getInstance().softDebugLevel_ = level;
     145        else if (device == OutputHandler::LD_Console)
     146            Core::getInstance().softDebugLevelConsole_ = level;
     147        else if (device == OutputHandler::LD_Logfile)
     148            Core::getInstance().softDebugLevelLogfile_ = level;
     149        else if (device == OutputHandler::LD_Shell)
     150            Core::getInstance().softDebugLevelShell_ = level;
    180151
    181             OutputHandler::setSoftDebugLevel(device, level);
    182         }
     152        OutputHandler::setSoftDebugLevel(device, level);
    183153     }
    184154
     
    188158    const std::string& Core::getLanguage()
    189159    {
    190         if (!Core::isCreatingCoreSettings())
    191             return Core::getInstance().language_;
    192 
    193         return Language::getLanguage().defaultLanguage_;
     160        return Core::getInstance().language_;
    194161    }
    195162
     
    209176        ResetConfigValue(language_);
    210177    }
     178
     179    void Core::initializeRandomNumberGenerator()
     180    {
     181        static bool bInitialized = false;
     182        if (!bInitialized && this->bInitializeRandomNumberGenerator_)
     183        {
     184            srand(time(0));
     185            rand();
     186            bInitialized = true;
     187        }
     188    }
    211189}
  • code/trunk/src/core/Core.h

    r2171 r2662  
    4040#include "CorePrereqs.h"
    4141
     42#include <cassert>
    4243#include "OrxonoxClass.h"
    4344#include "util/OutputHandler.h"
     
    4950    {
    5051        public:
    51             static Core& getInstance();
    52             static bool& isCreatingCoreSettings();
     52            Core();
     53            ~Core();
    5354            void setConfigValues();
    5455            void debugLevelChanged();
    5556            void languageChanged();
    5657
    57             static int getSoftDebugLevel(OutputHandler::OutputDevice device = OutputHandler::LD_All);
    58             static void setSoftDebugLevel(OutputHandler::OutputDevice device, int level);
     58            static Core& getInstance() { assert(Core::singletonRef_s); return *Core::singletonRef_s; }
     59
     60            static int   getSoftDebugLevel(OutputHandler::OutputDevice device = OutputHandler::LD_All);
     61            static void  setSoftDebugLevel(OutputHandler::OutputDevice device, int level);
    5962            static const std::string& getLanguage();
    60             static void resetLanguage();
     63            static void  resetLanguage();
    6164
    6265            // fast access global variables.
     
    7376
    7477        private:
     78            Core(const Core&);
    7579            void resetLanguageIntern();
    76 
    77             Core();
    78             Core(const Core& other);
    79             virtual ~Core();
     80            void initializeRandomNumberGenerator();
    8081
    8182            int softDebugLevel_;                            //!< The debug level
     
    8485            int softDebugLevelShell_;                       //!< The debug level for the ingame shell
    8586            std::string language_;                          //!< The language
     87            bool bInitializeRandomNumberGenerator_;          //!< If true, srand(time(0)) is called
    8688
    8789            static bool bShowsGraphics_s;                   //!< global variable that tells whether to show graphics
     
    9092            static bool bIsStandalone_s;
    9193            static bool bIsMaster_s;
     94
     95            static Core* singletonRef_s;
    9296    };
    9397}
  • code/trunk/src/core/CorePrereqs.h

    r2087 r2662  
    6969    {
    7070      LoadObject,
    71       SaveObject
     71      SaveObject,
     72      ExpandObject
    7273    };
    7374  }
     
    132133  class LanguageEntry;
    133134  class Loader;
     135  class LuaBind;
    134136  class MetaObjectList;
    135137  class MetaObjectListElement;
  • code/trunk/src/core/Factory.cc

    r2171 r2662  
    5858        @return The Identifier
    5959    */
    60     Identifier* Factory::getIdentifier(const unsigned int id)
     60    Identifier* Factory::getIdentifier(const uint32_t id)
    6161    {
    62         std::map<unsigned int, Identifier*>::const_iterator it = getFactoryPointer()->identifierNetworkIDMap_.find(id);
     62        std::map<uint32_t, Identifier*>::const_iterator it = getFactoryPointer()->identifierNetworkIDMap_.find(id);
    6363        if (it != getFactoryPointer()->identifierNetworkIDMap_.end())
    6464            return it->second;
     
    8585        @param newID The new networkID
    8686    */
    87     void Factory::changeNetworkID(Identifier* identifier, const unsigned int oldID, const unsigned int newID)
     87    void Factory::changeNetworkID(Identifier* identifier, const uint32_t oldID, const uint32_t newID)
    8888    {
    8989        getFactoryPointer()->identifierNetworkIDMap_.erase(oldID);
  • code/trunk/src/core/Factory.h

    r2171 r2662  
    4949#include <map>
    5050#include <string>
     51#include "util/Integers.h"
    5152
    5253namespace orxonox
     
    6061        public:
    6162            static Identifier* getIdentifier(const std::string& name);
    62             static Identifier* getIdentifier(const unsigned int id);
     63            static Identifier* getIdentifier(const uint32_t id);
    6364            static void add(const std::string& name, Identifier* identifier);
    64             static void changeNetworkID(Identifier* identifier, const unsigned int oldID, const unsigned int newID);
     65            static void changeNetworkID(Identifier* identifier, const uint32_t oldID, const uint32_t newID);
    6566            static void createClassHierarchy();
    6667
     
    8384
    8485            std::map<std::string, Identifier*> identifierStringMap_;            //!< The map, mapping the name with the Identifier
    85             std::map<unsigned int, Identifier*> identifierNetworkIDMap_;        //!< The map, mapping the network ID with the Identifier
     86            std::map<uint32_t, Identifier*> identifierNetworkIDMap_;        //!< The map, mapping the network ID with the Identifier
    8687    };
    8788
  • code/trunk/src/core/Functor.h

    r2087 r2662  
    167167            }
    168168
    169             FunctorMember* setObject(T* object)
     169            FunctorMember<T>* setObject(T* object)
    170170            {
    171171                this->bConstObject_ = false;
     
    174174            }
    175175
    176             FunctorMember* setObject(const T* object)
     176            FunctorMember<T>* setObject(const T* object)
    177177            {
    178178                this->bConstObject_ = true;
  • code/trunk/src/core/Identifier.cc

    r2171 r2662  
    9393        for (std::map<std::string, XMLPortObjectContainer*>::iterator it = this->xmlportObjectContainers_.begin(); it != this->xmlportObjectContainers_.end(); ++it)
    9494            delete (it->second);
     95        for (std::vector<Functor*>::iterator it = this->constructionCallbacks_.begin(); it != this->constructionCallbacks_.end(); ++it)
     96            delete *it;
     97    }
     98
     99    /**
     100        @brief Returns the identifier map with the names as received by typeid(). This is only used internally.
     101    */
     102    std::map<std::string, Identifier*>& Identifier::getTypeIDIdentifierMap()
     103    {
     104        static std::map<std::string, Identifier*> identifiers;    //!< The map to store all Identifiers.
     105        return identifiers;
    95106    }
    96107
     
    103114    Identifier* Identifier::getIdentifierSingleton(const std::string& name, Identifier* proposal)
    104115    {
    105         static std::map<std::string, Identifier*> identifiers;    //!< The map to store all Identifiers.
    106         std::map<std::string, Identifier*>::const_iterator it = identifiers.find(name);
    107 
    108         if (it != identifiers.end())
     116        std::map<std::string, Identifier*>::const_iterator it = getTypeIDIdentifierMap().find(name);
     117
     118        if (it != getTypeIDIdentifierMap().end())
    109119        {
    110120            // There is already an entry: return it and delete the proposal
     
    115125        {
    116126            // There is no entry: put the proposal into the map and return it
    117             identifiers[name] = proposal;
     127            getTypeIDIdentifierMap()[name] = proposal;
    118128            return proposal;
    119129        }
     
    192202    void Identifier::destroyAllIdentifiers()
    193203    {
    194         for (std::map<std::string, Identifier*>::iterator it = Identifier::getIdentifierMapIntern().begin(); it != Identifier::getIdentifierMapIntern().end(); ++it)
     204        for (std::map<std::string, Identifier*>::iterator it = Identifier::getTypeIDIdentifierMap().begin(); it != Identifier::getTypeIDIdentifierMap().end(); ++it)
    195205            delete (it->second);
    196206    }
     
    235245        @param id The new network ID
    236246    */
    237     void Identifier::setNetworkID(unsigned int id)
     247    void Identifier::setNetworkID(uint32_t id)
    238248    {
    239249        Factory::changeNetworkID(this, this->classID_, id);
  • code/trunk/src/core/Identifier.h

    r2171 r2662  
    6868#include "Super.h"
    6969#include "Functor.h"
     70#include "util/Integers.h"
    7071#include "util/Debug.h"
    7172#include "util/String.h"
     
    230231
    231232            /** @brief Returns the network ID to identify a class through the network. @return the network ID */
    232             inline const unsigned int getNetworkID() const { return this->classID_; }
     233            inline const uint32_t getNetworkID() const { return this->classID_; }
    233234
    234235            /** @brief Sets the network ID to a new value. @param id The new value */
    235             void setNetworkID(unsigned int id);
     236            void setNetworkID(uint32_t id);
    236237
    237238            void addConfigValueContainer(const std::string& varname, ConfigValueContainer* container);
     
    256257
    257258            void initializeClassHierarchy(std::set<const Identifier*>* parents, bool bRootClass);
     259
     260            static void destroyAllIdentifiers();
    258261
    259262        protected:
     
    299302            }
    300303
     304            static std::map<std::string, Identifier*>& getTypeIDIdentifierMap();
     305
    301306            void initialize(std::set<const Identifier*>* parents);
    302 
    303             static void destroyAllIdentifiers();
    304307
    305308            std::set<const Identifier*> parents_;                          //!< The parents of the class the Identifier belongs to
     
    315318            BaseFactory* factory_;                                         //!< The Factory, able to create new objects of the given class (if available)
    316319            static int hierarchyCreatingCounter_s;                         //!< Bigger than zero if at least one Identifier stores its parents (its an int instead of a bool to avoid conflicts with multithreading)
    317             unsigned int classID_;                                         //!< The network ID to identify a class through the network
     320            uint32_t classID_;                                             //!< The network ID to identify a class through the network
    318321
    319322            bool bHasConfigValues_;                                        //!< True if this class has at least one assigned config value
  • code/trunk/src/core/Iterator.h

    r2171 r2662  
    9696            inline Iterator(ObjectListElement<O>* element)
    9797            {
    98                 this->element_ = (element) ? (ObjectListBaseElement*)element : 0;
     98                this->element_ = (element) ? static_cast<ObjectListBaseElement*>(element) : 0;
    9999                this->list_ = ClassIdentifier<O>::getIdentifier()->getObjects();
    100100                this->iterator_ = this->list_->registerIterator(this);
     
    108108            inline Iterator(const ObjectListIterator<O>& other)
    109109            {
    110                 this->element_ = (other.element_) ? (ObjectListBaseElement*)other.element_ : 0;
     110                this->element_ = (other.element_) ? static_cast<ObjectListBaseElement*>(other.element_) : 0;
    111111                this->list_ = ClassIdentifier<O>::getIdentifier()->getObjects();
    112112                this->iterator_ = this->list_->registerIterator(this);
     
    163163                    this->list_->unregisterIterator(this->iterator_);
    164164
    165                 this->element_ = (element) ? (ObjectListBaseElement*)element : 0;
     165                this->element_ = (element) ? static_cast<ObjectListBaseElement*>(element) : 0;
    166166                this->list_ = ClassIdentifier<O>::getIdentifier()->getObjects();
    167167                this->iterator_ = this->list_->registerIterator(this);
  • code/trunk/src/core/Language.cc

    r2171 r2662  
    8787    // ###        Language         ###
    8888    // ###############################
     89
     90    Language* Language::singletonRef_s = 0;
     91
    8992    /**
    9093        @brief Constructor: Reads the default language file and sets some values.
     
    9295    Language::Language()
    9396    {
     97        assert(singletonRef_s == 0);
     98        singletonRef_s = this;
     99
    94100        this->defaultLanguage_ = "default";
    95101        this->defaultLocalisation_ = "ERROR: LANGUAGE ENTRY DOESN'T EXIST!";
     
    106112        for (std::map<std::string, LanguageEntry*>::iterator it = this->languageEntries_.begin(); it != this->languageEntries_.end(); ++it)
    107113            delete (it->second);
    108     }
    109 
    110     /**
    111         @brief Returns a reference to the only existing instance of the Language class and calls the setConfigValues() function.
    112         @return The reference to the only existing instance
    113     */
    114     Language& Language::getLanguage()
    115     {
    116         static Language instance = Language();
    117         return instance;
     114
     115        assert(singletonRef_s);
     116        singletonRef_s = 0;
    118117    }
    119118
     
    233232            if ((lineString != "") && (lineString.size() > 0))
    234233            {
    235                 unsigned int pos = lineString.find('=');
     234                size_t pos = lineString.find('=');
    236235
    237236                // Check if the length is at least 3 and if there's an entry before and behind the =
     
    279278            if ((lineString != "") && (lineString.size() > 0))
    280279            {
    281                 unsigned int pos = lineString.find('=');
     280                size_t pos = lineString.find('=');
    282281
    283282                // Check if the length is at least 3 and if there's an entry before and behind the =
  • code/trunk/src/core/Language.h

    r2171 r2662  
    5050#include <map>
    5151#include <string>
     52#include <cassert>
    5253
    5354#define AddLanguageEntry(label, fallbackstring) \
     
    116117
    117118        public:
    118             static Language& getLanguage();
     119            Language();
     120            ~Language();
     121
     122            static Language& getLanguage() { assert(singletonRef_s); return *singletonRef_s; }
    119123            void addEntry(const LanguageEntryLabel& label, const std::string& entry);
    120124            const std::string& getLocalisation(const LanguageEntryLabel& label) const;
    121125
    122126        private:
    123             Language();
    124             Language(const Language& language);     // don't copy
    125             virtual ~Language();
     127            Language(const Language&);
    126128
    127129            void readDefaultLanguageFile();
     
    134136            std::string defaultLocalisation_;                       //!< The returned string, if an entry unavailable entry is requested
    135137            std::map<std::string, LanguageEntry*> languageEntries_; //!< A map to store all LanguageEntry objects and their labels
     138
     139            static Language* singletonRef_s;
    136140    };
    137141}
  • code/trunk/src/core/Loader.cc

    r2171 r2662  
    120120
    121121        // let Lua work this out:
    122         LuaBind* lua = LuaBind::getInstance();
    123         lua->clearLuaOutput();
    124         lua->loadFile(file->getFilename(), true);
    125         lua->run();
     122        LuaBind& lua = LuaBind::getInstance();
     123        lua.clearLuaOutput();
     124        lua.loadFile(file->getFilename(), true);
     125        lua.run();
    126126
    127127        try
     
    135135            ticpp::Document xmlfile;
    136136            //xmlfile.ToDocument();
    137             xmlfile.Parse(lua->getLuaOutput(), true);
     137            xmlfile.Parse(lua.getLuaOutput(), true);
    138138
    139139            ticpp::Element rootElement;
  • code/trunk/src/core/LuaBind.cc

    r2508 r2662  
    4040namespace orxonox
    4141{
    42   LuaBind* LuaBind::singletonRef = NULL;
     42  LuaBind* LuaBind::singletonRef_s = NULL;
    4343
    4444  LuaBind::LuaBind()
    4545  {
     46    assert(LuaBind::singletonRef_s == 0);
     47    LuaBind::singletonRef_s = this;
     48
    4649    luaState_ = lua_open();
    4750    luaSource_ = "";
  • code/trunk/src/core/LuaBind.h

    r2087 r2662  
    4242}
    4343
     44#include <cassert>
    4445#include <list>
    4546#include <string>
     
    5859
    5960    public:
    60       inline static LuaBind* getInstance() { if (!LuaBind::singletonRef) LuaBind::singletonRef = new LuaBind(); return LuaBind::singletonRef; } // tolua_export
    61       inline ~LuaBind() { LuaBind::singletonRef = NULL; };
     61      LuaBind();
     62      inline ~LuaBind() { assert(singletonRef_s); LuaBind::singletonRef_s = NULL; };
     63
     64      inline static LuaBind& getInstance() { assert(singletonRef_s); return *LuaBind::singletonRef_s; } // tolua_export
    6265
    6366    void loadFile(std::string filename, bool luaTags);
     
    8386
    8487    private:
    85       LuaBind();
    86       static LuaBind* singletonRef;
     88      static LuaBind* singletonRef_s;
    8789
    8890      std::string luaSource_;
  • code/trunk/src/core/ObjectListIterator.h

    r1747 r2662  
    123123            {
    124124                if (this->element_)
    125                     this->element_ = (ObjectListElement<T>*)this->element_->next_;
     125                    this->element_ = static_cast<ObjectListElement<T>*>(this->element_->next_);
    126126                return *this;
    127127            }
     
    135135                ObjectListIterator<T> copy = *this;
    136136                if (this->element_)
    137                     this->element_ = (ObjectListElement<T>*)this->element_->next_;
     137                    this->element_ = static_cast<ObjectListElement<T>*>(this->element_->next_);
    138138                return copy;
    139139            }
     
    146146            {
    147147                if (this->element_)
    148                     this->element_ = (ObjectListElement<T>*)this->element_->prev_;
     148                    this->element_ = static_cast<ObjectListElement<T>*>(this->element_->prev_);
    149149                return *this;
    150150            }
     
    158158                ObjectListIterator<T> copy = *this;
    159159                if (this->element_)
    160                     this->element_ = (ObjectListElement<T>*)this->element_->prev_;
     160                    this->element_ = static_cast<ObjectListElement<T>*>(this->element_->prev_);
    161161                return copy;
    162162            }
  • code/trunk/src/core/RootGameState.cc

    r2103 r2662  
    3131#include "util/Debug.h"
    3232#include "util/Exception.h"
    33 #include "Core.h"
    3433#include "Clock.h"
    3534#include "CommandLine.h"
     
    123122    /**
    124123    @brief
     124        Main loop of the orxonox game.
    125125        Starts the game. The little 'while' denotes the main loop.
    126126        Whenever the root state is selected, the game ends.
    127127    @param name
    128128        State to start with (usually main menu or specified by command line)
     129    @note
     130        We use the Ogre::Timer to measure time since it uses the most precise
     131        method an a platform (however the windows timer lacks time when under
     132        heavy kernel load!).
    129133    */
    130134    void RootGameState::start()
    131135    {
    132 #ifdef NDEBUG
     136        // Don't catch errors when having a debugger in msvc
     137#if ORXONOX_COMPILER != ORXONOX_COMPILER_MSVC || defined(NDEBUG)
    133138        try
    134139        {
     
    136141            // start global orxonox time
    137142            Clock clock;
    138 
    139             // create the Core settings to configure the output level
    140             Core::getInstance();
    141143
    142144            this->activate();
     
    156158
    157159            this->deactivate();
    158 #ifdef NDEBUG
     160#if ORXONOX_COMPILER != ORXONOX_COMPILER_MSVC || defined(NDEBUG)
    159161        }
    160162        // Note: These are all unhandled exceptions that should not have made its way here!
     
    162164        catch (std::exception& ex)
    163165        {
    164             COUT(1) << ex.what() << std::endl;
    165             COUT(1) << "Program aborted." << std::endl;
     166            COUT(0) << ex.what() << std::endl;
     167            COUT(0) << "Program aborted." << std::endl;
     168            abort();
    166169        }
    167170        // anything that doesn't inherit from std::exception
    168171        catch (...)
    169172        {
    170             COUT(1) << "An unidentifiable exception has occured. Program aborted." << std::endl;
     173            COUT(0) << "An unidentifiable exception has occured. Program aborted." << std::endl;
     174            abort();
    171175        }
    172176#endif
  • code/trunk/src/core/RootGameState.h

    r2103 r2662  
    4848        void gotoState(const std::string& name);
    4949
    50         std::string           stateRequest_;
     50        std::string stateRequest_;
    5151    };
    5252}
  • code/trunk/src/core/Shell.cc

    r1792 r2662  
    7575
    7676        this->outputBuffer_.registerListener(this);
    77         OutputHandler::getOutStream().setOutputBuffer(this->outputBuffer_);
     77        OutputHandler::getOutStream().setOutputBuffer(&this->outputBuffer_);
    7878
    7979        this->setConfigValues();
     
    8484    Shell::~Shell()
    8585    {
     86        OutputHandler::getOutStream().setOutputBuffer(0);
    8687        if (this->inputBuffer_)
    8788            delete this->inputBuffer_;
  • code/trunk/src/core/Super.h

    r2171 r2662  
    9999            \
    100100            static void apply(void* temp) {} \
     101            \
    101102            static void apply(baseclass* temp) \
    102103            { \
     
    104105                for (std::set<const Identifier*>::iterator it = identifier->getDirectChildrenIntern().begin(); it != identifier->getDirectChildrenIntern().end(); ++it) \
    105106                { \
     107                    if (((ClassIdentifier<T>*)(*it))->bSuperFunctionCaller_##functionname##_isFallback_ && ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_) \
     108                    { \
     109                        delete ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_; \
     110                        ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_ = 0; \
     111                        ((ClassIdentifier<T>*)(*it))->bSuperFunctionCaller_##functionname##_isFallback_ = false; \
     112                    } \
     113                    \
    106114                    if (!((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_) \
    107115                    { \
     
    163171                for (std::set<const Identifier*>::iterator it = identifier->getDirectChildrenIntern().begin(); it != identifier->getDirectChildrenIntern().end(); ++it)
    164172                {
     173                    // Check if the caller is a fallback-caller
     174                    if (((ClassIdentifier<T>*)(*it))->bSuperFunctionCaller_##functionname##_isFallback_ && ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_)
     175                    {
     176                        // Delete the fallback caller an prepare to get a real caller
     177                        delete ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_;
     178                        ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_ = 0;
     179                        ((ClassIdentifier<T>*)(*it))->bSuperFunctionCaller_##functionname##_isFallback_ = false;
     180                    }
     181
    165182                    // Check if there's not already a caller
    166183                    if (!((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_)
     
    183200        struct SuperFunctionCondition<functionnumber, baseclass, 0, templatehack2> \
    184201        { \
    185             // The check function just behaves like the fallback - it advances to the check for the next super-function (functionnumber + 1)
     202            // The check function acts like the fallback - it advances to the check for the next super-function (functionnumber + 1)
    186203            static void check() \
    187204            { \
     
    233250    #define SUPER_processEvent(classname, functionname, ...) \
    234251        SUPER_ARGS(classname, functionname, __VA_ARGS__)
     252
     253    #define SUPER_changedScale(classname, functionname, ...) \
     254        SUPER_NOARGS(classname, functionname)
     255
     256    #define SUPER_changedMainState(classname, functionname, ...) \
     257        SUPER_NOARGS(classname, functionname)
     258
     259    #define SUPER_changedOwner(classname, functionname, ...) \
     260        SUPER_NOARGS(classname, functionname)
     261
     262    #define SUPER_changedOverlayGroup(classname, functionname, ...) \
     263        SUPER_NOARGS(classname, functionname)
     264
     265    #define SUPER_changedName(classname, functionname, ...) \
     266        SUPER_NOARGS(classname, functionname)
     267
     268    #define SUPER_changedGametype(classname, functionname, ...) \
     269        SUPER_NOARGS(classname, functionname)
    235270    // (1/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
    236271
     
    292327            }; \
    293328            \
     329            class _CoreExport SuperFunctionCaller_##functionname \
     330            { \
     331                public: \
     332                    virtual void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) ) = 0; \
     333                    virtual ~SuperFunctionCaller_##functionname () {} \
     334            }; \
     335            \
     336            template <class T> \
     337            class SuperFunctionClassCaller_purevirtualfallback_##functionname : public SuperFunctionCaller_##functionname \
     338            { \
     339                public: \
     340                    inline void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) ) \
     341                    { \
     342                    } \
     343            }; \
     344            \
    294345            template <class T> \
    295346            struct SuperFunctionInitialization<functionnumber, T> \
     
    297348                static void initialize(ClassIdentifier<T>* identifier) \
    298349                { \
    299                     identifier->superFunctionCaller_##functionname##_ = 0; \
     350                    identifier->superFunctionCaller_##functionname##_ = new SuperFunctionClassCaller_purevirtualfallback_##functionname <T>; \
     351                    identifier->bSuperFunctionCaller_##functionname##_isFallback_ = true; \
    300352                    SuperFunctionInitialization<functionnumber + 1, T>::initialize(identifier); \
    301353                } \
     
    313365            }; \
    314366            \
    315             class _CoreExport SuperFunctionCaller_##functionname \
    316             { \
    317                 public: \
    318                     virtual void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) ) = 0; \
    319                     virtual ~SuperFunctionCaller_##functionname () {} \
    320             }; \
    321             \
    322367            template <class T> \
    323368            class SuperFunctionClassCaller_##functionname : public SuperFunctionCaller_##functionname \
     
    366411        };
    367412
    368         // Initializes the SuperFunctionCaller-pointer with zero.
     413        // Baseclass of the super-function caller. The real call will be done by a
     414        // templatized subclass through the virtual () operator.
     415        class _CoreExport SuperFunctionCaller_##functionname
     416        {
     417            public:
     418                virtual void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) ) = 0;
     419                virtual ~SuperFunctionCaller_##functionname () {}
     420        };
     421
     422        // Fallback if the base is pure virtual
     423        template <class T>
     424        class SuperFunctionClassCaller_purevirtualfallback_##functionname : public SuperFunctionCaller_##functionname
     425        {
     426            public:
     427                // Fallback does nothing
     428                inline void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) )
     429                {
     430                }
     431        };
     432
     433        // Initializes the SuperFunctionCaller-pointer with a fallback caller in case the base function is pure virtual
    369434        template <class T>
    370435        struct SuperFunctionInitialization<functionnumber, T>
     
    372437            static void initialize(ClassIdentifier<T>* identifier)
    373438            {
    374                 identifier->superFunctionCaller_##functionname##_ = 0;
     439                identifier->superFunctionCaller_##functionname##_ = new SuperFunctionClassCaller_purevirtualfallback_##functionname <T>;
     440                identifier->bSuperFunctionCaller_##functionname##_isFallback_ = true;
    375441
    376442                // Calls the initialization of the next super-function (functionnumber + 1)
     
    391457                SuperFunctionDestruction<functionnumber + 1, T>::destroy(identifier);
    392458            }
    393         };
    394 
    395         // Baseclass of the super-function caller. The real call will be done by a
    396         // templatized subclass through the virtual () operator.
    397         class _CoreExport SuperFunctionCaller_##functionname
    398         {
    399             public:
    400                 virtual void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) ) = 0;
    401                 virtual ~SuperFunctionCaller_##functionname () {}
    402459        };
    403460
     
    441498            (event)
    442499        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
     500
     501        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(5, changedScale, false)
     502            ()
     503        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
     504
     505        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(6, changedMainState, false)
     506            ()
     507        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
     508
     509        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(7, changedOwner, false)
     510            ()
     511        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
     512
     513        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(8, changedOverlayGroup, false)
     514            ()
     515        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
     516
     517        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(9, changedName, false)
     518            ()
     519        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
     520
     521        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(10, changedGametype, false)
     522            ()
     523        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
    443524        // (2/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
    444525
     
    476557        #ifndef SUPER_INTRUSIVE_DECLARATION
    477558          #define SUPER_INTRUSIVE_DECLARATION(functionname) \
    478             SuperFunctionCaller_##functionname * superFunctionCaller_##functionname##_
     559            SuperFunctionCaller_##functionname * superFunctionCaller_##functionname##_; \
     560            bool bSuperFunctionCaller_##functionname##_isFallback_
    479561        #endif
    480562
     
    488570    SUPER_INTRUSIVE_DECLARATION(changedVisibility);
    489571    SUPER_INTRUSIVE_DECLARATION(processEvent);
     572    SUPER_INTRUSIVE_DECLARATION(changedScale);
     573    SUPER_INTRUSIVE_DECLARATION(changedMainState);
     574    SUPER_INTRUSIVE_DECLARATION(changedOwner);
     575    SUPER_INTRUSIVE_DECLARATION(changedOverlayGroup);
     576    SUPER_INTRUSIVE_DECLARATION(changedName);
     577    SUPER_INTRUSIVE_DECLARATION(changedGametype);
    490578    // (3/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
    491579
  • code/trunk/src/core/Template.cc

    r2261 r2662  
    4343
    4444        this->bIsLink_ = false;
     45        this->bLoadDefaults_ = true;
    4546        this->bIsReturningXMLElement_ = false;
    4647        this->baseclassIdentifier_ = 0;
     
    5657        SUPER(Template, XMLPort, xmlelement, mode);
    5758
    58         XMLPortParam(Template, "link", setLink, getLink, xmlelement, mode);
    59         XMLPortParam(Template, "baseclass", setBaseclass, getBaseclass, xmlelement, mode);
     59        XMLPortParam(Template, "link",      setLink,         getLink,         xmlelement, mode);
     60        XMLPortParam(Template, "baseclass", setBaseclass,    getBaseclass,    xmlelement, mode);
     61        XMLPortParam(Template, "defaults",  setLoadDefaults, getLoadDefaults, xmlelement, mode).defaultValues(true);
    6062
    6163        Element* element = xmlelement.FirstChildElement(false);
     
    7072    void Template::changedName()
    7173    {
     74        SUPER(Template, changedName);
     75
    7276        if (this->getName() != "")
    7377        {
     
    134138
    135139        Element temp = ((TiXmlElement*)&this->getXMLElement());
    136         object->XMLPort(temp, XMLPort::LoadObject);
     140
     141        if (this->bLoadDefaults_)
     142            object->XMLPort(temp, XMLPort::LoadObject);
     143        else
     144            object->XMLPort(temp, XMLPort::ExpandObject);
    137145    }
    138146
  • code/trunk/src/core/Template.h

    r2261 r2662  
    5353                { return this->link_; }
    5454
     55            inline void setLoadDefaults(bool bLoadDefaults)
     56                { this->bLoadDefaults_ = bLoadDefaults; }
     57            inline bool getLoadDefaults() const
     58                { return this->bLoadDefaults_; }
     59
    5560            inline void setXMLElement(const TiXmlElement& xmlelement)
    5661                { this->xmlelement_ = xmlelement; }
     
    7580            Identifier* baseclassIdentifier_;
    7681            bool bIsLink_;
     82            bool bLoadDefaults_;
    7783            mutable bool bIsReturningXMLElement_;
    7884    };
  • code/trunk/src/core/XMLFile.h

  • code/trunk/src/core/XMLIncludes.h

    r2261 r2662  
    6464namespace orxonox
    6565{
    66     typedef ticpp::Document Document;
    67     typedef ticpp::Element Element;
    68     typedef ticpp::Declaration Declaration;
    69     typedef ticpp::StylesheetReference StylesheetReference;
    70     typedef ticpp::Text Text;
    71     typedef ticpp::Comment Comment;
    72     typedef ticpp::Attribute Attribute;
     66    using ticpp::Document;
     67    using ticpp::Element;
     68    using ticpp::Declaration;
     69    using ticpp::StylesheetReference;
     70    using ticpp::Text;
     71    using ticpp::Comment;
     72    using ticpp::Attribute;
    7373}
  • code/trunk/src/core/XMLPort.h

    r2171 r2662  
    4343#include "CorePrereqs.h"
    4444
     45#include <cassert>
    4546#include "util/Debug.h"
    4647#include "util/Exception.h"
     
    7475    static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \
    7576    XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, classname, this, paramname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode)
     77
     78/**
     79    @brief Declares an XML attribute with a name, which will be set through a variable.
     80    @param classname The name of the class owning this param
     81    @param paramname The name of the attribute
     82    @param variable Name of the variable used to save and load the value
     83    @param xmlelement The XMLElement, you get this from the XMLPort function
     84    @param mode The mode (load or save), you get this from the XMLPort function
     85
     86    In the XML file, a param or attribute will be set like this:
     87    <classname paramname="value" />
     88
     89    The macro will then store "value" in the variable or read it when saving.
     90*/
     91#define XMLPortParamVariable(classname, paramname, variable, xmlelement, mode) \
     92    XMLPortVariableHelperClass xmlcontainer##variable##dummy((void*)&variable); \
     93    static ExecutorMember<orxonox::XMLPortVariableHelperClass>* xmlcontainer##variable##loadexecutor = static_cast<ExecutorMember<orxonox::XMLPortVariableHelperClass>*>(orxonox::createExecutor(orxonox::createFunctor(orxonox::XMLPortVariableHelperClass::getLoader(variable)), std::string( #classname ) + "::" + #variable + "loader")); \
     94    static ExecutorMember<orxonox::XMLPortVariableHelperClass>* xmlcontainer##variable##saveexecutor = static_cast<ExecutorMember<orxonox::XMLPortVariableHelperClass>*>(orxonox::createExecutor(orxonox::createFunctor(orxonox::XMLPortVariableHelperClass::getSaver (variable)), std::string( #classname ) + "::" + #variable + "saver" )); \
     95    XMLPortParamGeneric(xmlcontainer##variable, classname, orxonox::XMLPortVariableHelperClass, &xmlcontainer##variable##dummy, paramname, xmlcontainer##variable##loadexecutor, xmlcontainer##variable##saveexecutor, xmlelement, mode)
     96
    7697/**
    7798    @brief This is the same as XMLPortParam, but you can set the template arguments needed to store the loadfunction.
     
    161182        ClassIdentifier<classname>::getIdentifier()->addXMLPortParamContainer(paramname, containername); \
    162183    } \
    163     containername->port((BaseObject*)this, object, xmlelement, mode)
     184    containername->port(static_cast<BaseObject*>(this), object, xmlelement, mode)
    164185
    165186// --------------------
     
    175196    @param xmlelement The XMLElement (recieved through the XMLPort function)
    176197    @param mode The mode (load/save) (received through the XMLPort function)
    177     @param bApplyLoaderMask If this is true, an added sub-object only gets loaded if it's class is included in the Loaders ClassTreeMask (this is usually false)
    178     @param bLoadBefore If this is true, the sub-cobject gets loaded (through XMLPort) BEFORE it gets added to the main class (this is usually true)
     198    @param bApplyLoaderMask If this is true, an added sub-object gets loaded only if it's class is included in the Loaders ClassTreeMask (this is usually false)
     199    @param bLoadBefore If this is true, the sub-object gets loaded (through XMLPort) BEFORE it gets added to the main class (this is usually true)
    179200
    180201    bApplyLoaderMask is usually false for the following reason:
     
    183204    Of course, if there are "standalone" weapons in the level, they wont be loaded.
    184205
    185     If bLoadBefore, an added object already has all attributes set (like it's name). This is most
     206    If bLoadBefore is true, an added object already has all attributes set (like it's name). This is most
    186207    likely the best option, so this is usually true.
    187208
     
    222243    Note that "weapons" is the subsection. This allows you to add more types of sub-objects. In our example,
    223244    you could add pilots, blinking lights or other stuff. If you don't want a subsection, just use "" (an
    224     empty string). The you can add sub-objects directly into the mainclass.
     245    empty string). Then you can add sub-objects directly into the mainclass.
    225246*/
    226247#define XMLPortObjectExtended(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, mode, bApplyLoaderMask, bLoadBefore) \
     
    329350            }
    330351
     352            ~XMLPortClassParamContainer()
     353            {
     354                assert(this->loadexecutor_);
     355                delete this->loadexecutor_;
     356                if (this->saveexecutor_)
     357                    delete this->saveexecutor_;
     358            }
     359
    331360            XMLPortParamContainer& port(BaseObject* owner, T* object, Element& xmlelement, XMLPort::Mode mode)
    332361            {
     362                OrxAssert(owner, "XMLPortParamContainer must have a BaseObject as owner.");
    333363                this->owner_ = owner;
    334364                this->parseParams_.object = object;
     
    336366                this->parseParams_.mode = mode;
    337367
    338                 if (mode == XMLPort::LoadObject)
     368                if ((mode == XMLPort::LoadObject) || (mode == XMLPort::ExpandObject))
    339369                {
    340370                    try
    341371                    {
    342                         std::string attribute = xmlelement.GetAttribute(this->paramname_);
    343                         if ((attribute.size() > 0) || (this->loadexecutor_->allDefaultValuesSet()))
     372                        if (this->owner_->lastLoadedXMLElement_ != &xmlelement)
     373                        {
     374                            this->owner_->xmlAttributes_.clear();
     375                            // Iterate through the attributes manually in order to make them case insensitive
     376                            Attribute* attribute = xmlelement.FirstAttribute(false);
     377                            while (attribute != 0)
     378                            {
     379                                this->owner_->xmlAttributes_[getLowercase(attribute->Name())] = attribute->Value();
     380                                attribute = attribute->Next(false);
     381                            }
     382                            this->owner_->lastLoadedXMLElement_ = &xmlelement;
     383                        }
     384                        std::map<std::string, std::string>::const_iterator it = this->owner_->xmlAttributes_.find(getLowercase(this->paramname_));
     385                        std::string attributeValue("");
     386                        if (it != this->owner_->xmlAttributes_.end())
     387                            attributeValue = it->second;
     388
     389                        // TODO: Checking the iterator would be better since then we can have strings with value "" as well.
     390                        //       Unfortunately this does not seem to work with the Executor parser yet.
     391                        if ((!attributeValue.empty()) || ((mode != XMLPort::ExpandObject) && this->loadexecutor_->allDefaultValuesSet()))
    344392                        {
    345393                            COUT(5) << this->owner_->getLoaderIndentation() << "Loading parameter " << this->paramname_ << " in " << this->identifier_->getName() << " (objectname " << this->owner_->getName() << ")." << std::endl << this->owner_->getLoaderIndentation();
    346                             if (this->loadexecutor_->parse(object, attribute, ","))
     394                            if (this->loadexecutor_->parse(object, attributeValue, ",") || (mode  == XMLPort::ExpandObject))
    347395                                this->parseResult_ = PR_finished;
    348396                            else
    349397                                this->parseResult_ = PR_waiting_for_default_values;
    350398                        }
     399                        else if (mode == XMLPort::ExpandObject)
     400                            this->parseResult_ = PR_finished;
    351401                        else
    352402                            this->parseResult_ = PR_waiting_for_default_values;
     
    471521            }
    472522
     523            ~XMLPortClassObjectContainer()
     524            {
     525                assert(this->loadexecutor_);
     526                delete this->loadexecutor_;
     527                if (this->saveexecutor_)
     528                    delete this->saveexecutor_;
     529            }
     530
    473531            XMLPortObjectContainer& port(T* object, Element& xmlelement, XMLPort::Mode mode)
    474532            {
    475                 if (mode == XMLPort::LoadObject)
     533                if ((mode == XMLPort::LoadObject) || (mode == XMLPort::ExpandObject))
    476534                {
    477535                    try
     
    588646            ExecutorMember<T>* saveexecutor_;
    589647    };
     648
     649
     650    // ####################################
     651    // ###  XMLPortVariableHelperClass  ###
     652    // ####################################
     653    /**
     654    @brief
     655        Helper class to load and save simple variables with XMLPort.
     656
     657        getLoader and getSaver were necessary to get the type T with
     658        the help of template function type deduction (const T& is unused).
     659        These functions return the adress of save<T> or load<T>.
     660    */
     661    class XMLPortVariableHelperClass
     662    {
     663        public:
     664            XMLPortVariableHelperClass(void* var)
     665                : variable_(var)
     666                { }
     667
     668            template <class T>
     669            void load(const T& value)
     670                { *((T*)this->variable_) = value; }
     671
     672            template <class T>
     673            const T& save()
     674                { return *((T*)this->variable_); }
     675
     676            template <class T>
     677            static void (XMLPortVariableHelperClass::*getLoader(const T& var))(const T& value)
     678                { return &XMLPortVariableHelperClass::load<T>; }
     679
     680            template <class T>
     681            static const T& (XMLPortVariableHelperClass::*getSaver(const T& var))()
     682                { return &XMLPortVariableHelperClass::save<T>; }
     683
     684        private:
     685            void* variable_;
     686    };
    590687}
    591688
  • code/trunk/src/core/input/Button.cc

    r2103 r2662  
    5959        nCommands_[1]=0;
    6060        nCommands_[2]=0;
     61        this->configContainer_ = 0;
    6162        clear();
     63    }
     64
     65    Button::~Button()
     66    {
     67        this->clear();
     68
     69        if (this->configContainer_)
     70            delete this->configContainer_;
    6271    }
    6372
  • code/trunk/src/core/input/Button.h

    r2103 r2662  
    4949    public:
    5050        Button();
    51         virtual ~Button() { clear(); }
     51        virtual ~Button();
    5252        virtual void clear();
    5353        virtual bool addParamCommand(ParamCommand* command) { return false; }
  • code/trunk/src/core/input/InputBuffer.cc

    r1755 r2662  
    7373    }
    7474
     75    InputBuffer::~InputBuffer()
     76    {
     77        for (std::list<BaseInputBufferListenerTuple*>::const_iterator it = this->listeners_.begin();
     78            it != this->listeners_.end(); ++it)
     79            delete *it;
     80    }
     81
    7582    void InputBuffer::setConfigValues()
    7683    {
  • code/trunk/src/core/input/InputBuffer.h

    r1887 r2662  
    7979        public:
    8080            InputBuffer();
     81            ~InputBuffer();
    8182            InputBuffer(const std::string allowedChars);
    8283
  • code/trunk/src/core/input/InputInterfaces.h

    r1887 r2662  
    378378        const char* const ByString[] =
    379379        {
    380             "Button0",       "Button1",       "Button2",       "Button3",
    381             "Button4",       "Button5",       "Button6",       "Button7",
    382             "Button8",       "Button9",       "Button10",      "Button11",
     380            "Button00",      "Button01",      "Button02",      "Button03",
     381            "Button04",      "Button05",      "Button06",      "Button07",
     382            "Button08",      "Button09",      "Button10",      "Button11",
    383383            "Button12",      "Button13",      "Button14",      "Button15",
    384384            "Button16",      "Button17",      "Button18",      "Button19",
     
    416416            "Slider0", "Slider1", "Slider2", "Slider3",
    417417            "Slider4", "Slider5", "Slider6", "Slider7",
    418             "Axis0",   "Axis1",   "Axis2",   "Axis3",
    419             "Axis4",   "Axis5",   "Axis6",   "Axis7",
    420             "Axis8",   "Axis9",   "Axis10",  "Axis11",
     418            "Axis00",  "Axis01",  "Axis02",  "Axis03",
     419            "Axis04",  "Axis05",  "Axis06",  "Axis07",
     420            "Axis08",  "Axis09",  "Axis10",  "Axis11",
    421421            "Axis12",  "Axis13",  "Axis14",  "Axis15"
    422422        };
  • code/trunk/src/core/input/InputManager.cc

    r2103 r2662  
    6565    SetCommandLineSwitch(keyboard_no_grab);
    6666
    67     std::string InputManager::bindingCommmandString_s = "";
    6867    EmptyHandler InputManager::EMPTY_HANDLER;
    6968    InputManager* InputManager::singletonRef_s = 0;
     
    112111        , keyDetector_(0)
    113112        , calibratorCallbackBuffer_(0)
    114         , bCalibrating_(false)
    115113        , keyboardModifiers_(0)
    116114    {
     
    119117        assert(singletonRef_s == 0);
    120118        singletonRef_s = this;
     119
     120        setConfigValues();
     121    }
     122
     123    /**
     124    @brief
     125        Sets the configurable values.
     126    */
     127    void InputManager::setConfigValues()
     128    {
     129        SetConfigValue(calibrationFilename_, "joystick_calibration.ini")
     130            .description("Ini filename for the the joy stick calibration data.")
     131            .callback(this, &InputManager::_calibrationFileCallback);
     132    }
     133
     134    /**
     135    @brief
     136        Callback for the joy stick calibration config file. @see setConfigValues.
     137    */
     138    void InputManager::_calibrationFileCallback()
     139    {
     140        ConfigFileManager::getInstance().setFilename(ConfigFileType::JoyStickCalibration, calibrationFilename_);
    121141    }
    122142
     
    174194            if (joyStickSupport)
    175195                _initialiseJoySticks();
    176             // Do this anyway to also inform everyone if a joystick was detached.
    177             _configureNumberOfJoySticks();
     196            // Do this anyway to also inform everything when a joystick was detached.
     197            _configureJoySticks();
    178198
    179199            // Set mouse/joystick region
     
    183203            // clear all buffers
    184204            _clearBuffers();
    185 
    186             // load joy stick calibration
    187             setConfigValues();
    188205
    189206            internalState_ |= OISReady;
     
    335352    /**
    336353    @brief
     354        Helper function that loads the config value vector of one coefficient
     355    */
     356    void loadCalibration(std::vector<int>& list, const std::string& sectionName, const std::string& valueName, size_t size, int defaultValue)
     357    {
     358        list.resize(size);
     359        unsigned int configValueVectorSize = ConfigFileManager::getInstance().getVectorSize(ConfigFileType::JoyStickCalibration, sectionName, valueName);
     360        if (configValueVectorSize > size)
     361            configValueVectorSize = size;
     362
     363        for (unsigned int i = 0; i < configValueVectorSize; ++i)
     364        {
     365            list[i] = omni_cast<int>(ConfigFileManager::getInstance().getValue(
     366                ConfigFileType::JoyStickCalibration, sectionName, valueName, i, omni_cast<std::string>(defaultValue), false));
     367        }
     368
     369        // fill the rest with default values
     370        for (unsigned int i = configValueVectorSize; i < size; ++i)
     371        {
     372            list[i] = defaultValue;
     373        }
     374    }
     375
     376    /**
     377    @brief
    337378        Sets the size of all the different lists that are dependent on the number
    338         of joy stick devices created.
     379        of joy stick devices created and loads the joy stick calibration.
    339380    @remarks
    340381        No matter whether there are a mouse and/or keyboard, they will always
    341382        occupy 2 places in the device number dependent lists.
    342383    */
    343     void InputManager::_configureNumberOfJoySticks()
     384    void InputManager::_configureJoySticks()
    344385    {
    345386        joySticksSize_ = joySticks_.size();
    346         devicesNum_ = 2 + joySticksSize_;
     387        devicesNum_    = 2 + joySticksSize_;
     388        joyStickIDs_         .resize(joySticksSize_);
    347389        joyStickButtonsDown_ .resize(joySticksSize_);
    348390        povStates_           .resize(joySticksSize_);
    349391        sliderStates_        .resize(joySticksSize_);
    350         joySticksCalibration_.resize(joySticksSize_);
     392        joyStickMinValues_   .resize(joySticksSize_);
     393        joyStickMaxValues_   .resize(joySticksSize_);
     394        joyStickMiddleValues_.resize(joySticksSize_);
     395        joyStickCalibrations_.resize(joySticksSize_);
    351396
    352397        for (unsigned int iJoyStick = 0; iJoyStick < joySticksSize_; iJoyStick++)
    353398        {
    354             // reset the calibration with default values
    355             for (unsigned int i = 0; i < 24; i++)
    356             {
    357                 joySticksCalibration_[iJoyStick].negativeCoeff[i] = 1.0f/32767.0f;
    358                 joySticksCalibration_[iJoyStick].positiveCoeff[i] = 1.0f/32768.0f;
    359                 joySticksCalibration_[iJoyStick].zeroStates[i] = 0;
    360             }
    361         }
     399            // Generate some sort of execution unique id per joy stick
     400            std::string id = "JoyStick_";
     401            id += omni_cast<std::string>(joySticks_[iJoyStick]->getNumberOfComponents(OIS::OIS_Button))  + "_";
     402            id += omni_cast<std::string>(joySticks_[iJoyStick]->getNumberOfComponents(OIS::OIS_Axis))    + "_";
     403            id += omni_cast<std::string>(joySticks_[iJoyStick]->getNumberOfComponents(OIS::OIS_Slider))  + "_";
     404            id += omni_cast<std::string>(joySticks_[iJoyStick]->getNumberOfComponents(OIS::OIS_POV))     + "_";
     405            id += omni_cast<std::string>(joySticks_[iJoyStick]->getNumberOfComponents(OIS::OIS_Vector3)) + "_";
     406            id += joySticks_[iJoyStick]->vendor();
     407            for (unsigned int i = 0; i < iJoyStick; ++i)
     408            {
     409                if (id == joyStickIDs_[i])
     410                {
     411                    // Two joysticks are probably equal --> add the index as well
     412                    id += "_" + omni_cast<std::string>(iJoyStick);
     413                }
     414            }
     415            joyStickIDs_[iJoyStick] = id;
     416
     417            size_t axes = sliderAxes + (size_t)this->joySticks_[iJoyStick]->getNumberOfComponents(OIS::OIS_Axis);
     418            loadCalibration(joyStickMinValues_[iJoyStick], id, "MinValue", axes, -32768);
     419            loadCalibration(joyStickMaxValues_[iJoyStick], id, "MaxValue", axes,  32768);
     420            loadCalibration(joyStickMiddleValues_[iJoyStick], id, "MiddleValue", axes,      0);
     421        }
     422
     423        _evaluateCalibration();
    362424
    363425        // state management
     
    380442    }
    381443
    382     /**
    383     @brief
    384         Sets the configurable values.
    385         This mainly concerns joy stick calibrations.
    386     */
    387     void InputManager::setConfigValues()
    388     {
    389         if (joySticksSize_ > 0)
    390         {
    391             std::vector<double> coeffPos;
    392             std::vector<double> coeffNeg;
    393             std::vector<int> zero;
    394             coeffPos.resize(24);
    395             coeffNeg.resize(24);
    396             zero.resize(24);
    397             for (unsigned int i = 0; i < 24; i++)
    398             {
    399                 coeffPos[i] =  1.0f/32767.0f;
    400                 coeffNeg[i] =  1.0f/32768.0f;
    401                 zero[i]     =  0;
    402             }
    403 
    404             ConfigValueContainer* cont = getIdentifier()->getConfigValueContainer("CoeffPos");
    405             if (!cont)
    406             {
    407                 cont = new ConfigValueContainer(ConfigFileType::Settings, getIdentifier(), getIdentifier()->getName(), "CoeffPos", coeffPos);
    408                 getIdentifier()->addConfigValueContainer("CoeffPos", cont);
    409             }
    410             cont->getValue(&coeffPos, this);
    411 
    412             cont = getIdentifier()->getConfigValueContainer("CoeffNeg");
    413             if (!cont)
    414             {
    415                 cont = new ConfigValueContainer(ConfigFileType::Settings, getIdentifier(), getIdentifier()->getName(), "CoeffNeg", coeffNeg);
    416                 getIdentifier()->addConfigValueContainer("CoeffNeg", cont);
    417             }
    418             cont->getValue(&coeffNeg, this);
    419 
    420             cont = getIdentifier()->getConfigValueContainer("Zero");
    421             if (!cont)
    422             {
    423                 cont = new ConfigValueContainer(ConfigFileType::Settings, getIdentifier(), getIdentifier()->getName(), "Zero", zero);
    424                 getIdentifier()->addConfigValueContainer("Zero", cont);
    425             }
    426             cont->getValue(&zero, this);
    427 
    428             // copy values to our own variables
    429             for (unsigned int i = 0; i < 24; i++)
    430             {
    431                 joySticksCalibration_[0].positiveCoeff[i] = coeffPos[i];
    432                 joySticksCalibration_[0].negativeCoeff[i] = coeffNeg[i];
    433                 joySticksCalibration_[0].zeroStates[i]    = zero[i];
    434             }
    435         }
    436     }
    437 
     444    void InputManager::_evaluateCalibration()
     445    {
     446        for (unsigned int iJoyStick = 0; iJoyStick < this->joySticksSize_; ++iJoyStick)
     447        {
     448            for (unsigned int i = 0; i < this->joyStickMinValues_[iJoyStick].size(); i++)
     449            {
     450                this->joyStickCalibrations_[iJoyStick].middleValue[i] = this->joyStickMiddleValues_[iJoyStick][i];
     451                this->joyStickCalibrations_[iJoyStick].negativeCoeff[i] = - 1.0f / (this->joyStickMinValues_[iJoyStick][i] - this->joyStickMiddleValues_[iJoyStick][i]);
     452                this->joyStickCalibrations_[iJoyStick].positiveCoeff[i] =   1.0f / (this->joyStickMaxValues_[iJoyStick][i] - this->joyStickMiddleValues_[iJoyStick][i]);
     453            }
     454        }
     455    }
     456   
     457    void InputManager::_startCalibration()
     458    {
     459        for (unsigned int iJoyStick = 0; iJoyStick < this->joySticksSize_; ++iJoyStick)
     460        {
     461            // Set initial values
     462            for (unsigned int i = 0; i < this->joyStickMinValues_[iJoyStick].size(); ++i)
     463                this->joyStickMinValues_[iJoyStick][i] = INT_MAX;
     464            for (unsigned int i = 0; i < this->joyStickMaxValues_[iJoyStick].size(); ++i)
     465                this->joyStickMaxValues_[iJoyStick][i] = INT_MIN;
     466            for (unsigned int i = 0; i < this->joyStickMiddleValues_[iJoyStick].size(); ++i)
     467                this->joyStickMiddleValues_[iJoyStick][i] = 0;
     468        }
     469
     470        getInstance().internalState_ |= Calibrating;
     471        getInstance().requestEnterState("calibrator");
     472    }
     473
     474    void InputManager::_completeCalibration()
     475    {
     476        for (unsigned int iJoyStick = 0; iJoyStick < this->joySticksSize_; ++iJoyStick)
     477        {
     478            // Get the middle positions now
     479            unsigned int iAxis = 0;
     480            for (unsigned int i = 0; i < sliderAxes/2; ++i)
     481            {
     482                this->joyStickMiddleValues_[iJoyStick][iAxis++] = this->joySticks_[iJoyStick]->getJoyStickState().mSliders[i].abX;
     483                this->joyStickMiddleValues_[iJoyStick][iAxis++] = this->joySticks_[iJoyStick]->getJoyStickState().mSliders[i].abY;
     484            }
     485            // Note: joyStickMiddleValues_[iJoyStick] was already correctly resized in _configureJoySticks()
     486            assert(joySticks_[iJoyStick]->getJoyStickState().mAxes.size() == joyStickMiddleValues_[iJoyStick].size() - sliderAxes);
     487            for (unsigned int i = 0; i < joyStickMiddleValues_[iJoyStick].size() - sliderAxes; ++i)
     488            {
     489                this->joyStickMiddleValues_[iJoyStick][iAxis++] = this->joySticks_[iJoyStick]->getJoyStickState().mAxes[i].abs;
     490            }
     491
     492            for (unsigned int i = 0; i < joyStickMinValues_[iJoyStick].size(); ++i)
     493            {
     494                // Minimum values
     495                if (joyStickMinValues_[iJoyStick][i] == INT_MAX)
     496                    joyStickMinValues_[iJoyStick][i] = -32768;
     497                ConfigFileManager::getInstance().setValue(ConfigFileType::JoyStickCalibration,
     498                    this->joyStickIDs_[iJoyStick], "MinValue", i, omni_cast<std::string>(joyStickMinValues_[iJoyStick][i]), false);
     499
     500                // Maximum values
     501                if (joyStickMaxValues_[iJoyStick][i] == INT_MIN)
     502                    joyStickMaxValues_[iJoyStick][i] = 32767;
     503                ConfigFileManager::getInstance().setValue(ConfigFileType::JoyStickCalibration,
     504                    this->joyStickIDs_[iJoyStick], "MaxValue", i, omni_cast<std::string>(joyStickMaxValues_[iJoyStick][i]), false);
     505
     506                // Middle values
     507                ConfigFileManager::getInstance().setValue(ConfigFileType::JoyStickCalibration,
     508                    this->joyStickIDs_[iJoyStick], "MiddleValue", i, omni_cast<std::string>(joyStickMiddleValues_[iJoyStick][i]), false);
     509            }
     510        }
     511
     512        _evaluateCalibration();
     513
     514        // restore old input state
     515        requestLeaveState("calibrator");
     516        internalState_ &= ~Calibrating;
     517    }
    438518
    439519    // ############################################################
     
    492572            }
    493573        }
    494         singletonRef_s = 0;
     574
     575        singletonRef_s = 0;
    495576    }
    496577
     
    660741    /**
    661742    @brief
    662         Updates the InputManager. Tick is called by the Core class.
     743        Updates the states and the InputState situation.
    663744    @param dt
    664745        Delta time
     
    676757
    677758        // check for states to leave
    678         for (std::set<InputState*>::reverse_iterator rit = stateLeaveRequests_.rbegin();
    679             rit != stateLeaveRequests_.rend(); ++rit)
    680         {
    681             (*rit)->onLeave();
    682             // just to be sure that the state actually is registered
    683             assert(inputStatesByName_.find((*rit)->getName()) != inputStatesByName_.end());
    684 
    685             activeStates_.erase((*rit)->getPriority());
    686             _updateActiveStates();
    687         }
    688         stateLeaveRequests_.clear();
     759        if (!stateLeaveRequests_.empty())
     760        {
     761            for (std::set<InputState*>::reverse_iterator rit = stateLeaveRequests_.rbegin();
     762                rit != stateLeaveRequests_.rend(); ++rit)
     763            {
     764                (*rit)->onLeave();
     765                // just to be sure that the state actually is registered
     766                assert(inputStatesByName_.find((*rit)->getName()) != inputStatesByName_.end());
     767
     768                activeStates_.erase((*rit)->getPriority());
     769                _updateActiveStates();
     770            }
     771            stateLeaveRequests_.clear();
     772        }
    689773
    690774        // check for states to enter
    691         for (std::set<InputState*>::reverse_iterator rit = stateEnterRequests_.rbegin();
    692             rit != stateEnterRequests_.rend(); ++rit)
    693         {
    694             // just to be sure that the state actually is registered
    695             assert(inputStatesByName_.find((*rit)->getName()) != inputStatesByName_.end());
    696 
    697             activeStates_[(*rit)->getPriority()] = (*rit);
    698             _updateActiveStates();
    699             (*rit)->onEnter();
    700         }
    701         stateEnterRequests_.clear();
     775        if (!stateEnterRequests_.empty())
     776        {
     777            for (std::set<InputState*>::reverse_iterator rit = stateEnterRequests_.rbegin();
     778                rit != stateEnterRequests_.rend(); ++rit)
     779            {
     780                // just to be sure that the state actually is registered
     781                assert(inputStatesByName_.find((*rit)->getName()) != inputStatesByName_.end());
     782
     783                activeStates_[(*rit)->getPriority()] = (*rit);
     784                _updateActiveStates();
     785                (*rit)->onEnter();
     786            }
     787            stateEnterRequests_.clear();
     788        }
    702789
    703790        // check for states to destroy
    704         for (std::set<InputState*>::reverse_iterator rit = stateDestroyRequests_.rbegin();
    705             rit != stateDestroyRequests_.rend(); ++rit)
    706         {
    707             _destroyState((*rit));
    708         }
    709         stateDestroyRequests_.clear();
     791        if (!stateDestroyRequests_.empty())
     792        {
     793            for (std::set<InputState*>::reverse_iterator rit = stateDestroyRequests_.rbegin();
     794                rit != stateDestroyRequests_.rend(); ++rit)
     795            {
     796                _destroyState((*rit));
     797            }
     798            stateDestroyRequests_.clear();
     799        }
    710800
    711801        // check whether a state has changed its EMPTY_HANDLER situation
     
    733823            joySticks_[i]->capture();
    734824
    735         if (!bCalibrating_)
     825        if (!(internalState_ & Calibrating))
    736826        {
    737827            // call all the handlers for the held key events
     
    804894    /**
    805895    @brief
    806         Processes the accumultated data for the joy stick calibration.
    807     */
    808     void InputManager::_completeCalibration()
    809     {
    810         for (unsigned int i = 0; i < 24; i++)
    811         {
    812             // positive coefficient
    813             if (marginalsMax_[i] == INT_MIN)
    814                 marginalsMax_[i] =  32767;
    815             // coefficients
    816             if (marginalsMax_[i] - joySticksCalibration_[0].zeroStates[i])
    817             {
    818                 joySticksCalibration_[0].positiveCoeff[i]
    819                     = 1.0f/(marginalsMax_[i] - joySticksCalibration_[0].zeroStates[i]);
    820             }
    821             else
    822                 joySticksCalibration_[0].positiveCoeff[i] =  1.0f;
    823 
    824             // config value
    825             ConfigValueContainer* cont = getIdentifier()->getConfigValueContainer("CoeffPos");
    826             assert(cont);
    827             cont->set(i, joySticksCalibration_[0].positiveCoeff[i]);
    828 
    829             // negative coefficient
    830             if (marginalsMin_[i] == INT_MAX)
    831                 marginalsMin_[i] = -32768;
    832             // coefficients
    833             if (marginalsMin_[i] - joySticksCalibration_[0].zeroStates[i])
    834             {
    835                 joySticksCalibration_[0].negativeCoeff[i] = -1.0f
    836                     / (marginalsMin_[i] - joySticksCalibration_[0].zeroStates[i]);
    837             }
    838             else
    839                 joySticksCalibration_[0].negativeCoeff[i] =  1.0f;
    840             // config value
    841             cont = getIdentifier()->getConfigValueContainer("CoeffNeg");
    842             assert(cont);
    843             cont->set(i, joySticksCalibration_[0].negativeCoeff[i]);
    844 
    845             // zero states
    846             if (i < 8)
    847             {
    848                 if (!(i & 1))
    849                     joySticksCalibration_[0].zeroStates[i] = joySticks_[0]->getJoyStickState().mSliders[i/2].abX;
    850                 else
    851                     joySticksCalibration_[0].zeroStates[i] = joySticks_[0]->getJoyStickState().mSliders[i/2].abY;
    852             }
    853             else
    854             {
    855                 if (i - 8 < joySticks_[0]->getJoyStickState().mAxes.size())
    856                     joySticksCalibration_[0].zeroStates[i] = joySticks_[0]->getJoyStickState().mAxes[i - 8].abs;
    857                 else
    858                     joySticksCalibration_[0].zeroStates[i] = 0;
    859             }
    860             // config value
    861             cont = getIdentifier()->getConfigValueContainer("Zero");
    862             assert(cont);
    863             cont->set(i, joySticksCalibration_[0].zeroStates[i]);
    864         }
    865 
    866         // restore old input state
    867         requestLeaveState("calibrator");
    868         bCalibrating_ = false;
    869     }
    870 
     896        Clears all buffers that store what keys/buttons are being pressed at the moment.
     897    */
    871898    void InputManager::clearBuffers()
    872899    {
     
    10991126    void InputManager::_fireAxis(unsigned int iJoyStick, int axis, int value)
    11001127    {
    1101         if (bCalibrating_)
    1102         {
    1103             if (value > marginalsMax_[axis])
    1104                 marginalsMax_[axis] = value;
    1105             if (value < marginalsMin_[axis])
    1106                 marginalsMin_[axis] = value;
     1128        if (internalState_ & Calibrating)
     1129        {
     1130            if (value < joyStickMinValues_[iJoyStick][axis])
     1131                joyStickMinValues_[iJoyStick][axis] = value;
     1132            if (value > joyStickMaxValues_[iJoyStick][axis])
     1133                joyStickMaxValues_[iJoyStick][axis] = value;
    11071134        }
    11081135        else
    11091136        {
    1110             float fValue = value - joySticksCalibration_[iJoyStick].zeroStates[axis];
     1137            float fValue = value - joyStickCalibrations_[iJoyStick].middleValue[axis];
    11111138            if (fValue > 0.0f)
    1112                 fValue *= joySticksCalibration_[iJoyStick].positiveCoeff[axis];
     1139                fValue *= joyStickCalibrations_[iJoyStick].positiveCoeff[axis];
    11131140            else
    1114                 fValue *= joySticksCalibration_[iJoyStick].negativeCoeff[axis];
     1141                fValue *= joyStickCalibrations_[iJoyStick].negativeCoeff[axis];
    11151142
    11161143            activeStatesTop_[2 + iJoyStick]->joyStickAxisMoved(iJoyStick, axis, fValue);
     
    11241151
    11251152        // keep in mind that the first 8 axes are reserved for the sliders
    1126         _fireAxis(iJoyStick, axis + 8, arg.state.mAxes[axis].abs);
     1153        _fireAxis(iJoyStick, axis + sliderAxes, arg.state.mAxes[axis].abs);
    11271154
    11281155        return true;
     
    13901417    void InputManager::calibrate()
    13911418    {
    1392         getInstance().bCalibrating_ = true;
    1393         getInstance().requestEnterState("calibrator");
     1419        COUT(0) << "Move all joy stick axes fully in all directions." << std::endl
     1420                << "When done, put the axex in the middle position and press enter." << std::endl;
     1421
     1422        getInstance()._startCalibration();
    13941423    }
    13951424
  • code/trunk/src/core/input/InputManager.h

    r2102 r2662  
    7171    struct JoyStickCalibration
    7272    {
    73         int zeroStates[24];
     73        int middleValue[24];
    7474        float positiveCoeff[24];
    7575        float negativeCoeff[24];
     
    136136    public: // variables
    137137        static EmptyHandler                 EMPTY_HANDLER;
     138        static const unsigned int           sliderAxes = 8;
    138139
    139140    private: // functions
     
    145146        void _initialiseMouse();
    146147        void _initialiseJoySticks();
    147         void _configureNumberOfJoySticks();
     148        void _configureJoySticks();
     149
     150        void _loadCalibration();
     151        void _startCalibration();
     152        void _completeCalibration();
     153        void _evaluateCalibration();
    148154
    149155        void _destroyKeyboard();
     
    154160
    155161        void _reload(bool joyStickSupport);
    156 
    157         void _completeCalibration();
    158162
    159163        void _fireAxis(unsigned int iJoyStick, int axis, int value);
     
    178182
    179183        void setConfigValues();
     184        void _calibrationFileCallback();
    180185
    181186    private: // variables
     
    185190        std::vector<OIS::JoyStick*>         joySticks_;            //!< OIS joy sticks
    186191        unsigned int                        joySticksSize_;
     192        std::vector<std::string>            joyStickIDs_;          //!< Execution unique identification strings for the joy sticks
    187193        unsigned int                        devicesNum_;
    188194        size_t                              windowHnd_;            //!< Render window handle
     
    192198        SimpleInputState*                   stateEmpty_;
    193199        ExtendedInputState*                 stateMaster_;          //!< Always active master input state
    194         KeyDetector*                        keyDetector_;        //!< KeyDetector instance
     200        KeyDetector*                        keyDetector_;          //!< KeyDetector instance
    195201        InputBuffer*                        calibratorCallbackBuffer_;
    196202
     
    207213
    208214        // joystick calibration
    209         //std::vector<int> marginalsMaxConfig_;
    210         //std::vector<int> marginalsMinConfig_;
    211         int                                 marginalsMax_[24];
    212         int                                 marginalsMin_[24];
    213         bool                                bCalibrated_;
    214         bool                                bCalibrating_;
     215        std::vector<std::vector<int> >      joyStickMinValues_;
     216        std::vector<std::vector<int> >      joyStickMaxValues_;
     217        std::vector<std::vector<int> >      joyStickMiddleValues_;
     218        std::vector<ConfigValueContainer*>  calibrationConfigValueContainers_;
     219        std::vector<JoyStickCalibration>    joyStickCalibrations_;
    215220
    216221        unsigned int                        keyboardModifiers_;    //!< Bit mask representing keyboard modifiers.
    217222        std::vector<POVStates>              povStates_;            //!< Keeps track of the joy stick POV states.
    218223        std::vector<SliderStates>           sliderStates_;         //!< Keeps track of the possibly two slider axes.
    219         std::vector<JoyStickCalibration>    joySticksCalibration_;
    220224
    221225        std::vector<Key>                    keysDown_;
     
    223227        std::vector<std::vector<JoyStickButtonCode::ByEnum> >  joyStickButtonsDown_;
    224228
    225         static std::string                  bindingCommmandString_s;
     229        // ConfigValues
     230        std::string                         calibrationFilename_;  //!< Joy stick calibration ini filename
     231
    226232        static InputManager*                singletonRef_s;
    227233    };
  • code/trunk/src/core/input/KeyBinder.cc

    r2103 r2662  
    3333
    3434#include "KeyBinder.h"
     35
    3536#include <fstream>
    3637#include <string>
     38
    3739#include "util/Convert.h"
    3840#include "util/Debug.h"
     
    6668            std::string keyname = KeyCode::ByString[i];
    6769            if (!keyname.empty())
    68             {
    6970                keys_[i].name_ = std::string("Key") + keyname;
    70             }
    7171            else
    72             {
    73                 // some keys have name "" because the code is not occupied by OIS
    74                 // Use "Key_" plus the number as name to put it at the end of the config file section
    75                 std::string number = convertToString(i);
    76                 if (i < 100)
    77                     number.insert(0, "0");
    78                 keys_[i].name_ = std::string("Key_") + number;
    79             }
     72                keys_[i].name_ = "";
    8073            keys_[i].paramCommandBuffer_ = &paramCommandBuffer_;
    8174            keys_[i].groupName_ = "Keys";
     
    9790        for (unsigned int i = 0; i < MouseAxisCode::numberOfAxes * 2; i++)
    9891        {
    99             mouseAxes_[i].name_ = std::string("Mouse") + MouseAxisCode::ByString[i >> 1];
     92            mouseAxes_[i].name_ = std::string("Mouse") + MouseAxisCode::ByString[i / 2];
    10093            if (i & 1)
    10194                mouseAxes_[i].name_ += "Pos";
     
    224217        allHalfAxes_.clear();
    225218
     219        // Note: Don't include the dummy keys which don't actually exist in OIS but have a number
    226220        for (unsigned int i = 0; i < KeyCode::numberOfKeys; i++)
    227             allButtons_[keys_[i].name_] = keys_ + i;
     221            if (!keys_[i].name_.empty())
     222                allButtons_[keys_[i].name_] = keys_ + i;
    228223        for (unsigned int i = 0; i < numberOfMouseButtons_; i++)
    229224            allButtons_[mouseButtons_[i].name_] = mouseButtons_ + i;
     
    327322        if (bDeriveMouseInput_)
    328323        {
    329             // only update when derive dt has passed
     324            // only update when derivation dt has passed
    330325            if (deriveTime_ > derivePeriod_)
    331326            {
    332327                for (int i = 0; i < 2; i++)
    333328                {
    334                     if (mouseRelative_[i] > 0)
     329                    if (mouseRelative_[i] < 0)
    335330                    {
    336331                        mouseAxes_[2*i + 0].absVal_
    337                             =  mouseRelative_[i] / deriveTime_ * 0.0005 * mouseSensitivityDerived_;
     332                            = -mouseRelative_[i] / deriveTime_ * 0.0005 * mouseSensitivityDerived_;
    338333                        mouseAxes_[2*i + 1].absVal_ = 0.0f;
    339334                    }
    340                     else if (mouseRelative_[i] < 0)
     335                    else if (mouseRelative_[i] > 0)
    341336                    {
    342337                        mouseAxes_[2*i + 0].absVal_ = 0.0f;
    343338                        mouseAxes_[2*i + 1].absVal_
    344                             = -mouseRelative_[i] / deriveTime_ * 0.0005 * mouseSensitivityDerived_;
     339                            =  mouseRelative_[i] / deriveTime_ * 0.0005 * mouseSensitivityDerived_;
    345340                    }
    346341                    else
     
    363358            // Why dividing relative value by dt? The reason lies in the simple fact, that when you
    364359            // press a button that has relative movement, that value has to be multiplied by dt to be
    365             // frame rate independant. This can easily (and only) be done in tickInput(float).
     360            // frame rate independent. This can easily (and only) be done in tickInput(float).
    366361            // Hence we need to divide by dt here for the mouse to compensate, because the relative
    367362            // move movements have nothing to do with dt.
     
    441436            for (int i = 0; i < 2; i++)
    442437            {
    443                 if (rel[i]) // performance opt. if rel[i] == 0
     438                if (rel[i]) // performance opt. for the case that rel[i] == 0
    444439                {
    445440                    // write absolute values
     
    454449                        mousePosition_[i] = -mouseClippingSize_;
    455450
    456                     if (mousePosition_[i] >= 0)
     451                    if (mousePosition_[i] < 0)
    457452                    {
    458                         mouseAxes_[2*i + 0].absVal_ =   mousePosition_[i]/(float)mouseClippingSize_ * mouseSensitivity_;
     453                        mouseAxes_[2*i + 0].absVal_ =  -mousePosition_[i]/(float)mouseClippingSize_ * mouseSensitivity_;
    459454                        mouseAxes_[2*i + 1].absVal_ =  0.0f;
    460455                    }
     
    462457                    {
    463458                        mouseAxes_[2*i + 0].absVal_ =  0.0f;
    464                         mouseAxes_[2*i + 1].absVal_ =  -mousePosition_[i]/(float)mouseClippingSize_ * mouseSensitivity_;
     459                        mouseAxes_[2*i + 1].absVal_ =   mousePosition_[i]/(float)mouseClippingSize_ * mouseSensitivity_;
    465460                    }
    466461                }
     
    471466        for (int i = 0; i < 2; i++)
    472467        {
    473             if (rel[i] > 0)
    474                 mouseAxes_[0 + 2*i].relVal_ =  ((float)rel[i])/(float)mouseClippingSize_ * mouseSensitivity_;
     468            if (rel[i] < 0)
     469                mouseAxes_[0 + 2*i].relVal_ = -((float)rel[i])/(float)mouseClippingSize_ * mouseSensitivity_;
    475470            else
    476                 mouseAxes_[1 + 2*i].relVal_ = -((float)rel[i])/(float)mouseClippingSize_ * mouseSensitivity_;
     471                mouseAxes_[1 + 2*i].relVal_ =  ((float)rel[i])/(float)mouseClippingSize_ * mouseSensitivity_;
    477472        }
    478473    }
     
    484479    void KeyBinder::mouseScrolled(int abs, int rel)
    485480    {
    486         if (rel > 0)
    487             for (int i = 0; i < rel/mouseWheelStepSize_; i++)
     481        if (rel < 0)
     482            for (int i = 0; i < -rel/mouseWheelStepSize_; i++)
    488483                mouseButtons_[8].execute(KeybindMode::OnPress, ((float)abs)/mouseWheelStepSize_);
    489484        else
    490             for (int i = 0; i < -rel/mouseWheelStepSize_; i++)
     485            for (int i = 0; i < rel/mouseWheelStepSize_; i++)
    491486                mouseButtons_[9].execute(KeybindMode::OnPress, ((float)abs)/mouseWheelStepSize_);
    492487    }
     
    495490    {
    496491        int i = axis * 2;
    497         if (value >= 0)
    498         {
    499             joyStickAxes_[joyStickID][i].absVal_ = value;
    500             joyStickAxes_[joyStickID][i].relVal_ = value;
     492        if (value < 0)
     493        {
     494            joyStickAxes_[joyStickID][i].absVal_ = -value;
     495            joyStickAxes_[joyStickID][i].relVal_ = -value;
    501496            joyStickAxes_[joyStickID][i].hasChanged_ = true;
    502497            if (joyStickAxes_[joyStickID][i + 1].absVal_ > 0.0f)
     
    509504        else
    510505        {
    511             joyStickAxes_[joyStickID][i + 1].absVal_ = -value;
    512             joyStickAxes_[joyStickID][i + 1].relVal_ = -value;
     506            joyStickAxes_[joyStickID][i + 1].absVal_ = value;
     507            joyStickAxes_[joyStickID][i + 1].relVal_ = value;
    513508            joyStickAxes_[joyStickID][i + 1].hasChanged_ = true;
    514509            if (joyStickAxes_[joyStickID][i].absVal_ > 0.0f)
  • code/trunk/src/core/input/KeyBinder.h

    r2103 r2662  
    3939
    4040#include <vector>
     41#include <cassert>
     42
    4143#include "InputInterfaces.h"
    4244#include "Button.h"
     
    4446#include "InputCommands.h"
    4547#include "JoyStickDeviceNumberListener.h"
    46 #include "core/ConfigFileManager.h"
    4748
    4849namespace orxonox
     
    171172
    172173    inline void KeyBinder::keyPressed (const KeyEvent& evt)
    173     { keys_[evt.key].execute(KeybindMode::OnPress); }
     174    { assert(!keys_[evt.key].name_.empty()); keys_[evt.key].execute(KeybindMode::OnPress); }
    174175
    175176    inline void KeyBinder::keyReleased(const KeyEvent& evt)
    176     { keys_[evt.key].execute(KeybindMode::OnRelease); }
     177    { assert(!keys_[evt.key].name_.empty()); keys_[evt.key].execute(KeybindMode::OnRelease); }
    177178
    178179    inline void KeyBinder::keyHeld    (const KeyEvent& evt)
    179     { keys_[evt.key].execute(KeybindMode::OnHold); }
     180    { assert(!keys_[evt.key].name_.empty()); keys_[evt.key].execute(KeybindMode::OnHold); }
    180181
    181182
  • code/trunk/src/network/CMakeLists.txt

    r2131 r2662  
    1111  PacketBuffer.cc
    1212  Server.cc
    13   Synchronisable.cc
     13  TrafficControl.cc
    1414  Host.cc
    1515)
    1616
    1717ADD_SOURCE_DIRECTORY(NETWORK_SRC_FILES packet)
     18ADD_SOURCE_DIRECTORY(NETWORK_SRC_FILES synchronisable)
     19
    1820
    1921IF(WIN32)
  • code/trunk/src/network/Client.cc

    r2171 r2662  
    4343#include "Client.h"
    4444#include "Host.h"
    45 #include "Synchronisable.h"
     45#include "synchronisable/Synchronisable.h"
    4646#include "core/CoreIncludes.h"
    4747#include "packet/Packet.h"
  • code/trunk/src/network/ClientConnection.cc

    r2171 r2662  
    172172        break;
    173173      case ENET_EVENT_TYPE_RECEIVE:
    174         COUT(5) << "Cl.Con: receiver-Thread while loop: got new packet" << std::endl;
     174        //COUT(5) << "Cl.Con: receiver-Thread while loop: got new packet" << std::endl;
    175175        if ( !processData(event) ) COUT(2) << "Current packet was not pushed to packetBuffer -> ev ongoing SegFault" << std::endl;
    176         COUT(5) << "Cl.Con: processed Data in receiver-thread while loop" << std::endl;
     176        //COUT(5) << "Cl.Con: processed Data in receiver-thread while loop" << std::endl;
    177177        event = new ENetEvent;
    178178        break;
  • code/trunk/src/network/ClientInformation.cc

    r2171 r2662  
    4545namespace orxonox
    4646{
     47 
    4748
    4849  ClientInformation *ClientInformation::head_=0;
  • code/trunk/src/network/ClientInformation.h

    r2171 r2662  
    4646#include <boost/thread/recursive_mutex.hpp>
    4747
     48
    4849// WATCH OUT: THE CLIENTINFORMATION LIST IS NOT THREADSAFE ANYMORE
    4950
    5051namespace orxonox
    5152{
    52   static const unsigned int GAMESTATEID_INITIAL = (unsigned int)-1;
    53   static const unsigned int CLIENTID_UNKNOWN = (unsigned int)-2;
    5453
    5554  /**
  • code/trunk/src/network/ConnectionManager.cc

    r2171 r2662  
    5252#include "util/Sleep.h"
    5353#include "ClientInformation.h"
    54 #include "Synchronisable.h"
     54#include "synchronisable/Synchronisable.h"
    5555#include "packet/ClassID.h"
    5656
     
    206206        // log handling ================
    207207        case ENET_EVENT_TYPE_CONNECT:
    208           COUT(3) << "adding event_type_connect to queue" << std::endl;
     208          //COUT(3) << "adding event_type_connect to queue" << std::endl;
    209209        case ENET_EVENT_TYPE_DISCONNECT:
    210210          //addClient(event);
     
    214214        case ENET_EVENT_TYPE_RECEIVE:
    215215          //std::cout << "received data" << std::endl;
    216           COUT(5) << "Con.Man: receive event has occured" << std::endl;
     216          //COUT(5) << "Con.Man: receive event has occured" << std::endl;
    217217          // only add, if client has connected yet and not been disconnected
    218218          //if(head_->findClient(&event->peer->address))
  • code/trunk/src/network/GamestateClient.cc

    r2171 r2662  
    3535#include "core/BaseObject.h"
    3636#include "core/Iterator.h"
    37 #include "Synchronisable.h"
     37#include "synchronisable/Synchronisable.h"
     38#include "synchronisable/NetworkCallbackManager.h"
    3839#include "packet/Acknowledgement.h"
    3940
     
    7475    if(tempGamestate_==NULL)
    7576      return false;
     77    bool isDiffed = tempGamestate_->isDiffed();
    7678    int id = GAMESTATEID_INITIAL;
    7779    packet::Gamestate *processed = processGamestate(tempGamestate_);
    78 //    assert(processed);
    79     if (!processed)
    80         return false;
     80    assert(processed);
     81   
     82    //now call the queued callbacks
     83    NetworkCallbackManager::callCallbacks();
     84   
     85    if (!processed){
     86      sendAck(0);
     87      return false;
     88    }
    8189    //successfully loaded data from gamestate. now save gamestate for diff and delete the old gs
    8290    tempGamestate_=NULL;
    8391    gamestateMap_[processed->getID()]=processed;
    84     last_diff_ = processed->getID();
     92    if(isDiffed)
     93      last_diff_ = processed->getBaseID();
    8594    id = processed->getID();
    8695    sendAck(id);
     
    153162      packet::Gamestate *base = gamestateMap_[gs->getBaseID()];
    154163      if(!base){
     164        COUT(3) << "could not find base gamestate id: " << gs->getBaseID() << endl;
    155165        delete gs;
    156166        return 0;
     
    165175      return gs;
    166176    else
     177    {
     178      COUT(3) << "could not spread gamestate" << endl;
    167179      return NULL;
     180    }
    168181  }
    169182
  • code/trunk/src/network/GamestateManager.cc

    r2171 r2662  
    4949#include "core/BaseObject.h"
    5050#include "ClientInformation.h"
    51 #include "Synchronisable.h"
     51#include "synchronisable/Synchronisable.h"
     52#include "synchronisable/NetworkCallbackManager.h"
     53#include "packet/Acknowledgement.h"
    5254
    5355namespace orxonox
    5456{
    55   GamestateManager::GamestateManager() {
    56     id_=0;
    57   }
    58 
    59   GamestateManager::~GamestateManager() {
     57  GamestateManager::GamestateManager() :
     58  reference(0), id_(0)
     59  {
     60    trafficControl_ = new TrafficControl();
     61  }
     62
     63  GamestateManager::~GamestateManager()
     64  {
     65    delete trafficControl_;
    6066  }
    6167
     
    8692    // now clear the queue
    8793    gamestateQueue.clear();
     94    //and call all queued callbacks
     95    NetworkCallbackManager::callCallbacks();
    8896    return true;
    8997  }
     
    9199
    92100  bool GamestateManager::getSnapshot(){
     101    if ( reference != 0 )
     102      delete reference;
    93103    reference = new packet::Gamestate();
    94104    if(!reference->collectData(++id_)){ //we have no data to send
     
    99109  }
    100110
    101   /**
    102    * this function is used to keep the memory usage low
    103    * it tries to delete all the unused gamestates
    104    *
    105    *
    106    */
    107 /*  void GamestateManager::cleanup(){
    108     std::map<int,int>::iterator it = gamestateUsed.begin();
    109     while(it!=gamestateUsed.end()){
    110       if((id_-(*it).first)<KEEP_GAMESTATES)
    111         break;
    112       if( (*it).second <= 0 ){
    113         COUT(5) << "GameStateManager: deleting gamestate with id: " << (*it).first << ", uses: " << (*it).second << std::endl;
    114         std::map<int, packet::Gamestate *>::iterator tempit = gamestateMap.find((*it).first);
    115         if( tempit != gamestateMap.end() ){
    116           packet::Gamestate *temp = tempit->second;
    117           if(temp){
    118             delete gamestateMap[(*it).first];
    119             gamestateMap.erase((*it).first);
    120           }
    121         }
    122         gamestateUsed.erase(it++);
    123         continue;
    124       }
    125       it++;
    126     }
    127   }*/
    128111
    129112  packet::Gamestate *GamestateManager::popGameState(unsigned int clientID) {
     
    134117    if(!reference)
    135118      return 0;
    136     gs = reference->doSelection(clientID);
    137 //     gs = new packet::Gamestate(*reference);
     119    gs = reference->doSelection(clientID, 10000);
    138120//     gs = new packet::Gamestate(*reference);
    139121    // save the (undiffed) gamestate in the clients gamestate map
    140     gamestateMap_[clientID].insert(std::pair<int, packet::Gamestate*>(gs->getID(), gs));
     122    gamestateMap_[clientID][gs->getID()]=gs;
    141123    //chose wheather the next gamestate is the first or not
    142     packet::Gamestate *client=NULL;
     124    packet::Gamestate *client=0;
    143125    if(gID != GAMESTATEID_INITIAL){
    144       std::map<unsigned int, std::map<unsigned int, packet::Gamestate*> >::iterator clientMap = gamestateMap_.find(clientID);
    145       if(clientMap!=gamestateMap_.end()){
    146         std::map<unsigned int, packet::Gamestate*>::iterator it = clientMap->second.find(gID);
    147         if(it!=clientMap->second.end())
    148           client = it->second;
     126      assert(gamestateMap_.find(clientID)!=gamestateMap_.end());
     127      std::map<unsigned int, packet::Gamestate*>::iterator it = gamestateMap_[clientID].find(gID);
     128      if(it!=gamestateMap_[clientID].end())
     129      {
     130        client = it->second;
    149131      }
    150132    }
     
    152134//       COUT(3) << "diffing" << std::endl;
    153135      gs = gs->diff(client);
     136//       gs = new packet::Gamestate(*gs);
    154137    }
    155138    else{
     
    159142    bool b = gs->compressData();
    160143    assert(b);
     144    COUT(4) << "sending gamestate with id " << gs->getID();
     145    if(gs->isDiffed())
     146    COUT(4) << " and baseid " << gs->getBaseID() << endl;
     147    else
     148    COUT(4) << endl;
    161149    return gs;
    162150  }
     
    168156    unsigned int curid = temp->getGamestateID();
    169157
    170     if(gamestateID == 0){
     158    if(gamestateID == ACKID_NACK){
    171159      temp->setGamestateID(GAMESTATEID_INITIAL);
     160      // now delete all saved gamestates for this client
     161      std::map<unsigned int, packet::Gamestate*>::iterator it;
     162      for(it = gamestateMap_[clientID].begin(); it!=gamestateMap_[clientID].end(); ){
     163        delete it->second;
     164        gamestateMap_[clientID].erase(it++);
     165      }
    172166      return true;
    173167    }
     
    175169    assert(curid==(unsigned int)GAMESTATEID_INITIAL || curid<gamestateID);
    176170    COUT(4) << "acking gamestate " << gamestateID << " for clientid: " << clientID << " curid: " << curid << std::endl;
    177     std::map<unsigned int, packet::Gamestate*>::iterator it, tempit;
    178     for(it = gamestateMap_[clientID].begin(); it!=gamestateMap_[clientID].end() && it->first<gamestateID; it++){
    179       delete it->second;
    180       tempit=it++;
    181       gamestateMap_[clientID].erase(tempit);
     171    std::map<unsigned int, packet::Gamestate*>::iterator it;
     172    for(it = gamestateMap_[clientID].begin(); it!=gamestateMap_[clientID].end() && it->first<gamestateID; ){
     173      delete it->second;
     174      gamestateMap_[clientID].erase(it++);
    182175    }
    183176    temp->setGamestateID(gamestateID);
     177    TrafficControl::processAck(clientID, gamestateID);
    184178    return true;
    185179  }
  • code/trunk/src/network/GamestateManager.h

    r2171 r2662  
    4343#include "NetworkPrereqs.h"
    4444#include "GamestateHandler.h"
     45#include "TrafficControl.h"
    4546#include <map>
    4647
     
    8182    void removeClient(ClientInformation *client);
    8283    private:
    83 //     void cleanup(); // "garbage handler"
    8484    bool processGamestate(packet::Gamestate *gs);
    8585
     
    8989    std::map<unsigned int, packet::Gamestate*> gamestateQueue;
    9090    packet::Gamestate *reference;
     91    TrafficControl *trafficControl_;
    9192    unsigned int id_;
    9293  };
  • code/trunk/src/network/NetworkPrereqs.h

    r2171 r2662  
    5757
    5858//-----------------------------------------------------------------------
     59// Includes
     60//-----------------------------------------------------------------------
     61#include "util/Integers.h"
     62
     63//-----------------------------------------------------------------------
     64// Library global contants
     65//-----------------------------------------------------------------------
     66namespace orxonox
     67{
     68  static const unsigned int GAMESTATEID_INITIAL = (unsigned int)-1;
     69  static const unsigned int CLIENTID_UNKNOWN    = (unsigned int)-2;
     70  static const uint32_t     OBJECTID_UNKNOWN    = (uint32_t)(-1);
     71}
     72
     73//-----------------------------------------------------------------------
    5974// Forward declarations
    6075//-----------------------------------------------------------------------
     
    7085  class GamestateManager;
    7186  class GamestateHandler;
     87  class NetworkCallbackBase;
     88  template <class T> class NetworkCallback;
     89  class NetworkCallbackManager;
    7290  class PacketBuffer;
    7391  class Server;
    7492  class ServerFrameListener;
    7593  class Synchronisable;
     94  class SynchronisableVariableBase;
     95  template <class T> class SynchronisableVariable;
     96  template <class T> class SynchronisableVariableBidirectional;
    7697  struct ClientList;
    7798  struct PacketEnvelope;
    7899  struct QueueItem;
    79100  struct syncData;
    80   struct synchronisableVariable;
    81   namespace packet{
     101  class obj;
     102  class objInfo;
     103
     104  namespace packet
     105  {
    82106    class Gamestate;
    83107    class Packet;
  • code/trunk/src/network/Server.cc

    r2171 r2662  
    6363{
    6464  const unsigned int MAX_FAILURES = 20;
    65   const unsigned int NETWORK_FREQUENCY = 25;
    66   const float NETWORK_PERIOD = (float)1/NETWORK_FREQUENCY;
    6765
    6866  /**
     
    218216  */
    219217  void Server::updateGamestate() {
     218//     if( ClientInformation::getBegin()==NULL )
     219      //no client connected
     220//       return;
    220221    gamestates_->update();
    221222    COUT(5) << "Server: one gamestate update complete, goig to sendGameState" << std::endl;
     
    276277  bool Server::sendObjectDeletes(){
    277278    ClientInformation *temp = ClientInformation::getBegin();
     279    if( temp == NULL )
     280      //no client connected
     281      return true;
    278282    packet::DeleteObjects *del = new packet::DeleteObjects();
    279283    if(!del->fetchIDs())
  • code/trunk/src/network/Server.h

    r2171 r2662  
    5252{
    5353  const int CLIENTID_SERVER = 0;
     54  const unsigned int NETWORK_FREQUENCY = 25;
     55  const float NETWORK_PERIOD = 1./NETWORK_FREQUENCY;
    5456
    5557  /**
  • code/trunk/src/network/packet/Acknowledgement.cc

    r2171 r2662  
    6464
    6565bool Acknowledgement::process(){
     66COUT(0) << "processing ACK with ID: " << getAckID() << endl;
    6667  bool b = GamestateHandler::ackGamestate(getAckID(), clientID_);
    6768  delete this;
  • code/trunk/src/network/packet/Acknowledgement.h

    r2171 r2662  
    3232#include "Packet.h"
    3333
     34const unsigned int ACKID_NACK = 0;
    3435
    3536namespace orxonox {
  • code/trunk/src/network/packet/DeleteObjects.cc

    r2171 r2662  
    3030#include "DeleteObjects.h"
    3131#include <enet/enet.h>
    32 #include "network/Synchronisable.h"
     32#include "network/synchronisable/Synchronisable.h"
    3333#include "core/CoreIncludes.h"
    3434#include <assert.h>
     
    6161  if(number==0)
    6262    return false;
    63   COUT(3) << "sending DeleteObjects: ";
     63  COUT(4) << "sending DeleteObjects: ";
    6464  unsigned int size = sizeof(ENUM::Type) + sizeof(uint32_t)*(number+1);
    6565  data_ = new uint8_t[size];
    6666  uint8_t *tdata = data_;
    67   *(ENUM::Type *)(tdata) = ENUM::DeleteObjects;
     67  *reinterpret_cast<ENUM::Type*>(tdata) = ENUM::DeleteObjects;
    6868  tdata += sizeof(ENUM::Type);
    6969  *(uint32_t *)tdata = number;
     
    7272    unsigned int temp = Synchronisable::popDeletedObject();
    7373//     assert(temp<10000); //ugly hack
    74     *(uint32_t *)(tdata) = temp;
    75     COUT(3) << temp << " ";
     74    *reinterpret_cast<uint32_t*>(tdata) = temp;
     75    COUT(4) << temp << " ";
    7676    tdata += sizeof(uint32_t);
    7777  }
    78   COUT(3) << std::endl;
     78  COUT(4) << std::endl;
    7979  return true;
    8080}
     
    8787bool DeleteObjects::process(){
    8888  for(unsigned int i=0; i<*(unsigned int *)(data_+_QUANTITY); i++){
    89     COUT(3) << "deleting object with id: " << *(uint32_t*)(data_+_OBJECTIDS+i*sizeof(uint32_t)) << std::endl;
     89    COUT(4) << "deleting object with id: " << *(uint32_t*)(data_+_OBJECTIDS+i*sizeof(uint32_t)) << std::endl;
    9090    Synchronisable::deleteObject( *(uint32_t*)(data_+_OBJECTIDS+i*sizeof(uint32_t)) );
    9191  }
  • code/trunk/src/network/packet/Gamestate.cc

    r2171 r2662  
    2828
    2929#include "Gamestate.h"
    30 #include "network/ClientInformation.h"
    31 #include "network/GamestateHandler.h"
     30#include "../GamestateHandler.h"
     31#include "../synchronisable/Synchronisable.h"
     32#include "../TrafficControl.h"
     33#include "core/Core.h"
    3234#include "core/CoreIncludes.h"
    3335#include "core/Iterator.h"
    3436
    3537#include <zlib.h>
    36 #include <assert.h>
     38#include <cassert>
    3739
    3840
     
    4244namespace packet {
    4345
    44 #define GAMESTATE_START(data) (data + sizeof(GamestateHeader))
    45 #define GAMESTATE_HEADER(data) ((GamestateHeader *)data)
    46 #define HEADER GAMESTATE_HEADER(data_)
    47 
     46#define GAMESTATE_START(data) (data + GamestateHeader::getSize())
    4847
    4948#define PACKET_FLAG_GAMESTATE  ENET_PACKET_FLAG_RELIABLE
    5049
     50// Gamestate::Gamestate()
     51// {
     52//   flags_ = flags_ | PACKET_FLAG_GAMESTATE;
     53// }
     54
    5155Gamestate::Gamestate()
    5256{
    5357  flags_ = flags_ | PACKET_FLAG_GAMESTATE;
     58  header_ = 0;
    5459}
    5560
     
    5863{
    5964  flags_ = flags_ | PACKET_FLAG_GAMESTATE;
     65  header_ = new GamestateHeader(data_);
    6066}
    6167
     
    6470  flags_ = flags_ | PACKET_FLAG_GAMESTATE;
    6571  data_=data;
     72  header_ = new GamestateHeader(data_);
     73}
     74
     75Gamestate::Gamestate(const Gamestate& g) :
     76    Packet( *(Packet*)&g )
     77{
     78  flags_ = flags_ | PACKET_FLAG_GAMESTATE;
     79  header_ = new GamestateHeader(data_);
    6680}
    6781
     
    7387bool Gamestate::collectData(int id, uint8_t mode)
    7488{
    75   unsigned int tempsize=0, currentsize=0;
     89  assert(this->header_==0); // make sure the header didn't exist before
     90  uint32_t tempsize=0, currentsize=0;
    7691  assert(data_==0);
    77   unsigned int size = calcGamestateSize(id, mode);
     92  uint32_t size = calcGamestateSize(id, mode);
    7893
    7994  COUT(4) << "G.ST.Man: producing gamestate with id: " << id << std::endl;
    8095  if(size==0)
    8196    return false;
    82   data_ = new unsigned char[size + sizeof(GamestateHeader)];
     97  data_ = new uint8_t[size + GamestateHeader::getSize()];
    8398  if(!data_){
    8499    COUT(2) << "GameStateManager: could not allocate memory" << std::endl;
    85100    return false;
    86101  }
     102 
     103  // create the header object
     104  header_ = new GamestateHeader(data_);
    87105
    88106  //start collect data synchronisable by synchronisable
    89107  uint8_t *mem=data_;
    90   mem+=sizeof(GamestateHeader);
     108  mem += GamestateHeader::getSize();
    91109  ObjectList<Synchronisable>::iterator it;
    92110  for(it = ObjectList<Synchronisable>::begin(); it; ++it){
     111   
     112#ifndef NDEBUG
    93113    tempsize=it->getSize(id, mode);
    94 
    95114    if(currentsize+tempsize > size){
    96115      assert(0); // if we don't use multithreading this part shouldn't be neccessary
     
    98117      COUT(3) << "G.St.Man: need additional memory" << std::endl;
    99118      ObjectList<Synchronisable>::iterator temp = it;
    100       int addsize=tempsize;
     119      uint32_t addsize=tempsize;
    101120      while(++temp)
    102121        addsize+=temp->getSize(id, mode);
    103       data_ = (uint8_t *)realloc(data_, sizeof(GamestateHeader) + currentsize + addsize);
     122      data_ = (uint8_t *)realloc(data_, GamestateHeader::getSize() + currentsize + addsize);
    104123      if(!data_)
    105124        return false;
    106125      size = currentsize+addsize;
    107126    }// stop allocate additional memory
    108 
     127#endif
    109128
    110129    //if(it->doSelection(id))
    111     dataMap_[mem-data_]=(*it);  // save the mem location of the synchronisable data
     130    if ( it->doSync( id, mode ) )
     131      dataMap_.push_back( obj(it->getObjectID(), it->getCreatorID(), tempsize, mem-data_) );
     132//     dataMap_[mem-data_]=(*it);  // save the mem location of the synchronisable data
    112133    if(!it->getData(mem, id, mode))
    113134      return false; // mem pointer gets automatically increased because of call by reference
     
    118139
    119140  //start write gamestate header
    120   HEADER->packetType = ENUM::Gamestate;
    121   HEADER->datasize = currentsize;
    122   HEADER->id = id;
    123   HEADER->diffed = false;
    124   HEADER->complete = true;
    125   HEADER->compressed = false;
     141  header_->setDataSize( currentsize );
     142  header_->setID( id );
     143  header_->setDiffed( false );
     144  header_->setComplete( true );
     145  header_->setCompressed( false );
    126146  //stop write gamestate header
    127147
     
    133153bool Gamestate::spreadData(uint8_t mode)
    134154{
    135   assert(data_);
    136   assert(!HEADER->compressed);
    137   assert(!HEADER->diffed);
    138   uint8_t *mem=data_+sizeof(GamestateHeader);
     155  COUT(4) << "processing gamestate with id " << header_->getID() << endl;
     156  assert(data_);
     157  assert(!header_->isCompressed());
     158  assert(!header_->isDiffed());
     159  uint8_t *mem=data_+GamestateHeader::getSize();
    139160    // get the start of the Synchronisable list
    140161  //ObjectList<Synchronisable>::iterator it=ObjectList<Synchronisable>::begin();
     
    142163
    143164  // update the data of the objects we received
    144   while(mem < data_+sizeof(GamestateHeader)+HEADER->datasize){
    145     synchronisableHeader *objectheader = (synchronisableHeader*)mem;
    146 
    147     s = Synchronisable::getSynchronisable( objectheader->objectID );
     165  while(mem < data_+GamestateHeader::getSize()+header_->getDataSize()){
     166    SynchronisableHeader objectheader(mem);
     167
     168    s = Synchronisable::getSynchronisable( objectheader.getObjectID() );
    148169    if(!s)
    149170    {
    150       Synchronisable::fabricate(mem, mode);
     171      if (!Core::isMaster())
     172      {
     173        Synchronisable::fabricate(mem, mode);
     174      }
     175      else
     176      {
     177        mem += objectheader.getDataSize();
     178      }
     179//         COUT(0) << "could not fabricate synchronisable: " << objectheader->objectID << " classid: " << objectheader->classID << " creator: " << objectheader->creatorID << endl;
     180//       else
     181//         COUT(0) << "fabricated: " << objectheader->objectID << " classid: " << objectheader->classID << " creator: "  << objectheader->creatorID << endl;
    151182    }
    152183    else
     
    157188  }
    158189
     190   // In debug mode, check first, whether there are no duplicate objectIDs
     191#ifndef NDEBUG
     192  ObjectList<Synchronisable>::iterator it;
     193  for (it = ObjectList<Synchronisable>::begin(); it != ObjectList<Synchronisable>::end(); ++it) {
     194    if (it->getObjectID() == OBJECTID_UNKNOWN) {
     195      if (it->objectMode_ != 0x0) {
     196        COUT(0) << "Found object with OBJECTID_UNKNOWN on the client with objectMode != 0x0!" << std::endl;
     197        COUT(0) << "Possible reason for this error: Client created a synchronized object without the Server's approval." << std::endl;
     198        COUT(0) << "Objects class: " << it->getIdentifier()->getName() << std::endl;
     199        assert(false);
     200      }
     201    }
     202    else {
     203      ObjectList<Synchronisable>::iterator it2;
     204      for (it2 = ObjectList<Synchronisable>::begin(); it2 != ObjectList<Synchronisable>::end(); ++it2) {
     205        if (it->getObjectID() == it2->getObjectID() && *it != *it2) {
     206           COUT(0) << "Found duplicate objectIDs on the client!" << std::endl
     207                   << "Are you sure you don't create a Sychnronisable objcect with 'new' \
     208                       that doesn't have objectMode = 0x0?" << std::endl;
     209           assert(false);
     210        }
     211      }
     212    }
     213  }
     214#endif
     215
    159216  return true;
    160217}
    161218
    162 
    163 
    164 int Gamestate::getID(){
    165   return HEADER->id;
    166 }
    167 
    168 unsigned int Gamestate::getSize() const
    169 {
    170   assert(data_);
    171   if(HEADER->compressed)
    172     return HEADER->compsize+sizeof(GamestateHeader);
     219uint32_t Gamestate::getSize() const
     220{
     221  assert(data_);
     222  if(header_->isCompressed())
     223    return header_->getCompSize()+GamestateHeader::getSize();
    173224  else
    174225  {
    175     return HEADER->datasize+sizeof(GamestateHeader);
     226    return header_->getDataSize()+GamestateHeader::getSize();
    176227  }
    177228}
    178229
    179230bool Gamestate::operator==(packet::Gamestate gs){
    180   uint8_t *d1 = data_+sizeof(GamestateHeader);
    181   uint8_t *d2 = gs.data_+sizeof(GamestateHeader);
     231  uint8_t *d1 = data_+GamestateHeader::getSize();
     232  uint8_t *d2 = gs.data_+GamestateHeader::getSize();
    182233  assert(!isCompressed());
    183234  assert(!gs.isCompressed());
    184   while(d1<data_+HEADER->datasize)
     235  while(d1<data_+header_->getDataSize())
    185236  {
    186237    if(*d1!=*d2)
     
    201252bool Gamestate::compressData()
    202253{
    203   assert(HEADER);
    204   assert(!HEADER->compressed);
    205   uLongf buffer = (uLongf)(((HEADER->datasize + 12)*1.01)+1);
     254  assert(data_);
     255  assert(!header_->isCompressed());
     256  uLongf buffer = (uLongf)(((header_->getDataSize() + 12)*1.01)+1);
    206257  if(buffer==0)
    207258    return false;
    208259
    209   uint8_t *ndata = new uint8_t[buffer+sizeof(GamestateHeader)];
    210   uint8_t *dest = GAMESTATE_START(ndata);
     260  uint8_t *ndata = new uint8_t[buffer+GamestateHeader::getSize()];
     261  uint8_t *dest = ndata + GamestateHeader::getSize();
    211262  //unsigned char *dest = new unsigned char[buffer];
    212   uint8_t *source = GAMESTATE_START(data_);
     263  uint8_t *source = data_ + GamestateHeader::getSize();
    213264  int retval;
    214   retval = compress( dest, &buffer, source, (uLong)(HEADER->datasize) );
     265  retval = compress( dest, &buffer, source, (uLong)(header_->getDataSize()) );
    215266  switch ( retval ) {
    216267    case Z_OK: COUT(5) << "G.St.Man: compress: successfully compressed" << std::endl; break;
     
    219270    case Z_DATA_ERROR: COUT(2) << "G.St.Man: compress: data corrupted in gamestate.compress" << std::endl; return false;
    220271  }
    221 #ifndef NDEBUG
    222   //decompress and compare the start and the decompressed data
    223   uint8_t *rdata = new uint8_t[HEADER->datasize+sizeof(GamestateHeader)];
    224   uint8_t *d2 = GAMESTATE_START(rdata);
    225   uLongf length2 = HEADER->datasize;
    226   uncompress(d2, &length2, dest, buffer);
    227   for(unsigned int i=0; i<HEADER->datasize; i++){
    228     assert(*(source+i)==*(d2+i));
    229   }
    230   delete[] rdata;
    231 #endif
    232272
    233273  //copy and modify header
    234 #ifndef NDEBUG
    235   HEADER->crc32 = calcCRC(data_+sizeof(GamestateHeader), HEADER->datasize);
    236 #endif
    237   *GAMESTATE_HEADER(ndata) = *HEADER;
     274  GamestateHeader *temp = header_;
     275  header_ = new GamestateHeader(ndata, temp);
     276  delete temp;
    238277  //delete old data
    239278  delete[] data_;
    240279  //save new data
    241280  data_ = ndata;
    242   HEADER->compsize = buffer;
    243   HEADER->compressed = true;
    244   assert(HEADER->compressed);
    245   COUT(4) << "gamestate compress datasize: " << HEADER->datasize << " compsize: " << HEADER->compsize << std::endl;
     281  header_->setCompSize( buffer );
     282  header_->setCompressed( true );
     283  COUT(5) << "gamestate compress datasize: " << header_->getDataSize() << " compsize: " << header_->getCompSize() << std::endl;
    246284  return true;
    247285}
    248286bool Gamestate::decompressData()
    249287{
    250   assert(HEADER);
    251   assert(HEADER->compressed);
    252   COUT(4) << "GameStateClient: uncompressing gamestate. id: " << HEADER->id << ", baseid: " << HEADER->base_id << ", datasize: " << HEADER->datasize << ", compsize: " << HEADER->compsize << std::endl;
    253   unsigned int datasize = HEADER->datasize;
    254   unsigned int compsize = HEADER->compsize;
    255   unsigned int bufsize;
     288  assert(data_);
     289  assert(header_->isCompressed());
     290  COUT(4) << "GameStateClient: uncompressing gamestate. id: " << header_->getID() << ", baseid: " << header_->getBaseID() << ", datasize: " << header_->getDataSize() << ", compsize: " << header_->getCompSize() << std::endl;
     291  uint32_t datasize = header_->getDataSize();
     292  uint32_t compsize = header_->getCompSize();
     293  uint32_t bufsize;
    256294//  assert(compsize<=datasize);
    257295  bufsize = datasize;
    258296  assert(bufsize!=0);
    259   uint8_t *ndata = new uint8_t[bufsize + sizeof(GamestateHeader)];
    260   uint8_t *dest = ndata + sizeof(GamestateHeader);
    261   uint8_t *source = data_ + sizeof(GamestateHeader);
     297  uint8_t *ndata = new uint8_t[bufsize + GamestateHeader::getSize()];
     298  uint8_t *dest = ndata + GamestateHeader::getSize();
     299  uint8_t *source = data_ + GamestateHeader::getSize();
    262300  int retval;
    263301  uLongf length=bufsize;
     
    269307    case Z_DATA_ERROR: COUT(2) << "data corrupted (zlib)" << std::endl; return false;
    270308  }
    271 #ifndef NDEBUG
    272   assert(HEADER->crc32==calcCRC(ndata+sizeof(GamestateHeader), HEADER->datasize));
    273 #endif
    274309
    275310  //copy over the header
    276   *GAMESTATE_HEADER(ndata) = *HEADER;
     311  GamestateHeader *temp = header_;
     312  header_ = new GamestateHeader( data_, header_ );
     313  delete temp;
    277314
    278315  if (this->bDataENetAllocated_){
     
    289326  //set new pointers
    290327  data_ = ndata;
    291   HEADER->compressed = false;
    292   assert(HEADER->datasize==datasize);
    293   assert(HEADER->compsize==compsize);
     328  header_->setCompressed( false );
     329  assert(header_->getDataSize()==datasize);
     330  assert(header_->getCompSize()==compsize);
    294331  return true;
    295332}
     
    297334Gamestate *Gamestate::diff(Gamestate *base)
    298335{
    299   assert(HEADER);
    300   assert(!HEADER->compressed);
    301   assert(!HEADER->diffed);
     336  assert(data_);
     337  assert(!header_->isCompressed());
     338  assert(!header_->isDiffed());
     339  GamestateHeader diffHeader(base->data_);
    302340  //unsigned char *basep = base->getGs()/*, *gs = getGs()*/;
    303341  uint8_t *basep = GAMESTATE_START(base->data_), *gs = GAMESTATE_START(this->data_);
    304   unsigned int of=0; // pointers offset
    305   unsigned int dest_length=0;
    306   dest_length=HEADER->datasize;
     342  uint32_t of=0; // pointers offset
     343  uint32_t dest_length=0;
     344  dest_length=header_->getDataSize();
    307345  if(dest_length==0)
    308346    return NULL;
    309   uint8_t *ndata = new uint8_t[dest_length*sizeof(uint8_t)+sizeof(GamestateHeader)];
    310   uint8_t *dest = ndata + sizeof(GamestateHeader);
    311   while(of < GAMESTATE_HEADER(base->data_)->datasize && of < HEADER->datasize){
     347  uint8_t *ndata = new uint8_t[dest_length*sizeof(uint8_t)+GamestateHeader::getSize()];
     348  uint8_t *dest = ndata + GamestateHeader::getSize();
     349  while(of < diffHeader.getDataSize() && of < header_->getDataSize()){
    312350    *(dest+of)=*(basep+of)^*(gs+of); // do the xor
    313351    ++of;
    314352  }
    315   if(GAMESTATE_HEADER(base->data_)->datasize!=HEADER->datasize){
     353  if(diffHeader.getDataSize()!=header_->getDataSize()){
    316354    uint8_t n=0;
    317     if(GAMESTATE_HEADER(base->data_)->datasize < HEADER->datasize){
     355    if(diffHeader.getDataSize() < header_->getDataSize()){
    318356      while(of<dest_length){
    319357        *(dest+of)=n^*(gs+of);
     
    323361  }
    324362
    325   *GAMESTATE_HEADER(ndata) = *HEADER;
    326   GAMESTATE_HEADER(ndata)->diffed = true;
    327   GAMESTATE_HEADER(ndata)->base_id = base->getID();
    328363  Gamestate *g = new Gamestate(ndata, getClientID());
     364  *(g->header_) = *header_;
     365  g->header_->setDiffed( true );
     366  g->header_->setBaseID( base->getID() );
    329367  g->flags_=flags_;
    330368  g->packetDirection_ = packetDirection_;
     
    332370}
    333371
    334 Gamestate* Gamestate::doSelection(unsigned int clientID){
    335   assert(data_);
    336   std::map<unsigned int, Synchronisable *>::iterator it;
     372Gamestate* Gamestate::doSelection(unsigned int clientID, unsigned int targetSize){
     373  assert(data_);
     374  std::list<obj>::iterator it;
    337375
    338376  // allocate memory for new data
    339   uint8_t *gdata = new uint8_t[HEADER->datasize+sizeof(GamestateHeader)];
     377  uint8_t *gdata = new uint8_t[header_->getDataSize()+GamestateHeader::getSize()];
    340378  // create a gamestate out of it
    341379  Gamestate *gs = new Gamestate(gdata);
    342   uint8_t *newdata = gdata + sizeof(GamestateHeader);
     380  uint8_t *newdata = gdata + GamestateHeader::getSize();
    343381  uint8_t *origdata = GAMESTATE_START(data_);
    344382
    345383  //copy the GamestateHeader
    346   *(GamestateHeader*)gdata = *HEADER;
    347 
    348   synchronisableHeader *oldobjectheader, *newobjectheader;
    349   unsigned int objectOffset;
     384  assert(gs->header_);
     385  *(gs->header_) = *header_;
     386
     387  uint32_t objectOffset;
     388  unsigned int objectsize, destsize=0;
     389  // TODO: Why is this variable not used?
     390  //Synchronisable *object;
     391
     392  //call TrafficControl
     393  TrafficControl::getInstance()->processObjectList( clientID, header_->getID(), &dataMap_ );
    350394
    351395  //copy in the zeros
    352   for(it=dataMap_.begin(); it!=dataMap_.end(); it++){
    353     oldobjectheader = (synchronisableHeader*)origdata;
    354     newobjectheader = (synchronisableHeader*)newdata;
    355     unsigned int objectsize = oldobjectheader->size;
    356     assert(it->second->objectID==oldobjectheader->objectID);
    357     *newobjectheader = *oldobjectheader;
    358     objectOffset=sizeof(synchronisableHeader); //skip the size and the availableData variables in the objectheader
    359     if(it->second->doSelection(HEADER->id)){
    360       assert(newobjectheader->dataAvailable==true);
    361       memcpy(newdata+objectOffset, origdata+objectOffset, objectsize-objectOffset);
     396  for(it=dataMap_.begin(); it!=dataMap_.end();){
     397//    if((*it).objSize==0)
     398//      continue;
     399//    if(it->second->getSize(HEADER->id)==0) // merged from objecthierarchy2, doesn't work anymore; TODO: change this
     400//      continue;                            // merged from objecthierarchy2, doesn't work anymore; TODO: change this
     401    SynchronisableHeader oldobjectheader(origdata);
     402    SynchronisableHeader newobjectheader(newdata);
     403    if ( (*it).objSize == 0 )
     404    {
     405      ++it;
     406      continue;
     407    }
     408//     object = Synchronisable::getSynchronisable( (*it).objID );
     409//     assert(object->objectID == oldobjectheader->objectID);
     410    objectsize = oldobjectheader.getDataSize();
     411    objectOffset=SynchronisableHeader::getSize(); //skip the size and the availableData variables in the objectheader
     412    if ( (*it).objID == oldobjectheader.getObjectID() ){
     413      memcpy(newdata, origdata, objectsize);
     414      assert(newobjectheader.isDataAvailable()==true);
     415      ++it;
    362416    }else{
    363       newobjectheader->dataAvailable=false;
     417      newobjectheader = oldobjectheader;
     418      newobjectheader.setDataAvailable(false);
    364419      memset(newdata+objectOffset, 0, objectsize-objectOffset);
    365       assert(objectOffset==objectsize);
    366420    }
    367421    newdata += objectsize;
    368422    origdata += objectsize;
    369   }
     423    destsize += objectsize;
     424  }
     425#ifndef NDEBUG
     426  uint32_t origsize = destsize;
     427  while ( origsize < header_->getDataSize() )
     428  {
     429    SynchronisableHeader oldobjectheader(origdata);
     430    objectsize = oldobjectheader.getDataSize();
     431    origdata += objectsize;
     432    origsize += objectsize;
     433  }
     434  assert(origsize==header_->getDataSize());
     435  assert(destsize!=0);
     436#endif
     437  gs->header_->setDataSize( destsize );
    370438  return gs;
    371439}
    372440
    373441
    374 Gamestate* Gamestate::intelligentDiff(Gamestate *base, unsigned int clientID){
    375   // asserts
    376   assert(data_);
    377   assert(base->data_);
    378   assert(!GAMESTATE_HEADER(base->data_)->diffed);
    379   assert(!GAMESTATE_HEADER(base->data_)->compressed);
    380   assert(!HEADER->compressed);
    381   assert(!HEADER->diffed);
    382 
    383   //preparations
    384   std::map<unsigned int, Synchronisable *>::iterator it;
    385   uint8_t *origdata, *basedata, *destdata, *ndata;
    386   unsigned int objectOffset, streamOffset=0;    //data offset
    387   unsigned int minsize = (HEADER->datasize < GAMESTATE_HEADER(base->data_)->datasize) ? HEADER->datasize : GAMESTATE_HEADER(base->data_)->datasize;
    388   synchronisableHeader *origheader;
    389   synchronisableHeader *destheader;
    390 
    391   origdata = GAMESTATE_START(this->data_);
    392   basedata = GAMESTATE_START(base->data_);
    393   ndata = new uint8_t[HEADER->datasize + sizeof(GamestateHeader)];
    394   destdata = ndata + sizeof(GamestateHeader);
    395 
    396   // do the diff
    397   for(it=dataMap_.begin(); it!=dataMap_.end(); it++){
    398     assert(streamOffset<HEADER->datasize);
    399     bool sendData = it->second->doSelection(HEADER->id);
    400     origheader = (synchronisableHeader *)(origdata+streamOffset);
    401     destheader = (synchronisableHeader *)(destdata+streamOffset);
    402 
    403     //copy and partially diff the object header
    404     assert(sizeof(synchronisableHeader)==3*sizeof(unsigned int)+sizeof(bool));
    405     *(uint32_t*)destdata = *(uint32_t*)origdata; //size (do not diff)
    406     *(bool*)(destdata+sizeof(uint32_t)) = sendData;
    407     if(sendData){
    408       *(uint32_t*)(destdata+sizeof(uint32_t)+sizeof(bool)) = *(uint32_t*)(basedata+sizeof(uint32_t)+sizeof(bool)) ^ *(uint32_t*)(origdata+sizeof(uint32_t)+sizeof(bool)); //objectid (diff it)
    409       *(uint32_t*)(destdata+2*sizeof(uint32_t)+sizeof(bool)) = *(uint32_t*)(basedata+2*sizeof(uint32_t)+sizeof(bool)) ^ *(uint32_t*)(origdata+2*sizeof(uint32_t)+sizeof(bool)); //classid (diff it)
    410     }else{
    411       *(uint32_t*)(destdata+sizeof(uint32_t)+sizeof(bool)) = 0;
    412       *(uint32_t*)(destdata+2*sizeof(uint32_t)+sizeof(bool)) = 0;
    413     }
    414     objectOffset=sizeof(synchronisableHeader);
    415     streamOffset+=sizeof(synchronisableHeader);
    416 
    417     //now handle the object data or fill with zeros
    418     while(objectOffset<origheader->size ){
    419 
    420       if(sendData && streamOffset<minsize)
    421         *(destdata+objectOffset)=*(basedata+objectOffset)^*(origdata+objectOffset); // do the xor
    422       else if(sendData)
    423         *(destdata+objectOffset)=((uint8_t)0)^*(origdata+objectOffset); // xor with 0 (basestream is too short)
    424       else
    425         *(destdata+objectOffset)=0; // set to 0 because this object should not be transfered
    426 
    427       objectOffset++;
    428       streamOffset++;
    429     }
    430     destdata+=objectOffset;
    431     origdata+=objectOffset;
    432     basedata+=objectOffset;
    433   }
    434 
    435   //copy over the gamestate header and set the diffed flag
    436   *(GamestateHeader *)ndata = *HEADER; //copy over the header
    437   Gamestate *gs = new Gamestate(ndata);
    438   GAMESTATE_HEADER(ndata)->diffed=true;
    439   return gs;
    440 }
    441 
    442 Gamestate* Gamestate::intelligentUnDiff(Gamestate *base){
    443   // asserts
    444   assert(data_);
    445   assert(base->data_);
    446   assert(!GAMESTATE_HEADER(base->data_)->diffed);
    447   assert(!GAMESTATE_HEADER(base->data_)->compressed);
    448   assert(!HEADER->compressed);
    449   assert(HEADER->diffed);
    450 
    451   //preparations
    452   std::map<unsigned int, Synchronisable *>::iterator it;
    453   uint8_t *origdata, *basedata, *destdata, *ndata;
    454   unsigned int objectOffset, streamOffset=0;    //data offset
    455   unsigned int minsize = (HEADER->datasize < GAMESTATE_HEADER(base->data_)->datasize) ? HEADER->datasize : GAMESTATE_HEADER(base->data_)->datasize;
    456   synchronisableHeader *origheader;
    457   synchronisableHeader *destheader;
    458 
    459   origdata = GAMESTATE_START(this->data_);
    460   basedata = GAMESTATE_START(base->data_);
    461   ndata = new uint8_t[HEADER->datasize + sizeof(GamestateHeader)];
    462   destdata = ndata + sizeof(GamestateHeader);
    463 
    464   // do the undiff
    465   for(it=dataMap_.begin(); it!=dataMap_.end(); it++){
    466     assert(streamOffset<HEADER->datasize);
    467     origheader = (synchronisableHeader *)(origdata+streamOffset);
    468     destheader = (synchronisableHeader *)(destdata+streamOffset);
    469     bool sendData;
    470 
    471     //copy and partially diff the object header
    472     assert(sizeof(synchronisableHeader)==3*sizeof(unsigned int)+sizeof(bool));
    473     *(unsigned int*)destdata = *(unsigned int*)origdata; //size (do not diff)
    474     *(bool*)(destdata+sizeof(unsigned int)) = *(bool*)(origdata+sizeof(unsigned int));
    475     sendData = *(bool*)(origdata+sizeof(unsigned int));
    476     if(sendData){
    477       *(unsigned int*)(destdata+sizeof(unsigned int)+sizeof(bool)) = *(unsigned int*)(basedata+sizeof(unsigned int)+sizeof(bool)) ^ *(unsigned int*)(origdata+sizeof(unsigned int)+sizeof(bool)); //objectid (diff it)
    478       *(unsigned int*)(destdata+2*sizeof(unsigned int)+sizeof(bool)) = *(unsigned int*)(basedata+2*sizeof(unsigned int)+sizeof(bool)) ^ *(unsigned int*)(origdata+2*sizeof(unsigned int)+sizeof(bool)); //classid (diff it)
    479     }else{
    480       *(unsigned int*)(destdata+sizeof(unsigned int)+sizeof(bool)) = 0;
    481       *(unsigned int*)(destdata+2*sizeof(unsigned int)+sizeof(bool)) = 0;
    482     }
    483     objectOffset=sizeof(synchronisableHeader);
    484     streamOffset+=sizeof(synchronisableHeader);
    485 
    486     //now handle the object data or fill with zeros
    487     while(objectOffset<origheader->size ){
    488 
    489       if(sendData && streamOffset<minsize)
    490         *(destdata+objectOffset)=*(basedata+objectOffset)^*(origdata+objectOffset); // do the xor
    491       else if(sendData)
    492         *(destdata+objectOffset)=((unsigned char)0)^*(origdata+objectOffset); // xor with 0 (basestream is too short)
    493       else
    494         *(destdata+objectOffset)=0; // set to 0 because this object should not be transfered
    495 
    496       objectOffset++;
    497       streamOffset++;
    498     }
    499     destdata+=objectOffset;
    500     origdata+=objectOffset;
    501     basedata+=objectOffset;
    502   }
    503 
    504   //copy over the gamestate header and set the diffed flag
    505   *(GamestateHeader *)ndata = *HEADER; //copy over the header
    506   Gamestate *gs = new Gamestate(ndata);
    507   GAMESTATE_HEADER(ndata)->diffed=false;
    508   return gs;
    509 }
    510 
    511442Gamestate *Gamestate::undiff(Gamestate *base)
    512443{
    513   assert(this && base);assert(HEADER);
    514   assert(HEADER->diffed);
    515   assert(!HEADER->compressed && !GAMESTATE_HEADER(base->data_)->compressed);
     444  assert(this && base);assert(data_);
     445  assert(header_->isDiffed());
     446  assert(!header_->isCompressed() && !base->header_->isCompressed());
    516447  //unsigned char *basep = base->getGs()/*, *gs = getGs()*/;
    517448  uint8_t *basep = GAMESTATE_START(base->data_);
    518449  uint8_t *gs = GAMESTATE_START(this->data_);
    519   unsigned int of=0; // pointers offset
    520   unsigned int dest_length=0;
    521   dest_length=HEADER->datasize;
     450  uint32_t of=0; // pointers offset
     451  uint32_t dest_length=0;
     452  dest_length=header_->getDataSize();
    522453  if(dest_length==0)
    523454    return NULL;
    524   uint8_t *ndata = new uint8_t[dest_length*sizeof(uint8_t)+sizeof(GamestateHeader)];
    525   uint8_t *dest = ndata + sizeof(GamestateHeader);
    526   while(of < GAMESTATE_HEADER(base->data_)->datasize && of < HEADER->datasize){
     455  uint8_t *ndata = new uint8_t[dest_length*sizeof(uint8_t)+GamestateHeader::getSize()];
     456  uint8_t *dest = ndata + GamestateHeader::getSize();
     457  while(of < base->header_->getDataSize() && of < header_->getDataSize()){
    527458    *(dest+of)=*(basep+of)^*(gs+of); // do the xor
    528459    ++of;
    529460  }
    530   if(GAMESTATE_HEADER(base->data_)->datasize!=HEADER->datasize){
     461  if(base->header_->getDataSize()!=header_->getDataSize()){
    531462    uint8_t n=0;
    532     if(GAMESTATE_HEADER(base->data_)->datasize < HEADER->datasize){
     463    if(base->header_->getDataSize() < header_->getDataSize()){
    533464      while(of < dest_length){
    534465        *(dest+of)=n^*(gs+of);
     
    537468    }
    538469  }
    539   *GAMESTATE_HEADER(ndata) = *HEADER;
    540   GAMESTATE_HEADER(ndata)->diffed = false;
    541470  Gamestate *g = new Gamestate(ndata, getClientID());
     471  assert(g->header_);
     472  *(g->header_) = *header_;
     473  g->header_->setDiffed( false );
    542474  g->flags_=flags_;
    543475  g->packetDirection_ = packetDirection_;
     
    548480
    549481
    550 unsigned int Gamestate::calcGamestateSize(unsigned int id, uint8_t mode)
    551 {
    552   unsigned int size=0;
     482uint32_t Gamestate::calcGamestateSize(int32_t id, uint8_t mode)
     483{
     484  uint32_t size=0;
    553485    // get the start of the Synchronisable list
    554486  ObjectList<Synchronisable>::iterator it;
     
    556488  for(it = ObjectList<Synchronisable>::begin(); it; ++it)
    557489    size+=it->getSize(id, mode); // size of the actual data of the synchronisable
    558 //  size+=sizeof(GamestateHeader);
    559490  return size;
    560491}
    561492
    562 /**
    563  * This function removes a Synchronisable out of the universe
    564  * @param it iterator of the list pointing to the object
    565  * @return iterator pointing to the next object in the list
    566  */
    567   void Gamestate::removeObject(ObjectList<Synchronisable>::iterator &it) {
    568     ObjectList<Synchronisable>::iterator temp=it;
    569     ++it;
    570     delete  *temp;
    571   }
    572 
    573   bool Gamestate::isDiffed(){
    574     return HEADER->diffed;
    575   }
    576 
    577   bool Gamestate::isCompressed(){
    578     return HEADER->compressed;
    579   }
    580 
    581   int Gamestate::getBaseID(){
    582     return HEADER->base_id;
    583   }
    584 }
    585 
    586 }
     493} //namespace packet
     494} //namespace orxonox
  • code/trunk/src/network/packet/Gamestate.h

    r2171 r2662  
    3131#define NETWORK_PACKETGAMESTATE_H
    3232
    33 #include "../NetworkPrereqs.h"
     33#include "network/NetworkPrereqs.h"
    3434
    3535#include "Packet.h"
    36 #include "network/Synchronisable.h"
     36#include "network/TrafficControl.h"
     37#include "core/CoreIncludes.h"
    3738#include <map>
     39#include <list>
    3840#ifndef NDEBUG
    3941#include "util/CRC32.h"
     
    4446namespace packet {
    4547
    46 struct _NetworkExport GamestateHeader{
    47   ENUM::Type packetType;
    48   int32_t id; // id of the gamestate
    49   uint32_t compsize;
    50   uint32_t datasize;
    51   int32_t base_id; // id of the base-gamestate diffed from
    52   bool diffed:1; // wheter diffed or not
    53   bool complete:1; // wheter it is a complete gamestate or only partial
    54   bool compressed:1;
    55 #ifndef NDEBUG
    56   uint32_t crc32;
    57 #endif
     48class _NetworkExport GamestateHeader{
     49  public:
     50    GamestateHeader(uint8_t *data){ assert(data); data_ = data; *(uint32_t*)data_ = ENUM::Gamestate; }
     51    GamestateHeader(uint8_t *data, GamestateHeader* h)
     52    { assert(data); data_=data; memcpy(data_, h->data_, getSize()); }
     53    static inline uint32_t getSize()
     54    { return 21; }
     55
     56    inline int32_t getID() const
     57    { assert(data_); return *(int32_t*)(data_+4); }
     58    inline void setID(int32_t id)
     59    { assert(data_); *(int32_t*)(data_+4) = id; }
     60
     61    inline int32_t getBaseID() const
     62    { assert(data_); return *(int32_t*)(data_+8); }
     63    inline void setBaseID(int32_t id)
     64    { assert(data_); *(int32_t*)(data_+8) = id; }
     65
     66    inline uint32_t getDataSize() const
     67    { assert(data_); return *(uint32_t*)(data_+12); }
     68    inline void setDataSize(uint32_t size)
     69    { assert(data_); *(uint32_t*)(data_+12) = size; }
     70
     71    inline uint32_t getCompSize() const
     72    { assert(data_); return *(uint32_t*)(data_+16); }
     73    inline void setCompSize(uint32_t size)
     74    { assert(data_); *(uint32_t*)(data_+16) = size; }
     75
     76    inline bool isDiffed() const
     77    { assert(data_); return *(int8_t*)(data_+20) & 0x1; }
     78    inline void setDiffed(bool b)
     79    { assert(data_); *(int8_t*)(data_+20) = (b<<0) | (*(int8_t*)(data_+20) & 0x6 ); }
     80
     81    inline bool isComplete() const
     82    { assert(data_); return *(int8_t*)(data_+20) & 0x2; }
     83    inline void setComplete(bool b)
     84    { assert(data_); *(int8_t*)(data_+20) = (b<<1) | (*(int8_t*)(data_+20) & 0x5 ); }
     85
     86    inline bool isCompressed() const
     87    { assert(data_); return *(int8_t*)(data_+20) & 0x4; }
     88    inline void setCompressed(bool b)
     89    { assert(data_); *(int8_t*)(data_+20) = (b<<2) | (*(int8_t*)(data_+20) & 0x3 ); }
     90
     91    inline void operator=(GamestateHeader& h)
     92    { assert(data_); assert(h.data_); memcpy( data_, h.data_, getSize()); }
     93  private:
     94    uint8_t *data_;
     95//#define GAMESTATE_START(data) (data + sizeof(GamestateHeader))
     96//#define GAMESTATE_HEADER(data) ((GamestateHeader *)data)
     97//#define HEADER GAMESTATE_HEADER(data_)
     98
    5899};
    59100
     
    66107    Gamestate(uint8_t *data, unsigned int clientID);
    67108    Gamestate(uint8_t *data);
     109    Gamestate(const Gamestate& g);
    68110
    69111    ~Gamestate();
     
    71113    bool collectData(int id, uint8_t mode=0x0);
    72114    bool spreadData( uint8_t mode=0x0);
    73     int getID();
    74     bool isDiffed();
    75     bool isCompressed();
    76     int getBaseID();
     115    inline int32_t getID() const { return header_->getID(); }
     116    inline bool isDiffed() const { return header_->isDiffed(); }
     117    inline bool isCompressed() const { return header_->isCompressed(); }
     118    inline int32_t getBaseID() const { return header_->getBaseID(); }
    77119    Gamestate *diff(Gamestate *base);
    78     Gamestate* intelligentDiff(Gamestate *base, unsigned int clientID);
    79120    Gamestate *undiff(Gamestate *base);
    80     Gamestate* intelligentUnDiff(Gamestate *base);
    81     Gamestate* doSelection(unsigned int clientID);
     121    Gamestate* doSelection(unsigned int clientID, unsigned int targetSize);
    82122    bool compressData();
    83123    bool decompressData();
     
    85125    // Packet functions
    86126  private:
    87     virtual unsigned int getSize() const;
    88     virtual bool process();
     127    virtual uint32_t getSize() const;
     128    virtual inline bool process();
    89129
    90130    bool operator ==(packet::Gamestate gs);
    91131  private:
    92     unsigned int calcGamestateSize(unsigned int id, uint8_t mode=0x0);
    93     void removeObject(ObjectListIterator<Synchronisable> &it);
    94     std::map<unsigned int, Synchronisable*> dataMap_;
     132    uint32_t calcGamestateSize(int32_t id, uint8_t mode=0x0);
     133    std::list<obj> dataMap_;
     134    GamestateHeader* header_;
    95135};
    96136
  • code/trunk/src/network/packet/Packet.cc

    r2171 r2662  
    129129      return false;
    130130    }
    131     // Assures we don't create a packet and destroy it right after in another thread
    132     // without having a reference in the packetMap_
    133     boost::recursive_mutex::scoped_lock lock(Packet::packetMap_mutex);
    134131    // We deliver ENet the data address so that it doesn't memcpy everything again.
    135132    // --> We have to delete data_ ourselves!
     
    138135    // Add the packet to a global list so we can access it again once enet calls our
    139136    // deletePacket method. We can of course only give a one argument function to the ENet C library.
    140     packetMap_[(size_t)(void*)enetPacket_] = this;
     137    {
     138      // Assures we don't create a packet and destroy it right after in another thread
     139      // without having a reference in the packetMap_
     140      boost::recursive_mutex::scoped_lock lock(Packet::packetMap_mutex);
     141      packetMap_[(size_t)(void*)enetPacket_] = this;
     142    }
    141143  }
    142144#ifndef NDEBUG
  • code/trunk/src/network/packet/Welcome.cc

    r2171 r2662  
    3232#include "Welcome.h"
    3333#include "network/Host.h"
    34 #include "network/Synchronisable.h"
     34#include "network/synchronisable/Synchronisable.h"
    3535#include "core/CoreIncludes.h"
    3636#include <assert.h>
     
    4242#define _PACKETID             0
    4343#define _CLIENTID             _PACKETID + sizeof(ENUM::Type)
    44 #define _SHIPID               _CLIENTID + sizeof(uint32_t)
    45  
    46   Welcome::Welcome( unsigned int clientID, unsigned int shipID )
     44#define _ENDIANTEST           _CLIENTID + sizeof(uint32_t)
     45
     46  Welcome::Welcome( uint32_t clientID, uint32_t shipID )
    4747 : Packet()
    4848{
     
    5252  assert(data_);
    5353  *(packet::ENUM::Type *)(data_ + _PACKETID ) = packet::ENUM::Welcome;
    54   *(uint32_t *)&data_[ _CLIENTID ] = clientID;
    55   *(uint32_t *)&data_[ _SHIPID ] = shipID;
     54  *(uint32_t *)(data_ + _CLIENTID ) = static_cast<uint32_t>(clientID);
     55  *(uint32_t *)(data_ + _ENDIANTEST ) = 0xFEDC4321;
    5656}
    5757
    58 Welcome::Welcome( uint8_t* data, unsigned int clientID )
     58Welcome::Welcome( uint8_t* data, uint32_t clientID )
    5959  : Packet(data, clientID)
    6060{
     
    7474
    7575bool Welcome::process(){
    76   unsigned int shipID, clientID;
    77   clientID = *(uint32_t *)&data_[ _CLIENTID ];
    78   shipID = *(uint32_t *)&data_[ _SHIPID ];
     76  uint32_t clientID;
     77  clientID = *(uint32_t *)(data_ + _CLIENTID );
     78  assert(*(uint32_t *)(data_ + _ENDIANTEST ) == 0xFEDC4321);
    7979  Host::setClientID(clientID);
    80   Host::setShipID(shipID);
    81   COUT(3) << "Welcome set clientId: " << clientID << " shipID: " << shipID << std::endl;
     80  COUT(3) << "Welcome set clientId: " << clientID << endl;
    8281  Synchronisable::setClient(true);
    8382  delete this;
  • code/trunk/src/network/packet/Welcome.h

    r2171 r2662  
    4242{
    4343public:
    44   Welcome( unsigned int clientID, unsigned int shipID );
    45   Welcome( uint8_t* data, unsigned int clientID );
     44  Welcome( uint32_t clientID, uint32_t shipID );
     45  Welcome( uint8_t* data, uint32_t clientID );
    4646  virtual ~Welcome();
    4747
  • code/trunk/src/network/synchronisable/NetworkCallback.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/network/synchronisable/Synchronisable.cc

    r2653 r2662  
    2828 */
    2929
    30 //
    31 // C++ Implementation: synchronisable
    32 //
    33 // Description:
    34 //
    35 //
    36 // Author:  Dumeni, Oliver Scheuss, (C) 2007
    37 //
    38 // Copyright: See COPYING file that comes with this distribution
    39 //
    4030
    4131#include "Synchronisable.h"
     
    155145  Synchronisable *Synchronisable::fabricate(uint8_t*& mem, uint8_t mode)
    156146  {
    157     synchronisableHeader *header = (synchronisableHeader *)mem;
    158 
    159     if(!header->dataAvailable)
    160     {
    161       mem += header->size;
     147    SynchronisableHeader header(mem);
     148
     149    if(!header.isDataAvailable())
     150    {
     151      mem += header.getDataSize();
    162152      return 0;
    163153    }
    164154
    165     COUT(4) << "fabricating object with id: " << header->objectID << std::endl;
    166 
    167     Identifier* id = ClassByID(header->classID);
     155    COUT(4) << "fabricating object with id: " << header.getObjectID() << std::endl;
     156
     157    Identifier* id = ClassByID(header.getClassID());
    168158    if (!id)
    169159    {
     
    174164    assert(id);
    175165    BaseObject* creator = 0;
    176     if (header->creatorID != OBJECTID_UNKNOWN)
    177     {
    178       Synchronisable* synchronisable_creator = Synchronisable::getSynchronisable(header->creatorID);
     166    if (header.getCreatorID() != OBJECTID_UNKNOWN)
     167    {
     168      Synchronisable* synchronisable_creator = Synchronisable::getSynchronisable(header.getCreatorID());
    179169      if (!synchronisable_creator)
    180170      {
    181         mem += header->size; //.TODO: this suckz.... remove size from header
    182 //         assert(0); // TODO: uncomment this if we have a clean objecthierarchy (with destruction of children of objects) ^^
     171        mem += header.getDataSize(); //.TODO: this suckz.... remove size from header
     172        assert(0); // TODO: uncomment this if we have a clean objecthierarchy (with destruction of children of objects) ^^
    183173        return 0;
    184174      }
     
    186176        creator = dynamic_cast<BaseObject*>(synchronisable_creator);
    187177    }
    188     assert(getSynchronisable(header->objectID)==0);   //make sure no object with this id exists
     178    assert(getSynchronisable(header.getObjectID())==0);   //make sure no object with this id exists
    189179    BaseObject *bo = id->fabricate(creator);
    190180    assert(bo);
    191181    Synchronisable *no = dynamic_cast<Synchronisable *>(bo);
    192182    assert(no);
    193     no->objectID=header->objectID;
    194     no->creatorID=header->creatorID; //TODO: remove this
    195     no->classID=header->classID;
     183    no->objectID=header.getObjectID();
     184    no->creatorID=header.getCreatorID(); //TODO: remove this
     185    no->classID=header.getClassID();
    196186    COUT(4) << "fabricate objectID: " << no->objectID << " classID: " << no->classID << std::endl;
    197187          // update data and create object/entity...
     
    329319
    330320    // start copy header
    331     synchronisableHeader *header = (synchronisableHeader *)mem;
    332     header->size = size;
    333     header->objectID = this->objectID;
    334     header->creatorID = this->creatorID;
    335     header->classID = this->classID;
    336     header->dataAvailable = true;
    337     tempsize += sizeof(synchronisableHeader);
    338     mem += sizeof(synchronisableHeader);
     321    SynchronisableHeader header(mem);
     322    header.setDataSize( size );
     323    header.setObjectID( this->objectID );
     324    header.setCreatorID( this->creatorID );
     325    header.setClassID( this->classID );
     326    header.setDataAvailable( true );
     327    tempsize += SynchronisableHeader::getSize();
     328    mem += SynchronisableHeader::getSize();
    339329    // end copy header
    340330
     
    371361    uint8_t* data=mem;
    372362    // start extract header
    373     synchronisableHeader *syncHeader = (synchronisableHeader *)mem;
    374     assert(syncHeader->objectID==this->objectID);
    375     assert(syncHeader->creatorID==this->creatorID);
    376     assert(this->classID==syncHeader->classID); //TODO: fix this!!! maybe a problem with the identifier ?
    377     if(syncHeader->dataAvailable==false){
    378       mem += syncHeader->size;
     363    SynchronisableHeader syncHeader(mem);
     364    assert(syncHeader.getObjectID()==this->objectID);
     365    assert(syncHeader.getCreatorID()==this->creatorID);
     366    assert(syncHeader.getClassID()==this->classID);
     367    if(syncHeader.isDataAvailable()==false){
     368      mem += syncHeader.getDataSize();
    379369      return true;
    380370    }
    381371
    382     mem += sizeof(synchronisableHeader);
     372    mem += SynchronisableHeader::getSize();
    383373    // stop extract header
    384374
    385     COUT(5) << "Synchronisable: objectID " << syncHeader->objectID << ", classID " << syncHeader->classID << " size: " << syncHeader->size << " synchronising data" << std::endl;
    386     for(i=syncList.begin(); i!=syncList.end() && mem <= data+syncHeader->size; i++)
    387     {
     375    //COUT(5) << "Synchronisable: objectID " << syncHeader.getObjectID() << ", classID " << syncHeader.getClassID() << " size: " << syncHeader.getDataSize() << " synchronising data" << std::endl;
     376    for(i=syncList.begin(); i!=syncList.end(); i++)
     377    {
     378      assert( mem <= data+syncHeader.getDataSize() ); // always make sure we don't exceed the datasize in our stream
    388379      (*i)->putData( mem, mode, forceCallback );
    389380    }
    390     assert(mem == data+syncHeader->size);
     381    assert(mem == data+syncHeader.getDataSize());
    391382    return true;
    392383  }
     
    399390  */
    400391  uint32_t Synchronisable::getSize(int32_t id, uint8_t mode){
    401     int tsize=sizeof(synchronisableHeader);
     392    int tsize=SynchronisableHeader::getSize();
    402393    if(mode==0x0)
    403394      mode=state_;
     
    428419  bool Synchronisable::isMyData(uint8_t* mem)
    429420  {
    430     synchronisableHeader *header = (synchronisableHeader *)mem;
    431     assert(header->objectID==this->objectID);
    432     return header->dataAvailable;
     421    SynchronisableHeader header(mem);
     422    assert(header.getObjectID()==this->objectID);
     423    return header.isDataAvailable();
    433424  }
    434425
  • code/trunk/src/network/synchronisable/Synchronisable.h

    r2653 r2662  
    7272  }
    7373
    74   struct _NetworkExport synchronisableHeader{
    75     uint32_t size:31;
    76     bool dataAvailable:1;
    77     uint32_t objectID;
    78     uint32_t creatorID;
    79     uint32_t classID;
     74  /**
     75   * @brief: stores information about a Synchronisable
     76   *
     77   * This class stores the information about a Synchronisable (objectID, classID, creatorID, dataSize)
     78   * in an emulated bitset.
     79   * Bit 1 to 31 store the size of the Data the synchronisable consumes in the stream
     80   * Bit 32 is a bool and defines whether the data is actually stored or is just filled up with 0
     81   * Byte 5 to 8: objectID
     82   * Byte 9 to 12: classID
     83   * Byte 13 to 16: creatorID
     84   */
     85  class _NetworkExport SynchronisableHeader{
     86    private:
     87      uint8_t *data_;
     88    public:
     89      SynchronisableHeader(uint8_t* data)
     90        { data_ = data; }
     91      inline static uint32_t getSize()
     92        { return 16; }
     93      inline uint32_t getDataSize() const
     94        { return (*(uint32_t*)data_) & 0x7FFFFFFF; } //only use the first 31 bits
     95      inline void setDataSize(uint32_t size)
     96        { *(uint32_t*)(data_) = (size & 0x7FFFFFFF) | (*(uint32_t*)(data_) & 0x80000000 ); }
     97      inline bool isDataAvailable() const
     98        { return ( (*(uint32_t*)data_) & 0x80000000 ) == 0x80000000; }
     99      inline void setDataAvailable( bool b)
     100        { *(uint32_t*)(data_) = (b << 31) | (*(uint32_t*)(data_) & 0x7FFFFFFF ); }
     101      inline uint32_t getObjectID() const
     102        { return *(uint32_t*)(data_+4); }
     103      inline void setObjectID(uint32_t objectID)
     104        { *(uint32_t*)(data_+4) = objectID; }
     105      inline uint32_t getClassID() const
     106        { return *(uint32_t*)(data_+8); }
     107      inline void setClassID(uint32_t classID)
     108        { *(uint32_t*)(data_+8) = classID; }
     109      inline uint32_t getCreatorID() const
     110        { return *(uint32_t*)(data_+12); }
     111      inline void setCreatorID(uint32_t creatorID)
     112        { *(uint32_t*)(data_+12) = creatorID; }
     113      inline void operator=(SynchronisableHeader& h)
     114        { memcpy(data_, h.data_, getSize()); }
    80115  };
    81116
     
    83118  /**
    84119  * This class is the base class of all the Objects in the universe that need to be synchronised over the network
    85    * Every class, that inherits from this class has to link the DATA THAT NEEDS TO BE SYNCHRONISED into the linked list.
     120  * Every class, that inherits from this class has to link the DATA THAT NEEDS TO BE SYNCHRONISED into the linked list.
    86121  * @author Oliver Scheuss
    87122  */
  • code/trunk/src/orxonox/CMakeLists.txt

    r2171 r2662  
    44  LevelManager.cc
    55  Main.cc
     6  PawnManager.cc
    67  PlayerManager.cc
    78  Settings.cc
     
    4849  tinyxml_orxonox
    4950  tolualib_orxonox
     51  BulletDynamics
     52  BulletCollision
     53  LinearMath
    5054  util
    5155  core
  • code/trunk/src/orxonox/CameraManager.cc

    r2261 r2662  
    2929#include "CameraManager.h"
    3030
     31#include <OgreSceneManager.h>
    3132#include <OgreViewport.h>
     33#include <OgreCamera.h>
     34#include <OgreCompositorManager.h>
     35#include <OgreResource.h>
    3236
    3337#include "core/Core.h"
     38#include "core/Iterator.h"
    3439#include "objects/worldentities/Camera.h"
    35 
     40#include "objects/Scene.h"
     41#include "tools/Shader.h"
     42#include "util/String.h"
    3643
    3744namespace orxonox
     
    4451        assert(singletonRef_s == 0);
    4552        singletonRef_s = this;
     53
     54        this->fallbackCamera_ = 0;
    4655    }
    4756
     
    5059        assert(singletonRef_s != 0);
    5160        singletonRef_s = 0;
     61
     62        if (this->fallbackCamera_)
     63            this->fallbackCamera_->getSceneManager()->destroyCamera(this->fallbackCamera_);
    5264    }
    5365
     
    6880        if (this->cameraList_.size() > 0)
    6981            this->cameraList_.front()->removeFocus();
     82        else if (this->fallbackCamera_)
     83        {
     84            this->fallbackCamera_->getSceneManager()->destroyCamera(this->fallbackCamera_);
     85            this->fallbackCamera_ = 0;
     86        }
    7087
    71         camera->setFocus(this->viewport_);
     88        camera->setFocus();
     89
     90        // make sure we don't add it twice
     91        for (std::list<Camera*>::iterator it = this->cameraList_.begin(); it != this->cameraList_.end(); ++it)
     92            if ((*it) == camera)
     93                return;
    7294
    7395        // add to list
    74         std::list<Camera*>::iterator it;
    75         for (it = this->cameraList_.begin(); it != this->cameraList_.end(); ++it)
    76         {
    77             if ((*it) == camera)
    78                 return; // make sure we don't add it twice
    79         }
    8096        this->cameraList_.push_front(camera);
    8197    }
     
    92108            this->cameraList_.pop_front();
    93109
    94             // set new focus if necessary
    95             if (cameraList_.size() > 0)
    96                 cameraList_.front()->setFocus(this->viewport_);
     110            // set new focus if possible
     111            if (this->cameraList_.size() > 0)
     112                this->cameraList_.front()->setFocus();
     113            else
     114            {
     115                // there are no more cameras, create a fallback
     116                if (!this->fallbackCamera_)
     117                    this->fallbackCamera_ = camera->getScene()->getSceneManager()->createCamera(getUniqueNumberString());
     118                this->useCamera(this->fallbackCamera_);
     119            }
    97120        }
    98121        else
     
    101124        }
    102125    }
     126
     127    void CameraManager::useCamera(Ogre::Camera* camera)
     128    {
     129        // This workaround is needed to avoid weird behaviour with active compositors while
     130        // switching the camera (like freezing the image)
     131        //
     132        // Last known Ogre version needing this workaround:
     133        // 1.4.8
     134
     135        // deactivate all compositors
     136        {
     137            Ogre::ResourceManager::ResourceMapIterator iterator = Ogre::CompositorManager::getSingleton().getResourceIterator();
     138            while (iterator.hasMoreElements())
     139                Ogre::CompositorManager::getSingleton().setCompositorEnabled(this->viewport_, iterator.getNext()->getName(), false);
     140        }
     141
     142        this->viewport_->setCamera(camera);
     143
     144        // reactivate all visible compositors
     145        {
     146            for (ObjectList<Shader>::iterator it = ObjectList<Shader>::begin(); it != ObjectList<Shader>::end(); ++it)
     147                it->updateVisibility();
     148        }
     149    }
    103150}
  • code/trunk/src/orxonox/CameraManager.h

    r2261 r2662  
    5757            static CameraManager& getInstance() { assert(singletonRef_s); return *singletonRef_s; }
    5858
     59            void useCamera(Ogre::Camera* camera);
     60
    5961        private:
    6062            CameraManager(const CameraManager&);
     
    6264            std::list<Camera*> cameraList_;
    6365            Ogre::Viewport* viewport_;
     66            Ogre::Camera* fallbackCamera_;
    6467
    6568            static CameraManager* singletonRef_s;
  • code/trunk/src/orxonox/GraphicsEngine.cc

    r2087 r2662  
    7777        singletonRef_s = this;
    7878
     79        this->viewport_ = 0;
     80
    7981        this->detailLevelParticle_ = 0;
    8082
  • code/trunk/src/orxonox/GraphicsEngine.h

    r2087 r2662  
    7272        static GraphicsEngine* getInstancePtr() { return singletonRef_s; }
    7373
     74        inline void setViewport(Ogre::Viewport* viewport)
     75            { this->viewport_ = viewport; }
     76        inline Ogre::Viewport* getViewport() const
     77            { return this->viewport_; }
     78
    7479    private:
    7580        // don't mess with singletons
    7681        GraphicsEngine(GraphicsEngine&);
     82
     83        Ogre::Viewport*     viewport_;              //!< default full size viewport
    7784
    7885        // stats
  • code/trunk/src/orxonox/Main.cc

    r2103 r2662  
    4343#include "core/ConfigFileManager.h"
    4444#include "core/CommandLine.h"
     45#include "core/CommandExecutor.h"
     46#include "core/Identifier.h"
     47#include "core/Core.h"
     48#include "core/Language.h"
    4549
    4650#include "gamestates/GSRoot.h"
     
    9296
    9397    // create a signal handler (only works for linux)
    94     SignalHandler::getInstance()->doCatch(argv[0], "orxonox.log");
     98    SignalHandler signalHandler;
     99    signalHandler.doCatch(argv[0], "orxonox.log");
    95100
    96101    // Parse command line arguments
     
    109114    ConfigFileManager* configFileManager = new ConfigFileManager();
    110115    configFileManager->setFilename(ConfigFileType::Settings, CommandLine::getValue("settingsFile").getString());
     116    // create the Core settings to configure the output level
     117    Language* language = new Language();
     118    Core*     core     = new Core();
    111119
    112     // create the gamestates
    113     GSRoot root;
    114     GSGraphics graphics;
    115     GSStandalone standalone;
    116     GSServer server;
    117     GSClient client;
    118     GSDedicated dedicated;
    119     GSGUI gui;
    120     GSIOConsole ioConsole;
     120    // put GameStates in its own scope so we can destroy the identifiers at the end of main().
     121    {
     122        // create the gamestates
     123        GSRoot root;
     124        GSGraphics graphics;
     125        GSStandalone standalone;
     126        GSServer server;
     127        GSClient client;
     128        GSDedicated dedicated;
     129        GSGUI gui;
     130        GSIOConsole ioConsole;
    121131
    122     // make the hierarchy
    123     root.addChild(&graphics);
    124     graphics.addChild(&standalone);
    125     graphics.addChild(&server);
    126     graphics.addChild(&client);
    127     graphics.addChild(&gui);
    128     root.addChild(&ioConsole);
    129     root.addChild(&dedicated);
     132        // make the hierarchy
     133        root.addChild(&graphics);
     134        graphics.addChild(&standalone);
     135        graphics.addChild(&server);
     136        graphics.addChild(&client);
     137        graphics.addChild(&gui);
     138        root.addChild(&ioConsole);
     139        root.addChild(&dedicated);
    130140
    131     // Here happens the game
    132     root.start();
     141        // Here happens the game
     142        root.start();
     143    }
    133144
    134     // Destroy ConfigFileManager again.
     145    // destroy singletons
     146    delete core;
     147    delete language;
    135148    delete configFileManager;
     149
     150    // Clean up class hierarchy stuff (identifiers, xmlport, configvalue, consolecommand)
     151    Identifier::destroyAllIdentifiers();
     152    // destroy command line arguments
     153    CommandLine::destroyAllArguments();
     154    // Also delete external console command that don't belong to an Identifier
     155    CommandExecutor::destroyExternalCommands();
    136156
    137157    return 0;
  • code/trunk/src/orxonox/OrxonoxPrereqs.h

    r2261 r2662  
    7373    }
    7474
     75    //put here all existing munitionTypes
     76    namespace MunitionType
     77    {
     78
     79
     80
     81        enum Enum
     82        { laserGunMunition };
     83    }
     84
     85    //put here all weapon fire modes.
     86    //they have to be added to Pawn and HumanController, too.
     87    namespace WeaponMode
     88    {
     89        enum Enum
     90        {
     91            fire     = 0x1,
     92            altFire  = 0x2,
     93            altFire2 = 0x4
     94        };
     95    }
     96
     97
    7598    class GraphicsEngine;
    7699    class Settings;
     
    82105    class CameraManager;
    83106    class LevelManager;
     107    class PawnManager;
    84108    class PlayerManager;
    85109
     
    102126    class QuestHint;
    103127    class QuestItem;
     128    class QuestListener;
    104129    class QuestManager;
    105130    class Rewardable;
    106131
    107132    class WorldEntity;
    108     class PositionableEntity;
     133    class StaticEntity;
     134    class MobileEntity;
     135    class ControllableEntity;
    109136    class MovableEntity;
    110     class ControllableEntity;
    111137    class Sublevel;
    112138
     
    114140    class Billboard;
    115141    class BlinkingBillboard;
     142    class ExplosionChunk;
     143    class FadingBillboard;
     144    class GlobalShader;
    116145    class Light;
    117146    class Backlight;
     
    127156    class SpaceShip;
    128157
     158    class Item;
     159    class Engine;
     160    class MultiStateEngine;
     161    class RotatingEngine;
     162
    129163    class Trigger;
    130164    class DistanceTrigger;
     
    135169    class WeaponSet;
    136170    class WeaponSlot;
     171    class WeaponPack;
    137172    class Weapon;
    138173    class Munition;
     174    class LaserGun;
     175    class LaserGunMunition;
    139176
    140177    class EventListener;
     
    144181    class Controller;
    145182    class HumanController;
     183    class ArtificialController;
     184    class AIController;
     185    class ScriptController;
    146186
    147187    class Info;
    148188    class PlayerInfo;
    149189    class HumanPlayer;
     190    class Bot;
     191    class GametypeInfo;
    150192
    151193    class Gametype;
    152194
    153195    class Scores;
     196    class CreateLines;
     197    class Scoreboard;
     198    class Stats;
     199
     200    // collision
     201    class CollisionShape;
     202    class SphereCollisionShape;
     203    class CompoundCollisionShape;
     204    class PlaneCollisionShape;
     205    class WorldEntityCollisionShape;
    154206
    155207    // tools
     
    158210    class Mesh;
    159211    class ParticleInterface;
     212    class Shader;
    160213    template <class T>
    161214    class Timer;
     
    169222    class HUDRadar;
    170223    class HUDSpeedBar;
     224    class HUDHealthBar;
    171225    class InGameConsole;
     226    class Notification;
     227    class NotificationManager;
     228    class NotificationQueue;
    172229    class OrxonoxOverlay;
    173230    class OverlayGroup;
    174231    class OverlayText;
     232    class GametypeStatus;
     233    class CreateLines;
     234    class Scoreboard;
    175235
    176236    //gui
     
    206266}
    207267
     268// Bullet Physics Engine
     269
     270class btTransform;
     271class btVector3;
     272
     273class btRigidBody;
     274class btCollisionObject;
     275class btGhostObject;
     276class btManifoldPoint;
     277
     278class btCollisionShape;
     279class btSphereShape;
     280class btCompoundShape;
     281class btStaticPlaneShape;
     282
     283class btDiscreteDynamicsWorld;
     284class bt32BitAxisSweep3;
     285class btDefaultCollisionConfiguration;
     286class btCollisionDispatcher;
     287class btSequentialImpulseConstraintSolver;
     288
     289// lua
    208290struct lua_State;
    209291
  • code/trunk/src/orxonox/OrxonoxStableHeaders.h

    r2087 r2662  
    4747#include <Ogre.h>
    4848#include <CEGUI.h>
    49 #include "ois/OIS.h"
    5049#include <boost/thread/recursive_mutex.hpp>
    5150//#include <boost/thread/mutex.hpp>
     
    5352//#include <boost/thread/thread.hpp>
    5453#include <boost/static_assert.hpp>
     54
     55#include "BulletDynamics/Dynamics/btRigidBody.h"
     56#include "ois/OIS.h"
    5557#include "tinyxml/ticpp.h"
    5658#include "tinyxml/tinyxml.h"
     
    9597#include "core/input/InputManager.h"
    9698
    97 #include "network/Synchronisable.h"
     99#include "network/synchronisable/Synchronisable.h"
    98100
    99 #include "Settings.h"
     101//#include "Settings.h"
    100102
    101103//#endif /* ifdef NDEBUG */
    102104
    103 #endif /* ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC && !defined(ORXONOX_DISABLE_PCH) */
     105#endif /* defined(ORXONOX_ENABLE_PCH) */
    104106
    105107#endif /* _OrxonoxStableHeaders_H__ */
  • code/trunk/src/orxonox/PlayerManager.cc

    r2171 r2662  
    3838namespace orxonox
    3939{
     40    PlayerManager* PlayerManager::singletonRef_s = 0;
     41
    4042    PlayerManager::PlayerManager()
    4143    {
    4244        RegisterRootObject(PlayerManager);
     45
     46        assert(singletonRef_s == 0);
     47        singletonRef_s = this;
    4348
    4449        this->getConnectedClients();
     
    4752    PlayerManager::~PlayerManager()
    4853    {
    49     }
    50 
    51     PlayerManager& PlayerManager::getInstance()
    52     {
    53         static PlayerManager instance;
    54         return instance;
     54        assert(singletonRef_s);
     55        singletonRef_s = 0;
    5556    }
    5657
  • code/trunk/src/orxonox/PlayerManager.h

    r2171 r2662  
    3232#include "OrxonoxPrereqs.h"
    3333
     34#include <cassert>
    3435#include <map>
    3536#include "network/ClientConnectionListener.h"
     
    4344            virtual ~PlayerManager();
    4445
    45             static PlayerManager& getInstance();
     46            static PlayerManager& getInstance()
     47            { assert(singletonRef_s); return *singletonRef_s; }
    4648
    4749            PlayerInfo* getClient(unsigned int clientID) const;
     
    5456
    5557            std::map<unsigned int, PlayerInfo*> clients_;
     58
     59            static PlayerManager* singletonRef_s;
    5660    };
    5761}
  • code/trunk/src/orxonox/Settings.cc

    r2087 r2662  
    8383        }
    8484
    85         LuaBind::getInstance()->setIncludePath(this->dataPath_);
     85        LuaBind::getInstance().setIncludePath(this->dataPath_);
    8686    }
    8787
  • code/trunk/src/orxonox/gamestates/GSDedicated.cc

    r2171 r2662  
    3535#include "network/Server.h"
    3636#include "objects/Tickable.h"
     37#include "util/Sleep.h"
    3738
    3839namespace orxonox
     
    4142        : GameState<GSRoot>("dedicated")
    4243        , server_(0)
     44        , timeSinceLastUpdate_(0)
    4345    {
    4446    }
     
    7274    void GSDedicated::ticked(const Clock& time)
    7375    {
    74         GSLevel::ticked(time);
    75         server_->tick(time.getDeltaTime());
    76         this->tickChild(time);
     76//        static float startTime = time.getSecondsPrecise();
     77//        static int nrOfTicks = 0;
     78        timeSinceLastUpdate_ += time.getDeltaTime();
     79        if (timeSinceLastUpdate_ >= NETWORK_PERIOD)
     80        {
     81//            ++nrOfTicks;
     82//            COUT(0) << "estimated ticks/sec: " << nrOfTicks/(time.getSecondsPrecise()-startTime) << endl;
     83            timeSinceLastUpdate_ -= static_cast<unsigned int>(timeSinceLastUpdate_ / NETWORK_PERIOD) * NETWORK_PERIOD;
     84            GSLevel::ticked(time);
     85            server_->tick(time.getDeltaTime());
     86            this->tickChild(time);
     87        }
     88        else
     89        {
     90            usleep((int)((NETWORK_PERIOD - timeSinceLastUpdate_) * 1000 * 1000));
     91//            COUT(0) << "sleeping for " << (int)((NETWORK_PERIOD - timeSinceLastUpdate_) * 1000 * 1000) << " usec" << endl;
     92        }
    7793    }
    7894}
  • code/trunk/src/orxonox/gamestates/GSDedicated.h

    r2171 r2662  
    4949
    5050        Server*      server_;
     51        float        timeSinceLastUpdate_;
    5152    };
    5253}
  • code/trunk/src/orxonox/gamestates/GSGraphics.cc

    r2171 r2662  
    3131
    3232#include <fstream>
     33#include <OgreCompositorManager.h>
    3334#include <OgreConfigFile.h>
    3435#include <OgreFrameListener.h>
     
    7576        , graphicsEngine_(0)
    7677        , masterKeyBinder_(0)
    77         , frameCount_(0)
    78         , statisticsRefreshCycle_(0)
    79         , statisticsStartTime_(0)
    80         , statisticsStartCount_(0)
    81         , tickTime_(0)
    8278        , debugOverlay_(0)
    8379    {
     
    106102        SetConfigValue(ogreLogLevelCritical_, 2)
    107103            .description("Corresponding orxonox debug level for ogre Critical");
    108         SetConfigValue(statisticsRefreshCycle_, 200000)
    109             .description("Sets the time in microseconds interval at which average fps, etc. get updated.");
    110104        SetConfigValue(defaultMasterKeybindings_, "def_masterKeybindings.ini")
    111105            .description("Filename of default master keybindings.");
     
    155149        guiManager_->initialise(this->renderWindow_);
    156150
    157         // reset frame counter
    158         this->frameCount_ = 0;
    159         this->tickTime_ = 0;
    160         statisticsStartTime_ = 0;
    161         statisticsStartCount_ = 0;
    162 
    163151        // add console commands
    164152        FunctorMember<GSGraphics>* functor1 = createFunctor(&GSGraphics::printScreen);
    165153        functor1->setObject(this);
    166         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor1, "printScreen"));
     154        ccPrintScreen_ = createConsoleCommand(functor1, "printScreen");
     155        CommandExecutor::addConsoleCommandShortcut(ccPrintScreen_);
    167156    }
    168157
     
    170159    {
    171160        using namespace Ogre;
     161
     162        delete this->ccPrintScreen_;
    172163
    173164        // remove our WindowEventListener first to avoid bad calls after the window has been destroyed
     
    184175        Loader::unload(this->debugOverlay_);
    185176        delete this->debugOverlay_;
     177
     178        // unload all compositors
     179        Ogre::CompositorManager::getSingleton().removeAll();
    186180
    187181        // destroy render window
     
    206200        delete this->ogreRoot_;
    207201
    208 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
     202//#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
    209203        // delete the ogre log and the logManager (since we have created it).
    210204        this->ogreLogger_->getDefaultLog()->removeListener(this);
    211205        this->ogreLogger_->destroyLog(Ogre::LogManager::getSingleton().getDefaultLog());
    212206        delete this->ogreLogger_;
    213 #endif
     207//#endif
    214208
    215209        delete graphicsEngine_;
     
    219213
    220214    /**
    221         Main loop of the orxonox game.
    222         We use the Ogre::Timer to measure time since it uses the most precise
    223         method an a platform (however the windows timer lacks time when under
    224         heavy kernel load!).
    225         There is a simple mechanism to measure the average time spent in our
    226         ticks as it may indicate performance issues.
     215    @note
    227216        A note about the Ogre::FrameListener: Even though we don't use them,
    228217        they still get called. However, the delta times are not correct (except
     
    233222    void GSGraphics::ticked(const Clock& time)
    234223    {
    235         unsigned long long timeBeforeTick = time.getRealMicroseconds();
     224        uint64_t timeBeforeTick = time.getRealMicroseconds();
     225
    236226        float dt = time.getDeltaTime();
    237227
     
    248238        }
    249239
    250         unsigned long long timeAfterTick = time.getRealMicroseconds();
    251 
    252         tickTime_ += (unsigned int)(timeAfterTick - timeBeforeTick);
    253         if (timeAfterTick > statisticsStartTime_ + statisticsRefreshCycle_)
    254         {
    255             GraphicsEngine::getInstance().setAverageTickTime(
    256                 (float)tickTime_ * 0.001f / (frameCount_ - statisticsStartCount_));
    257             float avgFPS = (float)(frameCount_ - statisticsStartCount_)
    258                 / (timeAfterTick - statisticsStartTime_) * 1000000.0;
    259             GraphicsEngine::getInstance().setAverageFramesPerSecond(avgFPS);
    260 
    261             tickTime_ = 0;
    262             statisticsStartCount_ = frameCount_;
    263             statisticsStartTime_  = timeAfterTick;
    264         }
     240        uint64_t timeAfterTick = time.getRealMicroseconds();
     241
     242        // Also add our tick time to the list in GSRoot
     243        this->getParent()->addTickTime(timeAfterTick - timeBeforeTick);
     244
     245        // Update statistics overlay. Note that the values only change periodically in GSRoot.
     246        GraphicsEngine::getInstance().setAverageFramesPerSecond(this->getParent()->getAvgFPS());
     247        GraphicsEngine::getInstance().setAverageTickTime(this->getParent()->getAvgTickTime());
    265248
    266249        // don't forget to call _fireFrameStarted in ogre to make sure
     
    283266        // again, just to be sure ogre works fine
    284267        ogreRoot_->_fireFrameEnded(evt); // note: uses the same time as _fireFrameStarted
    285 
    286         ++frameCount_;
    287268    }
    288269
     
    296277
    297278        // TODO: LogManager doesn't work on oli platform. The why is yet unknown.
    298 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
     279//#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
    299280        // create a new logManager
    300281        ogreLogger_ = new Ogre::LogManager();
     
    311292        myLog->setLogDetail(Ogre::LL_BOREME);
    312293        myLog->addListener(this);
    313 #endif
     294//#endif
    314295
    315296        // Root will detect that we've already created a Log
     
    430411        // create a full screen default viewport
    431412        this->viewport_ = this->renderWindow_->addViewport(0, 0);
     413
     414        if (this->graphicsEngine_)
     415            this->graphicsEngine_->setViewport(this->viewport_);
    432416    }
    433417
  • code/trunk/src/orxonox/gamestates/GSGraphics.h

    r2103 r2662  
    9393
    9494        KeyBinder*            masterKeyBinder_;
    95 
    96         // variables for time statistics
    97         unsigned long         frameCount_;
    98         unsigned int          statisticsRefreshCycle_;
    99         unsigned long long    statisticsStartTime_;
    100         unsigned long         statisticsStartCount_;
    101         unsigned int          tickTime_;
    10295        XMLFile*              debugOverlay_;
    10396
     
    110103        int                   ogreLogLevelNormal_;       //!< Corresponding Orxonx debug level for LL_NORMAL
    111104        int                   ogreLogLevelCritical_;     //!< Corresponding Orxonx debug level for LL_CRITICAL
    112         unsigned int          detailLevelParticle_;      //!< Detail level of particle effects (0: off, 1: low, 2: normal, 3: high)
    113105        std::string           defaultMasterKeybindings_; //!< Filename of default master keybindings.
     106
     107        // console commands
     108        ConsoleCommand*       ccPrintScreen_;
    114109    };
    115110}
  • code/trunk/src/orxonox/gamestates/GSLevel.cc

    r2103 r2662  
    4141#include "core/CoreIncludes.h"
    4242#include "core/Core.h"
    43 //#include "objects/Backlight.h"
    4443#include "objects/Tickable.h"
    4544#include "objects/Radar.h"
    46 //#include "tools/ParticleInterface.h"
    4745#include "CameraManager.h"
    4846#include "LevelManager.h"
     47#include "PlayerManager.h"
    4948#include "Settings.h"
    5049
    5150namespace orxonox
    5251{
    53     SetCommandLineArgument(level, "sample2.oxw").shortcut("l");
     52    SetCommandLineArgument(level, "presentation.oxw").shortcut("l");
    5453
    5554    GSLevel::GSLevel()
    5655//        : GameState<GSGraphics>(name)
    57         : timeFactor_(1.0f)
    58         , keyBinder_(0)
     56        : keyBinder_(0)
    5957        , inputState_(0)
    6058        , radar_(0)
     
    6462    {
    6563        RegisterObject(GSLevel);
     64
     65        this->ccKeybind_ = 0;
     66        this->ccTkeybind_ = 0;
     67
    6668        setConfigValues();
    6769    }
     
    9597        }
    9698
     99        this->playerManager_ = new PlayerManager();
     100
    97101        if (Core::isMaster())
    98102        {
    99103            // create the global LevelManager
    100104            this->levelManager_ = new LevelManager();
    101 
    102             // reset game speed to normal
    103             timeFactor_ = 1.0f;
    104105
    105106            this->loadLevel();
     
    114115            FunctorMember<GSLevel>* functor1 = createFunctor(&GSLevel::keybind);
    115116            functor1->setObject(this);
    116             CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor1, "keybind"));
     117            ccKeybind_ = createConsoleCommand(functor1, "keybind");
     118            CommandExecutor::addConsoleCommandShortcut(ccKeybind_);
    117119            FunctorMember<GSLevel>* functor2 = createFunctor(&GSLevel::tkeybind);
    118120            functor2->setObject(this);
    119             CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor2, "tkeybind"));
     121            ccTkeybind_ = createConsoleCommand(functor2, "tkeybind");
     122            CommandExecutor::addConsoleCommandShortcut(ccTkeybind_);
    120123            // set our console command as callback for the key detector
    121124            InputManager::getInstance().setKeyDetectorCallback(std::string("keybind ") + keyDetectorCallbackCode_);
     
    124127            InputManager::getInstance().requestEnterState("game");
    125128        }
    126 
    127         if (Core::isMaster())
    128         {
    129             // time factor console command
    130             FunctorMember<GSLevel>* functor = createFunctor(&GSLevel::setTimeFactor);
    131             functor->setObject(this);
    132             CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor")).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);;
    133         }
    134129    }
    135130
    136131    void GSLevel::leave()
    137132    {
     133        // destroy console commands
     134        if (this->ccKeybind_)
     135        {
     136            delete this->ccKeybind_;
     137            this->ccKeybind_ = 0;
     138        }
     139        if (this->ccTkeybind_)
     140        {
     141            delete this->ccTkeybind_;
     142            this->ccTkeybind_ = 0;
     143        }
     144
    138145        // this call will delete every BaseObject!
    139146        // But currently this will call methods of objects that exist no more
     
    149156
    150157        if (this->radar_)
     158        {
    151159            delete this->radar_;
     160            this->radar_ = 0;
     161        }
    152162
    153163        if (this->cameraManager_)
     164        {
    154165            delete this->cameraManager_;
     166            this->cameraManager_ = 0;
     167        }
    155168
    156169        if (this->levelManager_)
     170        {
    157171            delete this->levelManager_;
     172            this->levelManager_ = 0;
     173        }
     174
     175        if (this->playerManager_)
     176        {
     177            delete this->playerManager_;
     178            this->playerManager_ = 0;
     179        }
    158180
    159181        if (Core::showsGraphics())
     
    162184            InputManager::getInstance().requestDestroyState("game");
    163185            if (this->keyBinder_)
     186            {
    164187                delete this->keyBinder_;
     188                this->keyBinder_ = 0;
     189            }
    165190        }
    166191    }
     
    172197        //for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it)
    173198        //    it->tick(time.getDeltaTime() * this->timeFactor_);
    174     }
    175 
    176     /**
    177     @brief
    178         Changes the speed of Orxonox
    179     */
    180     void GSLevel::setTimeFactor(float factor)
    181     {
    182 /*
    183         float change = factor / this->timeFactor_;
    184 */
    185         this->timeFactor_ = factor;
    186 /*
    187         for (ObjectList<ParticleInterface>::iterator it = ObjectList<ParticleInterface>::begin(); it; ++it)
    188             it->setSpeedFactor(it->getSpeedFactor() * change);
    189 
    190         for (ObjectList<Backlight>::iterator it = ObjectList<Backlight>::begin(); it; ++it)
    191             it->setTimeFactor(timeFactor_);
    192 */
    193199    }
    194200
  • code/trunk/src/orxonox/gamestates/GSLevel.h

    r2103 r2662  
    3232#include "OrxonoxPrereqs.h"
    3333#include <OgrePrerequisites.h>
    34 #include "core/GameState.h"
    35 #include "GSGraphics.h"
     34#include "core/OrxonoxClass.h"
    3635
    3736namespace orxonox
    3837{
    39     class _OrxonoxExport GSLevel : public OrxonoxClass //,public GameState<GSGraphics>
     38    class _OrxonoxExport GSLevel : public OrxonoxClass
    4039    {
    4140        friend class ClassIdentifier<GSLevel>;
     
    4342        GSLevel();
    4443        ~GSLevel();
    45 
    46         // this has to be public because proteced triggers a bug in msvc
    47         // when taking the function address.
    48         void setTimeFactor(float factor);
    49         float getTimeFactor() { return this->timeFactor_; }
    5044
    5145    protected:
     
    5650        void loadLevel();
    5751        void unloadLevel();
    58 
    59         float timeFactor_;       //!< A factor that sets the gamespeed. 1 is normal.
    6052
    6153        // console commands
     
    7062        CameraManager*        cameraManager_;
    7163        LevelManager*         levelManager_;
     64        PlayerManager*        playerManager_;
    7265
    7366        //##### ConfigValues #####
     
    7568        //! Filename of default keybindings.
    7669        std::string           defaultKeybindings_;
     70
     71        // console commands
     72        ConsoleCommand*       ccKeybind_;
     73        ConsoleCommand*       ccTkeybind_;
    7774
    7875    private:
  • code/trunk/src/orxonox/gamestates/GSRoot.cc

    r2171 r2662  
    3232#include "util/Exception.h"
    3333#include "util/Debug.h"
     34#include "core/Core.h"
    3435#include "core/Factory.h"
    3536#include "core/ConfigValueIncludes.h"
     
    4041#include "core/TclBind.h"
    4142#include "core/TclThreadManager.h"
     43#include "core/LuaBind.h"
    4244#include "tools/Timer.h"
    4345#include "objects/Tickable.h"
    4446#include "Settings.h"
    4547
    46 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32 
     48#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
    4749#  ifndef WIN32_LEAN_AND_MEAN
    4850#    define WIN32_LEAN_AND_MEAN
     
    6668    GSRoot::GSRoot()
    6769        : RootGameState("root")
     70        , timeFactor_(1.0f)
     71        , bPaused_(false)
     72        , timeFactorPauseBackup_(1.0f)
    6873        , settings_(0)
    6974        , tclBind_(0)
     
    7378        RegisterRootObject(GSRoot);
    7479        setConfigValues();
     80
     81        this->ccSetTimeFactor_ = 0;
     82        this->ccPause_ = 0;
    7583    }
    7684
     
    8189    void GSRoot::setConfigValues()
    8290    {
     91        SetConfigValue(statisticsRefreshCycle_, 250000)
     92            .description("Sets the time in microseconds interval at which average fps, etc. get updated.");
     93        SetConfigValue(statisticsAvgLength_, 1000000)
     94            .description("Sets the time in microseconds interval at which average fps, etc. gets calculated.");
    8395    }
    8496
     
    8799        // creates the class hierarchy for all classes with factories
    88100        Factory::createClassHierarchy();
     101
     102        // reset game speed to normal
     103        timeFactor_ = 1.0f;
     104
     105        // reset frame counter
     106        this->statisticsStartTime_ = 0;
     107        this->statisticsTickTimes_.clear();
     108        this->periodTickTime_ = 0;
     109        this->avgFPS_ = 0.0f;
     110        this->avgTickTime_ = 0.0f;
     111
     112        // Create the lua interface
     113        this->luaBind_ = new LuaBind();
    89114
    90115        // instantiate Settings class
     
    114139            setThreadAffinity((unsigned int)(limitToCPU - 1));
    115140
    116         // add console commands
    117         FunctorMember<GSRoot>* functor1 = createFunctor(&GSRoot::exitGame);
    118         functor1->setObject(this);
    119         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor1, "exit"));
    120 
    121         // add console commands
    122         FunctorMember01<GameStateBase, const std::string&>* functor2 = createFunctor(&GameStateBase::requestState);
    123         functor2->setObject(this);
    124         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor2, "selectGameState"));
     141        {
     142            // add console commands
     143            FunctorMember<GSRoot>* functor = createFunctor(&GSRoot::exitGame);
     144            functor->setObject(this);
     145            this->ccExit_ = createConsoleCommand(functor, "exit");
     146            CommandExecutor::addConsoleCommandShortcut(this->ccExit_);
     147        }
     148
     149        {
     150            // add console commands
     151            FunctorMember01<GameStateBase, const std::string&>* functor = createFunctor(&GameStateBase::requestState);
     152            functor->setObject(this);
     153            this->ccSelectGameState_ = createConsoleCommand(functor, "selectGameState");
     154            CommandExecutor::addConsoleCommandShortcut(this->ccSelectGameState_);
     155        }
     156
     157        {
     158            // time factor console command
     159            FunctorMember<GSRoot>* functor = createFunctor(&GSRoot::setTimeFactor);
     160            functor->setObject(this);
     161            this->ccSetTimeFactor_ = createConsoleCommand(functor, "setTimeFactor");
     162            CommandExecutor::addConsoleCommandShortcut(this->ccSetTimeFactor_).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);
     163        }
     164
     165        {
     166            // time factor console command
     167            FunctorMember<GSRoot>* functor = createFunctor(&GSRoot::pause);
     168            functor->setObject(this);
     169            this->ccPause_ = createConsoleCommand(functor, "pause");
     170            CommandExecutor::addConsoleCommandShortcut(this->ccPause_).accessLevel(AccessLevel::Offline);
     171        }
    125172    }
    126173
    127174    void GSRoot::leave()
    128175    {
    129         // TODO: remove and destroy console commands
     176        // destroy console commands
     177        delete this->ccExit_;
     178        delete this->ccSelectGameState_;
    130179
    131180        delete this->shell_;
     
    133182        delete this->tclBind_;
    134183
    135         delete settings_;
    136 
     184        delete this->settings_;
     185        delete this->luaBind_;
     186
     187        if (this->ccSetTimeFactor_)
     188        {
     189            delete this->ccSetTimeFactor_;
     190            this->ccSetTimeFactor_ = 0;
     191        }
     192
     193        if (this->ccPause_)
     194        {
     195            delete this->ccPause_;
     196            this->ccPause_ = 0;
     197        }
    137198    }
    138199
    139200    void GSRoot::ticked(const Clock& time)
    140201    {
     202        uint64_t timeBeforeTick = time.getRealMicroseconds();
     203
    141204        TclThreadManager::getInstance().tick(time.getDeltaTime());
    142205
     
    146209        /*** HACK *** HACK ***/
    147210        // Call the Tickable objects
     211        float leveldt = time.getDeltaTime();
     212        if (leveldt > 1.0f)
     213        {
     214            // just loaded
     215            leveldt = 0.0f;
     216        }
    148217        for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it)
    149             it->tick(time.getDeltaTime());
     218            it->tick(leveldt * this->timeFactor_);
    150219        /*** HACK *** HACK ***/
    151220
     221        uint64_t timeAfterTick = time.getRealMicroseconds();
     222
     223        // STATISTICS
     224        assert(timeAfterTick - timeBeforeTick >= 0 );
     225        statisticsTickInfo tickInfo = {timeAfterTick, timeAfterTick - timeBeforeTick};
     226        statisticsTickTimes_.push_back(tickInfo);
     227        assert(statisticsTickTimes_.back().tickLength==tickInfo.tickLength);
     228        this->periodTickTime_ += tickInfo.tickLength;
     229
     230        // Ticks GSGraphics or GSDedicated
    152231        this->tickChild(time);
     232
     233        if (timeAfterTick > statisticsStartTime_ + statisticsRefreshCycle_)
     234        {
     235            std::list<statisticsTickInfo>::iterator it = this->statisticsTickTimes_.begin();
     236            assert(it != this->statisticsTickTimes_.end());
     237            int64_t lastTime = timeAfterTick - statisticsAvgLength_;
     238            if ((int64_t)it->tickTime < lastTime)
     239            {
     240                do
     241                {
     242                    assert(this->periodTickTime_ > it->tickLength);
     243                    this->periodTickTime_ -= it->tickLength;
     244                    ++it;
     245                    assert(it != this->statisticsTickTimes_.end());
     246                } while ((int64_t)it->tickTime < lastTime);
     247                this->statisticsTickTimes_.erase(this->statisticsTickTimes_.begin(), it);
     248            }
     249
     250            uint32_t framesPerPeriod = this->statisticsTickTimes_.size();
     251            this->avgFPS_ = (float)framesPerPeriod / (timeAfterTick - this->statisticsTickTimes_.front().tickTime) * 1000000.0;
     252            this->avgTickTime_ = (float)this->periodTickTime_ / framesPerPeriod / 1000.0;
     253
     254            statisticsStartTime_ = timeAfterTick;
     255        }
     256
    153257    }
    154258
     
    160264
    161265        Copyright (c) 2000-2008 Torus Knot Software Ltd
    162        
     266
    163267        OGRE is licensed under the LGPL. For more info, see OGRE license.
    164268    */
     
    167271#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
    168272        // Get the current process core mask
    169             DWORD procMask;
    170             DWORD sysMask;
     273        DWORD procMask;
     274        DWORD sysMask;
    171275#  if _MSC_VER >= 1400 && defined (_M_X64)
    172             GetProcessAffinityMask(GetCurrentProcess(), (PDWORD_PTR)&procMask, (PDWORD_PTR)&sysMask);
     276        GetProcessAffinityMask(GetCurrentProcess(), (PDWORD_PTR)&procMask, (PDWORD_PTR)&sysMask);
    173277#  else
    174             GetProcessAffinityMask(GetCurrentProcess(), &procMask, &sysMask);
     278        GetProcessAffinityMask(GetCurrentProcess(), &procMask, &sysMask);
    175279#  endif
    176280
    177             // If procMask is 0, consider there is only one core available
    178             // (using 0 as procMask will cause an infinite loop below)
    179             if (procMask == 0)
    180                     procMask = 1;
     281        // If procMask is 0, consider there is only one core available
     282        // (using 0 as procMask will cause an infinite loop below)
     283        if (procMask == 0)
     284            procMask = 1;
    181285
    182286        // if the core specified with limitToCPU is not available, take the lowest one
     
    184288            limitToCPU = 0;
    185289
    186             // Find the lowest core that this process uses and limitToCPU suggests
     290        // Find the lowest core that this process uses and limitToCPU suggests
    187291        DWORD threadMask = 1;
    188             while ((threadMask & procMask) == 0 || (threadMask < (1u << limitToCPU)))
    189                     threadMask <<= 1;
    190 
    191             // Set affinity to the first core
    192             SetThreadAffinityMask(GetCurrentThread(), threadMask);
     292        while ((threadMask & procMask) == 0 || (threadMask < (1u << limitToCPU)))
     293            threadMask <<= 1;
     294
     295        // Set affinity to the first core
     296        SetThreadAffinityMask(GetCurrentThread(), threadMask);
    193297#endif
    194298    }
     299
     300    /**
     301    @brief
     302        Changes the speed of Orxonox
     303    */
     304    void GSRoot::setTimeFactor(float factor)
     305    {
     306        if (Core::isMaster())
     307        {
     308            if (!this->bPaused_)
     309            {
     310                TimeFactorListener::timefactor_s = factor;
     311
     312                for (ObjectList<TimeFactorListener>::iterator it = ObjectList<TimeFactorListener>::begin(); it != ObjectList<TimeFactorListener>::end(); ++it)
     313                    it->changedTimeFactor(factor, this->timeFactor_);
     314
     315                this->timeFactor_ = factor;
     316            }
     317            else
     318                this->timeFactorPauseBackup_ = factor;
     319        }
     320    }
     321
     322    void GSRoot::pause()
     323    {
     324        if (Core::isMaster())
     325        {
     326            if (!this->bPaused_)
     327            {
     328                this->timeFactorPauseBackup_ = this->timeFactor_;
     329                this->setTimeFactor(0.0f);
     330                this->bPaused_ = true;
     331            }
     332            else
     333            {
     334                this->bPaused_ = false;
     335                this->setTimeFactor(this->timeFactorPauseBackup_);
     336            }
     337        }
     338    }
     339
     340    ////////////////////////
     341    // TimeFactorListener //
     342    ////////////////////////
     343    float TimeFactorListener::timefactor_s = 1.0f;
     344
     345    TimeFactorListener::TimeFactorListener()
     346    {
     347        RegisterRootObject(TimeFactorListener);
     348    }
    195349}
  • code/trunk/src/orxonox/gamestates/GSRoot.h

    r1891 r2662  
    3131
    3232#include "OrxonoxPrereqs.h"
     33
     34#include <list>
    3335#include <OgreLog.h>
    3436#include "core/RootGameState.h"
     
    4042    {
    4143        friend class ClassIdentifier<GSRoot>;
     44
     45    public:
     46        struct statisticsTickInfo
     47        {
     48            uint64_t    tickTime;
     49            uint32_t    tickLength;
     50        };
     51   
    4252    public:
    4353        GSRoot();
     
    4656        void exitGame()
    4757        { requestState("root"); }
     58
     59        // this has to be public because proteced triggers a bug in msvc
     60        // when taking the function address.
     61        void setTimeFactor(float factor);
     62        void pause();
     63        float getTimeFactor() { return this->timeFactor_; }
     64
     65        float getAvgTickTime() { return this->avgTickTime_; }
     66        float getAvgFPS()      { return this->avgFPS_; }
     67
     68        inline void addTickTime(uint32_t length)
     69            { assert(!this->statisticsTickTimes_.empty()); this->statisticsTickTimes_.back().tickLength += length;
     70              this->periodTickTime_+=length; }
    4871
    4972    private:
     
    5578        void setThreadAffinity(unsigned int limitToCPU);
    5679
     80        float                 timeFactor_;       //!< A factor that sets the gamespeed. 1 is normal.
     81        bool                  bPaused_;
     82        float                 timeFactorPauseBackup_;
    5783        Settings*             settings_;
    5884        TclBind*              tclBind_;
    5985        TclThreadManager*     tclThreadManager_;
    6086        Shell*                shell_;
     87        LuaBind*              luaBind_;
     88
     89        // variables for time statistics
     90        uint64_t              statisticsStartTime_;
     91        std::list<statisticsTickInfo>
     92                              statisticsTickTimes_;
     93        uint32_t              periodTickTime_;
     94        float                 avgFPS_;
     95        float                 avgTickTime_;
     96
     97        // config values
     98        unsigned int          statisticsRefreshCycle_;
     99        unsigned int          statisticsAvgLength_;
     100
     101        // console commands
     102        ConsoleCommand*       ccExit_;
     103        ConsoleCommand*       ccSelectGameState_;
     104        ConsoleCommand*       ccSetTimeFactor_;
     105        ConsoleCommand*       ccPause_;
     106    };
     107
     108    class _OrxonoxExport TimeFactorListener : virtual public OrxonoxClass
     109    {
     110        friend class GSRoot;
     111
     112        public:
     113            TimeFactorListener();
     114            virtual ~TimeFactorListener() {}
     115
     116        protected:
     117            virtual void changedTimeFactor(float factor_new, float factor_old) {}
     118            inline float getTimeFactor() const
     119                { return TimeFactorListener::timefactor_s; }
     120
     121        private:
     122            static float timefactor_s;
    61123    };
    62124}
  • code/trunk/src/orxonox/gui/GUIManager.cc

    r2087 r2662  
    9696        {
    9797            // destroy our own tolua interfaces
    98                 //lua_pushnil(luaState_);
    99                 //lua_setglobal(luaState_, "Orxonox");
    100                 //lua_pushnil(luaState_);
    101                 //lua_setglobal(luaState_, "Core");
     98                lua_pushnil(luaState_);
     99                lua_setglobal(luaState_, "Orxonox");
     100                lua_pushnil(luaState_);
     101                lua_setglobal(luaState_, "Core");
    102102            // TODO: deleting the script module fails an assertation.
    103103            // However there is not much we can do about it since it occurs too when
    104104            // we don't open Core or Orxonox. Might be a CEGUI issue.
    105105            // The memory leak is not a problem anyway..
    106             //delete scriptModule_;
     106            delete scriptModule_;
    107107        }
    108108
  • code/trunk/src/orxonox/objects/CMakeLists.txt

    r2171 r2662  
    33  EventDispatcher.cc
    44  EventTarget.cc
     5  GlobalShader.cc
    56  Level.cc
    67  Radar.cc
     
    1314)
    1415
     16ADD_SOURCE_DIRECTORY(SRC_FILES collisionshapes)
    1517ADD_SOURCE_DIRECTORY(SRC_FILES controllers)
    1618ADD_SOURCE_DIRECTORY(SRC_FILES gametypes)
    1719ADD_SOURCE_DIRECTORY(SRC_FILES infos)
    18 #ADD_SOURCE_DIRECTORY(SRC_FILES pickup)
     20ADD_SOURCE_DIRECTORY(SRC_FILES items)
     21ADD_SOURCE_DIRECTORY(SRC_FILES pickup)
    1922ADD_SOURCE_DIRECTORY(SRC_FILES quest)
    2023ADD_SOURCE_DIRECTORY(SRC_FILES weaponSystem)
  • code/trunk/src/orxonox/objects/EventTarget.cc

    r2087 r2662  
    4848    void EventTarget::changedName()
    4949    {
     50        SUPER(EventTarget, changedName);
     51
    5052        for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ++it)
    5153            if (it->getName() == this->getName())
  • code/trunk/src/orxonox/objects/Level.cc

    r2261 r2662  
    8383    void Level::registerVariables()
    8484    {
    85         REGISTERSTRING(this->xmlfilename_, direction::toclient, new NetworkCallback<Level>(this, &Level::networkcallback_applyXMLFile));
    86         REGISTERSTRING(this->name_,        direction::toclient, new NetworkCallback<Level>(this, &Level::changedName));
    87         REGISTERSTRING(this->description_, direction::toclient);
     85        registerVariable(this->xmlfilename_, variableDirection::toclient, new NetworkCallback<Level>(this, &Level::networkcallback_applyXMLFile));
     86        registerVariable(this->name_,        variableDirection::toclient, new NetworkCallback<Level>(this, &Level::changedName));
     87        registerVariable(this->description_, variableDirection::toclient);
    8888    }
    8989
     
    141141    void Level::playerEntered(PlayerInfo* player)
    142142    {
    143         COUT(3) << "player entered level" << std::endl;
     143        COUT(3) << "player entered level (id: " << player->getClientID() << ", name: " << player->getName() << ")" << std::endl;
    144144        player->setGametype(this->getGametype());
    145145    }
     
    147147    void Level::playerLeft(PlayerInfo* player)
    148148    {
    149         COUT(3) << "player left level" << std::endl;
     149        COUT(3) << "player left level (id: " << player->getClientID() << ", name: " << player->getName() << ")" << std::endl;
    150150        player->setGametype(0);
    151151    }
  • code/trunk/src/orxonox/objects/Level.h

    r2261 r2662  
    3232#include "OrxonoxPrereqs.h"
    3333
    34 #include "network/Synchronisable.h"
     34#include "network/synchronisable/Synchronisable.h"
    3535#include "core/BaseObject.h"
    3636
  • code/trunk/src/orxonox/objects/Radar.cc

    r2087 r2662  
    9999    void Radar::tick(float dt)
    100100    {
     101        SUPER(Radar, tick, dt);
     102
    101103        if (this->focus_ != *(this->itFocus_))
    102104        {
     
    112114            for (ObjectList<RadarViewable>::iterator itElement = ObjectList<RadarViewable>::begin(); itElement; ++itElement)
    113115            {
    114 /*
    115                 if ((*itElement) != SpaceShip::getLocalShip() && (*itListener)->getRadarSensitivity() > (*itElement)->getRadarObjectCamouflage())
     116                if ((*itListener)->getRadarSensitivity() > (*itElement)->getRadarObjectCamouflage())
    116117                    (*itListener)->displayObject(*itElement, *itElement == this->focus_);
    117 */
    118118            }
    119119        }
     
    128128            this->focus_ = 0;
    129129        }
    130         else
    131         {
    132             Vector3 localPosition;// = SpaceShip::getLocalShip()->getPosition();
     130/*
     131        else if (this->owner_)
     132        {
     133            Vector3 localPosition = this->owner_->getPosition();
    133134            Vector3 targetPosition = localPosition;
    134135            if (*(this->itFocus_))
    135                 targetPosition = this->itFocus_->getWorldPosition();
     136                targetPosition = this->itFocus_->getRVWorldPosition();
    136137
    137138            // find the closed object further away than targetPosition
     
    143144            for (ObjectList<RadarViewable>::iterator it = ObjectList<RadarViewable>::begin(); it; ++it)
    144145            {
    145 /*
    146                 if (*it == SpaceShip::getLocalShip())
     146                if (*it == (RadarViewable*)this->owner_)
    147147                    continue;
    148 */
    149                 float targetDistance = localPosition.squaredDistance((*it)->getWorldPosition());
     148
     149                float targetDistance = localPosition.squaredDistance((*it)->getRVWorldPosition());
    150150                if (targetDistance > currentDistance && targetDistance < nextDistance)
    151151                {
     
    171171            }
    172172        }
     173*/
    173174    }
    174175
     
    186187        for (ObjectList<RadarViewable>::iterator it = ObjectList<RadarViewable>::begin(); it; ++it, ++i)
    187188        {
    188             COUT(3) << i++ << ": " << (*it)->getWorldPosition() << std::endl;
     189            COUT(3) << i++ << ": " << (*it)->getRVWorldPosition() << std::endl;
    189190        }
    190191    }
  • code/trunk/src/orxonox/objects/RadarViewable.cc

    r2087 r2662  
    2929#include "OrxonoxStableHeaders.h"
    3030#include "RadarViewable.h"
     31
    3132#include "util/Debug.h"
     33#include "util/Exception.h"
    3234#include "core/CoreIncludes.h"
    33 //#include "objects/WorldEntity.h"
    34 #include "Radar.h"
     35#include "objects/worldentities/WorldEntity.h"
     36#include "objects/Radar.h"
    3537
    3638namespace orxonox
     
    4042    */
    4143    RadarViewable::RadarViewable()
    42         : radarObject_(0)
    43         , radarObjectCamouflage_(0.0f)
    44         , radarObjectType_(Dot)
     44        : radarObjectCamouflage_(0.0f)
     45        , radarObjectShape_(Dot)
    4546        , radarObjectDescription_("staticObject")
    4647    {
     
    5253        Radar* radar = Radar::getInstancePtr();
    5354        if (radar)
    54             this->radarObjectType_ = radar->addObjectDescription(str);
     55            this->radarObjectShape_ = radar->addObjectDescription(str);
    5556        else
    5657        {
     
    6061    }
    6162
    62     const Vector3& RadarViewable::getWorldPosition() const
     63    const Vector3& RadarViewable::getRVWorldPosition() const
    6364    {
    64         validate();
    65         return Vector3::ZERO;//this->radarObject_->getWorldPosition();
     65        const WorldEntity* object = this->getWorldEntity();
     66        validate(object);
     67        return object->getWorldPosition();
    6668    }
    6769
    68     Vector3 RadarViewable::getOrientedVelocity() const
     70    Vector3 RadarViewable::getRVOrientedVelocity() const
    6971    {
    70         validate();
    71         return Vector3::ZERO;//this->radarObject_->getOrientation() * this->radarObject_->getVelocity();
     72        const WorldEntity* object = this->getWorldEntity();
     73        validate(object);
     74        return object->getWorldOrientation() * object->getVelocity();
    7275    }
    7376}
  • code/trunk/src/orxonox/objects/RadarViewable.h

    r2087 r2662  
    4444    class _OrxonoxExport RadarViewable : virtual public OrxonoxClass
    4545    {
    46     class WorldEntity;
    47 
    4846    public:
    4947        enum Shape
     
    5856        virtual ~RadarViewable() { }
    5957
    60         float getRadarObjectCamouflage() const { return this->radarObjectCamouflage_; }
    61         void setRadarObjectCamouflage(float camouflage) { this->radarObjectCamouflage_ = camouflage; }
     58        inline void setRadarObjectCamouflage(float camouflage)
     59            { this->radarObjectCamouflage_ = camouflage; }
     60        inline float getRadarObjectCamouflage() const
     61            { return this->radarObjectCamouflage_; }
    6262
    63         const ColourValue& getRadarObjectColour() const { return this->radarObjectColour_; }
    64         void setRadarObjectColour(const ColourValue& colour) { this->radarObjectColour_ = colour; }
     63        inline void setRadarObjectColour(const ColourValue& colour)
     64            { this->radarObjectColour_ = colour; }
     65        inline const ColourValue& getRadarObjectColour() const
     66            { return this->radarObjectColour_; }
    6567
    66         const std::string& getRadarObjectDescription() const { return this->radarObjectDescription_; }
    6768        void setRadarObjectDescription(const std::string& str);
     69        inline const std::string& getRadarObjectDescription() const
     70            { return this->radarObjectDescription_; }
    6871
    69         const WorldEntity* getWorldEntity() const { return this->radarObject_; }
    70         const Vector3& getWorldPosition() const;
    71         Vector3 getOrientedVelocity() const;
     72        virtual const WorldEntity* getWorldEntity() const = 0;
    7273
    73         Shape getRadarObjectType() const { return this->radarObjectType_; }
     74        const Vector3& getRVWorldPosition() const;
     75        Vector3 getRVOrientedVelocity() const;
    7476
    75     protected:
    76         WorldEntity* radarObject_;
     77        inline void setRadarObjectShape(Shape shape)
     78            { this->radarObjectShape_ = shape; }
     79        inline Shape getRadarObjectShape() const
     80            { return this->radarObjectShape_; }
    7781
    7882    private:
    79         void validate() const { if (!this->radarObject_)
    80         { COUT(1) << "Assertation: Every RadarViewable has to be assigned a WorldEntity pointer!" << std::endl; assert(0); } }
     83        void validate(const WorldEntity* object) const
     84        {
     85            if (!object)
     86            {
     87                COUT(1) << "Assertation: Every RadarViewable has to be assigned a WorldEntity pointer!" << std::endl;
     88                assert(0);
     89            }
     90        }
    8191
    8292        float radarObjectCamouflage_;
    83         Shape radarObjectType_;
     93        Shape radarObjectShape_;
    8494        std::string radarObjectDescription_;
    8595        ColourValue radarObjectColour_;
  • code/trunk/src/orxonox/objects/Scene.cc

    r2171 r2662  
    2222 *   Author:
    2323 *      Fabian 'x3n' Landau
     24 *      Reto Grieder (physics)
    2425 *   Co-authors:
    2526 *      ...
     
    3334#include <OgreSceneManagerEnumerator.h>
    3435#include <OgreSceneNode.h>
    35 #include <OgreLight.h>
     36
     37#include "BulletCollision/BroadphaseCollision/btAxisSweep3.h"
     38#include "BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h"
     39#include "BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h"
     40#include "BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h"
    3641
    3742#include "core/CoreIncludes.h"
    3843#include "core/Core.h"
    3944#include "core/XMLPort.h"
     45#include "tools/BulletConversions.h"
     46#include "objects/worldentities/WorldEntity.h"
    4047
    4148namespace orxonox
     
    4855
    4956        this->setScene(this);
    50         this->bShadows_ = false;
     57        this->bShadows_ = true;
    5158
    5259        if (Core::showsGraphics())
     
    7077        }
    7178
    72         // test test test
    73         if (Core::showsGraphics() && this->sceneManager_)
    74         {
    75             Ogre::Light* light;
    76             light = this->sceneManager_->createLight("Light-1");
    77             light->setType(Ogre::Light::LT_DIRECTIONAL);
    78             light->setDiffuseColour(ColourValue(1.0, 0.9, 0.6, 1.0));
    79             light->setSpecularColour(ColourValue(1.0, 0.9, 0.6, 1.0));
    80             light->setDirection(1, -0.3, 0.3);
    81         }
    82         // test test test
     79        // No physics yet, XMLPort will do that.
     80        const int defaultMaxWorldSize = 100000;
     81        this->negativeWorldRange_ = Vector3::UNIT_SCALE * -defaultMaxWorldSize;
     82        this->positiveWorldRange_ = Vector3::UNIT_SCALE *  defaultMaxWorldSize;
     83        this->gravity_ = Vector3::ZERO;
     84        this->physicalWorld_   = 0;
     85        this->solver_          = 0;
     86        this->dispatcher_      = 0;
     87        this->collisionConfig_ = 0;
     88        this->broadphase_      = 0;
    8389
    8490        this->registerVariables();
     
    9197            if (Ogre::Root::getSingletonPtr())
    9298            {
    93 //                this->sceneManager_->destroySceneNode(this->rootSceneNode_->getName()); // TODO: remove getName() for newer versions of Ogre
    9499                Ogre::Root::getSingleton().destroySceneManager(this->sceneManager_);
    95100            }
     
    98103                delete this->sceneManager_;
    99104            }
     105
     106            this->setPhysicalWorld(false);
    100107        }
    101108    }
     
    109116        XMLPortParam(Scene, "shadow", setShadow, getShadow, xmlelement, mode).defaultValues(true);
    110117
     118        XMLPortParam(Scene, "gravity", setGravity, getGravity, xmlelement, mode);
     119        XMLPortParam(Scene, "negativeWorldRange", setNegativeWorldRange, getNegativeWorldRange, xmlelement, mode);
     120        XMLPortParam(Scene, "positiveWorldRange", setPositiveWorldRange, getPositiveWorldRange, xmlelement, mode);
     121        XMLPortParam(Scene, "hasPhysics", setPhysicalWorld, hasPhysics, xmlelement, mode).defaultValues(true);
     122
    111123        XMLPortObjectExtended(Scene, BaseObject, "", addObject, getObject, xmlelement, mode, true, false);
    112124    }
     
    114126    void Scene::registerVariables()
    115127    {
    116         REGISTERSTRING(this->skybox_,     direction::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applySkybox));
    117         REGISTERDATA(this->ambientLight_, direction::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applyAmbientLight));
     128        registerVariable(this->skybox_,             variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applySkybox));
     129        registerVariable(this->ambientLight_,       variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applyAmbientLight));
     130        registerVariable(this->negativeWorldRange_, variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_negativeWorldRange));
     131        registerVariable(this->positiveWorldRange_, variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_positiveWorldRange));
     132        registerVariable(this->gravity_,            variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_gravity));
     133        registerVariable(this->bHasPhysics_,        variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_hasPhysics));
     134        registerVariable(this->bShadows_,           variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applyShadows));
     135    }
     136
     137    void Scene::setNegativeWorldRange(const Vector3& range)
     138    {
     139        if (range.length() < 10.0f)
     140        {
     141            CCOUT(2) << "Warning: Setting the negative world range to a very small value: "
     142                     << omni_cast<std::string>(range) << std::endl;
     143        }
     144        if (this->hasPhysics())
     145        {
     146            CCOUT(2) << "Warning: Attempting to set the physical world range at run time. "
     147                     << "This causes a complete physical reload which might take some time." << std::endl;
     148            this->setPhysicalWorld(false);
     149            this->negativeWorldRange_ = range;
     150            this->setPhysicalWorld(true);
     151        }
     152        else
     153            this->negativeWorldRange_ = range;
     154    }
     155
     156    void Scene::setPositiveWorldRange(const Vector3& range)
     157    {
     158        if (range.length() < 10.0f)
     159        {
     160            CCOUT(2) << "Warning: Setting the positive world range to a very small value: "
     161                     << omni_cast<std::string>(range) << std::endl;
     162        }
     163        if (this->hasPhysics())
     164        {
     165            CCOUT(2) << "Warning: Attempting to set the physical world range at run time. "
     166                     << "This causes a complete physical reload which might take some time." << std::endl;
     167            this->setPhysicalWorld(false);
     168            this->positiveWorldRange_ = range;
     169            this->setPhysicalWorld(true);
     170        }
     171        else
     172            this->positiveWorldRange_ = range;
     173    }
     174
     175    void Scene::setGravity(const Vector3& gravity)
     176    {
     177        this->gravity_ = gravity;
     178        if (this->hasPhysics())
     179            this->physicalWorld_->setGravity(omni_cast<btVector3>(this->gravity_));
     180    }
     181
     182    void Scene::setPhysicalWorld(bool wantPhysics)
     183    {
     184        this->bHasPhysics_ = wantPhysics;
     185        if (wantPhysics && !hasPhysics())
     186        {
     187            // Note: These are all little known default classes and values.
     188            //       It would require further investigation to properly dertermine the right choices.
     189            this->broadphase_      = new bt32BitAxisSweep3(
     190                omni_cast<btVector3>(this->negativeWorldRange_), omni_cast<btVector3>(this->positiveWorldRange_));
     191            this->collisionConfig_ = new btDefaultCollisionConfiguration();
     192            this->dispatcher_      = new btCollisionDispatcher(this->collisionConfig_);
     193            this->solver_          = new btSequentialImpulseConstraintSolver();
     194
     195            this->physicalWorld_   = new btDiscreteDynamicsWorld(this->dispatcher_, this->broadphase_, this->solver_, this->collisionConfig_);
     196            this->physicalWorld_->setGravity(omni_cast<btVector3>(this->gravity_));
     197
     198            // also set the collision callback variable.
     199            // Note: This is a global variable which we assign a static function.
     200            // TODO: Check whether this (or anything about Bullet) works with multiple physics engine instances.
     201            gContactAddedCallback = &Scene::collisionCallback;
     202        }
     203        else if (!wantPhysics && hasPhysics())
     204        {
     205            // Remove all WorldEntities and shove them to the queue since they would still like to be in a physical world.
     206            for (std::set<WorldEntity*>::const_iterator it = this->physicalObjects_.begin();
     207                it != this->physicalObjects_.end(); ++it)
     208            {
     209                this->physicalWorld_->removeRigidBody((*it)->physicalBody_);
     210                this->physicalObjectQueue_.insert(*it);
     211            }
     212            this->physicalObjects_.clear();
     213
     214            delete this->physicalWorld_;
     215            delete this->solver_;
     216            delete this->dispatcher_;
     217            delete this->collisionConfig_;
     218            delete this->broadphase_;
     219            this->physicalWorld_   = 0;
     220            this->solver_          = 0;
     221            this->dispatcher_      = 0;
     222            this->collisionConfig_ = 0;
     223            this->broadphase_      = 0;
     224        }
     225    }
     226
     227    void Scene::tick(float dt)
     228    {
     229        if (!Core::showsGraphics())
     230        {
     231            // We need to update the scene nodes if we don't render
     232            this->rootSceneNode_->_update(true, false);
     233        }
     234        if (this->hasPhysics())
     235        {
     236            // TODO: This here is bad practice! It will slow down the first tick() by ages.
     237            //       Rather have an initialise() method as well, called by the Level after everything has been loaded.
     238            if (this->physicalObjectQueue_.size() > 0)
     239            {
     240                // Add all scheduled WorldEntities
     241                for (std::set<WorldEntity*>::const_iterator it = this->physicalObjectQueue_.begin();
     242                    it != this->physicalObjectQueue_.end(); ++it)
     243                {
     244                    this->physicalWorld_->addRigidBody((*it)->physicalBody_);
     245                    this->physicalObjects_.insert(*it);
     246                }
     247                this->physicalObjectQueue_.clear();
     248            }
     249
     250            // Note: 60 means that Bullet will do physics correctly down to 1 frames per seconds.
     251            //       Under that mark, the simulation will "loose time" and get unusable.
     252            physicalWorld_->stepSimulation(dt, 60);
     253        }
    118254    }
    119255
     
    165301    }
    166302
    167     void Scene::tick(float dt)
    168     {
    169         if (!Core::showsGraphics())
    170         {
    171             // We need to update the scene nodes if we don't render
    172             this->rootSceneNode_->_update(true, false);
    173         }
     303    void Scene::addPhysicalObject(WorldEntity* object)
     304    {
     305        if (object)
     306        {
     307            std::set<WorldEntity*>::iterator it = this->physicalObjects_.find(object);
     308            if (it != this->physicalObjects_.end())
     309                return;
     310
     311            this->physicalObjectQueue_.insert(object);
     312        }
     313    }
     314
     315    void Scene::removePhysicalObject(WorldEntity* object)
     316    {
     317        // check queue first
     318        std::set<WorldEntity*>::iterator it = this->physicalObjectQueue_.find(object);
     319        if (it != this->physicalObjectQueue_.end())
     320        {
     321            this->physicalObjectQueue_.erase(it);
     322            return;
     323        }
     324
     325        it = this->physicalObjects_.find(object);
     326        if (it == this->physicalObjects_.end())
     327            return;
     328        this->physicalObjects_.erase(it);
     329
     330        if (this->hasPhysics())
     331            this->physicalWorld_->removeRigidBody(object->physicalBody_);
     332    }
     333
     334    /*static*/ bool Scene::collisionCallback(btManifoldPoint& cp, const btCollisionObject* colObj0, int partId0,
     335                                             int index0, const btCollisionObject* colObj1, int partId1, int index1)
     336    {
     337        // get the WorldEntity pointers
     338        WorldEntity* object0 = (WorldEntity*)colObj0->getUserPointer();
     339        assert(dynamic_cast<WorldEntity*>(object0));
     340        WorldEntity* object1 = (WorldEntity*)colObj1->getUserPointer();
     341        assert(dynamic_cast<WorldEntity*>(object1));
     342
     343        // false means that bullet will assume we didn't modify the contact
     344        bool modified = false;
     345        if (object0->isCollisionCallbackActive())
     346        {
     347            modified |= object0->collidesAgainst(object1, cp);
     348            if (object1->isCollisionCallbackActive())
     349                modified |= object1->collidesAgainst(object0, cp);
     350        }
     351        else
     352            modified |= object1->collidesAgainst(object0, cp);
     353
     354        return modified;
    174355    }
    175356}
  • code/trunk/src/orxonox/objects/Scene.h

    r2171 r2662  
    2222 *   Author:
    2323 *      Fabian 'x3n' Landau
     24 *      Reto Grieder (physics)
    2425 *   Co-authors:
    2526 *      ...
     
    3233#include "OrxonoxPrereqs.h"
    3334
    34 #include "network/Synchronisable.h"
     35#include "network/synchronisable/Synchronisable.h"
    3536#include "core/BaseObject.h"
    3637#include "util/Math.h"
     
    7576            void networkcallback_applyAmbientLight()
    7677                { this->setAmbientLight(this->ambientLight_); }
     78            void networkcallback_applyShadows()
     79                { this->setShadow(this->bShadows_); }
    7780
    78             Ogre::SceneManager*    sceneManager_;
    79             Ogre::SceneNode*       rootSceneNode_;
    80             std::string            skybox_;
    81             ColourValue            ambientLight_;
    82             std::list<BaseObject*> objects_;
    83             bool                   bShadows_;
     81            Ogre::SceneManager*      sceneManager_;
     82            Ogre::SceneNode*         rootSceneNode_;
     83
     84            std::string              skybox_;
     85            ColourValue              ambientLight_;
     86            std::list<BaseObject*>   objects_;
     87            bool                     bShadows_;
     88
     89
     90        /////////////
     91        // Physics //
     92        /////////////
     93
     94        public:
     95            inline bool hasPhysics()
     96                { return this->physicalWorld_ != 0; }
     97            void setPhysicalWorld(bool wantsPhysics);
     98
     99            void setNegativeWorldRange(const Vector3& range);
     100            inline const Vector3& getNegativeWorldRange() const
     101                { return this->negativeWorldRange_; }
     102
     103            void setPositiveWorldRange(const Vector3& range);
     104            inline const Vector3& getPositiveWorldRange() const
     105                { return this->positiveWorldRange_; }
     106
     107            void setGravity(const Vector3& gravity);
     108            inline const Vector3& getGravity() const
     109                { return this->gravity_; }
     110
     111            void addPhysicalObject(WorldEntity* object);
     112            void removePhysicalObject(WorldEntity* object);
     113
     114        private:
     115            inline void networkcallback_hasPhysics()
     116                { this->setPhysicalWorld(this->bHasPhysics_); }
     117            inline void networkcallback_negativeWorldRange()
     118                { this->setNegativeWorldRange(this->negativeWorldRange_); }
     119            inline void networkcallback_positiveWorldRange()
     120                { this->setPositiveWorldRange(this->positiveWorldRange_); }
     121            inline void networkcallback_gravity()
     122                { this->setGravity(this->gravity_); }
     123
     124            // collision callback from bullet
     125            static bool collisionCallback(btManifoldPoint& cp, const btCollisionObject* colObj0, int partId0,
     126                                          int index0, const btCollisionObject* colObj1, int partId1, int index1);
     127
     128            // Bullet objects
     129            btDiscreteDynamicsWorld*             physicalWorld_;
     130            bt32BitAxisSweep3*                   broadphase_;
     131            btDefaultCollisionConfiguration*     collisionConfig_;
     132            btCollisionDispatcher*               dispatcher_;
     133            btSequentialImpulseConstraintSolver* solver_;
     134
     135            std::set<WorldEntity*>               physicalObjectQueue_;
     136            std::set<WorldEntity*>               physicalObjects_;
     137            bool                                 bHasPhysics_;
     138            Vector3                              negativeWorldRange_;
     139            Vector3                              positiveWorldRange_;
     140            Vector3                              gravity_;
    84141    };
    85142}
  • code/trunk/src/orxonox/objects/Script.cc

    r2087 r2662  
    6464  void Script::execute()
    6565  {
    66     LuaBind* lua = LuaBind::getInstance();
    67     lua->loadString(this->code_);
    68     lua->run();
     66    LuaBind& lua = LuaBind::getInstance();
     67    lua.loadString(this->code_);
     68    lua.run();
    6969  }
    7070}
  • code/trunk/src/orxonox/objects/Test.cc

    r2171 r2662  
    6161        void Test::setConfigValues()
    6262        {
    63                 SetConfigValue ( v1, 1 )/*.callback ( this, &Test::checkV1 )*/;
    64     SetConfigValue ( v2, 2 )/*.callback ( this, &Test::checkV2 )*/;
    65     SetConfigValue ( v3, 3 )/*.callback ( this, &Test::checkV3 )*/;
    66     SetConfigValue ( v4, 4 )/*.callback ( this, &Test::checkV4 )*/;
     63                SetConfigValue ( u1, 1 )/*.callback ( this, &Test::checkV1 )*/;
     64    SetConfigValue ( u2, 2 )/*.callback ( this, &Test::checkV2 )*/;
     65    SetConfigValue ( u3, 3 )/*.callback ( this, &Test::checkV3 )*/;
     66    SetConfigValue ( u4, 4 )/*.callback ( this, &Test::checkV4 )*/;
     67   
     68    SetConfigValue ( s1, 1 )/*.callback ( this, &Test::checkV1 )*/;
     69    SetConfigValue ( s2, 2 )/*.callback ( this, &Test::checkV2 )*/;
     70    SetConfigValue ( s3, 3 )/*.callback ( this, &Test::checkV3 )*/;
     71    SetConfigValue ( s4, 4 )/*.callback ( this, &Test::checkV4 )*/;
    6772        }
    6873
     
    7075        void Test::registerVariables()
    7176        {
    72                 REGISTERDATA ( v1,direction::toclient, new NetworkCallback<Test> ( this, &Test::checkV1 ) );
    73     REGISTERDATA ( v2,direction::toserver, new NetworkCallback<Test> ( this, &Test::checkV2 ) );
    74                 REGISTERDATA ( v3,direction::serverMaster, new NetworkCallback<Test> ( this, &Test::checkV3 ) );
    75     REGISTERDATA ( v4,direction::clientMaster, new NetworkCallback<Test> ( this, &Test::checkV4 ) );
     77                registerVariable ( u1, variableDirection::toclient, new NetworkCallback<Test> ( this, &Test::checkU1 ));
     78    registerVariable ( u2, variableDirection::toserver, new NetworkCallback<Test> ( this, &Test::checkU2 ));
     79                registerVariable ( u3, variableDirection::serverMaster, new NetworkCallback<Test> ( this, &Test::checkU3 ), true );
     80    registerVariable ( u4, variableDirection::clientMaster, new NetworkCallback<Test> ( this, &Test::checkU4 ), true );
     81   
     82    registerVariable ( s1, variableDirection::toclient, new NetworkCallback<Test> ( this, &Test::checkS1 ));
     83    registerVariable ( s2, variableDirection::toserver, new NetworkCallback<Test> ( this, &Test::checkS2 ));
     84    registerVariable ( s3, variableDirection::serverMaster, new NetworkCallback<Test> ( this, &Test::checkS3 ), true );
     85    registerVariable ( s4, variableDirection::clientMaster, new NetworkCallback<Test> ( this, &Test::checkS4 ), true );
    7686        }
    7787
    78   void Test::checkV1(){
    79     COUT(1) << "V1 changed: " << v1 << std::endl;
    80   }
     88  void Test::checkU1(){ COUT(1) << "U1 changed: " << u1 << std::endl; }
     89  void Test::checkU2(){ COUT(1) << "U2 changed: " << u2 << std::endl; }
     90  void Test::checkU3(){ COUT(1) << "U3 changed: " << u3 << std::endl; }
     91  void Test::checkU4(){ COUT(1) << "U4 changed: " << u4 << std::endl; }
    8192
    82   void Test::checkV2(){
    83     COUT(1) << "V2 changed: " << v2 << std::endl;
    84   }
    85 
    86   void Test::checkV3(){
    87     COUT(1) << "V3 changed: " << v3 << std::endl;
    88   }
    89  
    90   void Test::checkV4(){
    91     COUT(1) << "V4 changed: " << v4 << std::endl;
    92   }
    93 
     93  void Test::checkS1(){ COUT(1) << "S1 changed: " << s1 << std::endl; }
     94  void Test::checkS2(){ COUT(1) << "S2 changed: " << s2 << std::endl; }
     95  void Test::checkS3(){ COUT(1) << "S3 changed: " << s3 << std::endl; }
     96  void Test::checkS4(){ COUT(1) << "S4 changed: " << s4 << std::endl; }
    9497
    9598}
  • code/trunk/src/orxonox/objects/Test.h

    r2171 r2662  
    3232#include "OrxonoxPrereqs.h"
    3333#include "core/BaseObject.h"
    34 #include "network/Synchronisable.h"
     34#include "network/synchronisable/Synchronisable.h"
     35
     36
     37typedef int TYPE;
     38typedef unsigned int UTYPE;
     39
    3540
    3641namespace orxonox
     
    4550      void registerVariables();
    4651
    47       void setV1(unsigned int value){ v1 = value; }
    48       void setV2(unsigned int value){ v2 = value; }
    49       void setV3(unsigned int value){ v3 = value; }
    50       void setV4(unsigned int value){ v4 = value; }
    5152
    52       void checkV1();
    53       void checkV2();
    54       void checkV3();
    55       void checkV4();
     53      //unsigned functions
     54      void setU1(UTYPE value){ u1 = value; }
     55      void setU2(UTYPE value){ u2 = value; }
     56      void setU3(UTYPE value){ u3 = value; }
     57      void setU4(UTYPE value){ u4 = value; }
     58      void checkU1();
     59      void checkU2();
     60      void checkU3();
     61      void checkU4();
    5662     
    57       void printV1(){ instance_->checkV1(); }
    58       void printV2(){ instance_->checkV2(); }
    59       void printV3(){ instance_->checkV3(); }
    60       void printV4(){ instance_->checkV4(); }
     63      //signed functions
     64      void setS1(TYPE value){ s1 = value; }
     65      void setS2(TYPE value){ s2 = value; }
     66      void setS3(TYPE value){ s3 = value; }
     67      void setS4(TYPE value){ s4 = value; }
     68      void checkS1();
     69      void checkS2();
     70      void checkS3();
     71      void checkS4();
     72     
     73      static void printV1(){ instance_->checkU1(); }
     74      static void printV2(){ instance_->checkU2(); }
     75      static void printV3(){ instance_->checkU3(); }
     76      static void printV4(){ instance_->checkU4(); }
    6177
    6278    private:
    63       unsigned int v1;
    64       unsigned int v2;
    65       unsigned int v3;
    66       unsigned int v4;
     79      UTYPE u1;
     80      UTYPE u2;
     81      UTYPE u3;
     82      UTYPE u4;
     83     
     84      TYPE s1;
     85      TYPE s2;
     86      TYPE s3;
     87      TYPE s4;
    6788     
    6889      static Test* instance_;
  • code/trunk/src/orxonox/objects/collisionshapes

  • code/trunk/src/orxonox/objects/controllers/CMakeLists.txt

    r2131 r2662  
    22  Controller.cc
    33  HumanController.cc
     4  ArtificialController.cc
     5  AIController.cc
     6  ScriptController.cc
    47)
    58
  • code/trunk/src/orxonox/objects/controllers/Controller.cc

    r2087 r2662  
    3131
    3232#include "core/CoreIncludes.h"
     33#include "overlays/OverlayGroup.h"
    3334
    3435namespace orxonox
     
    4243        this->player_ = 0;
    4344        this->controllableEntity_ = 0;
     45        this->hud_ = 0;
     46        this->bUpdateHUD_ = false;
    4447    }
    4548
    4649    Controller::~Controller()
    4750    {
     51        if (this->isInitialized() && this->hud_)
     52            delete this->hud_;
     53    }
     54
     55    void Controller::changedControllableEntity()
     56    {
     57        if (this->bUpdateHUD_)
     58        {
     59            this->updateHUD();
     60            this->bUpdateHUD_ = false;
     61        }
     62
     63        if (this->hud_)
     64            this->hud_->setOwner(this->getControllableEntity());
     65    }
     66
     67    void Controller::updateHUD()
     68    {
     69        if (this->hud_)
     70        {
     71            delete this->hud_;
     72            this->hud_ = 0;
     73        }
     74
     75        if (this->hudtemplate_ != "")
     76        {
     77            this->hud_ = new OverlayGroup(this);
     78            this->hud_->addTemplate(this->hudtemplate_);
     79            this->hud_->setOwner(this->getControllableEntity());
     80        }
    4881    }
    4982}
  • code/trunk/src/orxonox/objects/controllers/Controller.h

    r2087 r2662  
    4747                { return this->player_; }
    4848
    49             virtual inline void setControllableEntity(ControllableEntity* entity)
    50                 { this->controllableEntity_ = entity; }
    51             virtual inline ControllableEntity* getControllableEntity() const
     49            inline void setControllableEntity(ControllableEntity* entity)
     50            {
     51                if (entity != this->controllableEntity_)
     52                {
     53                    this->controllableEntity_ = entity;
     54                    this->changedControllableEntity();
     55                }
     56            }
     57            inline ControllableEntity* getControllableEntity() const
    5258                { return this->controllableEntity_; }
     59            virtual void changedControllableEntity();
     60
     61            inline void setHUDTemplate(const std::string& name)
     62            {
     63                if (name != this->hudtemplate_)
     64                {
     65                    this->hudtemplate_ = name;
     66                    if (this->controllableEntity_)
     67                        this->updateHUD();
     68                    else
     69                        this->bUpdateHUD_ = true;
     70                }
     71            }
     72            inline const std::string& getHUDTemplate() const
     73                { return this->hudtemplate_; }
     74
     75            inline OverlayGroup* getHUD() const
     76                { return this->hud_; }
    5377
    5478        protected:
     79            void updateHUD();
     80
    5581            PlayerInfo* player_;
    5682            ControllableEntity* controllableEntity_;
     83            std::string hudtemplate_;
     84            OverlayGroup* hud_;
     85            bool bUpdateHUD_;
    5786    };
    5887}
  • code/trunk/src/orxonox/objects/controllers/HumanController.cc

    r2087 r2662  
    3333#include "core/ConsoleCommand.h"
    3434#include "objects/worldentities/ControllableEntity.h"
     35#include "objects/worldentities/pawns/Pawn.h"
     36#include "objects/gametypes/Gametype.h"
    3537
    3638namespace orxonox
     
    4446    SetConsoleCommand(HumanController, fire,          true).keybindMode(KeybindMode::OnHold);
    4547    SetConsoleCommand(HumanController, altFire,       true).keybindMode(KeybindMode::OnHold);
     48    SetConsoleCommand(HumanController, boost,         true).keybindMode(KeybindMode::OnHold);
    4649    SetConsoleCommand(HumanController, greet,         true);
    4750    SetConsoleCommand(HumanController, use,           true);
    4851    SetConsoleCommand(HumanController, switchCamera,  true);
     52    SetConsoleCommand(HumanController, mouseLook,     true);
     53    SetConsoleCommand(HumanController, suicide,       true);
     54    SetConsoleCommand(HumanController, addBots,       true).defaultValues(1);
     55    SetConsoleCommand(HumanController, killBots,      true).defaultValues(0);
     56    SetConsoleCommand(HumanController, dropItems,     true);
    4957
    5058    CreateUnloadableFactory(HumanController);
     
    103111    {
    104112        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
    105             HumanController::localController_s->controllableEntity_->fire();
     113            HumanController::localController_s->controllableEntity_->fire(WeaponMode::fire);
    106114    }
    107115
     
    109117    {
    110118        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
    111             HumanController::localController_s->controllableEntity_->altFire();
     119            HumanController::localController_s->controllableEntity_->fire(WeaponMode::altFire);
     120    }
     121
     122    void HumanController::boost()
     123    {
     124        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
     125            HumanController::localController_s->controllableEntity_->boost();
    112126    }
    113127
     
    129143            HumanController::localController_s->controllableEntity_->switchCamera();
    130144    }
     145
     146    void HumanController::mouseLook()
     147    {
     148        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
     149            HumanController::localController_s->controllableEntity_->mouseLook();
     150    }
     151
     152    void HumanController::suicide()
     153    {
     154        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
     155        {
     156            Pawn* pawn = dynamic_cast<Pawn*>(HumanController::localController_s->controllableEntity_);
     157            if (pawn)
     158                pawn->kill();
     159        }
     160    }
     161
     162    void HumanController::addBots(unsigned int amount)
     163    {
     164        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && HumanController::localController_s->controllableEntity_->getGametype())
     165            HumanController::localController_s->controllableEntity_->getGametype()->addBots(amount);
     166    }
     167
     168    void HumanController::killBots(unsigned int amount)
     169    {
     170        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && HumanController::localController_s->controllableEntity_->getGametype())
     171            HumanController::localController_s->controllableEntity_->getGametype()->killBots(amount);
     172    }
     173
     174    void HumanController::dropItems()
     175    {
     176        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
     177            HumanController::localController_s->controllableEntity_->dropItems();
     178    }
    131179}
  • code/trunk/src/orxonox/objects/controllers/HumanController.h

    r2087 r2662  
    5454            static void altFire();
    5555
     56            static void boost();
    5657            static void greet();
    5758            static void use();
    5859            static void switchCamera();
     60            static void mouseLook();
     61            static void dropItems();
     62
     63            static void suicide();
     64
     65            static void addBots(unsigned int amount);
     66            static void killBots(unsigned int amount = 0);
    5967
    6068        private:
  • code/trunk/src/orxonox/objects/gametypes/Gametype.cc

    r2171 r2662  
    3434
    3535#include "core/CoreIncludes.h"
     36#include "core/ConfigValueIncludes.h"
     37#include "core/Template.h"
     38#include "core/Core.h"
     39#include "overlays/OverlayGroup.h"
    3640#include "objects/infos/PlayerInfo.h"
     41#include "objects/infos/Bot.h"
    3742#include "objects/worldentities/pawns/Spectator.h"
    3843#include "objects/worldentities/SpawnPoint.h"
     44#include "objects/worldentities/Camera.h"
     45#include "Settings.h"
    3946
    4047#include "network/Host.h"
     
    4451    CreateUnloadableFactory(Gametype);
    4552
    46     Gametype::Gametype(BaseObject* creator) : BaseObject(creator)
     53    Gametype::Gametype(BaseObject* creator) : BaseObject(creator), gtinfo_(creator)
    4754    {
    4855        RegisterObject(Gametype);
    4956
     57        this->setGametype(this);
     58
    5059        this->defaultControllableEntity_ = Class(Spectator);
    5160
    52         this->bStarted_ = false;
    53         this->bEnded_ = false;
    5461        this->bAutoStart_ = false;
    5562        this->bForceSpawn_ = false;
     63        this->numberOfBots_ = 0;
    5664
    5765        this->initialStartCountdown_ = 3;
    58         this->startCountdown_ = 0;
    59         this->bStartCountdownRunning_ = false;
     66
     67        this->setConfigValues();
     68
     69        this->addBots(this->numberOfBots_);
     70
     71        // load the corresponding score board
     72        if (Core::showsGraphics() && this->scoreboardTemplate_ != "")
     73        {
     74            this->scoreboard_ = new OverlayGroup(this);
     75            this->scoreboard_->addTemplate(this->scoreboardTemplate_);
     76            this->scoreboard_->setGametype(this);
     77        }
     78        else
     79            this->scoreboard_ = 0;
     80    }
     81
     82    void Gametype::setConfigValues()
     83    {
     84        SetConfigValue(initialStartCountdown_, 3.0f);
     85        SetConfigValue(bAutoStart_, false);
     86        SetConfigValue(bForceSpawn_, false);
     87        SetConfigValue(numberOfBots_, 0);
     88        SetConfigValue(scoreboardTemplate_, "defaultScoreboard");
    6089    }
    6190
    6291    void Gametype::tick(float dt)
    6392    {
    64         if (this->bStartCountdownRunning_ && !this->bStarted_)
    65             this->startCountdown_ -= dt;
    66 
    67         if (!this->bStarted_)
     93        SUPER(Gametype, tick, dt);
     94
     95        if (this->gtinfo_.bStartCountdownRunning_ && !this->gtinfo_.bStarted_)
     96            this->gtinfo_.startCountdown_ -= dt;
     97
     98        if (!this->gtinfo_.bStarted_)
    6899            this->checkStart();
    69100        else
     
    76107    {
    77108        COUT(0) << "game started" << std::endl;
    78         this->bStarted_ = true;
     109        this->gtinfo_.bStarted_ = true;
    79110
    80111        this->spawnPlayersIfRequested();
     
    84115    {
    85116        COUT(0) << "game ended" << std::endl;
    86         this->bEnded_ = true;
     117        this->gtinfo_.bEnded_ = true;
    87118    }
    88119
    89120    void Gametype::playerEntered(PlayerInfo* player)
    90121    {
    91         this->players_[player] = PlayerState::Joined;
     122        this->players_[player].state_ = PlayerState::Joined;
    92123
    93124        std::string message = player->getName() + " entered the game";
     
    98129    void Gametype::playerLeft(PlayerInfo* player)
    99130    {
    100         std::map<PlayerInfo*, PlayerState::Enum>::iterator it = this->players_.find(player);
     131        std::map<PlayerInfo*, Player>::iterator it = this->players_.find(player);
    101132        if (it != this->players_.end())
    102133        {
     
    140171    void Gametype::pawnKilled(Pawn* victim, Pawn* killer)
    141172    {
    142     }
    143 
    144     void Gametype::playerScored(PlayerInfo* player)
    145     {
     173        if (victim && victim->getPlayer())
     174        {
     175            std::string message;
     176            if (killer)
     177            {
     178                if (killer->getPlayer())
     179                    message = victim->getPlayer()->getName() + " was killed by " + killer->getPlayer()->getName();
     180                else
     181                    message = victim->getPlayer()->getName() + " was killed";
     182            }
     183            else
     184                message = victim->getPlayer()->getName() + " died";
     185
     186            COUT(0) << message << std::endl;
     187            Host::Broadcast(message);
     188        }
     189
     190        if (victim && victim->getPlayer())
     191        {
     192            std::map<PlayerInfo*, Player>::iterator it = this->players_.find(victim->getPlayer());
     193            if (it != this->players_.end())
     194            {
     195                it->second.state_ = PlayerState::Dead;
     196                it->second.killed_++;
     197
     198                // Reward killer
     199                if (killer)
     200                {
     201                    std::map<PlayerInfo*, Player>::iterator itKiller = this->players_.find(killer->getPlayer());
     202                    if (itKiller != this->players_.end())
     203                    {
     204                        this->playerScored(itKiller->second);
     205                    }
     206                    else
     207                        COUT(2) << "Warning: Killing Pawn was not in the playerlist" << std::endl;
     208                }
     209
     210                ControllableEntity* entity = this->defaultControllableEntity_.fabricate(victim->getCreator());
     211                if (victim->getCamera())
     212                {
     213                    entity->setPosition(victim->getCamera()->getWorldPosition());
     214                    entity->setOrientation(victim->getCamera()->getWorldOrientation());
     215                }
     216                else
     217                {
     218                    entity->setPosition(victim->getWorldPosition());
     219                    entity->setOrientation(victim->getWorldOrientation());
     220                }
     221                it->first->startControl(entity);
     222            }
     223            else
     224                COUT(2) << "Warning: Killed Pawn was not in the playerlist" << std::endl;
     225        }
     226    }
     227
     228    void Gametype::playerScored(Player& player)
     229    {
     230        player.frags_++;
    146231    }
    147232
     
    150235        if (this->spawnpoints_.size() > 0)
    151236        {
    152             srand(time(0));
    153             rnd();
    154 
    155237            unsigned int randomspawn = (unsigned int)rnd(this->spawnpoints_.size());
    156238            unsigned int index = 0;
     
    168250    void Gametype::assignDefaultPawnsIfNeeded()
    169251    {
    170         for (std::map<PlayerInfo*, PlayerState::Enum>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
    171         {
    172             if (!it->first->getControllableEntity() && (!it->first->isReadyToSpawn() || !this->bStarted_))
    173             {
    174                 SpawnPoint* spawn = this->getBestSpawnPoint(it->first);
    175                 if (spawn)
    176                 {
    177                     // force spawn at spawnpoint with default pawn
    178                     ControllableEntity* entity = this->defaultControllableEntity_.fabricate(spawn);
    179                     spawn->spawn(entity);
    180                     it->first->startControl(entity);
    181                     it->second = PlayerState::Dead;
     252        for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
     253        {
     254            if (!it->first->getControllableEntity())
     255            {
     256                it->second.state_ = PlayerState::Dead;
     257
     258                if (!it->first->isReadyToSpawn() || !this->gtinfo_.bStarted_)
     259                {
     260                    SpawnPoint* spawn = this->getBestSpawnPoint(it->first);
     261                    if (spawn)
     262                    {
     263                        // force spawn at spawnpoint with default pawn
     264                        ControllableEntity* entity = this->defaultControllableEntity_.fabricate(spawn);
     265                        spawn->spawn(entity);
     266                        it->first->startControl(entity);
     267                        it->second.state_ = PlayerState::Dead;
     268                    }
     269                    else
     270                    {
     271                        COUT(1) << "Error: No SpawnPoints in current Gametype" << std::endl;
     272                        abort();
     273                    }
     274                }
     275            }
     276        }
     277    }
     278
     279    void Gametype::checkStart()
     280    {
     281        if (!this->gtinfo_.bStarted_)
     282        {
     283            if (this->gtinfo_.bStartCountdownRunning_)
     284            {
     285                if (this->gtinfo_.startCountdown_ <= 0)
     286                {
     287                    this->gtinfo_.bStartCountdownRunning_ = false;
     288                    this->gtinfo_.startCountdown_ = 0;
     289                    this->start();
     290                }
     291            }
     292            else if (this->players_.size() > 0)
     293            {
     294                if (this->bAutoStart_)
     295                {
     296                    this->start();
    182297                }
    183298                else
    184299                {
    185                     COUT(1) << "Error: No SpawnPoints in current Gametype" << std::endl;
    186                     abort();
    187                 }
    188             }
    189         }
    190     }
    191 
    192     void Gametype::checkStart()
    193     {
    194         if (!this->bStarted_)
    195         {
    196             if (this->bStartCountdownRunning_)
    197             {
    198                 if (this->startCountdown_ <= 0)
    199                 {
    200                     this->bStartCountdownRunning_ = false;
    201                     this->startCountdown_ = 0;
    202                     this->start();
    203                 }
    204             }
    205             else if (this->players_.size() > 0)
    206             {
    207                 if (this->bAutoStart_)
    208                 {
    209                     this->start();
    210                 }
    211                 else
    212                 {
    213300                    bool allplayersready = true;
    214                     for (std::map<PlayerInfo*, PlayerState::Enum>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
     301                    bool hashumanplayers = false;
     302                    for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
    215303                    {
    216304                        if (!it->first->isReadyToSpawn())
    217305                            allplayersready = false;
    218                     }
    219                     if (allplayersready)
    220                     {
    221                         this->startCountdown_ = this->initialStartCountdown_;
    222                         this->bStartCountdownRunning_ = true;
     306                        if (it->first->isHumanPlayer())
     307                            hashumanplayers = true;
     308                    }
     309                    if (allplayersready && hashumanplayers)
     310                    {
     311                        this->gtinfo_.startCountdown_ = this->initialStartCountdown_;
     312                        this->gtinfo_.bStartCountdownRunning_ = true;
    223313                    }
    224314                }
     
    229319    void Gametype::spawnPlayersIfRequested()
    230320    {
    231         for (std::map<PlayerInfo*, PlayerState::Enum>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
     321        for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
    232322            if (it->first->isReadyToSpawn() || this->bForceSpawn_)
    233323                this->spawnPlayer(it->first);
     
    236326    void Gametype::spawnDeadPlayersIfRequested()
    237327    {
    238         for (std::map<PlayerInfo*, PlayerState::Enum>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
    239             if (it->second == PlayerState::Dead)
     328        for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
     329            if (it->second.state_ == PlayerState::Dead)
    240330                if (it->first->isReadyToSpawn() || this->bForceSpawn_)
    241331                    this->spawnPlayer(it->first);
     
    248338        {
    249339            player->startControl(spawnpoint->spawn());
    250             this->players_[player] = PlayerState::Alive;
     340            this->players_[player].state_ = PlayerState::Alive;
    251341        }
    252342        else
     
    256346        }
    257347    }
     348
     349    void Gametype::addBots(unsigned int amount)
     350    {
     351        for (unsigned int i = 0; i < amount; ++i)
     352            new Bot(this);
     353    }
     354
     355    void Gametype::killBots(unsigned int amount)
     356    {
     357        unsigned int i = 0;
     358        for (ObjectList<Bot>::iterator it = ObjectList<Bot>::begin(); (it != ObjectList<Bot>::end()) && ((amount == 0) || (i < amount)); )
     359        {
     360            if (it->getGametype() == this)
     361            {
     362                delete (*(it++));
     363                ++i;
     364            }
     365        }
     366    }
    258367}
  • code/trunk/src/orxonox/objects/gametypes/Gametype.h

    r2171 r2662  
    3838#include "objects/worldentities/ControllableEntity.h"
    3939#include "objects/Tickable.h"
     40#include "objects/infos/GametypeInfo.h"
    4041
    4142namespace orxonox
     
    5253    }
    5354
     55    struct Player
     56    {
     57        PlayerInfo* info_;
     58        PlayerState::Enum state_;
     59        int frags_;
     60        int killed_;
     61    };
     62
    5463    class _OrxonoxExport Gametype : public BaseObject, public Tickable
    5564    {
     
    6069            virtual ~Gametype() {}
    6170
     71            void setConfigValues();
     72
    6273            virtual void tick(float dt);
    6374
     75            inline const GametypeInfo* getGametypeInfo() const
     76                { return &this->gtinfo_; }
     77
    6478            inline bool hasStarted() const
    65                 { return this->bStarted_; }
     79                { return this->gtinfo_.bStarted_; }
    6680            inline bool hasEnded() const
    67                 { return this->bEnded_; }
     81                { return this->gtinfo_.bEnded_; }
    6882
    6983            virtual void start();
     
    7589            virtual void playerChangedName(PlayerInfo* player);
    7690
    77             virtual void playerScored(PlayerInfo* player);
     91            virtual void playerScored(Player& player);
    7892
    7993            virtual void pawnKilled(Pawn* victim, Pawn* killer = 0);
     
    8195            virtual void pawnPostSpawn(Pawn* pawn);
    8296
    83             inline const std::map<PlayerInfo*, PlayerState::Enum>& getPlayers() const
     97            inline const std::map<PlayerInfo*, Player>& getPlayers() const
    8498                { return this->players_; }
    8599
     
    88102
    89103            inline bool isStartCountdownRunning() const
    90                 { return this->bStartCountdownRunning_; }
     104                { return this->gtinfo_.bStartCountdownRunning_; }
    91105            inline float getStartCountdown() const
    92                 { return this->startCountdown_; }
     106                { return this->gtinfo_.startCountdown_; }
     107
     108            void addBots(unsigned int amount);
     109            void killBots(unsigned int amount = 0);
     110
     111            inline unsigned int getNumberOfPlayers() const
     112                { return this->players_.size(); }
    93113
    94114        private:
     
    104124            void spawnDeadPlayersIfRequested();
    105125
    106             bool bStarted_;
    107             bool bEnded_;
     126            GametypeInfo gtinfo_;
     127
    108128            bool bAutoStart_;
    109129            bool bForceSpawn_;
    110130
    111131            float initialStartCountdown_;
    112             float startCountdown_;
    113             bool bStartCountdownRunning_;
     132            unsigned int numberOfBots_;
    114133
    115             std::map<PlayerInfo*, PlayerState::Enum> players_;
     134            std::map<PlayerInfo*, Player> players_;
    116135            std::set<SpawnPoint*> spawnpoints_;
    117136            SubclassIdentifier<ControllableEntity> defaultControllableEntity_;
     137
     138            OverlayGroup* scoreboard_;
     139
     140            // Config Values
     141            std::string scoreboardTemplate_;
    118142    };
    119143}
  • code/trunk/src/orxonox/objects/infos/CMakeLists.txt

    r2171 r2662  
    11SET( SRC_FILES
     2  Bot.cc
    23  Info.cc
    34  PlayerInfo.cc
    45  HumanPlayer.cc
     6  GametypeInfo.cc
    57)
    68
  • code/trunk/src/orxonox/objects/infos/HumanPlayer.cc

    r2171 r2662  
    3737#include "objects/controllers/HumanController.h"
    3838#include "objects/gametypes/Gametype.h"
     39#include "overlays/OverlayGroup.h"
    3940
    4041namespace orxonox
     
    6364    {
    6465        SetConfigValue(nick_, "Player").callback(this, &HumanPlayer::configvaluecallback_changednick);
     66        SetConfigValue(hudtemplate_, "defaultHUD").callback(this, &HumanPlayer::configvaluecallback_changedHUDTemplate);
    6567    }
    6668
    6769    void HumanPlayer::registerVariables()
    6870    {
    69         REGISTERSTRING(this->synchronize_nick_, direction::toserver, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_changednick));
     71        registerVariable(this->synchronize_nick_, variableDirection::toserver, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_changednick));
    7072
    71         REGISTERDATA(this->clientID_,     direction::toclient, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_clientIDchanged));
    72         REGISTERDATA(this->server_initialized_, direction::toclient, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_server_initialized));
    73         REGISTERDATA(this->client_initialized_, direction::toserver, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_client_initialized));
     73        registerVariable(this->clientID_,           variableDirection::toclient, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_clientIDchanged));
     74        registerVariable(this->server_initialized_, variableDirection::toclient, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_server_initialized));
     75        registerVariable(this->client_initialized_, variableDirection::toserver, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_client_initialized));
    7476    }
    7577
     
    8385                this->setName(this->nick_);
    8486        }
     87    }
     88
     89    void HumanPlayer::configvaluecallback_changedHUDTemplate()
     90    {
     91        this->changedController();
    8592    }
    8693
     
    99106
    100107            if (!Core::isMaster())
    101                 this->setObjectMode(direction::bidirectional);
     108                this->setObjectMode(objectDirection::bidirectional);
    102109            else
    103110                this->setName(this->nick_);
     
    138145        this->networkcallback_clientIDchanged();
    139146    }
     147
     148    void HumanPlayer::changedController()
     149    {
     150        if (this->getController())
     151        {
     152            this->getController()->setHUDTemplate(this->hudtemplate_);
     153
     154            if (this->getController() && this->getController()->getHUD())
     155                this->getController()->getHUD()->setOwner(this->getControllableEntity());
     156        }
     157    }
    140158}
  • code/trunk/src/orxonox/objects/infos/HumanPlayer.h

    r2171 r2662  
    3333
    3434#include "PlayerInfo.h"
    35 #include "core/Identifier.h"
    36 #include "objects/controllers/Controller.h"
    3735
    3836namespace orxonox
     
    5351            void setClientID(unsigned int clientID);
    5452
     53            virtual void changedController();
     54
    5555        protected:
    5656            void configvaluecallback_changednick();
     57            void configvaluecallback_changedHUDTemplate();
    5758            void networkcallback_changednick();
    5859            void networkcallback_clientIDchanged();
     
    6263            std::string nick_;
    6364            std::string synchronize_nick_;
     65            std::string hudtemplate_;
    6466            bool server_initialized_;
    6567            bool client_initialized_;
  • code/trunk/src/orxonox/objects/infos/Info.h

    r2171 r2662  
    3232#include "OrxonoxPrereqs.h"
    3333
    34 #include "network/Synchronisable.h"
     34#include "network/synchronisable/Synchronisable.h"
    3535#include "core/BaseObject.h"
    3636
  • code/trunk/src/orxonox/objects/infos/PlayerInfo.cc

    r2171 r2662  
    4646        this->bLocalPlayer_ = false;
    4747        this->bReadyToSpawn_ = false;
     48        this->bSetUnreadyAfterSpawn_ = true;
    4849        this->controller_ = 0;
    4950        this->controllableEntity_ = 0;
     
    6465                this->controller_ = 0;
    6566            }
     67
     68            if (this->getGametype())
     69                this->getGametype()->playerLeft(this);
    6670        }
    6771    }
     
    6973    void PlayerInfo::registerVariables()
    7074    {
    71         REGISTERSTRING(this->name_,                 direction::toclient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::changedName));
    72         REGISTERDATA  (this->controllableEntityID_, direction::toclient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedcontrollableentityID));
    73         REGISTERDATA  (this->bReadyToSpawn_,        direction::toserver);
     75        registerVariable(this->name_,                 variableDirection::toclient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::changedName));
     76        registerVariable(this->controllableEntityID_, variableDirection::toclient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedcontrollableentityID));
     77        registerVariable(this->bReadyToSpawn_,        variableDirection::toserver);
    7478    }
    7579
    7680    void PlayerInfo::changedName()
    7781    {
     82        SUPER(PlayerInfo, changedName);
     83
    7884        if (this->isInitialized() && this->getGametype())
    7985            this->getGametype()->playerChangedName(this);
     
    109115        if (this->controllableEntity_)
    110116            this->controller_->setControllableEntity(this->controllableEntity_);
     117        this->changedController();
    111118    }
    112119
    113     void PlayerInfo::startControl(ControllableEntity* entity)
     120    void PlayerInfo::startControl(ControllableEntity* entity, bool callback)
    114121    {
     122        if (entity == this->controllableEntity_)
     123            return;
     124
    115125        if (this->controllableEntity_)
    116             this->stopControl(this->controllableEntity_);
     126            this->stopControl(this->controllableEntity_, callback);
    117127
    118128        this->controllableEntity_ = entity;
     
    122132            this->controllableEntityID_ = entity->getObjectID();
    123133            entity->setPlayer(this);
    124             this->bReadyToSpawn_ = false;
     134            this->bReadyToSpawn_ &= (!this->bSetUnreadyAfterSpawn_);
    125135        }
    126136        else
  • code/trunk/src/orxonox/objects/infos/PlayerInfo.h

    r2171 r2662  
    6565                { return this->bReadyToSpawn_; }
    6666
    67             void startControl(ControllableEntity* entity);
     67            void startControl(ControllableEntity* entity, bool callback = true);
    6868            void stopControl(ControllableEntity* entity, bool callback = true);
    6969
     
    7171                { return this->controllableEntity_; }
    7272
     73            inline Controller* getController() const
     74                { return this->controller_; }
     75            virtual void changedController() {}
     76
    7377        protected:
    7478            void createController();
    75             void networkcallback_changedcontrollableentityID();
    7679
    7780            bool bHumanPlayer_;
    7881            bool bLocalPlayer_;
     82            bool bSetUnreadyAfterSpawn_;
     83            SubclassIdentifier<Controller> defaultController_;
     84            unsigned int clientID_;
     85
     86        private:
     87            void networkcallback_changedcontrollableentityID();
     88
    7989            bool bReadyToSpawn_;
    80             SubclassIdentifier<Controller> defaultController_;
    8190            Controller* controller_;
    8291            ControllableEntity* controllableEntity_;
    8392            unsigned int controllableEntityID_;
    84             unsigned int clientID_;
    8593    };
    8694}
  • code/trunk/src/orxonox/objects/pickup/CMakeLists.txt

    r2131 r2662  
    11SET( SRC_FILES
    2   ShipEquipmentClasses.cc
    3   ShipItem.cc
     2  PickupSpawner.cc
     3  BaseItem.cc
     4  Turbo.cc
     5  ShipEquipment.cc
    46)
    57
  • code/trunk/src/orxonox/objects/pickup/ShipEquipment.h

    r2094 r2662  
    1 
    21#ifndef _ShipEquipment_H__
    32#define _ShipEquipment_H__
    43#include <string>
    5 #include <multimap>
     4#include <map>
     5
     6/*
     7multimap<std::string, BaseItem*> equipment_;
     8equipment_.insert(pair<std::string, BaseItem*>("Weapon", new BaseItem()));*/
    69
    710
    8 /*
    9 multimap<std::string, Item*> equipment_;
    10 equipment_.insert(pair<std::string, Item*>("Weapon", new Item()));*/
     11/*          std::map<std::itemtype, BaseItem*> EQClasses;
     12            EQClasses["jacke"] = 0;
     13            BaseItem* item = itemMap_["jacke"];
    1114
    12 
     15           if (itemMap_["jacke"])
     16           if (itemMap_.find("jacke") != itemMap_.end()) */
    1317namespace orxonox
    1418{
     19    class BaseItem;
     20/**
     21@brief
     22    ShipEquipment is the inventory of a player. It's part of the Pawn class.
     23
     24*/
    1525    class _OrxonoxExport ShipEquipment
    1626    {
    1727        public:
    18             void AddItem(Shipitem toAddItem);
    19             void RemoveItem(Shipitem toRemoveItem);
    20             bool CheckifValid(Shipitem toBeChecked);
    21             int
    22 
     28        inline int getSpace()
     29        {
     30        return Usable.size()+Trunk.size();
     31        };
     32        bool insert(BaseItem* item);
     33        bool erase (BaseItem* item);
     34        //void print(std::multimap<std::string, BaseItem*> eut);
     35        void eraseAll();
     36        //bool checkSlot(BaseItem* item);
     37        BaseItem* checkSlot(BaseItem* item);
     38//      const std::multimap<std::string, BaseItem*>& getEquipment() const { return this->Equipment; }
     39        inline std::multimap<std::string, BaseItem*>& getEquipment() {return this->Equipment;}
     40        inline std::multimap<std::string, BaseItem*>& getUsable() {return this->Usable;}
     41        inline std::multimap<std::string, BaseItem*>& getTrunk() {return this->Trunk;}
     42        inline Pawn* getPlayer() {return this->player ;}
     43        inline void setPlayer(Pawn* setplayer)
     44        {this->player = setplayer;}
    2345        private:
    24             std::multimap<std::string, Item*> Equipment;
     46            Pawn* player;//!< Is a pointer to the belonging player
     47            std::multimap<std::string, BaseItem*> Equipment;//!< the Equipment for permanent Items
     48            std::multimap<std::string, BaseItem*> Usable;//!< Where Usables are stored
     49            std::multimap<std::string, BaseItem*> Trunk;//!< Every other Item is stored here
    2550    };
    2651}
     
    3964
    4065
    41 
    42 
    43 
    44 
    4566#endif
  • code/trunk/src/orxonox/objects/pickup/ShipEquipmentClasses.cc

    r2094 r2662  
    5757                }
    5858                break;
    59             default:;
    6059            }
    6160        case Useable:
    6261            return CheckifSpace();
    63         case default:;
    6462        }
    6563        return true;
     
    6765
    6866    /*Adds the Item to the Ship*/
    69     void ShipEquipment::AddItem(Shipitem* toAddItem)
     67    void ShipEquipment::AddItem(ShipItem* toAddItem)
    7068    {
    7169        if(CheckifValid(toAddItem)==true)
     
    9088        }
    9189    }
     90
     91    /*Adds the Item to the Ship*/
     92    void ShipEquipment::AddItem(Shipitem* toAddItem)
     93    {
     94        if(CheckifValid(toAddItem)==true)
     95        {
     96            switch(toAddItem.CheckType()){
     97                case Permanent:
     98                    Equipment.insert ( pair<std::string, ShipItem*>(toAddItem.itemname,toAddItem) );
     99                    break;
     100                case Usable:
     101                    Usable.insert ( pair<std::string, ShipItem*>(toAddItem.itemname,toAddItem) );
     102                    break;
     103                case Trunk:
     104                    Trunk.insert ( pair<std::string, ShipItem*>(toAddItem.itemname,toAddItem) );
     105                    break;
     106            }
     107        }
     108        else if(toAddItem.CheckType()==Permanent)
     109        {
     110            if(CheckifSpace()==true)
     111                Trunk.insert ( pair<std::string, ShipItem*>(toAddItem.itemname,toAddItem) );
     112        }
     113    }
     114
     115    void ShipEquipment::SwitchItem(Permanent* toSwitchItem)
     116    {
     117        multimap<string, ShipItem*>::iterator it;
     118        string equippedname;
     119        equippedname=GetNameofPermanent(toSwitchItem.CheckSubType());
     120        it=Equipment.find(equippedname);
     121        Trunk.insert (find(equippedname));
     122        Equipment.erase (it);
     123        Equipment.insert(pair<std::string, ShipItem*>(toSwitchItem.itemname,toSwitchItem)
     124    }
     125
     126    string ShipEquipment::GetNameofPermanent (subItemTypePermanent NametoGet)
     127    {
     128        multimap<string, ShipItem*>::iterator it;
     129        for ( it=Equipment.begin() ; it != Equipment.end(); it++ ){
     130            if((*it).second->CheckSubType()==NametoGet){
     131                return (*it).first.itemname;
     132            }
     133        }
     134        return 0;
     135    }
    92136}
  • code/trunk/src/orxonox/objects/pickup/ShipEquipmentClasses.h

    r2094 r2662  
    88
    99/*
    10 multimap<std::string, Item*> equipment_;
    11 equipment_.insert(pair<std::string, Item*>("Weapon", new Item()));*/
     10multimap<std::string, BaseItem*> equipment_;
     11equipment_.insert(pair<std::string, BaseItem*>("Weapon", new BaseItem()));*/
    1212
    1313
    14 /*          std::map<std::itemtype, Item*> EQClasses;
     14/*          std::map<std::itemtype, BaseItem*> EQClasses;
    1515            EQClasses["jacke"] = 0;
    16             Item* item = itemMap_["jacke"];
     16            BaseItem* item = itemMap_["jacke"];
    1717
    1818           if (itemMap_["jacke"])
     
    2323    {
    2424        public:
    25             void AddItem(Shipitem* toAddItem);
     25            /*void AddItem(Shipitem* toAddItem);
    2626            void RemoveItem(Shipitem* toRemoveItem);
    2727            bool CheckifValid(Shipitem* toBeChecked);
    2828            bool CheckifSpace();
     29            void SwitchItem(Permanent* toSwitchItem);
     30            string GetNameofPermanent (subItemTypePermanent NametoGet);*/ //holt den Namen des getragenen Items im jeweiligen Slot.
    2931
    3032        private:
    31             multimap<std::string, ShipItem*> Equipment;
    32             multimap<std::string, ShipItem*> Usable;
    33             multimap<std::string, ShipItem*> Trunk;
     33            multimap<std::string, BaseItem*> Equipment;
     34            multimap<std::string, BaseItem*> Usable;
     35            multimap<std::string, BaseItem*> Trunk;
    3436    };
    3537}
  • code/trunk/src/orxonox/objects/pickup/ShipItem.cc

    r2089 r2662  
    55    itemtype ShipItem::CheckType()
    66    {
    7         return this.type;
     7        return this->type;
    88    }
    99
    1010    subItemTypePermanent CheckSubType()
    1111    {
    12         return this.subtype_permanent;
     12        return this->subtype_permanent;
    1313    }
     14
     15    subItemTypePowerups CheckSubType()
     16    {
     17        return this->subtype_powerups;
     18    }
     19    subItemTypeUsable CheckSubType()
     20    {
     21        return this->subtype_usables;
     22    }
     23
    1424}
  • code/trunk/src/orxonox/objects/pickup/ShipItem.h

    r2094 r2662  
    2121        public:
    2222            itemType CheckType();
    23             virtual
     23            //virtual ChecksubType();
    2424
    2525        private:
     
    2727            string itemname;
    2828    };
    29 
    3029
    3130    /* Useables are Items the Player can choose when to activate and then show an instant action/effect
     
    3736            Rockets,
    3837            Repairkits,
    39             Triggers,           //trigger events usable by the player (Quests f.exp.)
     38            Triggers,       //trigger events usable by the player (Quests f.exp.)
    4039            Boosters,
    4140            Shields,
  • code/trunk/src/orxonox/objects/pickup/Usable.h

  • code/trunk/src/orxonox/objects/quest/AddQuest.cc

    r2261 r2662  
    2828
    2929/**
    30     @file AddQuest.cc
    31     @brief
    32     Implementation of the AddQuest class.
     30    @file
     31    @brief Implementation of the AddQuest class.
    3332*/
    3433
     
    4544#include "Quest.h"
    4645
    47 namespace orxonox {
    48 
     46namespace orxonox
     47{
    4948    CreateFactory(AddQuest);
    5049
     
    109108        }
    110109
    111         COUT(3) << "Quest {" << this->getQuestId() << "} successfully added to player." << std::endl;
     110        COUT(3) << "Quest {" << this->getQuestId() << "} successfully added to player: " << player << " ." << std::endl;
    112111        return true;
    113112    }
  • code/trunk/src/orxonox/objects/quest/AddQuest.h

    r2261 r2662  
    2828
    2929/**
    30     @file AddQuest.h
    31     @brief
    32     Definition of the AddQuest class.
     30    @file
     31    @brief Definition of the AddQuest class.
    3332*/
    3433
     
    4342#include "ChangeQuestStatus.h"
    4443
    45 namespace orxonox {
    46 
     44namespace orxonox
     45{
    4746    /**
    4847    @brief
     
    5857    {
    5958        public:
    60             AddQuest(BaseObject* creator);
    61             virtual ~AddQuest();
    62 
    63             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a AddQuest object through XML.
    64 
    65             virtual bool invoke(PlayerInfo* player); //!< Invokes the QuestEffect.
     59        AddQuest(BaseObject* creator);
     60        virtual ~AddQuest();
     61   
     62        virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a AddQuest object through XML.
     63   
     64        virtual bool invoke(PlayerInfo* player); //!< Invokes the QuestEffect.
    6665
    6766    };
  • code/trunk/src/orxonox/objects/quest/AddQuestHint.cc

    r2261 r2662  
    2828
    2929/**
    30     @file AddQuestHint.cc
    31     @brief
    32     Implementation of the AddQuestHint class.
     30    @file
     31    @brief Implementation of the AddQuestHint class.
    3332*/
    3433
     
    4443#include "QuestHint.h"
    4544
    46 namespace orxonox {
    47 
     45namespace orxonox
     46{
    4847    CreateFactory(AddQuestHint);
    4948
     
    130129        }
    131130
    132         COUT(3) << "QuestHint {" << this->getHintId() << "} successfully added to player." << std::endl;
     131        COUT(3) << "QuestHint {" << this->getHintId() << "} successfully added to player: " << player << " ." << std::endl;
    133132        return true;
    134133
  • code/trunk/src/orxonox/objects/quest/AddQuestHint.h

    r2261 r2662  
    2828
    2929/**
    30     @file AddQuestHint.h
    31     @brief
    32     Definition of the AddQuestHint class.
     30    @file
     31    @brief Definition of the AddQuestHint class.
    3332*/
    3433
     
    4241#include "QuestEffect.h"
    4342
    44 namespace orxonox {
    45 
     43namespace orxonox
     44{
    4645    /**
    4746    @brief
     
    7372            inline const std::string & getHintId(void) const
    7473                { return this->hintId_; }
     74           
    7575            bool setHintId(const std::string & id); //!< Sets the id of the QuestHint.
    7676
  • code/trunk/src/orxonox/objects/quest/AddReward.cc

    r2261 r2662  
    2828
    2929/**
    30     @file AddReward.cc
    31     @brief
    32     Implementation of the AddReward class.
     30    @file
     31    @brief Implementation of the AddReward class.
    3332*/
    3433
     
    4140#include "Rewardable.h"
    4241
    43 namespace orxonox {
    44 
     42namespace orxonox
     43{
    4544    CreateFactory(AddReward);
    4645
     
    106105    bool AddReward::invoke(PlayerInfo* player)
    107106    {
     107        COUT(3) << "AddReward on player: " << player << " ." << std::endl;
     108       
    108109        bool check = true;
    109110        for ( std::list<Rewardable*>::iterator reward = this->rewards_.begin(); reward != this->rewards_.end(); ++reward )
     
    111112            check = check && (*reward)->reward(player);
    112113        }
     114       
     115        COUT(3) << "Rewardable successfully added to player." << player << " ." << std::endl;
    113116
    114117        return check;
  • code/trunk/src/orxonox/objects/quest/AddReward.h

    r2261 r2662  
    2828
    2929/**
    30     @file AddReward.h
    31     @brief
    32     Definition of the AddReward class.
     30    @file
     31    @brief Definition of the AddReward class.
    3332*/
    3433
     
    4342#include "QuestEffect.h"
    4443
    45 namespace orxonox {
    46 
     44namespace orxonox
     45{
    4746    /**
    4847    @brief
     
    7877            inline void addRewardable(Rewardable* reward)
    7978                { this->rewards_.push_back(reward); }
     79       
    8080            const Rewardable* getRewardables(unsigned int index) const; //!< Returns the Rewardable object at the given index.
    8181
  • code/trunk/src/orxonox/objects/quest/CMakeLists.txt

    r2261 r2662  
    1414  QuestHint.cc
    1515  QuestItem.cc
     16  QuestListener.cc
    1617  QuestManager.cc
    1718  Rewardable.cc
  • code/trunk/src/orxonox/objects/quest/ChangeQuestStatus.cc

    r2261 r2662  
    2828
    2929/**
    30     @file ChangeQuestStatus.cc
    31     @brief
    32     Implementation of the ChangeQuestStatus class.
     30    @file
     31    @brief Implementation of the ChangeQuestStatus class.
    3332*/
    3433
     
    4039#include "QuestItem.h"
    4140
    42 namespace orxonox {
    43 
     41namespace orxonox
     42{
    4443    /**
    4544    @brief
  • code/trunk/src/orxonox/objects/quest/ChangeQuestStatus.h

    r2261 r2662  
    2828
    2929/**
    30     @file ChangeQuestStatus.h
    31     @brief
    32     Definition of the ChangeQuestStatus class.
     30    @file
     31    @brief Definition of the ChangeQuestStatus class.
    3332*/
    3433
     
    4342#include "QuestEffect.h"
    4443
    45 namespace orxonox {
    46 
     44namespace orxonox
     45{
    4746    /**
    4847    @brief
     
    6362        protected:
    6463            /**
    65                 @brief Returns the id of the Quest.
    66                 @return Returns the id of the Quest.
     64            @brief Returns the id of the Quest.
     65            @return Returns the id of the Quest.
    6766            */
    6867            inline const std::string & getQuestId(void) const
  • code/trunk/src/orxonox/objects/quest/CompleteQuest.cc

    r2261 r2662  
    2828 
    2929/**
    30     @file CompleteQuest.cc
    31     @brief
    32     Implementation of the CompleteQuest class.
     30    @file
     31    @brief Implementation of the CompleteQuest class.
    3332*/
    3433
     
    4342#include "Quest.h"
    4443
    45 namespace orxonox {
    46 
     44namespace orxonox
     45{
    4746    CreateFactory(CompleteQuest);
    4847
  • code/trunk/src/orxonox/objects/quest/CompleteQuest.h

    r2261 r2662  
    2828
    2929/**
    30     @file CompleteQuest.h
    31     @brief
    32     Definition of the CompleteQuest class.
     30    @file
     31    @brief Definition of the CompleteQuest class.
    3332*/
    3433
     
    4342#include "ChangeQuestStatus.h"
    4443
    45 namespace orxonox {
    46 
     44namespace orxonox
     45{
    4746    /**
    4847    @brief
  • code/trunk/src/orxonox/objects/quest/FailQuest.cc

    r2261 r2662  
    2828 
    2929/**
    30     @file FailQuest.cc
    31     @brief
    32     Implementation of the FailQuest class.
     30    @file
     31    @brief Implementation of the FailQuest class.
    3332*/
    3433
     
    4342#include "Quest.h"
    4443
    45 namespace orxonox {
    46 
     44namespace orxonox
     45{
    4746    CreateFactory(FailQuest);
    4847
  • code/trunk/src/orxonox/objects/quest/FailQuest.h

    r2261 r2662  
    2828
    2929/**
    30     @file FailQuest.h
    31     @brief
    32     Definition of the FailQuest class.
     30    @file
     31    @brief Definition of the FailQuest class.
    3332*/
    3433
     
    4342#include "ChangeQuestStatus.h"
    4443
    45 namespace orxonox {
    46 
     44namespace orxonox
     45{
    4746    /**
    4847    @brief
  • code/trunk/src/orxonox/objects/quest/GlobalQuest.cc

    r2261 r2662  
    2828 
    2929/**
    30     @file GlobalQuest.cc
    31     @brief
    32     Implementation of the GlobalQuest class.
     30    @file
     31    @brief Implementation of the GlobalQuest class.
    3332*/
    3433
     
    3837#include "orxonox/objects/infos/PlayerInfo.h"
    3938#include "core/CoreIncludes.h"
     39#include "core/Super.h"
    4040#include "util/Exception.h"
    4141
    4242#include "QuestEffect.h"
    4343
    44 namespace orxonox {
    45 
     44namespace orxonox
     45{
    4646    CreateFactory(GlobalQuest);
    4747
     
    8888    bool GlobalQuest::fail(PlayerInfo* player)
    8989    {
    90         if(this->isFailable(player)) //!< Check whether the Quest can be failed.
    91         {
    92             this->setStatus(player, questStatus::failed);
    93            
    94             //! Iterate through all players possessing this Quest.
    95             for(std::set<PlayerInfo*>::const_iterator it = players_.begin(); it != players_.end(); it++)
    96             {
    97                 QuestEffect::invokeEffects(*it, this->getFailEffectList());
    98             }
    99 
    100             return true;
    101         }
    102        
    103         COUT(4) << "A non-completable quest was trying to be failed." << std::endl;
    104         return false;
     90        if(!this->isFailable(player)) //!< Check whether the Quest can be failed.
     91        {
     92            COUT(4) << "A non-completable quest was trying to be failed." << std::endl;
     93            return false;
     94        }
     95       
     96        Quest::fail(player);
     97   
     98    //! Iterate through all players possessing this Quest.
     99    for(std::set<PlayerInfo*>::const_iterator it = players_.begin(); it != players_.end(); it++)
     100    {
     101        QuestEffect::invokeEffects(*it, this->getFailEffectList());
     102    }
     103
     104    return true;
    105105    }
    106106
     
    117117    bool GlobalQuest::complete(PlayerInfo* player)
    118118    {
    119         if(this->isCompletable(player)) //!< Check whether the Quest can be completed.
    120         {
    121             this->setStatus(player, questStatus::completed);
    122            
    123             //! Iterate through all players possessing the Quest.
    124             for(std::set<PlayerInfo*>::const_iterator it = players_.begin(); it != players_.end(); it++)
    125             {
    126                 QuestEffect::invokeEffects(*it, this->getCompleteEffectList());
    127             }
    128            
    129             QuestEffect::invokeEffects(player, this->rewards_); //!< Invoke reward QuestEffects on the player completing the Quest.
    130             return true;
    131         }
    132        
    133         COUT(4) << "A non-completable quest was trying to be completed." << std::endl;
    134         return false;
     119        if(!this->isCompletable(player)) //!< Check whether the Quest can be completed.
     120        {
     121            COUT(4) << "A non-completable quest was trying to be completed." << std::endl;
     122            return false;
     123        }
     124       
     125        //! Iterate through all players possessing the Quest.
     126        for(std::set<PlayerInfo*>::const_iterator it = players_.begin(); it != players_.end(); it++)
     127        {
     128            QuestEffect::invokeEffects(*it, this->getCompleteEffectList());
     129        }
     130   
     131        Quest::complete(player);
     132   
     133        QuestEffect::invokeEffects(player, this->rewards_); //!< Invoke reward QuestEffects on the player completing the Quest.
     134        return true;
    135135    }
    136136
     
    207207        }
    208208
    209     return questStatus::inactive;
     209        return questStatus::inactive;
    210210    }
    211211
  • code/trunk/src/orxonox/objects/quest/GlobalQuest.h

    r2261 r2662  
    2828 
    2929/**
    30     @file GlobalQuest.h
    31     @brief
    32     Definition of the GlobalQuest class.
     30    @file
     31    @brief Definition of the GlobalQuest class.
    3332*/
    3433
     
    4443#include "Quest.h"
    4544
    46 namespace orxonox {
    47 
     45namespace orxonox
     46{
    4847    /**
    4948    @brief
     
    5655            <QuestDescription title="Title" description="Description." /> //The description of the quest.
    5756            <subquests>
    58         <Quest id ="questId1" /> //A list of n subquest, be aware, each of the <Quest /> tags must have a description and so on and so forth as well.
    59         ...
    60         <Quest id="questIdn" />
    61         </subquests>
    62         <hints>
    63         <QuestHint id="hintId1" /> //A list of n QuestHints, see QuestHint for the full XML representation of those.
    64         ...
    65         <QuestHint id="hintIdn" />
    66         </hints>
     57                <Quest id ="questId1" /> //A list of n subquest, be aware, each of the <Quest /> tags must have a description and so on and so forth as well.
     58                ...
     59                <Quest id="questIdn" />
     60            </subquests>
     61            <hints>
     62                <QuestHint id="hintId1" /> //A list of n QuestHints, see QuestHint for the full XML representation of those.
     63                ...
     64                <QuestHint id="hintIdn" />
     65            </hints>
    6766            <fail-effects>
    6867                <QuestEffect /> //A list of QuestEffects, invoked on all players possessing this quest, when the Quest is failed, see QuestEffect for the full XML representation.
  • code/trunk/src/orxonox/objects/quest/LocalQuest.cc

    r2261 r2662  
    2828
    2929/**
    30     @file LocalQuest.cc
    31     @brief
    32     Implementation of the LocalQuest class.
     30    @file
     31    @brief Implementation of the LocalQuest class.
    3332*/
    3433
     
    3736
    3837#include "core/CoreIncludes.h"
     38#include "core/Super.h"
    3939#include "util/Exception.h"
    4040
     
    4242#include "QuestEffect.h"
    4343
    44 namespace orxonox {
    45 
     44namespace orxonox
     45{
    4646    CreateFactory(LocalQuest);
    4747
     
    8686    bool LocalQuest::fail(PlayerInfo* player)
    8787    {
    88         if(this->isFailable(player)) //!< Checks whether the quest can be failed.
    89         {
    90             this->setStatus(player, questStatus::failed);
    91             QuestEffect::invokeEffects(player, this->getFailEffectList()); //!< Invoke the failEffects.
    92             return true;
    93         }
    94        
    95         COUT(4) << "A non-failable quest was trying to be failed." << std::endl;
    96         return false;
     88        if(!this->isFailable(player)) //!< Checks whether the quest can be failed.
     89        {
     90            COUT(4) << "A non-failable quest was trying to be failed." << std::endl;
     91            return false;
     92        }
     93       
     94        Quest::fail(player);
     95       
     96        QuestEffect::invokeEffects(player, this->getFailEffectList()); //!< Invoke the failEffects.
     97        return true;
    9798    }
    9899
     
    108109    bool LocalQuest::complete(PlayerInfo* player)
    109110    {
    110         if(this->isCompletable(player)) //!< Checks whether the Quest can be completed.
    111         {
    112             this->setStatus(player, questStatus::completed);
    113             QuestEffect::invokeEffects(player, this->getCompleteEffectList()); //!< Invoke the complete QuestEffects.
    114             return true;
    115         }
    116        
    117         COUT(4) << "A non-completable quest was trying to be completed." << std::endl;
    118         return false;
     111        if(!this->isCompletable(player)) //!< Checks whether the Quest can be completed.
     112        {
     113            COUT(4) << "A non-completable quest was trying to be completed." << std::endl;
     114            return false;
     115        }
     116       
     117        Quest::complete(player);
     118       
     119        QuestEffect::invokeEffects(player, this->getCompleteEffectList()); //!< Invoke the complete QuestEffects.
     120        return true;
    119121    }
    120122
  • code/trunk/src/orxonox/objects/quest/LocalQuest.h

    r2261 r2662  
    2828 
    2929/**
    30     @file LocalQuest.h
    31     @brief
    32     Definition of the LocalQuest class.
     30    @file
     31    @brief Definition of the LocalQuest class.
    3332*/
    3433
     
    4443#include "Quest.h"
    4544
    46 namespace orxonox {
    47 
     45namespace orxonox
     46{
    4847    /**
    4948    @brief
     
    5655            <QuestDescription title="Title" description="Description." /> //The description of the quest.
    5756            <subquests>
    58         <Quest id ="questId1" /> //A list of n subquest, be aware, each of the <Quest /> tags must have a description and so on and so forth as well.
    59         ...
    60         <Quest id="questIdn" />
    61         </subquests>
    62         <hints>
    63         <QuestHint id="hintId1" /> //A list of n QuestHints, see QuestHint for the full XML representation of those.
    64         ...
    65         <QuestHint id="hintIdn" />
    66         </hints>
     57                <Quest id ="questId1" /> //A list of n subquest, be aware, each of the <Quest /> tags must have a description and so on and so forth as well.
     58                ...
     59                <Quest id="questIdn" />
     60                </subquests>
     61                <hints>
     62                <QuestHint id="hintId1" /> //A list of n QuestHints, see QuestHint for the full XML representation of those.
     63                ...
     64                <QuestHint id="hintIdn" />
     65                </hints>
    6766            <fail-effects>
    6867                <QuestEffect /> //A list of QuestEffects, invoked when the Quest is failed, see QuestEffect for the full XML representation.
  • code/trunk/src/orxonox/objects/quest/Quest.cc

    r2261 r2662  
    2828 
    2929/**
    30     @file Quest.cc
    31     @brief
    32     Implementation of the Quest class.
     30    @file
     31    @brief Implementation of the Quest class.
    3332*/
    3433
     
    4342#include "QuestHint.h"
    4443#include "QuestEffect.h"
    45 
    46 namespace orxonox {
    47 
     44#include "QuestListener.h"
     45
     46namespace orxonox
     47{
    4848    /**
    4949    @brief
     
    363363        return this->getStatus(player) == questStatus::completed;
    364364    }
     365   
     366    /**
     367    @brief
     368        Fails the Quest for an input player.
     369    @param player
     370        The player.
     371    @return
     372        Returns true if the Quest could be failed, false if not.
     373    */
     374    bool Quest::fail(PlayerInfo* player)
     375    {
     376        QuestListener::advertiseStatusChange(this->listeners_, "fail"); //!< Tells the QuestListeners, that the status has changed to failed.
     377        this->setStatus(player, questStatus::failed);
     378       
     379        COUT(4) << "Quest {" << this->getId() << "} is failed for player: " << player << " ." <<std::endl;
     380       
     381        this->getDescription()->sendFailQuestNotification();
     382        return true;
     383    }
     384   
     385    /**
     386    @brief
     387        Completes the Quest for an input player.
     388    @param player
     389        The player.
     390    @return
     391        Returns true if the Quest could be completed, false if not.
     392    */
     393    bool Quest::complete(PlayerInfo* player)
     394    {
     395        QuestListener::advertiseStatusChange(this->listeners_, "complete"); //!< Tells the QuestListeners, that the status has changed to completed.
     396        this->setStatus(player, questStatus::completed);
     397       
     398        COUT(4) << "Quest {" << this->getId() << "} is completed for player: " << player << " ." <<std::endl;
     399       
     400        this->getDescription()->sendCompleteQuestNotification();
     401        return true;
     402    }
    365403
    366404    /**
     
    374412    bool Quest::start(PlayerInfo* player)
    375413    {
    376         if(this->isStartable(player)) //!< Checks whether the quest can be started.
    377         {
    378             this->setStatus(player, questStatus::active);
    379             return true;
    380         }
    381        
    382         COUT(4) << "A non-startable quest was trying to be started." << std::endl;
    383         return false;
     414        if(!this->isStartable(player)) //!< Checks whether the quest can be started.
     415        {
     416            COUT(4) << "A non-startable quest was trying to be started." << std::endl;
     417            return false;
     418        }
     419       
     420        COUT(4) << "Quest {" << this->getId() << "} is started for player: " << player << " ." <<std::endl;
     421       
     422        QuestListener::advertiseStatusChange(this->listeners_, "start"); //!< Tells the QuestListeners, that the status has changed to active.
     423       
     424        this->setStatus(player, questStatus::active);
     425       
     426        this->getDescription()->sendAddQuestNotification();
     427        return true;
     428    }
     429   
     430    /**
     431    @brief
     432        Adds a QuestListener to the list of QuestListeners listening to this Quest.
     433    @param listener
     434        The QuestListener to be added.
     435    @return
     436        Returns true if successful, false if not.
     437    */
     438    bool Quest::addListener(QuestListener* listener)
     439    {
     440        if(listener == NULL)
     441        {
     442            COUT(2) << "A NULL-QuestListener was trying to be added to a Quests listeners." << std::endl;
     443            return false;
     444        }
     445       
     446        this->listeners_.push_back(listener);
     447        return true;
    384448    }
    385449
  • code/trunk/src/orxonox/objects/quest/Quest.h

    r2261 r2662  
    2828 
    2929/**
    30     @file Quest.h
    31     @brief
    32     Definition of the Quest class.
    33    
    34     The Quest is the parent class of LocalQuest and GlobalQuest.
     30    @file
     31    @brief Definition of the Quest class.
     32        The Quest is the parent class of LocalQuest and GlobalQuest.
    3533*/
    3634 
     
    4745#include "QuestItem.h"
    4846
    49 namespace questStatus
     47namespace orxonox
    5048{
     49    namespace questStatus
     50    {
    5151
    52     //!Different states of a Quest.
    53     enum Enum
    54     {
    55         inactive,
    56         active,
    57         failed,
    58         completed
    59     };
     52        //!Different states of a Quest.
     53        enum Enum
     54        {
     55            inactive,
     56            active,
     57            failed,
     58            completed
     59        };
    6060
    61 }
    62 
    63 namespace orxonox {
     61    }
    6462
    6563    /**
     
    9088                { return this->parentQuest_; }
    9189               
    92             /**
    93             @brief Returns the list of subquests.
    94             @return Returns a reference to the list of subquests of the quest.
    95             */
    96             inline const std::list<Quest*> & getSubQuestList(void) const
    97                 { return this->subQuests_; }
    98                    
    99             /**
    100             @brief Returns the list of all QuestHints of this Quest.
    101             @return Returns a reference to the list of QuestHints of the Quest.
    102             */
    103             inline const std::list<QuestHint*> & getHintsList(void) const
    104                 { return this->hints_; }
    105            
    106             bool isInactive(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'inactive'.
    107             bool isActive(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'active'.
    108             bool isFailed(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'failed'.
    109             bool isCompleted(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'completed'.
    110            
    111             bool start(PlayerInfo* player); //!< Sets a Quest to active.
    112             virtual bool fail(PlayerInfo* player) = 0; //!< Fails the Quest.
    113             virtual bool complete(PlayerInfo* player) = 0; //!< Completes the Quest.
     90            /**
     91            @brief Returns the list of subquests.
     92            @return Returns a reference to the list of subquests of the quest.
     93            */
     94            inline const std::list<Quest*> & getSubQuestList(void) const
     95                { return this->subQuests_; }
     96
     97            /**
     98            @brief Returns the list of all QuestHints of this Quest.
     99            @return Returns a reference to the list of QuestHints of the Quest.
     100            */
     101            inline const std::list<QuestHint*> & getHintsList(void) const
     102                { return this->hints_; }
     103       
     104            bool isInactive(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'inactive'.
     105            bool isActive(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'active'.
     106            bool isFailed(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'failed'.
     107            bool isCompleted(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'completed'.
     108       
     109            bool start(PlayerInfo* player); //!< Sets a Quest to active.
     110            virtual bool fail(PlayerInfo* player); //!< Fails the Quest.
     111            virtual bool complete(PlayerInfo* player); //!< Completes the Quest.
     112       
     113            bool addListener(QuestListener* listener); //!< Adds a QuestListener to the list of QuestListeners listening to this Quest.
    114114
    115115        protected:
     
    131131                { return this->failEffects_; }
    132132               
    133             /**
    134             @brief Returns the list of complete QuestEffects.
    135             @return Returns a reference to the list of complete QuestEffects.
    136             */
    137             inline std::list<QuestEffect*> & getCompleteEffectList(void)
     133            /**
     134            @brief Returns the list of complete QuestEffects.
     135            @return Returns a reference to the list of complete QuestEffects.
     136            */
     137            inline std::list<QuestEffect*> & getCompleteEffectList(void)
    138138                { return this->completeEffects_; }
    139139
     
    141141            virtual bool setStatus(PlayerInfo* player, const questStatus::Enum & status) = 0; //!< Changes the status for a specific player.
    142142           
    143     private:
     143        private:
    144144            Quest* parentQuest_; //!< Pointer to the parentquest.
    145145            std::list<Quest*> subQuests_; //!< List of all the subquests.
     
    149149            std::list<QuestEffect*> failEffects_; //!< A list of all QuestEffects to be invoked, when the Quest has been failed.
    150150            std::list<QuestEffect*> completeEffects_; //!< A list of QuestEffects to be invoked, when the Quest has been completed.
     151           
     152            std::list<QuestListener*> listeners_; //!< A list of QuestListeners, that listen to what exactly happens with this Quest.
    151153           
    152154            bool setParentQuest(Quest* quest); //!< Sets the parentquest of the Quest.
  • code/trunk/src/orxonox/objects/quest/QuestDescription.cc

    r2261 r2662  
    2828
    2929/**
    30     @file QuestDescription.cc
    31     @brief
    32     Implementation of the QuestDescription class.
     30    @file
     31    @brief Implementation of the QuestDescription class.
    3332*/
    3433
     
    3837
    3938#include "core/CoreIncludes.h"
     39#include "orxonox/overlays/notifications/Notification.h"
    4040
    41 namespace orxonox {
    42 
     41namespace orxonox
     42{
    4343    CreateFactory(QuestDescription);
    4444
     
    7474        XMLPortParam(QuestDescription, "title", setTitle, getTitle, xmlelement, mode);
    7575        XMLPortParam(QuestDescription, "description", setDescription, getDescription, xmlelement, mode);
     76        XMLPortParam(QuestDescription, "failMessage", setFailMessage, getFailMessage, xmlelement, mode);
     77        XMLPortParam(QuestDescription, "completeMessage", setCompleteMessage, getCompleteMessage, xmlelement, mode);
    7678
    7779        COUT(3) << "New QuestDescription with title '" << this->getTitle() << "' created." << std::endl;
     80    }
     81   
     82    /**
     83    @brief
     84        This method is a helper for sending QuestDescriptions as Notifications.
     85    @param item
     86        The item the QuestDescription is for.
     87    @param status
     88        The status the QuestDescription us for.
     89    @return
     90        Returns true if successful.
     91    */
     92    bool QuestDescription::notificationHelper(const std::string & item, const std::string & status) const
     93    {
     94        std::string message = "";
     95        std::string title = "";
     96        if(item == "hint")
     97        {
     98            title = "You received a hint: '" + this->title_ + "'";
     99            message = this->description_;
     100        }
     101        else if(item == "quest")
     102        {
     103            if(status == "start")
     104            {
     105                title = "You received a new quest: '" + this->title_ + "'";
     106                message = this->description_;
     107            }
     108            else if(status == "fail")
     109            {
     110                title = "You failed the quest: '" + this->title_ + "'";
     111                message = this->failMessage_;
     112            }
     113            else if(status == "complete")
     114            {
     115                title = "You successfully completed the quest: '" + this->title_ + "'";
     116                message = this->completeMessage_;
     117            }
     118            else
     119            {
     120                COUT(2) << "Bad input in notificationHelper, this should not be happening!" << std::endl;
     121                return false;
     122            }
     123        }
     124        else
     125        {
     126            COUT(2) << "Bad input in notificationHelper, this should not be happening!" << std::endl;
     127            return false;
     128        }
     129       
     130        Notification* notification = new Notification(0, message, title, 30);
     131        notification->send();
     132        return true;
    78133    }
    79134
  • code/trunk/src/orxonox/objects/quest/QuestDescription.h

    r2261 r2662  
    2828
    2929/**
    30     @file QuestDescription.h
    31     @brief
    32     Definition of the QuestDescription class.
     30    @file
     31    @brief Definition of the QuestDescription class.
    3332*/
    3433
     
    4342#include "core/XMLPort.h"
    4443
    45 namespace orxonox {
    46 
     44namespace orxonox
     45{
    4746    /**
    4847    @brief
     
    5251        Creating a QuestDescription through XML goes as follows:
    5352       
    54         <QuestDescription title="Title" description="Description Text" />
     53        <QuestDescription title="Title" description="Description Text" failMessage="You fail." completeMessage="You win!" />
    5554    @author
    5655        Damian 'Mozork' Frick
    5756    */
    58     class _OrxonoxExport QuestDescription : public BaseObject {
    59 
     57    class _OrxonoxExport QuestDescription : public BaseObject
     58    {
    6059        public:
    6160            QuestDescription(BaseObject* creator);
     
    6463            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a QuestDescription object through XML.
    6564
    66         /**
    67         @brief Returns the title.
    68         @return Returns a string containing the title of the QuestDescription.
    69         */
     65            /**
     66            @brief Returns the title.
     67            @return Returns a string containing the title of the QuestDescription.
     68            */
    7069            inline const std::string & getTitle(void) const
    7170                { return this->title_; }
    7271       
    73         /**
    74         @brief Returns the description text.
    75         @return Returns a string containing the description text of the QuestDescription.
    76         */
     72            /**
     73            @brief Returns the description text.
     74            @return Returns a string containing the description text of the QuestDescription.
     75            */
    7776            inline const std::string & getDescription(void) const
    7877                { return this->description_; }
     78       
     79            /**
     80            @brief Returns the fail message.
     81            @return Returns a string containing the fail message of the QuestDescription.
     82            */
     83            inline const std::string & getFailMessage(void) const
     84                { return this->failMessage_; }
     85       
     86            /**
     87            @brief Returns the complete message.
     88            @return Returns a string containing the complete message of the QuestDescription.
     89            */
     90            inline const std::string & getCompleteMessage(void) const
     91                { return this->completeMessage_; }
     92       
     93            /**
     94            @brief Sends a Notification displaying that a QuestHint was added.
     95            @return Returns true if successful.
     96            */
     97            inline bool sendAddHintNotification(void) const
     98                { return notificationHelper("hint", ""); }
     99       
     100            /**
     101            @brief Sends a Notification displaying that a Quest was added.
     102            @return Returns true if successful.
     103            */
     104            inline bool sendAddQuestNotification(void) const
     105                { return notificationHelper("quest", "start"); }
     106       
     107            /**
     108            @brief Sends a Notification displaying that a Quest was failed.
     109            @return Returns true if successful.
     110            */
     111            inline bool sendFailQuestNotification(void) const
     112                { return notificationHelper("quest", "fail"); }
     113       
     114            /**
     115            @brief Sends a Notification displaying that a Quest was completed.
     116            @return Returns true if successful.
     117            */
     118            inline bool sendCompleteQuestNotification(void) const
     119                { return notificationHelper("quest", "complete"); }
    79120
    80121        private:
    81122            std::string title_; //!< The title.
    82123            std::string description_; //!< The description.
     124            std::string failMessage_; //!< The message displayed when the Quest is failed.
     125            std::string completeMessage_; //!< The message displayed when the Quest is completed.
     126
     127            bool notificationHelper(const std::string & item, const std::string & status) const; //!< Helper for sending QuestDescriptions as Notifications.
    83128
    84129            /**
     
    89134                { this->title_ = title; }
    90135               
    91         /**
     136            /**
    92137            @brief Sets the description text.
    93138            @param description The description text to be set.
     
    96141                { this->description_ = description; }
    97142
     143            /**
     144            @brief Sets the fail message.
     145            @param message The fail message to be set.
     146            */
     147            inline void setFailMessage(const std::string & message)
     148                { this->failMessage_ = message; }
     149               
     150            /**
     151            @brief Sets the complete message.
     152            @param message The complete message to be set.
     153            */
     154            inline void setCompleteMessage(const std::string & message)
     155                { this->completeMessage_ = message; }
     156
    98157    };
    99158
  • code/trunk/src/orxonox/objects/quest/QuestEffect.cc

    r2261 r2662  
    2828
    2929/**
    30     @file QuestEffect.cc
    31     @brief
    32     Implementation of the QuestEffect class.
     30    @file
     31    @brief Implementation of the QuestEffect class.
    3332*/
    3433
     
    4039#include "orxonox/objects/infos/PlayerInfo.h"
    4140
    42 namespace orxonox {
    43 
     41namespace orxonox
     42{
    4443    /**
    4544    @brief
     
    7170        Returns false if there was an error, view console of log for further detail.
    7271    */
    73     bool QuestEffect::invokeEffects(PlayerInfo* player, std::list<QuestEffect*> & effects)
     72    /*static*/ bool QuestEffect::invokeEffects(PlayerInfo* player, std::list<QuestEffect*> & effects)
    7473    {
    7574        bool check = true;
     75       
     76        COUT(4) << "Invoking QuestEffects on player: " << player << " ."  << std::endl;
    7677
    7778        for (std::list<QuestEffect*>::iterator effect = effects.begin(); effect != effects.end(); effect++)
  • code/trunk/src/orxonox/objects/quest/QuestEffect.h

    r2261 r2662  
    2828 
    2929/**
    30     @file QuestEffect.h
    31     @brief
    32     Definition of the QuestEffect class.
     30    @file
     31    @brief Definition of the QuestEffect class.
    3332*/
    3433
     
    4241#include "core/BaseObject.h"
    4342
    44 namespace orxonox {
    45 
     43namespace orxonox
     44{
    4645    /**
    4746    @brief
  • code/trunk/src/orxonox/objects/quest/QuestEffectBeacon.cc

    r2262 r2662  
    2828
    2929/**
    30     @file QuestEffectBeacon.cc
    31     @brief
    32     Implementation of the QuestEffectBeacon class.
     30    @file
     31    @brief Implementation of the QuestEffectBeacon class.
    3332*/
    3433
     
    4645#include "QuestEffect.h"
    4746
    48 namespace orxonox {
    49 
     47namespace orxonox
     48{
    5049    CreateFactory(QuestEffectBeacon);
    5150
     
    5453        Constructor. Registers the object and initializes defaults.
    5554    */
    56     QuestEffectBeacon::QuestEffectBeacon(BaseObject* creator) : PositionableEntity(creator)
     55    QuestEffectBeacon::QuestEffectBeacon(BaseObject* creator) : StaticEntity(creator)
    5756    {
    5857        RegisterObject(QuestEffectBeacon);
    5958       
    6059        this->status_ = QuestEffectBeaconStatus::active;
    61         this->times_ = INFINITE;
     60        this->times_ = INFINITE_TIME;
    6261    }
    6362
     
    9190        SUPER(QuestEffectBeacon, processEvent, event);
    9291   
    93     SetSubclassEvent(QuestEffectBeacon, "execute", execute, event, PlayerTrigger);
     92        SetSubclassEvent(QuestEffectBeacon, "execute", execute, event, PlayerTrigger);
    9493    }
    9594   
     
    145144            this->decrementTimes(); //!< Decrement the number of times the beacon can be used.
    146145            return true;
    147     }
    148 
    149     return false;
     146        }
     147
     148        return false;
    150149    }
    151150   
     
    187186            return false;
    188187        }
    189         if(this->getTimes() == INFINITE) //!< If times is infinity the QuestEffectBeacon can be executed an infinite number fo times.
     188        if(this->getTimes() == INFINITE_TIME) //!< If times is infinity the QuestEffectBeacon can be executed an infinite number fo times.
    190189        {
    191190            return true;
     
    193192       
    194193        this->times_ = this->times_ - 1; //!< Decrement number of times the QuestEffectBeacon can be executed.
    195     if(this->getTimes() == 0) //!< Set the QuestEffectBeacon to inactive when the number of times it can be executed is reduced to 0.
    196     {
     194        if(this->getTimes() == 0) //!< Set the QuestEffectBeacon to inactive when the number of times it can be executed is reduced to 0.
     195        {
    197196            this->status_ = QuestEffectBeaconStatus::inactive;
    198     }
     197        }
    199198       
    200199        return true;
     
    213212    bool QuestEffectBeacon::setTimes(const int & n)
    214213    {
    215         if(n < 0 && n != INFINITE)
     214        if(n < 0 && n != INFINITE_TIME)
    216215        {
    217216            return false;
  • code/trunk/src/orxonox/objects/quest/QuestEffectBeacon.h

    r2262 r2662  
    2828
    2929/**
    30     @file QuestEffectBeacon.h
    31     @brief
    32     Definition of the QuestEffectBeacon class.
     30    @file
     31    @brief Definition of the QuestEffectBeacon class.
    3332*/
    3433
     
    3837#include "OrxonoxPrereqs.h"
    3938
    40 #include "orxonox/objects/worldentities/PositionableEntity.h"
     39#include "orxonox/objects/worldentities/StaticEntity.h"
    4140
    42 namespace QuestEffectBeaconStatus
     41namespace orxonox
    4342{
     43    namespace QuestEffectBeaconStatus
     44    {
    4445
    45     //! The status of the beacon, can be either active or inactive.
    46     enum Enum
    47     {
    48         inactive,
    49         active
    50     };
     46        //! The status of the beacon, can be either active or inactive.
     47        enum Enum
     48        {
     49            inactive,
     50            active
     51        };
    5152
    52 }
    53 
    54 namespace orxonox {
     53    }
    5554
    5655    /**
     
    6160        A QuestEffectBeacon can be inactive or active.
    6261       
    63     Creating a QuestEffectBeacon through XML goes as follows:
    64    
    65     <QuestEffectBeacon times=n> //Where 'n' is eighter a number >= 0, which means the QuestEffectBeacon can be executed n times. Or n = -1, which means the QuestEffectBeacon can be executed an infinite number of times.
     62        Creating a QuestEffectBeacon through XML goes as follows:
     63       
     64        <QuestEffectBeacon times=n> //Where 'n' is eighter a number >= 0, which means the QuestEffectBeacon can be executed n times. Or n = -1, which means the QuestEffectBeacon can be executed an infinite number of times.
    6665            <effects>
    6766                <QuestEffect /> //A list of QuestEffects, invoked when the QuestEffectBeacon is executed, see QuestEffect for the full XML representation.
     
    7069            </effects>
    7170            <events>
    72         <execute>
    73             <EventListener event=eventIdString />
    74         </execute>
    75         </events>
    76         <attached>
    77            <PlayerTrigger name=eventIdString /> //A PlayerTrigger triggering the execution of the QuestEffectBeacon.
    78         </attached>
    79     </QuestEffectBeacon>
     71                <execute>
     72                    <EventListener event=eventIdString />
     73                </execute>
     74            </events>
     75            <attached>
     76                <PlayerTrigger name=eventIdString /> //A PlayerTrigger triggering the execution of the QuestEffectBeacon.
     77            </attached>
     78        </QuestEffectBeacon>
    8079    @author
    8180        Damian 'Mozork' Frick
    8281    */
    83     class _OrxonoxExport QuestEffectBeacon : public PositionableEntity
     82    class _OrxonoxExport QuestEffectBeacon : public StaticEntity
    8483    {
    85     public:
    86         QuestEffectBeacon(BaseObject* creator);
    87         virtual ~QuestEffectBeacon();
    88        
    89         virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a QuestEffectBeacon object through XML.
    90        
    91         virtual void processEvent(Event& event); //!< Processes an event for this QuestEffectBeacon.
    92        
    93         bool execute(bool b, PlayerTrigger* trigger); //!< Executes the QuestEffects of the QuestEffectBeacon.
    94        
    95         /**
    96         @brief Tests whether the QuestEffectBeacon is active.
    97         @return Returns true if the QuestEffectBeacon is active, fals if not.
    98         */
    99         inline bool isActive(void)
    100            { return this->status_ == QuestEffectBeaconStatus::active; }
    101        
    102         bool setActive(bool activate); //!< Set the status of the QuestEffectBeacon.
    103        
    104     protected:
     84        public:
     85            QuestEffectBeacon(BaseObject* creator);
     86            virtual ~QuestEffectBeacon();
     87           
     88            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a QuestEffectBeacon object through XML.
     89           
     90            virtual void processEvent(Event& event); //!< Processes an event for this QuestEffectBeacon.
     91           
     92            bool execute(bool b, PlayerTrigger* trigger); //!< Executes the QuestEffects of the QuestEffectBeacon.
     93           
     94            /**
     95            @brief Tests whether the QuestEffectBeacon is active.
     96            @return Returns true if the QuestEffectBeacon is active, fals if not.
     97            */
     98            inline bool isActive(void)
     99            { return this->status_ == QuestEffectBeaconStatus::active; }
     100           
     101            bool setActive(bool activate); //!< Set the status of the QuestEffectBeacon.
     102           
     103        protected:
    105104            bool decrementTimes(void); //!< Decrement the number of times the QuestEffectBeacon can still be executed.
    106105           
     
    111110            inline const int & getTimes(void) const
    112111                { return this->times_; }
    113 
     112   
    114113        private:
    115             static const int INFINITE = -1; //!< Constant to avoid using magic numbers.
    116        
     114            static const int INFINITE_TIME = -1; //!< Constant to avoid using magic numbers.
     115           
    117116            std::list<QuestEffect*> effects_; //!< The list of QuestEffects to be invoked on the executing player.
    118117            int times_; //!< Number of times the beacon can be exectued.
  • code/trunk/src/orxonox/objects/quest/QuestHint.cc

    r2261 r2662  
    2828 
    2929/**
    30     @file QuestHint.cc
    31     @brief
    32     Implementation of the QuestHint class.
     30    @file
     31    @brief Implementation of the QuestHint class.
    3332*/
    3433
     
    4140#include "orxonox/objects/infos/PlayerInfo.h"
    4241#include "QuestManager.h"
     42#include "QuestDescription.h"
    4343#include "Quest.h"
    4444
    45 namespace orxonox {
    46 
     45namespace orxonox
     46{
    4747    CreateFactory(QuestHint);
    4848
     
    122122            {
    123123                this->playerStatus_[player] = questHintStatus::active;
     124               
     125                this->getDescription()->sendAddHintNotification();
    124126                return true;
    125127            }
  • code/trunk/src/orxonox/objects/quest/QuestHint.h

    r2261 r2662  
    2828 
    2929/**
    30     @file QuestHint.h
    31     @brief
    32     Definition of the QuestHint class.
     30    @file
     31    @brief Definition of the QuestHint class.
    3332*/
    3433
     
    4443#include "QuestItem.h"
    4544
    46 namespace questHintStatus
    47 {
    48 
    49     //! The status of the hint.
    50     enum Enum
    51     {
    52         inactive,
    53         active
    54     };
    55 
    56 }
    57 
    5845namespace orxonox
    5946{
     47    namespace questHintStatus
     48    {
     49
     50        //! The state of the hint.
     51        enum Enum
     52        {
     53            inactive,
     54            active
     55        };
     56
     57    }
    6058
    6159    /**
     
    9694        private:
    9795            Quest* quest_; //!< The Quest the QuestHint belongs to.
    98             std::map<const PlayerInfo*, questHintStatus::Enum> playerStatus_; //!< List of the status for each player, with the Player-pointer as key.
     96            std::map<const PlayerInfo*, questHintStatus::Enum> playerStatus_; //!< List of the states for each player, with the Player-pointer as key.
    9997
    10098    };
  • code/trunk/src/orxonox/objects/quest/QuestItem.cc

    r2261 r2662  
    2828 
    2929/**
    30     @file QuestItem.cc
    31     @brief
    32     Implementation of the QuestItem class.
     30    @file
     31    @brief Implementation of the QuestItem class.
    3332*/
    3433
     
    4039#include "QuestDescription.h"
    4140
    42 namespace orxonox {
    43 
     41namespace orxonox
     42{
    4443    /**
    4544    @brief
     
    9998    @return
    10099        Returns true if the string is likely to be of the required form.
    101     @todo
    102         Clarify form, more vigorous checks.
    103100    */
    104     bool QuestItem::isId(const std::string & id)
     101    /*static*/ bool QuestItem::isId(const std::string & id)
    105102    {
    106103        return id.size() >= 32;
  • code/trunk/src/orxonox/objects/quest/QuestItem.h

    r2261 r2662  
    2828 
    2929/**
    30     @file QuestItem.h
    31     @brief
    32     Definition of the QuestItem class.
    33    
    34     The QuestItem is the parent class of Quest and QuestHint.
     30    @file
     31    @brief Definition of the QuestItem class.
     32        The QuestItem is the parent class of Quest and QuestHint.
    3533*/
    3634
     
    4644#include "core/XMLPort.h"
    4745
    48 namespace orxonox {
    49 
    50 
     46namespace orxonox
     47{
    5148    /**
    5249    @brief
     
    6764            /**
    6865            @brief Returns the id of this QuestItem.
    69         @return Returns the id of the QuestItem.
     66            @return Returns the id of the QuestItem.
    7067            */
    7168            inline const std::string & getId(void) const
    7269                { return this->id_; }
    73         /**
    74         @brief Returns the QuestDescription of the QuestItem.
    75         @return Returns a pointer to the QuestDescription object of the QuestItem.
    76         */
     70           
     71            /**
     72            @brief Returns the QuestDescription of the QuestItem.
     73            @return Returns a pointer to the QuestDescription object of the QuestItem.
     74            */
    7775            inline const QuestDescription* getDescription(void) const
    7876                { return this->description_; }
  • code/trunk/src/orxonox/objects/quest/QuestManager.cc

    r2261 r2662  
    2828
    2929/**
    30     @file QuestManager.cc
    31     @brief
    32     Implementation of the QuestManager class.
     30    @file
     31    @brief Implementation of the QuestManager class.
    3332*/
    3433
     
    4241#include "QuestHint.h"
    4342
    44 namespace orxonox {
    45 
     43namespace orxonox
     44{
    4645    //! All Quests registered by their id's.
    4746    std::map<std::string, Quest*> QuestManager::questMap_s;
     
    7675        Returns true if successful, false if not.
    7776    */
    78     bool QuestManager::registerQuest(Quest* quest)
     77    /*static*/ bool QuestManager::registerQuest(Quest* quest)
    7978    {
    8079        if(quest == NULL) //!< Doh! Just as if there were actual quests behind NULL-pointers.
     
    108107        Returns true if successful, false if not.
    109108    */
    110     bool QuestManager::registerHint(QuestHint* hint)
     109    /*static*/ bool QuestManager::registerHint(QuestHint* hint)
    111110    {
    112111        if(hint == NULL) //!< Still not liking NULL-pointers.
     
    142141        Throws an exception if the given questId is invalid.
    143142    */
    144     Quest* QuestManager::findQuest(const std::string & questId)
     143    /*static*/ Quest* QuestManager::findQuest(const std::string & questId)
    145144    {
    146145        if(!QuestItem::isId(questId)) //!< Check vor validity of the given id.
     
    176175        Throws an exception if the given hintId is invalid.
    177176    */
    178     QuestHint* QuestManager::findHint(const std::string & hintId)
     177    /*static*/ QuestHint* QuestManager::findHint(const std::string & hintId)
    179178    {
    180179        if(!QuestItem::isId(hintId)) //!< Check vor validity of the given id.
  • code/trunk/src/orxonox/objects/quest/QuestManager.h

    r2261 r2662  
    2828
    2929/**
    30     @file QuestManager.h
    31     @brief
    32     Definition of the QuestManager class.
     30    @file
     31    @brief Definition of the QuestManager class.
    3332*/
    3433
     
    4342#include "core/BaseObject.h"
    4443
    45 namespace orxonox {
    46 
     44namespace orxonox
     45{
    4746    /**
    4847    @brief
  • code/trunk/src/orxonox/objects/quest/Rewardable.cc

    r2261 r2662  
    2828
    2929/**
    30     @file Rewardable.cc
    31     @brief
    32     Implementation of the Rewardable class.
     30    @file
     31    @brief Implementation of the Rewardable class.
    3332*/
    3433
     
    3837#include "core/CoreIncludes.h"
    3938
    40 namespace orxonox {
    41 
     39namespace orxonox
     40{
    4241    /**
    4342    @brief
  • code/trunk/src/orxonox/objects/quest/Rewardable.h

    r2261 r2662  
    2828
    2929/**
    30     @file Rewardable.h
    31     @brief
    32     Definition of the Rewardable class.
     30    @file
     31    @brief Definition of the Rewardable class.
    3332*/
    3433
     
    4039#include "core/BaseObject.h"
    4140
    42 namespace orxonox {
    43 
     41namespace orxonox
     42{
    4443    /**
    4544    @brief
     
    5251    class _OrxonoxExport Rewardable : public BaseObject
    5352    {
    54 
    5553        public:
    5654            Rewardable(BaseObject* creator);
     
    6159                Method to transcribe a rewardable object to the player.
    6260                Must be implemented by every class inheriting from Rewardable.
    63         @param player
     61            @param player
    6462                A pointer to the ControllableEntity, do whatever you want with it.
    65         @return
     63            @return
    6664                Return true if successful.
    6765            */
    68             virtual bool reward(PlayerInfo* player) = 0; //!<
     66            virtual bool reward(PlayerInfo* player) = 0;
    6967
    7068    };
  • code/trunk/src/orxonox/objects/weaponSystem/CMakeLists.txt

    r2131 r2662  
    22  Munition.cc
    33  Weapon.cc
     4  WeaponPack.cc
    45  WeaponSet.cc
    56  WeaponSlot.cc
     
    78)
    89
    9 #ADD_SOURCE_DIRECTORY(SRC_FILES munitions)
    10 #ADD_SOURCE_DIRECTORY(SRC_FILES projectiles)
    11 #ADD_SOURCE_DIRECTORY(SRC_FILES weapons)
     10ADD_SOURCE_DIRECTORY(SRC_FILES munitions)
     11ADD_SOURCE_DIRECTORY(SRC_FILES projectiles)
     12ADD_SOURCE_DIRECTORY(SRC_FILES weapons)
    1213
    1314ADD_SOURCE_FILES(SRC_FILES)
  • code/trunk/src/orxonox/objects/weaponSystem/Munition.cc

    r2097 r2662  
    3737namespace orxonox
    3838{
     39    CreateFactory(Munition);
     40
    3941    Munition::Munition(BaseObject* creator) : BaseObject(creator)
    4042    {
     
    4648    }
    4749
     50    unsigned int Munition::bullets()
     51    {
     52        if (this->bullets_ > 0)
     53            return bullets_;
     54        else
     55            return 0;
     56    }
     57
     58    unsigned int Munition::magazines()
     59    {
     60        if (this->magazines_ > 0)
     61            return magazines_;
     62        else
     63            return 0;
     64    }
     65
     66    void Munition::setMaxBullets(unsigned int amount)
     67    { this->maxBullets_ = amount; }
     68
     69    void Munition::setMaxMagazines(unsigned int amount)
     70    { this->maxMagazines_ = amount; }
     71
     72    void Munition::removeBullets(unsigned int amount)
     73    {
     74        if ( this->bullets_ != 0 )
     75            this->bullets_ = this->bullets_ - amount;
     76    }
     77
     78    void Munition::removeMagazines(unsigned int amount)
     79    {
     80        if ( this->magazines_ != 0 )
     81            this->magazines_ = this->magazines_ - amount;
     82    }
     83
     84    void Munition::addBullets(unsigned int amount)
     85    {
     86        if ( this->bullets_ == this->maxBullets_ )
     87        {
     88            //cannot add bullets to actual magazine
     89        }
     90        else
     91            this->bullets_ = this->bullets_ + amount;
     92    }
     93
     94    void Munition::addMagazines(unsigned int amount)
     95    {
     96        if ( this->magazines_ == this->maxMagazines_ )
     97        {
     98            //no more capacity for another magazine
     99        }
     100        else
     101            this->magazines_ = this->magazines_ + amount;
     102    }
     103
     104
     105    void Munition::fillBullets()
     106    {
     107//COUT(0) << "Munition::fillBullets maxBullets_=" << this->maxBullets_ << std::endl;
     108        this->bullets_ = this->maxBullets_;
     109    }
     110
     111    void Munition::fillMagazines()
     112    {
     113        this->magazines_ = this->maxMagazines_;
     114    }
     115
    48116    void Munition::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    49117    {
    50 
     118        SUPER(Munition, XMLPort, xmlelement, mode);
    51119    }
    52120
  • code/trunk/src/orxonox/objects/weaponSystem/Munition.h

    r2106 r2662  
    3434#include "core/BaseObject.h"
    3535
     36#include "Weapon.h"
     37
    3638
    3739namespace orxonox
     
    4547            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    4648
     49            void setMaxBullets(unsigned int amount);
     50            void setMaxMagazines(unsigned int amount);
     51
     52            void fillBullets();
     53            void fillMagazines();
     54
     55            unsigned int bullets();
     56            unsigned int magazines();
     57
     58            void removeBullets(unsigned int k);
     59            void removeMagazines(unsigned int k);
     60            void addBullets(unsigned int k);
     61            void addMagazines(unsigned int k);
    4762
    4863        private:
    4964
    50 
     65        protected:
     66            unsigned int bullets_;
     67            unsigned int magazines_;
     68            unsigned int maxBullets_;
     69            unsigned int maxMagazines_;
    5170    };
    5271}
  • code/trunk/src/orxonox/objects/weaponSystem/Weapon.cc

    r2098 r2662  
    3737namespace orxonox
    3838{
    39     Weapon::Weapon(BaseObject* creator) : BaseObject(creator)
     39    CreateFactory(Weapon);
     40
     41    Weapon::Weapon(BaseObject* creator) : StaticEntity(creator)
    4042    {
    4143        RegisterObject(Weapon);
     44        this->bulletReadyToShoot_ = true;
     45        this->magazineReadyToShoot_ = true;
     46        this->parentWeaponSystem_ = 0;
     47        this->attachedToWeaponSlot_ = 0;
     48        this->munition_ = 0;
     49        this->bulletLoadingTime_ = 0;
     50        this->magazineLoadingTime_ = 0;
     51        this->bReloading_ = false;
    4252
    43         this->loadingTime_ = 0;
    44         this->munition_ = 0;
    45 
     53        this->setObjectMode(0x0);
    4654    }
    4755
     
    5058    }
    5159
    52     void Weapon::addMunition()
     60
     61    void Weapon::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    5362    {
     63        SUPER(Weapon, XMLPort, xmlelement, mode);
     64        XMLPortParam(Weapon, "munitionType", setMunitionType, getMunitionType, xmlelement, mode);
     65        XMLPortParam(Weapon, "bulletLoadingTime", setBulletLoadingTime, getBulletLoadingTime, xmlelement, mode);
     66        XMLPortParam(Weapon, "magazineLoadingTime", setMagazineLoadingTime, getMagazineLoadingTime, xmlelement, mode);
     67    }
     68
     69    void Weapon::setWeapon()
     70    {
     71        this->munition_->fillBullets();
     72        this->munition_->fillMagazines();
     73    }
     74
     75
     76    void Weapon::fire()
     77    {
     78//COUT(0) << "LaserGun::fire, this=" << this << std::endl;
     79        if ( this->bulletReadyToShoot_ && this->magazineReadyToShoot_ && !this->bReloading_)
     80        {
     81//COUT(0) << "LaserGun::fire - ready to shoot" << std::endl;
     82//COUT(0) << "LaserGun::fire - bullets" << this->munition_->bullets() << std::endl;
     83            this->bulletReadyToShoot_ = false;
     84            if ( this->munition_->bullets() > 0)
     85            {
     86                //shoot
     87                this->takeBullets();
     88                this->createProjectile();
     89            }
     90            //if there are no bullets, but magazines
     91            else if ( this->munition_->magazines() > 0 && this->munition_->bullets() == 0 )
     92            {
     93//COUT(0) << "LaserGun::fire - no bullets" << std::endl;
     94                this->takeMagazines();
     95            }
     96            else
     97            {
     98//COUT(0) << "LaserGun::fire - no magazines" << std::endl;
     99                //actions
     100            }
     101        }
     102        else
     103        {
     104//COUT(0) << "LaserGun::fire - weapon not reloaded - bullets remaining:" << this->munition_->bullets() << std::endl;
     105            //actions
     106        }
    54107
    55108    }
    56109
    57     void Weapon::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     110
     111    void Weapon::bulletTimer(float bulletLoadingTime)
    58112    {
    59 
     113//COUT(0) << "Weapon::bulletTimer started" << std::endl;
     114        this->bReloading_ = true;
     115        this->bulletReloadTimer_.setTimer( bulletLoadingTime , false , this , createExecutor(createFunctor(&Weapon::bulletReloaded)));
     116    }
     117    void Weapon::magazineTimer(float magazineLoadingTime)
     118    {
     119//COUT(0) << "Weapon::magazineTimer started" << std::endl;
     120        this->bReloading_ = true;
     121        this->magazineReloadTimer_.setTimer( magazineLoadingTime , false , this , createExecutor(createFunctor(&Weapon::magazineReloaded)));
    60122    }
    61123
    62     void Weapon::fire()
     124    void Weapon::bulletReloaded()
    63125    {
     126        this->bReloading_ = false;
     127        this->bulletReadyToShoot_ = true;
     128    }
    64129
     130    void Weapon::magazineReloaded()
     131    {
     132        this->bReloading_ = false;
     133        this->munition_->fillBullets();
     134        this->magazineReadyToShoot_ = true;
     135        this->bulletReadyToShoot_ = true;
    65136    }
     137
     138
     139    void Weapon::attachNeededMunition(std::string munitionName)
     140    {
     141//COUT(0) << "Weapon::attachNeededMunition, parentWeaponSystem=" << this->parentWeaponSystem_ << std::endl;
     142        //if munition type already exists attach it, else create a new one of this type and attach it to the weapon and to the WeaponSystem
     143        if (this->parentWeaponSystem_)
     144        {
     145//COUT(0) << "Weapon::attachNeededMunition " << munitionName << std::endl;
     146            Munition* munition = this->parentWeaponSystem_->getMunitionType(munitionName);
     147            if ( munition )
     148                this->munition_ = munition;
     149            else
     150            {
     151                //create new munition with identifier
     152//COUT(0) << "Weapon::attachNeededMunition, create new Munition of Type " << munitionName << std::endl;
     153                this->munitionIdentifier_ = ClassByString(munitionName);
     154                this->munition_ = this->munitionIdentifier_.fabricate(this);
     155                this->parentWeaponSystem_->setNewMunition(munitionName, this->munition_);
     156            }
     157        }
     158    }
     159
     160
     161     /*get and set functions
     162     *
     163     */
     164
     165    void Weapon::setMunitionType(std::string munitionType)
     166    {   this->munitionType_ = munitionType; }
     167
     168    const std::string Weapon::getMunitionType()
     169    {   return this->munitionType_;  }
     170
     171    void Weapon::setBulletLoadingTime(float loadingTime)
     172    {   this->bulletLoadingTime_ = loadingTime; }
     173
     174    const float Weapon::getBulletLoadingTime()
     175    {   return this->bulletLoadingTime_;  }
     176
     177    void Weapon::setMagazineLoadingTime(float loadingTime)
     178    {   this->magazineLoadingTime_ = loadingTime; }
     179
     180    const float Weapon::getMagazineLoadingTime()
     181    {   return this->magazineLoadingTime_;  }
     182
     183
     184    Munition * Weapon::getAttachedMunition(std::string munitionType)
     185    {
     186//COUT(0) << "Weapon::getAttachedMunition, parentWeaponSystem_="<< this->parentWeaponSystem_ << std::endl;
     187        this->munition_ = this->parentWeaponSystem_->getMunitionType(munitionType);
     188//COUT(0) << "Weapon::getAttachedMunition, munition_="<< this->munition_ << std::endl;
     189        return this->munition_;
     190    }
     191
     192    void Weapon::takeBullets() { };
     193    void Weapon::createProjectile() { };
     194    void Weapon::takeMagazines() { };
     195
    66196}
  • code/trunk/src/orxonox/objects/weaponSystem/Weapon.h

    r2106 r2662  
    3333
    3434#include "core/BaseObject.h"
     35#include "tools/BillboardSet.h"
     36#include "tools/Timer.h"
     37#include "core/Identifier.h"
    3538
     39#include "WeaponSystem.h"
     40#include "Munition.h"
     41
     42#include "objects/worldentities/StaticEntity.h"
    3643
    3744namespace orxonox
    3845{
    39     class _OrxonoxExport Weapon : public BaseObject
     46    class _OrxonoxExport Weapon : public StaticEntity
    4047    {
    4148        public:
     
    4552            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    4653
    47             void addMunition();
    4854            virtual void fire();
     55            void attachNeededMunition(std::string munitionType);
     56            Munition * getAttachedMunition(std::string munitiontype);
     57
     58            //reloading
     59            void bulletTimer(float bulletLoadingTime);
     60            void magazineTimer(float magazineLoadingTime);
     61            void bulletReloaded();
     62            void magazineReloaded();
     63
     64            virtual void setMunitionType(std::string munitionType);
     65            virtual const std::string getMunitionType();
     66            virtual void setBulletLoadingTime(float loadingTime);
     67            virtual const float getBulletLoadingTime();
     68            virtual void setMagazineLoadingTime(float loadingTime);
     69            virtual const float getMagazineLoadingTime();
     70
     71            virtual void takeBullets();
     72            virtual void takeMagazines();
     73            virtual void createProjectile();
     74
     75            inline void setParentWeaponSystem(WeaponSystem *parentWeaponSystem)
     76                { this->parentWeaponSystem_=parentWeaponSystem; };
     77            inline WeaponSystem * getParentWeaponSystem()
     78                { return this->parentWeaponSystem_; };
     79
     80            inline void setAttachedToWeaponSlot(WeaponSlot * wSlot)
     81                { this->attachedToWeaponSlot_ = wSlot; }
     82            inline WeaponSlot * getAttachedToWeaponSlot()
     83                { return this->attachedToWeaponSlot_; }
     84
     85            virtual void setWeapon();
    4986
    5087        private:
    51             int loadingTime_;
    52             Munition *munition_;
    5388
     89        protected:
     90            bool bReloading_;
     91            bool bulletReadyToShoot_;
     92            bool magazineReadyToShoot_;
     93            float bulletLoadingTime_;
     94            float magazineLoadingTime_;
     95            std::string munitionType_;
    5496
     97            WeaponSlot * attachedToWeaponSlot_;
     98            Munition * munition_;
     99            WeaponSystem * parentWeaponSystem_;
    55100
     101            SubclassIdentifier<Munition> munitionIdentifier_;
     102
     103            Timer<Weapon> bulletReloadTimer_;
     104            Timer<Weapon> magazineReloadTimer_;
    56105    };
    57106}
  • code/trunk/src/orxonox/objects/weaponSystem/WeaponSet.cc

    r2098 r2662  
    3333#include "core/XMLPort.h"
    3434#include "util/Debug.h"
     35#include "objects/worldentities/pawns/Pawn.h"
    3536
    3637#include "WeaponSet.h"
     38#include "WeaponPack.h"
    3739
    3840namespace orxonox
    3941{
     42    CreateFactory(WeaponSet);
     43
    4044    WeaponSet::WeaponSet(BaseObject* creator, int k) : BaseObject(creator)
    4145    {
     
    4347
    4448        this->parentWeaponSystem_ = 0;
    45 
    46         for (int i=0;i<k;i++)
    47         {
    48             attachWeaponSlot(new WeaponSlot(this));
    49         }
     49        this->attachedWeaponPack_ = 0;
    5050    }
    5151
     
    5454    }
    5555
    56     //Vorwärtsdeklaration
    57     WeaponSystem * parentWeaponSystem_;
     56    void WeaponSet::attachWeaponPack(WeaponPack *wPack)
     57    {
     58//COUT(0) << "WeaponSet::attachWeaponPack" << std::endl;
     59//COUT(0) << "........ parentWeaponSystem_=" << this->parentWeaponSystem_ << std::endl;
     60//COUT(0) << "........ this->parentWeaponSystem_->getWeaponSlotSize()" << this->parentWeaponSystem_->getWeaponSlotSize() << std::endl;
     61//COUT(0) << "........ wPack->getSize()" << wPack->getSize() << std::endl;
     62        if ( this->parentWeaponSystem_->getWeaponSlotSize()>0 && wPack->getSize()>0 && ( wPack->getSize() <= this->parentWeaponSystem_->getWeaponSlotSize() ) )
     63        {
     64//COUT(0) << "WeaponSet::attachWeaponPack after if" << std::endl;
     65            this->attachedWeaponPack_ = wPack;
     66            int wPackWeapon = 0;    //WeaponCounter for Attaching
     67            //should be possible to choose which slot to use
     68            for (  int i=0; i < wPack->getSize() ; i++  )
     69            {
     70                //at the moment this function only works for one weaponPack in the entire WeaponSystem...
     71                if ( this->parentWeaponSystem_->getWeaponSlotPointer(i)->getAttachedWeapon() == 0 && this->parentWeaponSystem_->getWeaponSlotPointer(i) != 0) //if slot not full
     72                {
     73//COUT(0) << "WeaponSet::attachWeaponPack attaching Weapon" << std::endl;
     74                    this->setWeaponSlots_.push_back( this->parentWeaponSystem_->getWeaponSlotPointer(i) );
     75                    this->parentWeaponSystem_->getWeaponSlotPointer(i)->attachWeapon( wPack->getWeaponPointer(wPackWeapon) );
     76                    this->parentWeaponSystem_->getParentPawn()->attach( wPack->getWeaponPointer(wPackWeapon) );
     77                    wPackWeapon++;
     78                }
     79                else
     80                {
     81                    for (int k=0; k < this->parentWeaponSystem_->getWeaponSlotSize(); k++)
     82                    {
     83                        if ( this->parentWeaponSystem_->getWeaponSlotPointer(k)->getAttachedWeapon() == 0 )
     84                        {
     85//COUT(0) << "WeaponSet::attachWeaponPack mode 2 k="<< k << std::endl;
     86                            this->setWeaponSlots_.push_back( this->parentWeaponSystem_->getWeaponSlotPointer(k) );
     87                            this->parentWeaponSystem_->getWeaponSlotPointer(k)->attachWeapon( wPack->getWeaponPointer(wPackWeapon) );
     88                            this->parentWeaponSystem_->getParentPawn()->attach( wPack->getWeaponPointer(wPackWeapon) );
     89                            wPackWeapon++;
     90                        }
     91                    }
     92                }
     93            }
     94        }
     95    }
    5896
    59     void WeaponSet::attachWeaponSlot(WeaponSlot *wSlot)
    60     {
    61         this->weaponSlots_.push_back(wSlot);
    62     }
    6397
    6498    void WeaponSet::fire()
    6599    {
    66         for (int i=0; i < (int) this->weaponSlots_.size(); i++)
    67         {
    68             this->weaponSlots_[i]->fire();
    69         }
     100        //fires all WeaponSlots available for this weaponSet attached from the WeaponPack
     101//COUT(0) << "WeaponSet::fire from Pack: " << this->attachedWeaponPack_ << std::endl;
     102        if (this->attachedWeaponPack_)
     103            this->attachedWeaponPack_->fire();
    70104    }
    71105
    72     WeaponSlot * WeaponSet::getWeaponSlotPointer(unsigned int n)
    73     {
    74         if (n < this->weaponSlots_.size())
    75             return this->weaponSlots_[n];
    76         else
    77             return 0;
    78     }
     106    void WeaponSet::setFireMode(const unsigned int firemode)
     107    {   this->firemode_ = firemode; }
    79108
     109    const unsigned int WeaponSet::getFireMode() const
     110    {   return this->firemode_; }
    80111
    81112    void WeaponSet::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    82113    {
    83 
     114        SUPER(WeaponSet, XMLPort, xmlelement, mode);
     115        XMLPortParam(WeaponSet, "firemode", setFireMode, getFireMode, xmlelement, mode);
    84116    }
    85117
  • code/trunk/src/orxonox/objects/weaponSystem/WeaponSet.h

    r2106 r2662  
    4848            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    4949
    50             void attachWeaponSlot(WeaponSlot *wSlot);
     50            void attachWeaponPack(WeaponPack *wPack);
    5151            void fire();
    52             WeaponSlot * getWeaponSlotPointer(unsigned int n);
     52
     53            void setFireMode(const unsigned int firemode);
     54            const unsigned int getFireMode() const;
    5355
    5456            inline void setParentWeaponSystem(WeaponSystem *parentWeaponSystem)
     
    5860
    5961        private:
    60             std::vector<WeaponSlot *> weaponSlots_;
    6162            WeaponSystem *parentWeaponSystem_;
     63            std::vector<WeaponSlot *> setWeaponSlots_;
     64            unsigned int firemode_;
     65            WeaponPack * attachedWeaponPack_;
    6266    };
    6367}
  • code/trunk/src/orxonox/objects/weaponSystem/WeaponSlot.cc

    r2098 r2662  
    3636
    3737
    38 
    3938namespace orxonox
    4039{
    41     WeaponSlot::WeaponSlot(BaseObject* creator) : BaseObject(creator)
     40    CreateFactory(WeaponSlot);
     41
     42    WeaponSlot::WeaponSlot(BaseObject* creator) : StaticEntity(creator)
    4243    {
    4344        RegisterObject(WeaponSlot);
    4445
    4546        this->unlimitedAmmo_ = false;
    46 
    4747        this->attachedWeapon_ = 0;
    48         this->parentWeaponSet_ = 0;
     48        this->setObjectMode(0x0);
    4949    }
    5050
     
    5353    }
    5454
    55     void WeaponSlot::attachWeapon(Weapon *weaponName)
    56     {
    57 
    58     }
    5955
    6056    /*sets the munition type
     
    6763    }
    6864
     65
    6966    void WeaponSlot::fire()
    7067    {
     68        if ( this->attachedWeapon_ )
     69//COUT(0) << "WeaponSlot::fire" << std::endl;
     70        this->attachedWeapon_->fire();
     71    }
    7172
    72     }
    7373
    7474    void WeaponSlot::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    7575    {
     76        SUPER(WeaponSlot, XMLPort, xmlelement, mode);
     77    }
    7678
     79    void WeaponSlot::attachWeapon(Weapon *weapon)
     80    {
     81        this->attachedWeapon_ = weapon;
     82        weapon->setAttachedToWeaponSlot(this);
     83//COUT(0) << "WeaponSlot::attachWeapon position=" << this->getWorldPosition() << std::endl;
     84        weapon->setPosition(this->getPosition());
     85    }
     86
     87    Weapon * WeaponSlot::getAttachedWeapon() const
     88    {
     89        return this->attachedWeapon_;
    7790    }
    7891}
  • code/trunk/src/orxonox/objects/weaponSystem/WeaponSlot.h

    r2106 r2662  
    3232#include "OrxonoxPrereqs.h"
    3333
    34 #include "core/BaseObject.h"
    35 
    36 
    3734#include "Weapon.h"
    38 
     35#include "objects/worldentities/StaticEntity.h"
    3936
    4037namespace orxonox
    4138{
    42     class _OrxonoxExport WeaponSlot : public BaseObject
     39    class _OrxonoxExport WeaponSlot : public StaticEntity
    4340    {
    4441        public:
     
    4845            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    4946
    50             void attachWeapon(Weapon *weaponName);
     47            void attachWeapon(Weapon *weapon);
     48            Weapon * getAttachedWeapon() const;
    5149            void setAmmoType(bool isUnlimited);
    5250            void fire();
    5351
    54             inline void setParentWeaponSet(WeaponSet *parentWeaponSet)
    55                 { parentWeaponSet_=parentWeaponSet; }
    56             inline WeaponSet * getParentWeaponSet()
    57                 { return parentWeaponSet_; }
    58 
     52            inline void setParentWeaponSystem(WeaponSystem *parentWeaponSystem)
     53                { parentWeaponSystem_=parentWeaponSystem; }
     54            inline WeaponSystem * getParentWeaponSystem()
     55                { return parentWeaponSystem_; }
    5956
    6057
     
    6360            bool unlimitedAmmo_;
    6461
    65             WeaponSet *parentWeaponSet_;
     62            WeaponSystem *parentWeaponSystem_;
    6663    };
    6764}
  • code/trunk/src/orxonox/objects/weaponSystem/WeaponSystem.cc

    r2261 r2662  
    3737#include "WeaponSystem.h"
    3838
     39
    3940/* WEAPONSYSTEM
    4041 * creates the WeaponSystem and the ability to use weapons and munition
     
    4546namespace orxonox
    4647{
     48    CreateFactory(WeaponSystem);
     49
    4750    WeaponSystem::WeaponSystem(BaseObject* creator) : BaseObject(creator)
    4851    {
     
    5053
    5154        this->activeWeaponSet_ = 0;
    52         this->parentSpaceShip_ = 0;
     55        this->parentPawn_ = 0;
    5356    }
    5457
     
    5760    }
    5861
    59     //creates empty weaponSet
     62    void WeaponSystem::attachWeaponPack(WeaponPack *wPack, unsigned int firemode)
     63    {
     64        if (firemode < this->weaponSets_.size())
     65            this->weaponSets_[firemode]->attachWeaponPack(wPack);
     66        this->weaponPacks_.push_back(wPack);
     67    }
     68
     69    void WeaponSystem::attachWeaponSlot(WeaponSlot *wSlot)
     70    {
     71        wSlot->setParentWeaponSystem(this);
     72        this->weaponSlots_.push_back(wSlot);
     73    }
     74
    6075    void WeaponSystem::attachWeaponSet(WeaponSet *wSet)
    6176    {
     77        wSet->setParentWeaponSystem(this);
    6278        this->weaponSets_.push_back(wSet);
    63         wSet->setParentWeaponSystem(this);
    6479    }
    6580
     81    void WeaponSystem::setNewMunition(std::string munitionType, Munition * munitionToAdd)
     82    {
     83        this->munitionSet_[munitionType] = munitionToAdd;
     84    }
     85
     86    //returns the Pointer to the munitionType
     87    Munition * WeaponSystem::getMunitionType(std::string munitionType)
     88    {
     89//COUT(0) << "WeaponSystem::getMunitionType " << munitionType << std::endl;
     90        std::map<std::string, Munition *>::const_iterator it = this->munitionSet_.find(munitionType);
     91        if (it != this->munitionSet_.end())
     92            return it->second;
     93        else
     94            return 0;
     95    }
     96
     97
     98/*
    6699    //the first weaponSet is at n=0
    67100    void WeaponSystem::setActiveWeaponSet(unsigned int n)
     
    69102        if (n < this->weaponSets_.size())
    70103            this->activeWeaponSet_ = this->weaponSets_[n];
     104        else
     105            this->activeWeaponSet_ = this->weaponSets_[0];
     106    }
     107*/
     108
     109
     110    //n is the n'th weaponSet, starting with zero
     111    //SpaceShip.cc only needs to have the keybinding to a specific Set-number n
     112    void WeaponSystem::fire(WeaponMode::Enum n)
     113    {
     114        int set = 0;
     115        switch (n)
     116        {
     117            case WeaponMode::fire:
     118                set = 0;
     119                break;
     120            case WeaponMode::altFire:
     121                set = 1;
     122                break;
     123            case WeaponMode::altFire2:
     124                set = 2;
     125                break;
     126        }
     127//COUT(0) << "WeaponSystem::fire" << std::endl;
     128        if (set < (int)this->weaponSets_.size())
     129//COUT(0) << "WeaponSystem::fire - after if" << std::endl;
     130            this->weaponSets_[set]->fire();
    71131    }
    72132
    73     //n is the n'th weaponSet, starting with zero
    74     //Spaceship.cc only needs to have the keybinding to a specific Set-number n
    75     void WeaponSystem::fire(unsigned int n)
    76     {
    77         if (n < this->weaponSets_.size())
    78             this->weaponSets_[n]->fire();
    79     }
    80 
    81     void WeaponSystem::fire()
    82     {
    83         if (this->activeWeaponSet_)
    84             this->activeWeaponSet_->fire();
    85     }
    86133
    87134    WeaponSet * WeaponSystem::getWeaponSetPointer(unsigned int n)
     
    93140    }
    94141
     142    WeaponSlot * WeaponSystem::getWeaponSlotPointer(unsigned int n)
     143    {
     144        if (n < this->weaponSlots_.size())
     145            return this->weaponSlots_[n];
     146        else
     147            return 0;
     148    }
     149
     150    WeaponPack * WeaponSystem::getWeaponPackPointer(unsigned int n)
     151    {
     152        if (n < this->weaponPacks_.size())
     153            return this->weaponPacks_[n];
     154        else
     155            return 0;
     156    }
     157
    95158    void WeaponSystem::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    96159    {
    97 
     160        SUPER(WeaponSystem, XMLPort, xmlelement, mode);
    98161    }
    99162
  • code/trunk/src/orxonox/objects/weaponSystem/WeaponSystem.h

    r2261 r2662  
    3636
    3737#include "WeaponSet.h"
     38#include "WeaponPack.h"
    3839
    3940namespace orxonox
    4041{
     42
    4143    class _OrxonoxExport WeaponSystem : public BaseObject
    4244    {
     
    4749            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    4850
     51            void attachWeaponSlot(WeaponSlot *wSlot);
    4952            void attachWeaponSet(WeaponSet *wSet);
    50             void fire();
    51             void fire(unsigned int n);
    52             void setActiveWeaponSet(unsigned int n);
     53            //void fire();
     54            void fire(WeaponMode::Enum fireMode);
     55            //void setActiveWeaponSet(unsigned int n);
     56            void attachWeaponPack(WeaponPack * wPack, unsigned int firemode);
    5357            WeaponSet * getWeaponSetPointer(unsigned int n);
     58            WeaponSlot * getWeaponSlotPointer(unsigned int n);
     59            WeaponPack * getWeaponPackPointer(unsigned int n);
     60            void setNewMunition(std::string munitionType, Munition * munitionToAdd);
     61            Munition * getMunitionType(std::string munitionType);
    5462
    55             inline void setParentSpaceShip(SpaceShip *parentSpaceShip)
    56                 { parentSpaceShip_=parentSpaceShip; }
    57             inline SpaceShip * getParentSpaceShip()
    58                 { return parentSpaceShip_; }
     63            inline void setParentPawn(Pawn *parentPawn)
     64                { parentPawn_=parentPawn; }
     65            inline Pawn * getParentPawn()
     66                { return parentPawn_; }
    5967
     68            inline int getWeaponSlotSize()
     69                { return this->weaponSlots_.size(); }
    6070
    6171        private:
    6272            std::vector<WeaponSet *> weaponSets_;
     73            std::vector<WeaponSlot *> weaponSlots_;
     74            std::vector<WeaponPack *> weaponPacks_;
     75            std::map<std::string, Munition *> munitionSet_;
    6376            WeaponSet *activeWeaponSet_;
    64 
    65             SpaceShip *parentSpaceShip_;
     77            Pawn *parentPawn_;
    6678    };
    6779}
  • code/trunk/src/orxonox/objects/weaponSystem/munitions/LaserGunMunition.cc

    r2097 r2662  
    3737namespace orxonox
    3838{
    39     LaserGunMunition::LaserGunMunition(BaseObject* creator) : BaseObject(creator)
     39    CreateFactory(LaserGunMunition);
     40
     41    LaserGunMunition::LaserGunMunition(BaseObject* creator) : Munition(creator)
    4042    {
    4143        RegisterObject(LaserGunMunition);
     44
     45        this->maxBullets_ = 40;
     46        this->maxMagazines_ = 100;
    4247    }
    4348
  • code/trunk/src/orxonox/objects/weaponSystem/munitions/LaserGunMunition.h

    r2106 r2662  
    3333
    3434#include "core/BaseObject.h"
    35 
     35#include "../Munition.h"
    3636
    3737namespace orxonox
    3838{
    39     class _OrxonoxExport LaserGunMunition : public BaseObject
     39    class _OrxonoxExport LaserGunMunition : public Munition
    4040    {
    4141        public:
     
    4747
    4848        private:
    49             int bullets_;
    50             int magazines_;
    51             int maxBullets_;
    52             int maxMagazines_;
    5349
    5450
  • code/trunk/src/orxonox/objects/weaponSystem/projectiles/BillboardProjectile.cc

    r2099 r2662  
    3030#include "BillboardProjectile.h"
    3131
    32 #include <OgreBillboard.h>
     32#include <OgreBillboardSet.h>
    3333
     34#include "core/Core.h"
    3435#include "core/CoreIncludes.h"
     36#include "objects/Scene.h"
    3537
    3638namespace orxonox
     
    3840    CreateFactory(BillboardProjectile);
    3941
    40     BillboardProjectile::BillboardProjectile(BaseObject* creator, Weapon* owner) : Projectile(creator, owner)
     42    BillboardProjectile::BillboardProjectile(BaseObject* creator) : Projectile(creator)
    4143    {
    4244        RegisterObject(BillboardProjectile);
    4345
    44         this->billboard_.setBillboardSet("Examples/Flare", ColourValue(1.0, 1.0, 0.5), 1);
    45         this->attachObject(this->billboard_.getBillboardSet());
    46         this->scale(0.5);
     46        if (Core::showsGraphics())
     47        {
     48            assert(this->getScene()->getSceneManager()); // getScene() was already checked by WorldEntity
     49            this->billboard_.setBillboardSet(this->getScene()->getSceneManager(), "Examples/Flare", ColourValue(0.5, 0.5, 0.7, 0.8), 1);
     50            this->attachOgreObject(this->billboard_.getBillboardSet());
     51        }
     52
     53        this->setScale(0.2);
    4754    }
    4855
    4956    BillboardProjectile::~BillboardProjectile()
    5057    {
    51         if (this->isInitialized() && this->owner_)
    52             this->detachObject(this->billboard_.getBillboardSet());
     58        if (this->isInitialized() && Core::showsGraphics() && this->billboard_.getBillboardSet())
     59            this->detachOgreObject(this->billboard_.getBillboardSet());
    5360    }
    5461
    5562    void BillboardProjectile::setColour(const ColourValue& colour)
    5663    {
    57         this->billboard_.getBillboardSet()->getBillboard(0)->setColour(colour);
     64        this->billboard_.setColour(colour);
    5865    }
    5966
     
    6168    {
    6269        SUPER(BillboardProjectile, changedVisibility);
     70
    6371        this->billboard_.setVisible(this->isVisible());
    6472    }
  • code/trunk/src/orxonox/objects/weaponSystem/projectiles/BillboardProjectile.h

    r2099 r2662  
    4141    {
    4242        public:
    43             BillboardProjectile(BaseObject* creator, Weapon* owner = 0);
     43            BillboardProjectile(BaseObject* creator);
    4444            virtual ~BillboardProjectile();
    4545
  • code/trunk/src/orxonox/objects/weaponSystem/projectiles/ParticleProjectile.cc

    r2099 r2662  
    3030#include "ParticleProjectile.h"
    3131
    32 #include "SpaceShip.h"
     32#include <OgreParticleSystem.h>
     33#include <OgreParticleEmitter.h>
     34
     35#include "core/Core.h"
    3336#include "core/CoreIncludes.h"
    3437#include "core/ConfigValueIncludes.h"
     38#include "objects/Scene.h"
    3539
    3640namespace orxonox
     
    3842    CreateFactory(ParticleProjectile);
    3943
    40     ParticleProjectile::ParticleProjectile(BaseObject* creator, Weapon* owner) : BillboardProjectile(creator, owner)
     44    ParticleProjectile::ParticleProjectile(BaseObject* creator) : BillboardProjectile(creator)
    4145    {
    4246        RegisterObject(ParticleProjectile);
    4347
    44         this->particles_ = new ParticleInterface("Orxonox/shot2", LODParticle::normal);
    45         this->particles_->addToSceneNode(this->getNode());
    46         this->particles_->setKeepParticlesInLocalSpace(true);
    47         if (this->owner_)
     48        if (Core::showsGraphics())
    4849        {
     50            this->particles_ = new ParticleInterface(this->getScene()->getSceneManager(), "Orxonox/shot3_small", LODParticle::normal);
     51            this->attachOgreObject(this->particles_->getParticleSystem());
     52            this->particles_->setKeepParticlesInLocalSpace(0);
     53
     54            this->particles_->getAllEmitters()->setDirection(-WorldEntity::FRONT);
    4955        }
    50 //        else
    51 //        {
    52 //            this->particles_ = 0;
    53 //        }
    54 
    55         this->setConfigValues();
     56        else
     57            this->particles_ = 0;
    5658    }
    5759
     
    5961    {
    6062        if (this->isInitialized() && this->particles_)
     63        {
     64            this->detachOgreObject(this->particles_->getParticleSystem());
    6165            delete this->particles_;
    62     }
    63 
    64     void ParticleProjectile::setConfigValues()
    65     {
    66         SetConfigValue(speed_, 5000.0).description("The speed of a projectile in units per second").callback((Projectile*)this, &ParticleProjectile::speedChanged);
     66        }
    6767    }
    6868
     
    7070    {
    7171        SUPER(ParticleProjectile, changedVisibility);
    72         this->particles_->setEnabled(this->isVisible());
    73     }
    7472
    75     bool ParticleProjectile::create(){
    76       if(!Projectile::create())
    77         return false;
    78       this->particles_->getAllEmitters()->setDirection(-this->getOrientation()*Vector3(1,0,0));
    79       return true;
     73        if (this->particles_)
     74            this->particles_->setEnabled(this->isVisible());
    8075    }
    8176}
  • code/trunk/src/orxonox/objects/weaponSystem/projectiles/ParticleProjectile.h

    r2099 r2662  
    4141    {
    4242        public:
    43             ParticleProjectile(BaseObject* creator, Weapon* owner = 0);
     43            ParticleProjectile(BaseObject* creator);
    4444            virtual ~ParticleProjectile();
    4545            virtual void changedVisibility();
    46             void setConfigValues();
    47 
    48             virtual bool create();
    4946
    5047        private:
  • code/trunk/src/orxonox/objects/weaponSystem/projectiles/Projectile.cc

    r2100 r2662  
    4040#include "objects/worldentities/Model.h"
    4141#include "objects/worldentities/ParticleSpawner.h"
    42 #include "Settings.h"
     42#include "objects/collisionshapes/SphereCollisionShape.h"
     43#include "core/Core.h"
    4344
    4445namespace orxonox
    4546{
    46     float Projectile::speed_s = 5000;
    47 
    48     Projectile::Projectile(BaseObject* creator, Weapon* owner) : MovableEntity(creator), owner_(owner)
     47    Projectile::Projectile(BaseObject* creator) : MovableEntity(creator)
    4948    {
    5049        RegisterObject(Projectile);
    5150
    5251        this->setConfigValues();
    53         this->explosionTemplateName_ = "Orxonox/explosion3";
    54         this->smokeTemplateName_ = "Orxonox/smoke4";
     52        this->bDestroy_ = false;
     53        this->owner_ = 0;
    5554
    56         this->setStatic(false);
    57         this->translate(Vector3(55, 0, 0), Ogre::Node::TS_LOCAL);
     55        // Get notification about collisions
    5856
    59         if (this->owner_)
     57        if (Core::isMaster())
    6058        {
    61             this->setOrientation(this->owner_->getOrientation());
    62             this->setPosition(this->owner_->getPosition());
    63             this->setVelocity(this->owner_->getInitialDir() * this->speed_);
     59            this->enableCollisionCallback();
     60
     61            this->setCollisionType(Kinematic);
     62
     63            SphereCollisionShape* shape = new SphereCollisionShape(this);
     64            shape->setRadius(10);
     65            this->attachCollisionShape(shape);
     66
     67            this->destroyTimer_.setTimer(this->lifetime_, false, this, createExecutor(createFunctor(&Projectile::destroyObject)));
    6468        }
    65 
    66         if(!orxonox::Settings::isClient()) //only if not on client
    67           this->destroyTimer_.setTimer(this->lifetime_, false, this, createExecutor(createFunctor(&Projectile::destroyObject)));
    6869    }
    6970
     
    7677        SetConfigValue(damage_, 15.0).description("The damage caused by the projectile");
    7778        SetConfigValue(lifetime_, 4.0).description("The time in seconds a projectile stays alive");
    78         SetConfigValue(speed_, 5000.0).description("The speed of a projectile in units per second").callback(this, &Projectile::speedChanged);
    7979    }
    8080
    81     void Projectile::speedChanged()
    82     {
    83         Projectile::speed_s = this->speed_;
    84         if (this->owner_)
    85             this->setVelocity(this->owner_->getInitialDir() * this->speed_);
    86     }
    8781
    8882    void Projectile::tick(float dt)
     
    9387            return;
    9488
    95         float radius;
    96         for (ObjectList<Model>::iterator it = ObjectList<Model>::begin(); it; ++it)
    97         {
    98 //            if ((*it) != this->owner_)
    99             {
    100                 radius = it->getScale3D().x * 3.0;
    101 
    102                 if (this->getPosition().squaredDistance(it->getPosition()) <= (radius*radius))
    103                 {
    104                     // hit
    105                     ParticleSpawner* explosion = new ParticleSpawner(this->explosionTemplateName_, LODParticle::low, 2.0);
    106                     explosion->setPosition(this->getPosition());
    107                     explosion->create();
    108                     ParticleSpawner* smoke = new ParticleSpawner(this->smokeTemplateName_, LODParticle::normal, 2.0, 0.0);
    109                     smoke->setPosition(this->getPosition());
    110 //                    smoke->getParticleInterface()->setSpeedFactor(3.0);
    111                     smoke->create();
    112                     delete this;
    113                     return;
    114                 }
    115             }
    116         }
     89        if (this->bDestroy_)
     90            delete this;
    11791    }
    11892
    11993    void Projectile::destroyObject()
    12094    {
    121         delete this;
     95        if (Core::isMaster())
     96            delete this;
    12297    }
    12398
    124     bool Projectile::create(){
    125       return WorldEntity::create();
     99    bool Projectile::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
     100    {
     101        if (!this->bDestroy_ && Core::isMaster())
     102        {
     103            this->bDestroy_ = true;
     104
     105            if (this->owner_)
     106            {
     107                {
     108                    ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator());
     109                    effect->setPosition(this->getPosition());
     110                    effect->setOrientation(this->getOrientation());
     111                    effect->setDestroyAfterLife(true);
     112                    effect->setSource("Orxonox/explosion3");
     113                    effect->setLifetime(2.0f);
     114                }
     115                {
     116                    ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator());
     117                    effect->setPosition(this->getPosition());
     118                    effect->setOrientation(this->getOrientation());
     119                    effect->setDestroyAfterLife(true);
     120                    effect->setSource("Orxonox/smoke4");
     121                    effect->setLifetime(3.0f);
     122                }
     123            }
     124
     125            Pawn* victim = dynamic_cast<Pawn*>(otherObject);
     126            if (victim)
     127                victim->damage(this->damage_, this->owner_);
     128        }
     129        return false;
     130    }
     131
     132    void Projectile::destroyedPawn(Pawn* pawn)
     133    {
     134        if (this->owner_ == pawn)
     135            this->owner_ = 0;
    126136    }
    127137}
  • code/trunk/src/orxonox/objects/weaponSystem/projectiles/Projectile.h

    r2099 r2662  
    3333
    3434#include "objects/worldentities/MovableEntity.h"
     35#include "objects/worldentities/pawns/Pawn.h"
    3536#include "tools/Timer.h"
    3637
    3738namespace orxonox
    3839{
    39     class _OrxonoxExport Projectile : public MovableEntity
     40    class _OrxonoxExport Projectile : public MovableEntity, public PawnListener
    4041    {
    4142        public:
     43            Projectile(BaseObject* creator);
    4244            virtual ~Projectile();
     45
    4346            void setConfigValues();
    44             void speedChanged();
    4547            void destroyObject();
     48
    4649            virtual void tick(float dt);
     50            virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);
     51            virtual void destroyedPawn(Pawn* pawn);
    4752
    48             virtual bool create();
    49 
    50             static float getSpeed()
    51                 { return Projectile::speed_s; }
    52 
    53         protected:
    54             Projectile(BaseObject* creator, Weapon* owner = 0);
    55             SpaceShip* owner_;
     53            inline void setOwner(Pawn* owner)
     54                { this->owner_ = owner; }
     55            inline Pawn* getOwner() const
     56                { return this->owner_; }
    5657
    5758        private:
    58             std::string explosionTemplateName_;
    59             std::string smokeTemplateName_;
    60         protected:
    61             static float speed_s;
    62             float speed_;
    63         private:
     59            Pawn* owner_;
    6460            float lifetime_;
    6561            float damage_;
     62            bool bDestroy_;
    6663            Timer<Projectile> destroyTimer_;
    6764    };
  • code/trunk/src/orxonox/objects/weaponSystem/weapons/CMakeLists.txt

    r2131 r2662  
    11SET( SRC_FILES
     2  Fusion.cc
    23  LaserGun.cc
    3   Missile.cc
     4#  Missile.cc
    45)
    56
  • code/trunk/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc

    r2097 r2662  
    3434#include "util/Debug.h"
    3535
     36#include "LaserGun.h"
     37
    3638
    3739namespace orxonox
    3840{
     41    CreateFactory(LaserGun);
     42
    3943    LaserGun::LaserGun(BaseObject* creator) : Weapon(creator)
    4044    {
    4145        RegisterObject(LaserGun);
    4246
    43         projectileColor_ = ColourValue(1.0, 1.0, 0.5)
     47        this->speed_ = 1250;
     48
    4449    }
    4550
     
    4853    }
    4954
    50     LaserGun::fire()
     55    void LaserGun::takeBullets()
    5156    {
    52             BillboardProjectile* projectile = new ParticleProjectile(this);
    53             projectile->setColour(this->projectileColor_);
    54             projectile->create();
    55             if (projectile->getClassID() == 0)
    56             {
    57               COUT(3) << "generated projectile with classid 0" <<  std::endl; // TODO: remove this output
    58             }
    59 
    60             projectile->setObjectMode(0x3);
     57//COUT(0) << "LaserGun::takeBullets" << std::endl;
     58        this->munition_->removeBullets(1);
     59        this->bulletTimer(this->bulletLoadingTime_);
    6160    }
    6261
    63     LaserGun::addMunition()
     62    void LaserGun::takeMagazines()
    6463    {
    65         //this->munition_ = ;
     64        this->munition_->removeMagazines(1);
     65        this->magazineTimer(this->magazineLoadingTime_);
    6666    }
    6767
    68     void LaserGun::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     68    void LaserGun::createProjectile()
    6969    {
    70 
    71     }
    72 
    73     ColorValue LaserGun::getProjectileColor()
    74     {
    75         return projectileColor_;
     70//COUT(0) << "LaserGun::createProjectile" << std::endl;
     71        BillboardProjectile* projectile = new ParticleProjectile(this);
     72        projectile->setOrientation(this->getWorldOrientation());
     73        projectile->setPosition(this->getWorldPosition());
     74        projectile->setVelocity(this->getWorldOrientation() * WorldEntity::FRONT * this->speed_);
     75        projectile->setOwner(this->getParentWeaponSystem()->getParentPawn());
    7676    }
    7777}
  • code/trunk/src/orxonox/objects/weaponSystem/weapons/LaserGun.h

    r2106 r2662  
    3434#include "core/BaseObject.h"
    3535
    36 #include "LaserGunMunition.h"
    37 #include "tools/BillboardSet.h"
     36#include "../munitions/LaserGunMunition.h"
    3837#include "util/Math.h"
     38#include "../Weapon.h"
     39#include "../projectiles/BillboardProjectile.h"
     40#include "../projectiles/ParticleProjectile.h"
    3941
    4042namespace orxonox
     
    4648            virtual ~LaserGun();
    4749
    48             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    49 
    50             ColourValue LaserGun::getProjectileColour();
     50            virtual void takeBullets();
     51            virtual void takeMagazines();
     52            virtual void createProjectile();
    5153
    5254        private:
    53             ColorValue projectileColor_;
    54 
    55 
     55            float speed_;
    5656
    5757    };
  • code/trunk/src/orxonox/objects/worldentities/Backlight.cc

    r2261 r2662  
    3030#include "Backlight.h"
    3131
    32 #include <OgreBillboard.h>
    3332#include <OgreRibbonTrail.h>
    3433#include <OgreSceneManager.h>
    3534
     35#include "core/Core.h"
    3636#include "core/CoreIncludes.h"
    37 #include "core/ConfigValueIncludes.h"
    3837#include "core/Executor.h"
    39 #include "util/Math.h"
    40 #include "GraphicsEngine.h"
     38#include "core/XMLPort.h"
     39#include "objects/Scene.h"
     40#include "util/Exception.h"
    4141
    4242namespace orxonox
     
    4444    CreateFactory(Backlight);
    4545
    46     float Backlight::timeFactor_s = 1.0;
    47 
    48     Backlight::Backlight(float maxspeed, float brakingtime, float scale)
     46    Backlight::Backlight(BaseObject* creator) : FadingBillboard(creator)
    4947    {
    5048        RegisterObject(Backlight);
    5149
    52         this->setConfigValues();
    53         this->traillength_ = 1;
    54 
    55         this->configure(maxspeed, brakingtime, scale);
    56     }
    57    
    58     bool Backlight::create(){
    59       if(!WorldEntity::create())
    60         return false;
    61      
    62       this->getNode()->setInheritScale(false);
    63 
    64       this->billboard_.setBillboardSet("Flares/backlightflare");
    65       this->attachObject(this->billboard_.getBillboardSet());
    66 
    67       this->ribbonTrail_ = GraphicsEngine::getInstance().getLevelSceneManager()->createRibbonTrail(this->getName() + "RibbonTrail");
    68       this->ribbonTrailNode_ = GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->createChildSceneNode(this->getName() + "RibbonTrailNode");
    69       this->ribbonTrailNode_->attachObject(this->ribbonTrail_);
    70       this->ribbonTrail_->addNode(this->getNode());
    71 
    72 
    73       this->ribbonTrail_->setTrailLength(this->maxTraillength_);
    74       this->ribbonTrail_->setMaterialName("Trail/backlighttrail");
    75 
    76         //this->setTimeFactor(Orxonox::getInstance().getTimeFactor());
    77       this->setTimeFactor(1.0f);
    78      
    79       this->ribbonTrail_->setMaxChainElements(this->maxTrailsegments_);
    80       this->ribbonTrail_->setTrailLength(this->traillength_ = 2 * this->maxTrailsegments_);
    81       this->ribbonTrail_->setInitialWidth(0, this->width_ * this->getScale());
    82       this->ribbonTrail_->setWidthChange(0, this->width_ * this->getScale() / this->maxLifeTime_ * Backlight::timeFactor_s);
    83       return true;
     50        this->ribbonTrail_ = 0;
     51        this->ribbonTrailNode_ = 0;
     52
     53        this->width_ = 0;
     54        this->length_ = 1.0f;
     55        this->lifetime_ = 0.001f;
     56        this->maxelements_ = 1;
     57
     58        this->tickcount_ = 0;
     59
     60        if (Core::showsGraphics())
     61        {
     62            if (!this->getScene())
     63                ThrowException(AbortLoading, "Can't create Backlight, no scene given.");
     64            if (!this->getScene()->getSceneManager())
     65                ThrowException(AbortLoading, "Can't create Backlight, no scene manager given.");
     66            if (!this->getScene()->getRootSceneNode())
     67                ThrowException(AbortLoading, "Can't create Backlight, no root scene node given.");
     68
     69            this->ribbonTrail_ = this->getScene()->getSceneManager()->createRibbonTrail(this->getNode()->getName());
     70
     71            this->ribbonTrailNode_ = this->getScene()->getRootSceneNode()->createChildSceneNode();
     72            this->ribbonTrailNode_->attachObject(this->ribbonTrail_);
     73
     74            this->ribbonTrail_->setMaxChainElements(this->maxelements_);
     75            this->ribbonTrail_->setTrailLength(this->length_);
     76            this->ribbonTrail_->setInitialWidth(0, 0);
     77        }
     78
     79        this->registerVariables();
    8480    }
    8581
     
    8884        if (this->isInitialized())
    8985        {
    90             this->detachObject(this->billboard_.getBillboardSet());
    91             GraphicsEngine::getInstance().getLevelSceneManager()->destroySceneNode(this->getName() + "RibbonTrailNode");
    92             GraphicsEngine::getInstance().getLevelSceneManager()->destroyRibbonTrail(this->ribbonTrail_);
    93         }
    94     }
    95 
    96     void Backlight::setConfigValues()
    97     {
    98         SetConfigValue(maxLifeTime_, 4.0).description("The maximal amount of seconds the trail behind a SpaceShip stays visible");
    99         SetConfigValue(trailSegmentLength_, 50).description("The length of one segment of the trail behind a SpaceShip (lower values make it more smooth)");
    100         SetConfigValue(width_, 7.0).description("The width of the trail");
    101     }
    102 
    103     void Backlight::setTimeFactor(float factor)
    104     {
    105         Backlight::timeFactor_s = factor;
    106         float change = Backlight::timeFactor_s / this->maxLifeTime_;
    107         this->ribbonTrail_->setWidthChange(0, this->width_ * change);
    108         this->updateColourChange();
    109     }
    110 
    111     void Backlight::updateColourChange()
    112     {
    113         this->ribbonTrail_->setColourChange(0, ColourValue(0, 0, 0, this->maxTraillength_ / this->traillength_ / this->maxLifeTime_ * Backlight::timeFactor_s));
    114     }
    115    
    116    
    117     void Backlight::XMLPort(Element& xmlelement, XMLPort::Mode mode){
    118       SUPER(Backlight, XMLPort, xmlelement, mode);
    119      
    120       Backlight::create();
     86            if (this->ribbonTrail_)
     87            {
     88                if (this->ribbonTrailNode_)
     89                {
     90                    this->ribbonTrailNode_->detachObject(this->ribbonTrail_);
     91                    this->getScene()->getSceneManager()->destroySceneNode(this->ribbonTrailNode_->getName());
     92                }
     93                this->getScene()->getSceneManager()->destroyRibbonTrail(this->ribbonTrail_);
     94            }
     95        }
     96    }
     97
     98    void Backlight::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     99    {
     100        SUPER(Backlight, XMLPort, xmlelement, mode);
     101
     102        XMLPortParam(Backlight, "length",        setLength,        getLength,        xmlelement, mode).defaultValues(100.0f);
     103        XMLPortParam(Backlight, "width",         setWidth,         getWidth,         xmlelement, mode).defaultValues(1.0f);
     104        XMLPortParam(Backlight, "elements",      setMaxElements,   getMaxElements,   xmlelement, mode).defaultValues(10);
     105        XMLPortParam(Backlight, "lifetime",      setLifetime,      getLifetime,      xmlelement, mode).defaultValues(1.0f);
     106        XMLPortParam(Backlight, "trailmaterial", setTrailMaterial, getTrailMaterial, xmlelement, mode);
     107    }
     108
     109    void Backlight::registerVariables()
     110    {
     111        registerVariable(this->width_,         variableDirection::toclient, new NetworkCallback<Backlight>(this, &Backlight::update_width));
     112        registerVariable(this->lifetime_,      variableDirection::toclient, new NetworkCallback<Backlight>(this, &Backlight::update_lifetime));
     113        registerVariable(this->length_,        variableDirection::toclient, new NetworkCallback<Backlight>(this, &Backlight::update_length));
     114        registerVariable(this->maxelements_,   variableDirection::toclient, new NetworkCallback<Backlight>(this, &Backlight::update_maxelements));
     115        registerVariable(this->trailmaterial_, variableDirection::toclient, new NetworkCallback<Backlight>(this, &Backlight::update_trailmaterial));
     116    }
     117
     118    void Backlight::changedColour()
     119    {
     120        FadingBillboard::changedColour();
     121
     122        if (this->ribbonTrail_ && this->tickcount_ >= 2)
     123            this->ribbonTrail_->setInitialColour(0, this->getFadedColour());
     124    }
     125
     126    void Backlight::update_width()
     127    {
     128        if (this->ribbonTrail_ && this->tickcount_ >= 2)
     129            this->ribbonTrail_->setInitialWidth(0, this->width_ * this->getWorldScale());
     130        this->update_lifetime();
     131    }
     132
     133    void Backlight::update_lifetime()
     134    {
     135        if (this->ribbonTrail_ && this->tickcount_ >= 2)
     136        {
     137            this->ribbonTrail_->setWidthChange(0, this->width_ * this->getWorldScale() / this->lifetime_ * this->getTimeFactor());
     138            this->ribbonTrail_->setColourChange(0, 0, 0, 0, 1.0f / this->lifetime_ * this->getTimeFactor());
     139        }
     140    }
     141
     142    void Backlight::update_length()
     143    {
     144        if (this->ribbonTrail_ && this->tickcount_ >= 2)
     145            this->ribbonTrail_->setTrailLength(this->length_ * this->getWorldScale());
     146    }
     147
     148    void Backlight::update_maxelements()
     149    {
     150        if (this->ribbonTrail_ && this->tickcount_ >= 2)
     151            this->ribbonTrail_->setMaxChainElements(this->maxelements_);
     152    }
     153
     154    void Backlight::update_trailmaterial()
     155    {
     156        if (this->ribbonTrail_ && this->tickcount_ >= 2)
     157            this->ribbonTrail_->setMaterialName(this->trailmaterial_);
     158    }
     159
     160    void Backlight::changedVisibility()
     161    {
     162        SUPER(Backlight, changedVisibility);
     163
     164        if (this->ribbonTrail_)
     165            this->ribbonTrail_->setVisible(this->isVisible());
     166    }
     167
     168    void Backlight::startturnonoff()
     169    {
     170        FadingBillboard::startturnonoff();
     171
     172        if (this->ribbonTrail_ && this->isActive() && this->isVisible())
     173            this->ribbonTrail_->setVisible(true);
     174    }
     175
     176    void Backlight::stopturnonoff()
     177    {
     178        this->postprocessingtime_ = max(0.0f, this->lifetime_ - this->turnofftime_);
     179
     180        FadingBillboard::stopturnonoff();
     181
     182        if (this->ribbonTrail_)
     183            this->ribbonTrail_->setInitialColour(0, this->getFadedColour());
     184    }
     185
     186    void Backlight::poststopturnonoff()
     187    {
     188        FadingBillboard::poststopturnonoff();
     189
     190        if (this->ribbonTrail_)
     191            this->ribbonTrail_->setVisible(false);
     192    }
     193
     194    void Backlight::changedScale()
     195    {
     196        SUPER(Backlight, changedScale);
     197
     198        this->update_width();
     199        this->update_length();
    121200    }
    122201
    123202    void Backlight::tick(float dt)
    124203    {
     204        if (this->tickcount_ < 2)
     205        {
     206            ++this->tickcount_;
     207            if (this->tickcount_ == 2)
     208            {
     209                this->changedColour();
     210                this->update_width();
     211                this->update_lifetime();
     212                this->update_length();
     213                this->update_maxelements();
     214                this->update_trailmaterial();
     215                if (this->ribbonTrail_)
     216                    this->ribbonTrail_->addNode(this->node_);
     217            }
     218        }
     219
    125220        SUPER(Backlight, tick, dt);
    126221
    127         if (this->isActive())
    128         {
    129             if (this->traillength_ < this->maxTraillength_)
    130             {
    131                 this->traillength_ = min<float>(this->maxTraillength_, this->traillength_ + dt * this->maxTraillength_ / this->maxLifeTime_);
    132                 this->updateColourChange();
    133             }
    134         }
    135         else
    136         {
    137             if (this->traillength_ > 1)
    138             {
    139                 this->traillength_ = max<float>(1, this->traillength_ - this->brakefactor_ * dt * this->maxTraillength_ / this->maxLifeTime_);
    140                 this->updateColourChange();
    141             }
    142         }
    143 
    144         this->ribbonTrail_->setTrailLength(this->traillength_);
    145     }
    146 
    147     void Backlight::setColour(const ColourValue& colour)
    148     {
    149         this->billboard_.getBillboardSet()->getBillboard(0)->setColour(colour);
    150         this->ribbonTrail_->setInitialColour(0, ColourValue(colour.r / 4 + 0.75, colour.g / 4 + 0.75, colour.b / 4 + 0.75));
    151     }
    152 
    153     void Backlight::configure(float maxspeed, float brakingtime, float scale)
    154     {
    155         this->maxTraillength_ = this->maxLifeTime_ * maxspeed;
    156         this->maxTrailsegments_ = (size_t)(this->maxTraillength_ / this->trailSegmentLength_);
    157 
    158         this->brakefactor_ = this->maxLifeTime_ / brakingtime;
    159 
    160         this->scale(scale);
    161     }
    162 
    163     void Backlight::changedVisibility()
    164     {
    165         SUPER(Backlight, changedVisibility);
    166 
    167         this->billboard_.setVisible(this->isVisible());
    168         this->ribbonTrail_->setVisible(this->isVisible());
     222        if (this->ribbonTrail_ && this->changedirection_ != 0)
     223        {
     224            // we use alpha_blend, only adjust alpha
     225            const ColourValue& colour = this->getColour();
     226            this->ribbonTrail_->setInitialColour(0, colour.r, colour.g, colour.b, this->getFadedColour().a);
     227        }
     228    }
     229
     230    void Backlight::changedTimeFactor(float factor_new, float factor_old)
     231    {
     232        this->update_lifetime();
    169233    }
    170234}
  • code/trunk/src/orxonox/objects/worldentities/Backlight.h

    r2261 r2662  
    3131
    3232#include "OrxonoxPrereqs.h"
    33 
    34 #include "PositionableEntity.h"
    35 #include "tools/BillboardSet.h"
     33#include "FadingBillboard.h"
     34#include "gamestates/GSRoot.h"
    3635
    3736namespace orxonox
    3837{
    39     class _OrxonoxExport Backlight : public PositionableEntity
     38    class _OrxonoxExport Backlight : public FadingBillboard, public TimeFactorListener
    4039    {
    4140        public:
    42             Backlight(float maxspeed = 1.0, float brakingtime = 1.0, float scale = 1.0);
     41            Backlight(BaseObject* creator);
    4342            virtual ~Backlight();
    4443
    45             void setConfigValues();
    4644            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     45            void registerVariables();
     46
    4747            virtual void tick(float dt);
    4848            virtual void changedVisibility();
    49             virtual bool create();
    5049
    51             void setColour(const ColourValue& colour);
    52             void setTimeFactor(float factor);
     50            inline void setWidth(float width)
     51                { this->width_ = width; this->update_width(); }
     52            inline float getWidth() const
     53                { return this->width_; }
     54
     55            inline void setLifetime(float lifetime)
     56                { this->lifetime_ = lifetime; this->update_lifetime(); }
     57            inline float getLifetime() const
     58                { return this->lifetime_; }
     59
     60            inline void setLength(float length)
     61                { this->length_ = length; this->update_length(); }
     62            inline float getLength() const
     63                { return this->length_; }
     64
     65            inline void setMaxElements(size_t maxelements)
     66                { this->maxelements_ = maxelements; this->update_maxelements(); }
     67            inline size_t getMaxElements() const
     68                { return this->maxelements_; }
     69
     70            inline void setTrailMaterial(const std::string& material)
     71                { this->trailmaterial_ = material; this->update_trailmaterial(); }
     72            inline const std::string& getTrailMaterial() const
     73                { return this->trailmaterial_; }
     74
     75            virtual void changedScale();
     76
     77        protected:
     78            virtual void changedTimeFactor(float factor_new, float factor_old);
    5379
    5480        private:
    55             void configure(float maxspeed, float brakingtime, float scale = 1);
    56             void updateColourChange();
     81            virtual void startturnonoff();
     82            virtual void stopturnonoff();
     83            virtual void poststopturnonoff();
     84            virtual void changedColour();
     85            void update_width();
     86            void update_lifetime();
     87            void update_length();
     88            void update_maxelements();
     89            void update_trailmaterial();
    5790
    58             static float timeFactor_s;
    59             BillboardSet billboard_;
     91            Ogre::RibbonTrail* ribbonTrail_;
    6092            Ogre::SceneNode* ribbonTrailNode_;
    61             Ogre::RibbonTrail* ribbonTrail_;
    62 
    63             float maxLifeTime_;
    64             float trailSegmentLength_;
    6593            float width_;
    66 
    67             float brakefactor_;
    68 
    69             float maxTraillength_;
    70             float traillength_;
    71 
    72             size_t maxTrailsegments_;
     94            float length_;
     95            float lifetime_;
     96            size_t maxelements_;
     97            std::string trailmaterial_;
     98            char tickcount_;
    7399    };
    74100}
  • code/trunk/src/orxonox/objects/worldentities/Billboard.cc

    r2171 r2662  
    3030#include "Billboard.h"
    3131
     32#include <OgreBillboardSet.h>
     33
    3234#include "core/CoreIncludes.h"
    3335#include "core/XMLPort.h"
     36#include "core/Core.h"
    3437#include "objects/Scene.h"
    3538
     
    3841    CreateFactory(Billboard);
    3942
    40     Billboard::Billboard(BaseObject* creator) : PositionableEntity(creator)
     43    Billboard::Billboard(BaseObject* creator) : StaticEntity(creator)
    4144    {
    4245        RegisterObject(Billboard);
     46
     47        this->material_ = "";
     48        this->colour_ = ColourValue::White;
    4349
    4450        this->registerVariables();
     
    5056        {
    5157            if (this->isInitialized() && this->billboard_.getBillboardSet())
    52                 this->getNode()->detachObject(this->billboard_.getName());
     58                this->detachOgreObject(this->billboard_.getBillboardSet());
    5359        }
    5460    }
     
    6470    void Billboard::registerVariables()
    6571    {
    66         REGISTERSTRING(this->material_, direction::toclient, new NetworkCallback<Billboard>(this, &Billboard::changedMaterial));
    67         REGISTERDATA  (this->colour_,   direction::toclient, new NetworkCallback<Billboard>(this, &Billboard::changedColour));
     72        registerVariable(this->material_, variableDirection::toclient, new NetworkCallback<Billboard>(this, &Billboard::changedMaterial));
     73        registerVariable(this->colour_,   variableDirection::toclient, new NetworkCallback<Billboard>(this, &Billboard::changedColour));
    6874    }
    6975
    7076    void Billboard::changedMaterial()
    7177    {
     78        if (this->material_ == "")
     79            return;
     80
    7281        if (!this->billboard_.getBillboardSet())
    7382        {
    74             if (this->getScene() && this->getScene()->getSceneManager())
     83            if (this->getScene() && Core::showsGraphics())
    7584            {
    7685                this->billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->material_, this->colour_, 1);
    7786                if (this->billboard_.getBillboardSet())
    78                     this->getNode()->attachObject(this->billboard_.getBillboardSet());
     87                     this->attachOgreObject(this->billboard_.getBillboardSet());
    7988                this->billboard_.setVisible(this->isVisible());
    8089            }
     
    8897        if (!this->billboard_.getBillboardSet())
    8998        {
    90             if (this->getScene() && this->getScene()->getSceneManager())
     99/*
     100            if (this->getScene() && Core::showsGraphics() && (this->material_ != ""))
    91101            {
    92102                this->billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->material_, this->colour_, 1);
    93103                if (this->billboard_.getBillboardSet())
    94                     this->getNode()->attachObject(this->billboard_.getBillboardSet());
     104                    this->attachOgreObject(this->billboard_.getBillboardSet());
    95105                this->billboard_.setVisible(this->isVisible());
    96106            }
     107*/
    97108        }
    98109        else
  • code/trunk/src/orxonox/objects/worldentities/Billboard.h

    r2087 r2662  
    3131
    3232#include "OrxonoxPrereqs.h"
    33 #include "PositionableEntity.h"
     33#include "StaticEntity.h"
    3434#include "util/Math.h"
    3535#include "tools/BillboardSet.h"
     
    3737namespace orxonox
    3838{
    39     class _OrxonoxExport Billboard : public PositionableEntity
     39    class _OrxonoxExport Billboard : public StaticEntity
    4040    {
    4141        public:
     
    6161                { return this->colour_; }
    6262
     63        protected:
     64            inline BillboardSet& getBillboardSet()
     65                { return this->billboard_; }
     66
     67            virtual void changedColour();
     68
    6369        private:
    6470            void changedMaterial();
    65             void changedColour();
    6671
    6772            BillboardSet billboard_;
  • code/trunk/src/orxonox/objects/worldentities/BlinkingBillboard.cc

    r2171 r2662  
    6868    void BlinkingBillboard::registerVariables()
    6969    {
    70 //        REGISTERDATA(this->amplitude_, direction::toclient);
    71 //        REGISTERDATA(this->frequency_, direction::toclient);
    72 //        REGISTERDATA(this->phase_,     direction::toclient);
     70//        registerVariable(this->amplitude_, variableDirection::toclient);
     71//        registerVariable(this->frequency_, variableDirection::toclient);
     72//        registerVariable(this->phase_,     variableDirection::toclient);
    7373    }
    7474
    7575    void BlinkingBillboard::tick(float dt)
    7676    {
     77        SUPER(BlinkingBillboard, tick, dt);
     78
    7779        if (Core::isMaster() && this->isActive())
    7880        {
  • code/trunk/src/orxonox/objects/worldentities/CMakeLists.txt

    r2131 r2662  
    11SET( SRC_FILES
    22  WorldEntity.cc
    3   PositionableEntity.cc
     3  StaticEntity.cc
    44  MovableEntity.cc
     5  MobileEntity.cc
    56  ControllableEntity.cc
    6   Model.cc
     7
     8  Backlight.cc
    79  Billboard.cc
    810  BlinkingBillboard.cc
     11  ExplosionChunk.cc
     12  FadingBillboard.cc
    913  Light.cc
    1014  Camera.cc
    1115  CameraPosition.cc
    12   SpawnPoint.cc
     16  Model.cc
    1317  ParticleEmitter.cc
    1418  ParticleSpawner.cc
    15 #  Backlight.cc
     19  Planet.cc
     20  SpawnPoint.cc
    1621)
    1722
  • code/trunk/src/orxonox/objects/worldentities/Camera.cc

    r2261 r2662  
    3636#include <OgreSceneManager.h>
    3737#include <OgreSceneNode.h>
    38 #include <OgreViewport.h>
    3938
    4039#include "util/Exception.h"
     
    4847    CreateFactory(Camera);
    4948
    50     Camera::Camera(BaseObject* creator) : PositionableEntity(creator)
     49    Camera::Camera(BaseObject* creator) : StaticEntity(creator)
    5150    {
    5251        RegisterObject(Camera);
    5352
    54         if (!this->getScene() || !this->getScene()->getSceneManager())
    55             ThrowException(AbortLoading, "Can't create Camera, no scene or no scene manager given.");
     53        if (!this->getScene())
     54            ThrowException(AbortLoading, "Can't create Camera, no scene.");
     55        if (!this->getScene()->getSceneManager())
     56            ThrowException(AbortLoading, "Can't create Camera, no scene-manager given.");
     57        if (!this->getScene()->getRootSceneNode())
     58            ThrowException(AbortLoading, "Can't create Camera, no root-scene-node given.");
    5659
    5760        this->camera_ = this->getScene()->getSceneManager()->createCamera(getUniqueNumberString());
    58         this->getNode()->attachObject(this->camera_);
     61        this->cameraNode_ = this->getScene()->getRootSceneNode()->createChildSceneNode();
     62        this->attachNode(this->cameraNode_);
     63        this->cameraNode_->attachObject(this->camera_);
    5964
    6065        this->bHasFocus_ = false;
     
    6671        this->setConfigValues();
    6772        this->configvaluecallback_changedNearClipDistance();
    68 
    69         this->requestFocus(); // ! HACK ! REMOVE THIS !
    7073    }
    7174
     
    7578        {
    7679            this->releaseFocus();
     80
     81            this->cameraNode_->detachAllObjects();
     82            this->getScene()->getSceneManager()->destroyCamera(this->camera_);
     83
     84            if (this->bDrag_)
     85                this->detachNode(this->cameraNode_);
     86
     87            if (this->getScene()->getSceneManager())
     88                this->getScene()->getSceneManager()->destroySceneNode(this->cameraNode_->getName());
    7789        }
    7890    }
     
    90102    void Camera::tick(float dt)
    91103    {
    92 /*
    93         // this stuff here may need some adjustments
    94         float coeff = (this->bDrag_) ? min(1.0f, 15.0f * dt) : (1.0f);
     104        SUPER(Camera, tick, dt);
    95105
    96         Vector3 offset = this->getNode()->getWorldPosition() - this->cameraNode_->getWorldPosition();
    97         this->cameraNode_->translate(coeff * offset);
     106        if (this->bDrag_)
     107        {
     108            // this stuff here may need some adjustments
     109            float coeff = min(1.0f, 15.0f * dt);
    98110
    99         this->cameraNode_->setOrientation(Quaternion::Slerp(coeff, this->cameraNode_->getWorldOrientation(), this->getWorldOrientation(), false));
    100 */
     111            Vector3 offset = this->getWorldPosition() - this->cameraNode_->getWorldPosition();
     112            this->cameraNode_->translate(coeff * offset);
     113
     114            this->cameraNode_->setOrientation(Quaternion::Slerp(coeff, this->cameraNode_->getWorldOrientation(), this->getWorldOrientation(), true));
     115            //this->cameraNode_->setOrientation(this->getWorldOrientation());
     116        }
    101117    }
    102118
     
    120136    }
    121137
    122     void Camera::setFocus(Ogre::Viewport* viewport)
     138    void Camera::setFocus()
    123139    {
    124140        this->bHasFocus_ = true;
    125         viewport->setCamera(this->camera_);
     141        CameraManager::getInstance().useCamera(this->camera_);
     142    }
     143
     144    void Camera::setDrag(bool bDrag)
     145    {
     146        if (bDrag != this->bDrag_)
     147        {
     148            this->bDrag_ = bDrag;
     149
     150            if (!bDrag)
     151            {
     152                this->attachNode(this->cameraNode_);
     153                this->cameraNode_->setPosition(Vector3::ZERO);
     154                this->cameraNode_->setOrientation(Quaternion::IDENTITY);
     155            }
     156            else
     157            {
     158                this->detachNode(this->cameraNode_);
     159                this->cameraNode_->setPosition(this->getWorldPosition());
     160                this->cameraNode_->setOrientation(this->getWorldOrientation());
     161            }
     162        }
    126163    }
    127164}
  • code/trunk/src/orxonox/objects/worldentities/Camera.h

    r2261 r2662  
    3333
    3434#include <OgrePrerequisites.h>
    35 #include "objects/worldentities/PositionableEntity.h"
     35#include "objects/worldentities/StaticEntity.h"
    3636#include "objects/Tickable.h"
    3737
    3838namespace orxonox
    3939{
    40     class _OrxonoxExport Camera : public PositionableEntity, public Tickable
     40    class _OrxonoxExport Camera : public StaticEntity, public Tickable
    4141    {
    4242        friend class CameraManager;
     
    5555                { return this->bHasFocus_; }
    5656
    57             inline void setDrag(bool bDrag)
    58                 { this->bDrag_ = bDrag; }
     57            void setDrag(bool bDrag);
    5958            inline bool getDrag() const
    6059                { return this->bDrag_; }
     
    6261        private:
    6362            void removeFocus();
    64             void setFocus(Ogre::Viewport* viewport);
     63            void setFocus();
    6564            void configvaluecallback_changedNearClipDistance();
    6665
    67             Ogre::Camera*   camera_;
    68             float           nearClipDistance_;
    69             bool            bHasFocus_;
    70             bool            bDrag_;
     66            Ogre::Camera*    camera_;
     67            Ogre::SceneNode* cameraNode_;
     68            float            nearClipDistance_;
     69            bool             bHasFocus_;
     70            bool             bDrag_;
    7171    };
    7272}
  • code/trunk/src/orxonox/objects/worldentities/CameraPosition.cc

    r2087 r2662  
    3838    CreateFactory(CameraPosition);
    3939
    40     CameraPosition::CameraPosition(BaseObject* creator) : PositionableEntity(creator)
     40    CameraPosition::CameraPosition(BaseObject* creator) : StaticEntity(creator)
    4141    {
    4242        RegisterObject(CameraPosition);
    4343
    4444        this->bDrag_ = false;
     45        this->bAllowMouseLook_ = false;
    4546
    4647        this->setObjectMode(0x0);
     
    5657
    5758        XMLPortParam(CameraPosition, "drag", setDrag, getDrag, xmlelement, mode).defaultValues(false);
     59        XMLPortParam(CameraPosition, "mouselook", setAllowMouseLook, getAllowMouseLook, xmlelement, mode).defaultValues(false);
    5860    }
    5961
    6062    void CameraPosition::attachCamera(Camera* camera)
    6163    {
    62         camera->setDrag(this->bDrag_);
     64        if (!this->bDrag_)
     65            camera->setDrag(false);
     66
    6367        this->attach(camera);
     68
     69        if (this->bDrag_)
     70            camera->setDrag(true);
    6471    }
    6572}
  • code/trunk/src/orxonox/objects/worldentities/CameraPosition.h

    r2087 r2662  
    3232#include "OrxonoxPrereqs.h"
    3333
    34 #include "objects/worldentities/PositionableEntity.h"
     34#include "objects/worldentities/StaticEntity.h"
    3535
    3636namespace orxonox
    3737{
    38     class _OrxonoxExport CameraPosition : public PositionableEntity
     38    class _OrxonoxExport CameraPosition : public StaticEntity
    3939    {
    4040        public:
     
    4949                { return this->bDrag_; }
    5050
     51            inline void setAllowMouseLook(bool bAllow)
     52                { this->bAllowMouseLook_ = bAllow; }
     53            inline bool getAllowMouseLook() const
     54                { return this->bAllowMouseLook_; }
     55
    5156            void attachCamera(Camera* camera);
    5257
    5358        private:
    5459            bool bDrag_;
     60            bool bAllowMouseLook_;
    5561    };
    5662}
  • code/trunk/src/orxonox/objects/worldentities/ControllableEntity.cc

    r2171 r2662  
    2323 *      Fabian 'x3n' Landau
    2424 *   Co-authors:
    25  *      ...
     25 *      Reto Grieder
    2626 *
    2727 */
     
    3030#include "ControllableEntity.h"
    3131
     32#include <OgreSceneManager.h>
     33
    3234#include "core/CoreIncludes.h"
     35#include "core/ConfigValueIncludes.h"
    3336#include "core/Core.h"
    3437#include "core/XMLPort.h"
    3538#include "core/Template.h"
    3639
     40#include "objects/Scene.h"
    3741#include "objects/infos/PlayerInfo.h"
    3842#include "objects/worldentities/Camera.h"
    3943#include "objects/worldentities/CameraPosition.h"
     44#include "objects/gametypes/Gametype.h"
    4045#include "overlays/OverlayGroup.h"
    4146
     
    4449    CreateFactory(ControllableEntity);
    4550
    46     ControllableEntity::ControllableEntity(BaseObject* creator) : WorldEntity(creator)
     51    ControllableEntity::ControllableEntity(BaseObject* creator) : MobileEntity(creator)
    4752    {
    4853        RegisterObject(ControllableEntity);
    4954
    50         this->bControlled_ = false;
     55        this->bHasLocalController_ = false;
     56        this->bHasHumanController_ = false;
     57
    5158        this->server_overwrite_ = 0;
    5259        this->client_overwrite_ = 0;
     
    5663        this->camera_ = 0;
    5764        this->bDestroyWhenPlayerLeft_ = false;
    58 
    59         this->velocity_ = Vector3::ZERO;
    60         this->acceleration_ = Vector3::ZERO;
    61 
    62         this->server_position_ = Vector3::ZERO;
    63         this->client_position_ = Vector3::ZERO;
    64         this->server_velocity_ = Vector3::ZERO;
    65         this->client_velocity_ = Vector3::ZERO;
    66         this->server_orientation_ = Quaternion::IDENTITY;
    67         this->client_orientation_ = Quaternion::IDENTITY;
    68 
     65        this->cameraPositionRootNode_ = this->node_->createChildSceneNode();
     66        this->bMouseLook_ = false;
     67        this->mouseLookSpeed_ = 200;
     68
     69        this->gtinfo_ = 0;
     70        this->gtinfoID_ = OBJECTID_UNKNOWN;
     71        this->changedGametype();
     72
     73        this->server_position_         = Vector3::ZERO;
     74        this->client_position_         = Vector3::ZERO;
     75        this->server_linear_velocity_  = Vector3::ZERO;
     76        this->client_linear_velocity_  = Vector3::ZERO;
     77        this->server_orientation_      = Quaternion::IDENTITY;
     78        this->client_orientation_      = Quaternion::IDENTITY;
     79        this->server_angular_velocity_ = Vector3::ZERO;
     80        this->client_angular_velocity_ = Vector3::ZERO;
     81
     82
     83        this->setConfigValues();
     84        this->setPriority( priority::very_high );
    6985        this->registerVariables();
    7086    }
     
    7490        if (this->isInitialized())
    7591        {
    76             if (this->bControlled_)
    77                 this->stopLocalControl();
     92            this->bDestroyWhenPlayerLeft_ = false;
     93
     94            if (this->bHasLocalController_ && this->bHasHumanController_)
     95                this->stopLocalHumanControl();
     96
     97            if (this->getPlayer() && this->getPlayer()->getControllableEntity() == this)
     98                this->getPlayer()->stopControl(this, false);
    7899
    79100            if (this->hud_)
     
    83104                delete this->camera_;
    84105
    85             if (this->getPlayer() && this->getPlayer()->getControllableEntity() == this)
    86                 this->getPlayer()->stopControl(this, false);
     106            for (std::list<CameraPosition*>::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)
     107                delete (*it);
     108
     109            if (this->getScene()->getSceneManager())
     110                this->getScene()->getSceneManager()->destroySceneNode(this->cameraPositionRootNode_->getName());
    87111        }
    88112    }
     
    98122    }
    99123
     124    void ControllableEntity::setConfigValues()
     125    {
     126        SetConfigValue(mouseLookSpeed_, 3.0f);
     127    }
     128
     129    void ControllableEntity::changedGametype()
     130    {
     131        //SUPER(ControllableEntity, changedGametype);
     132        WorldEntity::changedGametype();
     133
     134        this->gtinfo_ = 0;
     135        this->gtinfoID_ = OBJECTID_UNKNOWN;
     136
     137        if (this->getGametype() && this->getGametype()->getGametypeInfo())
     138        {
     139            this->gtinfo_ = this->getGametype()->getGametypeInfo();
     140            this->gtinfoID_ = this->gtinfo_->getObjectID();
     141        }
     142    }
     143
    100144    void ControllableEntity::addCameraPosition(CameraPosition* position)
    101145    {
    102         this->attach(position);
     146        if (position->getAllowMouseLook())
     147            position->attachToNode(this->cameraPositionRootNode_);
     148        else
     149            this->attach(position);
    103150        this->cameraPositions_.push_back(position);
    104151    }
     
    141188            else
    142189            {
    143                 this->attach(this->camera_);
     190                this->camera_->attachToNode(this->cameraPositionRootNode_);
    144191            }
    145192        }
     193    }
     194
     195    void ControllableEntity::mouseLook()
     196    {
     197        this->bMouseLook_ = !this->bMouseLook_;
     198
     199        if (!this->bMouseLook_)
     200            this->cameraPositionRootNode_->setOrientation(Quaternion::IDENTITY);
     201    }
     202
     203    void ControllableEntity::rotateYaw(const Vector2& value)
     204    {
     205        if (this->bMouseLook_)
     206            this->cameraPositionRootNode_->yaw(Radian(value.y * this->mouseLookSpeed_), Ogre::Node::TS_LOCAL);
     207    }
     208
     209    void ControllableEntity::rotatePitch(const Vector2& value)
     210    {
     211        if (this->bMouseLook_)
     212            this->cameraPositionRootNode_->pitch(Radian(value.y * this->mouseLookSpeed_), Ogre::Node::TS_LOCAL);
     213    }
     214
     215    void ControllableEntity::rotateRoll(const Vector2& value)
     216    {
     217        if (this->bMouseLook_)
     218            this->cameraPositionRootNode_->roll(Radian(value.y * this->mouseLookSpeed_), Ogre::Node::TS_LOCAL);
    146219    }
    147220
     
    156229        this->player_ = player;
    157230        this->playerID_ = player->getObjectID();
    158         this->bControlled_ = (player->isLocalPlayer() && player->isHumanPlayer());
    159         if (this->bControlled_)
    160         {
    161             this->startLocalControl();
     231        this->bHasLocalController_ = player->isLocalPlayer();
     232        this->bHasHumanController_ = player->isHumanPlayer();
     233
     234        if (this->bHasLocalController_ && this->bHasHumanController_)
     235        {
     236            this->startLocalHumanControl();
    162237
    163238            if (!Core::isMaster())
    164239            {
    165240                this->client_overwrite_ = this->server_overwrite_;
    166 COUT(0) << "CE: bidirectional synchronization" << std::endl;
    167                 this->setObjectMode(direction::bidirectional);
     241                this->setObjectMode(objectDirection::bidirectional);
    168242            }
    169243        }
     
    172246    void ControllableEntity::removePlayer()
    173247    {
    174         if (this->bControlled_)
    175             this->stopLocalControl();
     248        if (this->bHasLocalController_ && this->bHasHumanController_)
     249            this->stopLocalHumanControl();
    176250
    177251        this->player_ = 0;
    178252        this->playerID_ = OBJECTID_UNKNOWN;
    179         this->bControlled_ = false;
    180         this->setObjectMode(direction::toclient);
     253        this->bHasLocalController_ = false;
     254        this->bHasHumanController_ = false;
     255        this->setObjectMode(objectDirection::toclient);
    181256
    182257        if (this->bDestroyWhenPlayerLeft_)
     
    195270    }
    196271
    197     void ControllableEntity::startLocalControl()
    198     {
    199 //        std::cout << this->getObjectID() << " ###### start local control" << std::endl;
    200         this->camera_ = new Camera(this);
    201         this->camera_->requestFocus();
    202         if (this->cameraPositionTemplate_ != "")
    203             this->addTemplate(this->cameraPositionTemplate_);
    204         if (this->cameraPositions_.size() > 0)
    205             this->cameraPositions_.front()->attachCamera(this->camera_);
    206         else
    207             this->attach(this->camera_);
    208 
    209         if (this->hudtemplate_ != "")
    210         {
    211             this->hud_ = new OverlayGroup(this);
    212             this->hud_->addTemplate(this->hudtemplate_);
    213         }
    214     }
    215 
    216     void ControllableEntity::stopLocalControl()
    217     {
    218 //        std::cout << "###### stop local control" << std::endl;
    219         this->camera_->detachFromParent();
    220         delete this->camera_;
    221         this->camera_ = 0;
    222 
    223         delete this->hud_;
    224         this->hud_ = 0;
     272    void ControllableEntity::networkcallback_changedgtinfoID()
     273    {
     274        if (this->gtinfoID_ != OBJECTID_UNKNOWN)
     275        {
     276            this->gtinfo_ = dynamic_cast<GametypeInfo*>(Synchronisable::getSynchronisable(this->gtinfoID_));
     277
     278            if (!this->gtinfo_)
     279                this->gtinfoID_ = OBJECTID_UNKNOWN;
     280        }
     281    }
     282
     283    void ControllableEntity::startLocalHumanControl()
     284    {
     285        if (!this->camera_)
     286        {
     287            this->camera_ = new Camera(this);
     288            this->camera_->requestFocus();
     289            if (this->cameraPositionTemplate_ != "")
     290                this->addTemplate(this->cameraPositionTemplate_);
     291            if (this->cameraPositions_.size() > 0)
     292                this->cameraPositions_.front()->attachCamera(this->camera_);
     293            else
     294                this->camera_->attachToNode(this->cameraPositionRootNode_);
     295        }
     296
     297        if (!this->hud_)
     298        {
     299            if (this->hudtemplate_ != "")
     300            {
     301                this->hud_ = new OverlayGroup(this);
     302                this->hud_->addTemplate(this->hudtemplate_);
     303                this->hud_->setOwner(this);
     304            }
     305        }
     306    }
     307
     308    void ControllableEntity::stopLocalHumanControl()
     309    {
     310        if (this->camera_)
     311        {
     312            this->camera_->detachFromParent();
     313            delete this->camera_;
     314            this->camera_ = 0;
     315        }
     316
     317        if (this->hud_)
     318        {
     319            delete this->hud_;
     320            this->hud_ = 0;
     321        }
    225322    }
    226323
    227324    void ControllableEntity::tick(float dt)
    228325    {
     326        MobileEntity::tick(dt);
     327
    229328        if (this->isActive())
    230329        {
    231             this->velocity_ += (dt * this->acceleration_);
    232             this->node_->translate(dt * this->velocity_, Ogre::Node::TS_LOCAL);
    233 
    234             if (Core::isMaster())
     330            // Check whether Bullet doesn't do the physics for us
     331            if (!this->isDynamic())
    235332            {
    236                 this->server_velocity_ = this->velocity_;
    237                 this->server_position_ = this->node_->getPosition();
     333                if (Core::isMaster())
     334                {
     335                    this->server_position_ = this->getPosition();
     336                    this->server_orientation_ = this->getOrientation();
     337                    this->server_linear_velocity_ = this->getVelocity();
     338                    this->server_angular_velocity_ = this->getAngularVelocity();
     339                }
     340                else if (this->bHasLocalController_)
     341                {
     342                    this->client_position_ = this->getPosition();
     343                    this->client_orientation_ = this->getOrientation();
     344                    this->client_linear_velocity_ = this->getVelocity();
     345                    this->client_angular_velocity_ = this->getAngularVelocity();
     346                }
    238347            }
    239             else if (this->bControlled_)
    240             {
    241 //                COUT(2) << "setting client position" << endl;
    242                 this->client_velocity_ = this->velocity_;
    243                 this->client_position_ = this->node_->getPosition();
    244             }
    245348        }
    246349    }
     
    248351    void ControllableEntity::registerVariables()
    249352    {
    250         REGISTERSTRING(this->cameraPositionTemplate_, direction::toclient);
    251 
    252         REGISTERDATA(this->client_overwrite_,   direction::toserver);
    253        
    254         REGISTERDATA(this->server_position_,    direction::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerPosition));
    255         REGISTERDATA(this->server_velocity_,    direction::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerVelocity));
    256         REGISTERDATA(this->server_orientation_, direction::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerOrientation));
    257         REGISTERDATA(this->server_overwrite_,   direction::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processOverwrite));
    258 
    259         REGISTERDATA(this->client_position_,    direction::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientPosition));
    260         REGISTERDATA(this->client_velocity_,    direction::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientVelocity));
    261         REGISTERDATA(this->client_orientation_, direction::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientOrientation));
    262 
    263 
    264         REGISTERDATA(this->playerID_, direction::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedplayerID));
     353        registerVariable(this->cameraPositionTemplate_,  variableDirection::toclient);
     354        registerVariable(this->hudtemplate_,             variableDirection::toclient);
     355
     356        registerVariable(this->server_position_,         variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerPosition));
     357        registerVariable(this->server_linear_velocity_,  variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerLinearVelocity));
     358        registerVariable(this->server_orientation_,      variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerOrientation));
     359        registerVariable(this->server_angular_velocity_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerAngularVelocity));
     360
     361        registerVariable(this->server_overwrite_,        variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processOverwrite));
     362        registerVariable(this->client_overwrite_,        variableDirection::toserver);
     363
     364        registerVariable(this->client_position_,         variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientPosition));
     365        registerVariable(this->client_linear_velocity_,  variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientLinearVelocity));
     366        registerVariable(this->client_orientation_,      variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientOrientation));
     367        registerVariable(this->client_angular_velocity_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientAngularVelocity));
     368
     369        registerVariable(this->playerID_,                variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedplayerID));
     370        registerVariable(this->gtinfoID_,                variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedgtinfoID));
    265371    }
    266372
    267373    void ControllableEntity::processServerPosition()
    268374    {
    269         if (!this->bControlled_)
    270             this->node_->setPosition(this->server_position_);
    271     }
    272 
    273     void ControllableEntity::processServerVelocity()
    274     {
    275         if (!this->bControlled_)
    276             this->velocity_ = this->server_velocity_;
     375        if (!this->bHasLocalController_)
     376            MobileEntity::setPosition(this->server_position_);
     377    }
     378
     379    void ControllableEntity::processServerLinearVelocity()
     380    {
     381        if (!this->bHasLocalController_)
     382            MobileEntity::setVelocity(this->server_linear_velocity_);
    277383    }
    278384
    279385    void ControllableEntity::processServerOrientation()
    280386    {
    281         if (!this->bControlled_)
    282             this->node_->setOrientation(this->server_orientation_);
     387        if (!this->bHasLocalController_)
     388            MobileEntity::setOrientation(this->server_orientation_);
     389    }
     390
     391    void ControllableEntity::processServerAngularVelocity()
     392    {
     393        if (!this->bHasLocalController_)
     394            MobileEntity::setAngularVelocity(this->server_angular_velocity_);
    283395    }
    284396
    285397    void ControllableEntity::processOverwrite()
    286398    {
    287         if (this->bControlled_)
     399        if (this->bHasLocalController_)
    288400        {
    289401            this->setPosition(this->server_position_);
    290             this->setVelocity(this->server_velocity_);
    291402            this->setOrientation(this->server_orientation_);
     403            this->setVelocity(this->server_linear_velocity_);
     404            this->setAngularVelocity(this->server_angular_velocity_);
    292405
    293406            this->client_overwrite_ = this->server_overwrite_;
     
    299412        if (this->server_overwrite_ == this->client_overwrite_)
    300413        {
    301 //            COUT(2) << "callback: setting client position" << endl;
    302             this->node_->setPosition(this->client_position_);
    303             this->server_position_ = this->client_position_;
    304         }
    305 //        else
    306 //          COUT(2) << "callback: not setting client position" << endl;
    307     }
    308 
    309     void ControllableEntity::processClientVelocity()
     414            MobileEntity::setPosition(this->client_position_);
     415            this->server_position_ = this->getPosition();
     416        }
     417    }
     418
     419    void ControllableEntity::processClientLinearVelocity()
    310420    {
    311421        if (this->server_overwrite_ == this->client_overwrite_)
    312422        {
    313             this->velocity_ = this->client_velocity_;
    314             this->server_velocity_ = this->client_velocity_;
     423            MobileEntity::setVelocity(this->client_linear_velocity_);
     424            this->server_linear_velocity_ = this->getVelocity();
    315425        }
    316426    }
     
    320430        if (this->server_overwrite_ == this->client_overwrite_)
    321431        {
    322             this->node_->setOrientation(this->client_orientation_);
    323             this->server_orientation_ = this->client_orientation_;
    324         }
    325     }
    326 
     432            MobileEntity::setOrientation(this->client_orientation_);
     433            this->server_orientation_ = this->getOrientation();
     434        }
     435    }
     436
     437    void ControllableEntity::processClientAngularVelocity()
     438    {
     439        if (this->server_overwrite_ == this->client_overwrite_)
     440        {
     441            MobileEntity::setAngularVelocity(this->client_angular_velocity_);
     442            this->server_angular_velocity_ = this->getAngularVelocity();
     443        }
     444    }
    327445
    328446    void ControllableEntity::setPosition(const Vector3& position)
     
    330448        if (Core::isMaster())
    331449        {
    332             this->node_->setPosition(position);
    333             this->server_position_ = position;
     450            MobileEntity::setPosition(position);
     451            this->server_position_ = this->getPosition();
    334452            ++this->server_overwrite_;
    335453        }
    336         else if (this->bControlled_)
    337         {
    338             this->node_->setPosition(position);
    339             this->client_position_ = position;
     454        else if (this->bHasLocalController_)
     455        {
     456            MobileEntity::setPosition(position);
     457            this->client_position_ = this->getPosition();
     458        }
     459    }
     460
     461    void ControllableEntity::setOrientation(const Quaternion& orientation)
     462    {
     463        if (Core::isMaster())
     464        {
     465            MobileEntity::setOrientation(orientation);
     466            this->server_orientation_ = this->getOrientation();
     467            ++this->server_overwrite_;
     468        }
     469        else if (this->bHasLocalController_)
     470        {
     471            MobileEntity::setOrientation(orientation);
     472            this->client_orientation_ = this->getOrientation();
    340473        }
    341474    }
     
    345478        if (Core::isMaster())
    346479        {
    347             this->velocity_ = velocity;
    348             this->server_velocity_ = velocity;
     480            MobileEntity::setVelocity(velocity);
     481            this->server_linear_velocity_ = this->getVelocity();
    349482            ++this->server_overwrite_;
    350483        }
    351         else if (this->bControlled_)
    352         {
    353             this->velocity_ = velocity;
    354             this->client_velocity_ = velocity;
    355         }
    356     }
    357 
    358     void ControllableEntity::translate(const Vector3& distance, Ogre::Node::TransformSpace relativeTo)
     484        else if (this->bHasLocalController_)
     485        {
     486            MobileEntity::setVelocity(velocity);
     487            this->client_linear_velocity_ = this->getVelocity();
     488        }
     489    }
     490
     491    void ControllableEntity::setAngularVelocity(const Vector3& velocity)
    359492    {
    360493        if (Core::isMaster())
    361494        {
    362             this->node_->translate(distance, relativeTo);
    363             this->server_position_ = this->node_->getPosition();
     495            MobileEntity::setAngularVelocity(velocity);
     496            this->server_angular_velocity_ = this->getAngularVelocity();
    364497            ++this->server_overwrite_;
    365498        }
    366         else if (this->bControlled_)
    367         {
    368             this->node_->translate(distance, relativeTo);
    369             this->client_position_ = this->node_->getPosition();
    370         }
    371     }
    372 
    373     void ControllableEntity::setOrientation(const Quaternion& orientation)
    374     {
     499        else if (this->bHasLocalController_)
     500        {
     501            MobileEntity::setAngularVelocity(velocity);
     502            this->client_angular_velocity_ = this->getAngularVelocity();
     503        }
     504    }
     505
     506    void ControllableEntity::setWorldTransform(const btTransform& worldTrans)
     507    {
     508        MobileEntity::setWorldTransform(worldTrans);
    375509        if (Core::isMaster())
    376510        {
    377             this->node_->setOrientation(orientation);
    378             this->server_orientation_ = orientation;
    379             ++this->server_overwrite_;
    380         }
    381         else if (this->bControlled_)
    382         {
    383             this->node_->setOrientation(orientation);
    384             this->client_orientation_ = orientation;
    385         }
    386     }
    387 
    388     void ControllableEntity::rotate(const Quaternion& rotation, Ogre::Node::TransformSpace relativeTo)
    389     {
    390         if (Core::isMaster())
    391         {
    392             this->node_->rotate(rotation, relativeTo);
    393             this->server_orientation_ = this->node_->getOrientation();
    394             ++this->server_overwrite_;
    395         }
    396         else if (this->bControlled_)
    397         {
    398             this->node_->rotate(rotation, relativeTo);
    399             this->client_orientation_ = this->node_->getOrientation();
    400         }
    401     }
    402 
    403     void ControllableEntity::yaw(const Degree& angle, Ogre::Node::TransformSpace relativeTo)
    404     {
    405         if (Core::isMaster())
    406         {
    407             this->node_->yaw(angle, relativeTo);
    408             this->server_orientation_ = this->node_->getOrientation();
    409             ++this->server_overwrite_;
    410         }
    411         else if (this->bControlled_)
    412         {
    413             this->node_->yaw(angle, relativeTo);
    414             this->client_orientation_ = this->node_->getOrientation();
    415         }
    416     }
    417 
    418     void ControllableEntity::pitch(const Degree& angle, Ogre::Node::TransformSpace relativeTo)
    419     {
    420         if (Core::isMaster())
    421         {
    422             this->node_->pitch(angle, relativeTo);
    423             this->server_orientation_ = this->node_->getOrientation();
    424             ++this->server_overwrite_;
    425         }
    426         else if (this->bControlled_)
    427         {
    428             this->node_->pitch(angle, relativeTo);
    429             this->client_orientation_ = this->node_->getOrientation();
    430         }
    431     }
    432 
    433     void ControllableEntity::roll(const Degree& angle, Ogre::Node::TransformSpace relativeTo)
    434     {
    435         if (Core::isMaster())
    436         {
    437             this->node_->roll(angle, relativeTo);
    438             this->server_orientation_ = this->node_->getOrientation();
    439             ++this->server_overwrite_;
    440         }
    441         else if (this->bControlled_)
    442         {
    443             this->node_->roll(angle, relativeTo);
    444             this->client_orientation_ = this->node_->getOrientation();
    445         }
    446     }
    447 
    448     void ControllableEntity::lookAt(const Vector3& target, Ogre::Node::TransformSpace relativeTo, const Vector3& localDirectionVector)
    449     {
    450         if (Core::isMaster())
    451         {
    452             this->node_->lookAt(target, relativeTo, localDirectionVector);
    453             this->server_orientation_ = this->node_->getOrientation();
    454             ++this->server_overwrite_;
    455         }
    456         else if (this->bControlled_)
    457         {
    458             this->node_->lookAt(target, relativeTo, localDirectionVector);
    459             this->client_orientation_ = this->node_->getOrientation();
    460         }
    461     }
    462 
    463     void ControllableEntity::setDirection(const Vector3& direction, Ogre::Node::TransformSpace relativeTo, const Vector3& localDirectionVector)
    464     {
    465         if (Core::isMaster())
    466         {
    467             this->node_->setDirection(direction, relativeTo, localDirectionVector);
    468             this->server_orientation_ = this->node_->getOrientation();
    469             ++this->server_overwrite_;
    470         }
    471         else if (this->bControlled_)
    472         {
    473             this->node_->setDirection(direction, relativeTo, localDirectionVector);
    474             this->client_orientation_ = this->node_->getOrientation();
     511            this->server_position_ = this->getPosition();
     512            this->server_orientation_ = this->getOrientation();
     513            this->server_linear_velocity_ = this->getVelocity();
     514            this->server_angular_velocity_ = this->getAngularVelocity();
     515        }
     516        else if (this->bHasLocalController_)
     517        {
     518            this->client_position_ = this->getPosition();
     519            this->client_orientation_ = this->getOrientation();
     520            this->client_linear_velocity_ = this->getVelocity();
     521            this->client_angular_velocity_ = this->getAngularVelocity();
    475522        }
    476523    }
  • code/trunk/src/orxonox/objects/worldentities/ControllableEntity.h

    r2087 r2662  
    2323 *      Fabian 'x3n' Landau
    2424 *   Co-authors:
    25  *      ...
     25 *      Reto Grieder
    2626 *
    2727 */
     
    3232#include "OrxonoxPrereqs.h"
    3333
    34 #include "WorldEntity.h"
    35 #include "objects/Tickable.h"
     34#include "MobileEntity.h"
     35#include "objects/weaponSystem/WeaponSystem.h"
    3636
    3737namespace orxonox
    3838{
    39     class _OrxonoxExport ControllableEntity : public WorldEntity, public Tickable
     39    class _OrxonoxExport ControllableEntity : public MobileEntity
    4040    {
    4141        public:
     
    4646            virtual void tick(float dt);
    4747            void registerVariables();
     48            void setConfigValues();
     49
     50            virtual void changedGametype();
    4851
    4952            virtual void setPlayer(PlayerInfo* player);
     
    6164            virtual void moveUpDown(const Vector2& value) {}
    6265
    63             virtual void rotateYaw(const Vector2& value) {}
    64             virtual void rotatePitch(const Vector2& value) {}
    65             virtual void rotateRoll(const Vector2& value) {}
     66            virtual void rotateYaw(const Vector2& value);
     67            virtual void rotatePitch(const Vector2& value);
     68            virtual void rotateRoll(const Vector2& value);
    6669
    67             virtual void fire() {}
    68             virtual void altFire() {}
     70            inline void moveFrontBack(float value)
     71                { this->moveFrontBack(Vector2(value, 0)); }
     72            inline void moveRightLeft(float value)
     73                { this->moveRightLeft(Vector2(value, 0)); }
     74            inline void moveUpDown(float value)
     75                { this->moveUpDown(Vector2(value, 0)); }
    6976
     77            inline void rotateYaw(float value)
     78                { this->rotateYaw(Vector2(value, 0)); }
     79            inline void rotatePitch(float value)
     80                { this->rotatePitch(Vector2(value, 0)); }
     81            inline void rotateRoll(float value)
     82                { this->rotateRoll(Vector2(value, 0)); }
     83
     84            virtual void fire(WeaponMode::Enum fireMode) {}
     85            virtual void altFire(WeaponMode::Enum fireMode) {}
     86
     87            virtual void boost() {}
    7088            virtual void greet() {}
    7189            virtual void use() {}
     90            virtual void dropItems() {}
    7291            virtual void switchCamera();
     92            virtual void mouseLook();
    7393
    74             inline const Vector3& getVelocity() const
    75                 { return this->velocity_; }
    76             inline const Vector3& getAcceleration() const
    77                 { return this->acceleration_; }
    7894            inline const std::string& getHudTemplate() const
    7995                { return this->hudtemplate_; }
    80 
    81             using WorldEntity::setPosition;
    82             using WorldEntity::translate;
    83             using WorldEntity::setOrientation;
    84             using WorldEntity::rotate;
    85             using WorldEntity::yaw;
    86             using WorldEntity::pitch;
    87             using WorldEntity::roll;
    88             using WorldEntity::lookAt;
    89             using WorldEntity::setDirection;
    90 
    91             void setPosition(const Vector3& position);
    92             void translate(const Vector3& distance, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
    93             void setOrientation(const Quaternion& orientation);
    94             void rotate(const Quaternion& rotation, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
    95             void yaw(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
    96             void pitch(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
    97             void roll(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
    98             void lookAt(const Vector3& target, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);
    99             void setDirection(const Vector3& direction, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);
    100 
    101             void setVelocity(const Vector3& velocity);
    102             inline void setVelocity(float x, float y, float z)
    103                 { this->velocity_.x = x; this->velocity_.y = y; this->velocity_.z = z; }
    104 
    105             inline void setAcceleration(const Vector3& acceleration)
    106                 { this->acceleration_ = acceleration; }
    107             inline void setAcceleration(float x, float y, float z)
    108                 { this->acceleration_.x = x; this->acceleration_.y = y; this->acceleration_.z = z; }
    10996
    11097            inline Camera* getCamera() const
     
    123110                { return this->cameraPositionTemplate_; }
    124111
     112            using WorldEntity::setPosition;
     113            using WorldEntity::setOrientation;
     114            using MobileEntity::setVelocity;
     115            using MobileEntity::setAngularVelocity;
     116
     117            void setPosition(const Vector3& position);
     118            void setOrientation(const Quaternion& orientation);
     119            void setVelocity(const Vector3& velocity);
     120            void setAngularVelocity(const Vector3& velocity);
     121
     122            inline bool hasLocalController() const
     123                { return this->bHasLocalController_; }
     124            inline bool hasHumanController() const
     125                { return this->bHasHumanController_; }
     126
     127            inline const GametypeInfo* getGametypeInfo() const
     128                { return this->gtinfo_; }
     129
     130            inline bool isInMouseLook() const
     131                { return this->bMouseLook_; }
     132            inline float getMouseLookSpeed() const
     133                { return this->mouseLookSpeed_; }
     134
    125135        protected:
    126             virtual void startLocalControl();
    127             virtual void stopLocalControl();
     136            virtual void startLocalHumanControl();
     137            virtual void stopLocalHumanControl();
    128138
    129139            inline void setHudTemplate(const std::string& name)
    130140                { this->hudtemplate_ = name; }
    131 
    132             inline bool isLocallyControlled() const
    133                 { return this->bControlled_; }
    134 
    135             Vector3 acceleration_;
    136141
    137142        private:
     
    140145
    141146            void processServerPosition();
    142             void processServerVelocity();
     147            void processServerLinearVelocity();
    143148            void processServerOrientation();
     149            void processServerAngularVelocity();
    144150
    145151            void processClientPosition();
    146             void processClientVelocity();
     152            void processClientLinearVelocity();
    147153            void processClientOrientation();
     154            void processClientAngularVelocity();
    148155
    149156            void networkcallback_changedplayerID();
     157            void networkcallback_changedgtinfoID();
     158
     159            // Bullet btMotionState related
     160            void setWorldTransform(const btTransform& worldTrans);
    150161
    151162            unsigned int server_overwrite_;
    152163            unsigned int client_overwrite_;
    153164
    154             Vector3 velocity_;
     165            bool bHasLocalController_;
     166            bool bHasHumanController_;
     167            bool bDestroyWhenPlayerLeft_;
    155168
    156             bool bControlled_;
    157169            Vector3 server_position_;
    158170            Vector3 client_position_;
    159             Vector3 server_velocity_;
    160             Vector3 client_velocity_;
     171            Vector3 server_linear_velocity_;
     172            Vector3 client_linear_velocity_;
    161173            Quaternion server_orientation_;
    162174            Quaternion client_orientation_;
     175            Vector3 server_angular_velocity_;
     176            Vector3 client_angular_velocity_;
    163177
    164178            PlayerInfo* player_;
    165179            unsigned int playerID_;
     180
    166181            std::string hudtemplate_;
    167182            OverlayGroup* hud_;
     183
    168184            Camera* camera_;
    169             bool bDestroyWhenPlayerLeft_;
    170 
     185            bool bMouseLook_;
     186            float mouseLookSpeed_;
     187            Ogre::SceneNode* cameraPositionRootNode_;
    171188            std::list<CameraPosition*> cameraPositions_;
    172189            std::string cameraPositionTemplate_;
     190
     191            const GametypeInfo* gtinfo_;
     192            unsigned int gtinfoID_;
    173193    };
    174194}
  • code/trunk/src/orxonox/objects/worldentities/Light.cc

    r2171 r2662  
    3636
    3737#include "util/String.h"
    38 #include "util/Convert.h"
     38#include "util/Exception.h"
     39#include "core/Core.h"
    3940#include "core/CoreIncludes.h"
    4041#include "core/XMLPort.h"
     
    4344namespace orxonox
    4445{
    45     unsigned int Light::lightCounter_s = 0;
    46 
    4746    CreateFactory(Light);
    4847
    49     Light::Light(BaseObject* creator) : PositionableEntity(creator)
     48    Light::Light(BaseObject* creator) : StaticEntity(creator)
    5049    {
    5150        RegisterObject(Light);
    5251
    53         if (this->getScene() && this->getScene()->getSceneManager())
    54         this->light_ = this->getScene()->getSceneManager()->createLight("Light" + convertToString(Light::lightCounter_s++));
    55         this->getNode()->attachObject(this->light_);
     52        this->light_ = 0;
     53        this->diffuse_ = ColourValue::White;
     54        this->specular_ = ColourValue::White;
     55        this->type_ = Ogre::Light::LT_POINT;
     56        this->attenuation_ = Vector4(100000, 1, 0, 0);
     57        this->spotlightRange_ = Vector3(40.0f, 30.0f, 1.0f);
     58
     59        if (Core::showsGraphics())
     60        {
     61            if (!this->getScene())
     62                ThrowException(AbortLoading, "Can't create Light, no scene given.");
     63            if (!this->getScene()->getSceneManager())
     64                ThrowException(AbortLoading, "Can't create Light, no scene manager given.");
     65
     66            if (this->getScene() && this->getScene()->getSceneManager())
     67            {
     68                this->light_ = this->getScene()->getSceneManager()->createLight("Light" + getUniqueNumberString());
     69                this->light_->setDirection(WorldEntity::FRONT);
     70                this->attachOgreObject(this->light_);
     71
     72                this->updateType();
     73                this->updateDiffuseColour();
     74                this->updateSpecularColour();
     75                this->updateAttenuation();
     76                this->updateSpotlightRange();
     77            }
     78        }
    5679
    5780        this->registerVariables();
     
    7194        SUPER(Light, XMLPort, xmlelement, mode);
    7295
    73         XMLPortParam(Light, "type", setTypeString, getTypeString, xmlelement, mode).defaultValues("point");
    74         XMLPortParamExternTemplate(Light, Ogre::Light, this->light_, "diffuse",   setDiffuseColour,  getDiffuseColour,  xmlelement, mode, const ColourValue&);
    75         XMLPortParamExternTemplate(Light, Ogre::Light, this->light_, "specular",  setSpecularColour, getSpecularColour, xmlelement, mode, const ColourValue&);
    76         XMLPortParamExternTemplate(Light, Ogre::Light, this->light_, "direction", setDirection,      getDirection,      xmlelement, mode, const Vector3&);
     96        XMLPortParam(Light, "type",           setTypeString,     getTypeString,     xmlelement, mode).defaultValues("point");
     97        XMLPortParam(Light, "diffuse",        setDiffuseColour,  getDiffuseColour,  xmlelement, mode).defaultValues(ColourValue::White);
     98        XMLPortParam(Light, "specular",       setSpecularColour, getSpecularColour, xmlelement, mode).defaultValues(ColourValue::White);
     99        XMLPortParam(Light, "attenuation",    setAttenuation,    getAttenuation,    xmlelement, mode).defaultValues(Vector4(100000, 1, 0, 0));
     100        XMLPortParam(Light, "spotlightrange", setSpotlightRange, getSpotlightRange, xmlelement, mode).defaultValues(Vector3(40.0f, 30.0f, 1.0f));
    77101    }
    78102
    79103    void Light::registerVariables()
    80104    {
    81         REGISTERDATA(this->type_, direction::toclient, new NetworkCallback<Light>(this, &Light::changedType));
    82         REGISTERDATA(this->light_->getDiffuseColour(), direction::toclient);
    83         REGISTERDATA(this->light_->getSpecularColour(), direction::toclient);
    84         REGISTERDATA(this->light_->getDirection(), direction::toclient);
     105        registerVariable((int&)this->type_,     variableDirection::toclient, new NetworkCallback<Light>(this, &Light::updateType));
     106        registerVariable(this->diffuse_,        variableDirection::toclient, new NetworkCallback<Light>(this, &Light::updateDiffuseColour));
     107        registerVariable(this->specular_,       variableDirection::toclient, new NetworkCallback<Light>(this, &Light::updateSpecularColour));
     108        registerVariable(this->attenuation_,    variableDirection::toclient, new NetworkCallback<Light>(this, &Light::updateAttenuation));
     109        registerVariable(this->spotlightRange_, variableDirection::toclient, new NetworkCallback<Light>(this, &Light::updateSpotlightRange));
    85110    }
    86111
    87     const std::string& Light::getName() const
     112    void Light::updateDiffuseColour()
    88113    {
    89114        if (this->light_)
    90             return this->light_->getName();
    91         else
    92             return BLANKSTRING;
     115            this->light_->setDiffuseColour(this->diffuse_);
    93116    }
    94117
    95     void Light::setDiffuseColour(const ColourValue& colour)
     118    void Light::updateSpecularColour()
    96119    {
    97120        if (this->light_)
    98             this->light_->setDiffuseColour(colour);
     121            this->light_->setSpecularColour(this->specular_);
    99122    }
    100123
    101     const ColourValue& Light::getDiffuseColour() const
     124    void Light::updateAttenuation()
    102125    {
    103         if (this->light_)
    104             return this->light_->getDiffuseColour();
    105         else
    106             return ColourValue::White;
     126        if (this->light_ && this->type_ != Ogre::Light::LT_DIRECTIONAL)
     127            this->light_->setAttenuation(this->attenuation_.x, this->attenuation_.y, this->attenuation_.z, this->attenuation_.w);
    107128    }
    108129
    109     void Light::setSpecularColour(const ColourValue& colour)
     130    void Light::updateSpotlightRange()
    110131    {
    111         if (this->light_)
    112             this->light_->setSpecularColour(colour);
    113     }
    114 
    115     const ColourValue& Light::getSpecularColour() const
    116     {
    117         if (this->light_)
    118             return this->light_->getSpecularColour();
    119         else
    120             return ColourValue::White;
    121     }
    122 
    123     void Light::setDirection(const Vector3& direction)
    124     {
    125         if (this->light_)
    126             this->light_->setDirection(direction);
    127     }
    128 
    129     const Vector3& Light::getDirection() const
    130     {
    131         if (this->light_)
    132             return this->light_->getDirection();
    133         else
    134             return Vector3::ZERO;
     132        if (this->light_ && this->type_ == Ogre::Light::LT_SPOTLIGHT)
     133            this->light_->setSpotlightRange(Degree(this->spotlightRange_.x), Degree(this->spotlightRange_.y), this->spotlightRange_.z);
    135134    }
    136135
     
    157156            case Ogre::Light::LT_POINT:
    158157            default:
    159                 return "poinT";
     158                return "point";
    160159        }
    161160    }
    162161
    163     void Light::changedType()
     162    void Light::updateType()
    164163    {
    165         this->light_->setType(this->type_);
     164        if (this->light_)
     165        {
     166            this->light_->setType(this->type_);
     167
     168            if (this->type_ != Ogre::Light::LT_DIRECTIONAL)
     169                this->updateAttenuation();
     170            if (this->type_ == Ogre::Light::LT_SPOTLIGHT)
     171                this->updateSpotlightRange();
     172        }
    166173    }
    167174
     
    170177        SUPER(Light, changedVisibility);
    171178
    172         this->light_->setVisible(this->isVisible());
     179        if (this->light_)
     180            this->light_->setVisible(this->isVisible());
    173181    }
    174182}
  • code/trunk/src/orxonox/objects/worldentities/Light.h

    r2087 r2662  
    3131
    3232#include "OrxonoxPrereqs.h"
    33 #include "PositionableEntity.h"
     33#include "StaticEntity.h"
    3434
    3535#include <string>
     
    4040namespace orxonox
    4141{
    42     class _OrxonoxExport Light : public PositionableEntity
     42    class _OrxonoxExport Light : public StaticEntity
    4343    {
    4444        public:
     
    5454                { return this->light_; }
    5555
    56             const std::string& getName() const;
    57 
    5856            inline void setType(Ogre::Light::LightTypes type)
    59                 { this->type_ = type; this->changedType(); }
    60             Ogre::Light::LightTypes getType() const
     57                { this->type_ = type; this->updateType(); }
     58            inline Ogre::Light::LightTypes getType() const
    6159                { return this->type_; }
    6260
    63             void setDiffuseColour(const ColourValue& colour);
    64             const ColourValue& getDiffuseColour() const;
     61            inline void setDiffuseColour(const ColourValue& colour)
     62                { this->diffuse_ = colour; this->updateDiffuseColour(); }
     63            inline const ColourValue& getDiffuseColour() const
     64                { return this->diffuse_; }
    6565
    66             void setSpecularColour(const ColourValue& colour);
    67             const ColourValue& getSpecularColour() const;
     66            inline void setSpecularColour(const ColourValue& colour)
     67                { this->specular_ = colour; this->updateSpecularColour(); }
     68            inline const ColourValue& getSpecularColour() const
     69                { return this->specular_; }
    6870
    69             void setDirection(const Vector3& direction);
    70             const Vector3& getDirection() const;
     71            /**
     72                @brief Sets the attenuation parameters of the light source i.e. how it diminishes with distance.
     73
     74                @param attenuation.x range (The absolute upper range of the light in world units)
     75                @param attenuation.y constant (The constant factor in the attenuation formula: 1.0 means never attenuate, 0.0 is complete attenuation)
     76                @param attenuation.z linear (The linear factor in the attenuation formula: 1 means attenuate evenly over the distance)
     77                @param attenuation.w quadratic (The quadratic factor in the attenuation formula: adds a curvature to the attenuation formula)
     78
     79                Quote from the Ogre API:
     80                Lights normally get fainter the further they are away. Also, each light is given a maximum range beyond which it cannot affect any objects.
     81                Light attenuation is not applicable to directional lights since they have an infinite range and constant intensity.
     82                This follows a standard attenuation approach - see any good 3D text for the details of what they mean since i don't have room here!
     83
     84                Quote from the Ogre wiki:
     85                "Using these numbers, the light has 100% intensity at 0 distance, and
     86                trails off to near black at a distance equal to the Range. Keep in mind
     87                that most of the light falls in the first 20% of the range."
     88
     89                Range   Constant   Linear     Quadratic
     90                3250,     1.0,     0.0014,    0.000007
     91                600,      1.0,     0.007,     0.0002
     92                325,      1.0,     0.014,     0.0007
     93                200,      1.0,     0.022,     0.0019
     94                160,      1.0,     0.027,     0.0028
     95                100,      1.0,     0.045,     0.0075
     96                65,       1.0,     0.07,      0.017
     97                50,       1.0,     0.09,      0.032
     98                32,       1.0,     0.14,      0.07
     99                20,       1.0,     0.22,      0.20
     100                13,       1.0,     0.35,      0.44
     101                7,        1.0,     0.7,       1.8
     102            */
     103            inline void setAttenuation(const Vector4& attenuation)
     104                { this->attenuation_ = attenuation; this->updateAttenuation(); }
     105            inline const Vector4& getAttenuation() const
     106                { return this->attenuation_; }
     107
     108            /**
     109                @brief Sets the range of a spotlight, i.e. the angle of the inner and outer cones and the rate of falloff between them.
     110
     111                @param spotlightRange.x innerAngle (The angle covered by the bright inner cone)
     112                @param spotlightRange.x outerAngle (The angle covered by the outer cone)
     113                @param spotlightRange.x falloff (The rate of falloff between the inner and outer cones. 1.0 means a linear falloff, less means slower falloff, higher means faster falloff.)
     114            */
     115            inline void setSpotlightRange(const Vector3& spotlightRange)
     116                { this->spotlightRange_ = spotlightRange; this->updateSpotlightRange(); }
     117            inline const Vector3& getSpotlightRange() const
     118                { return this->spotlightRange_; }
    71119
    72120        private:
     
    74122            std::string getTypeString() const;
    75123
    76             void changedType();
     124            void updateType();
     125            void updateDiffuseColour();
     126            void updateSpecularColour();
     127            void updateAttenuation();
     128            void updateSpotlightRange();
    77129
    78             static unsigned int lightCounter_s;
    79130            Ogre::Light* light_;
    80131            Ogre::Light::LightTypes type_;
    81 
     132            ColourValue diffuse_;
     133            ColourValue specular_;
     134            Vector4 attenuation_;
     135            Vector3 spotlightRange_;
    82136    };
    83137}
  • code/trunk/src/orxonox/objects/worldentities/MobileEntity.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/worldentities/MobileEntity.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/worldentities/Model.cc

    r2171 r2662  
    2929#include "OrxonoxStableHeaders.h"
    3030
     31#include <OgreEntity.h>
    3132#include "Model.h"
    3233#include "core/CoreIncludes.h"
     
    3839    CreateFactory(Model);
    3940
    40     Model::Model(BaseObject* creator) : PositionableEntity(creator)
     41    Model::Model(BaseObject* creator) : StaticEntity(creator)
    4142    {
    4243        RegisterObject(Model);
     44
     45        this->bCastShadows_ = true;
    4346
    4447        this->registerVariables();
     
    4851    {
    4952        if (this->isInitialized() && this->mesh_.getEntity())
    50             this->getNode()->detachObject(this->mesh_.getEntity());
     53            this->detachOgreObject(this->mesh_.getEntity());
    5154    }
    5255
     
    6164    void Model::registerVariables()
    6265    {
    63         REGISTERSTRING(this->meshSrc_,    direction::toclient, new NetworkCallback<Model>(this, &Model::changedMesh));
    64         REGISTERDATA(this->bCastShadows_, direction::toclient, new NetworkCallback<Model>(this, &Model::changedShadows));
     66        registerVariable(this->meshSrc_,    variableDirection::toclient, new NetworkCallback<Model>(this, &Model::changedMesh));
     67        registerVariable(this->bCastShadows_, variableDirection::toclient, new NetworkCallback<Model>(this, &Model::changedShadows));
    6568    }
    6669
    6770    void Model::changedMesh()
    6871    {
    69         if (this->mesh_.getEntity())
    70             this->getNode()->detachObject(this->mesh_.getEntity());
     72        if (Core::showsGraphics())
     73        {
     74            if (this->mesh_.getEntity())
     75                this->detachOgreObject(this->mesh_.getEntity());
    7176
    72         this->mesh_.setMeshSource(this->getScene()->getSceneManager(), this->meshSrc_);
     77            this->mesh_.setMeshSource(this->getScene()->getSceneManager(), this->meshSrc_);
    7378
    74         if (this->mesh_.getEntity())
    75         {
    76             this->getNode()->attachObject(this->mesh_.getEntity());
    77             this->mesh_.getEntity()->setCastShadows(this->bCastShadows_);
    78             this->mesh_.setVisible(this->isVisible());
     79            if (this->mesh_.getEntity())
     80            {
     81                this->attachOgreObject(this->mesh_.getEntity());
     82                this->mesh_.getEntity()->setCastShadows(this->bCastShadows_);
     83                this->mesh_.setVisible(this->isVisible());
     84            }
    7985        }
    8086    }
  • code/trunk/src/orxonox/objects/worldentities/Model.h

    r2087 r2662  
    3131
    3232#include "OrxonoxPrereqs.h"
    33 #include "PositionableEntity.h"
     33#include "StaticEntity.h"
    3434#include "tools/Mesh.h"
    3535
    3636namespace orxonox
    3737{
    38     class _OrxonoxExport Model : public PositionableEntity
     38    class _OrxonoxExport Model : public StaticEntity
    3939    {
    4040        public:
     
    7070}
    7171
    72 #endif /* _PositionableEntity_H__ */
     72#endif /* _Model_H__ */
  • code/trunk/src/orxonox/objects/worldentities/MovableEntity.cc

    r2171 r2662  
    2222 *   Author:
    2323 *      Fabian 'x3n' Landau
     24 *      Reto Grieder
    2425 *   Co-authors:
    2526 *      ...
     
    3334#include "core/XMLPort.h"
    3435#include "core/Executor.h"
    35 #include "tools/Timer.h"
     36#include "core/Core.h"
    3637
    3738namespace orxonox
    3839{
    3940    static const float MAX_RESYNCHRONIZE_TIME = 3.0f;
     41    static const float CONTINUOUS_SYNCHRONIZATION_TIME = 10.0f;
    4042
    4143    CreateFactory(MovableEntity);
    4244
    43     MovableEntity::MovableEntity(BaseObject* creator) : WorldEntity(creator)
     45    MovableEntity::MovableEntity(BaseObject* creator) : MobileEntity(creator)
    4446    {
    4547        RegisterObject(MovableEntity);
    4648
    47         this->velocity_ = Vector3::ZERO;
    48         this->acceleration_ = Vector3::ZERO;
    49         this->rotationAxis_ = Vector3::ZERO;
    50         this->rotationRate_ = 0;
    51         this->momentum_ = 0;
     49        this->overwrite_position_    = Vector3::ZERO;
     50        this->overwrite_orientation_ = Quaternion::IDENTITY;
    5251
    53         this->overwrite_position_ = Vector3::ZERO;
    54         this->overwrite_orientation_ = Quaternion::IDENTITY;
     52        this->continuousResynchroTimer_ = 0;
     53
     54        this->setPriority(priority::low);
    5555
    5656        this->registerVariables();
     
    5959    MovableEntity::~MovableEntity()
    6060    {
     61        if (this->isInitialized())
     62            if (this->continuousResynchroTimer_)
     63                delete this->continuousResynchroTimer_;
    6164    }
    6265
     
    6467    {
    6568        SUPER(MovableEntity, XMLPort, xmlelement, mode);
    66 
    67         XMLPortParamTemplate(MovableEntity, "velocity", setVelocity, getVelocity, xmlelement, mode, const Vector3&);
    68         XMLPortParamTemplate(MovableEntity, "rotationaxis", setRotationAxis, getRotationAxis, xmlelement, mode, const Vector3&);
    69         XMLPortParamTemplate(MovableEntity, "rotationrate", setRotationRate, getRotationRate, xmlelement, mode, const Degree&);
    70     }
    71 
    72     void MovableEntity::tick(float dt)
    73     {
    74         if (this->isActive())
    75         {
    76             this->velocity_ += (dt * this->acceleration_);
    77             this->node_->translate(dt * this->velocity_);
    78 
    79             this->rotationRate_ += (dt * this->momentum_);
    80             this->node_->rotate(this->rotationAxis_, this->rotationRate_  * dt);
    81         }
    8269    }
    8370
    8471    void MovableEntity::registerVariables()
    8572    {
    86         REGISTERDATA(this->velocity_.x, direction::toclient);
    87         REGISTERDATA(this->velocity_.y, direction::toclient);
    88         REGISTERDATA(this->velocity_.z, direction::toclient);
     73        registerVariable(this->linearVelocity_,        variableDirection::toclient, new NetworkCallback<MovableEntity>(this, &MovableEntity::processLinearVelocity));
     74        registerVariable(this->angularVelocity_,       variableDirection::toclient, new NetworkCallback<MovableEntity>(this, &MovableEntity::processAngularVelocity));
    8975
    90         REGISTERDATA(this->rotationAxis_.x, direction::toclient);
    91         REGISTERDATA(this->rotationAxis_.y, direction::toclient);
    92         REGISTERDATA(this->rotationAxis_.z, direction::toclient);
    93 
    94         REGISTERDATA(this->rotationRate_, direction::toclient);
    95 
    96         REGISTERDATA(this->overwrite_position_,    direction::toclient, new NetworkCallback<MovableEntity>(this, &MovableEntity::overwritePosition));
    97         REGISTERDATA(this->overwrite_orientation_, direction::toclient, new NetworkCallback<MovableEntity>(this, &MovableEntity::overwriteOrientation));
    98     }
    99 
    100     void MovableEntity::overwritePosition()
    101     {
    102         this->node_->setPosition(this->overwrite_position_);
    103     }
    104 
    105     void MovableEntity::overwriteOrientation()
    106     {
    107         this->node_->setOrientation(this->overwrite_orientation_);
     76        registerVariable(this->overwrite_position_,    variableDirection::toclient, new NetworkCallback<MovableEntity>(this, &MovableEntity::overwritePosition));
     77        registerVariable(this->overwrite_orientation_, variableDirection::toclient, new NetworkCallback<MovableEntity>(this, &MovableEntity::overwriteOrientation));
    10878    }
    10979
    11080    void MovableEntity::clientConnected(unsigned int clientID)
    11181    {
    112         new Timer<MovableEntity>(rnd() * MAX_RESYNCHRONIZE_TIME, false, this, createExecutor(createFunctor(&MovableEntity::resynchronize)), true);
     82        this->resynchronizeTimer_.setTimer(rnd() * MAX_RESYNCHRONIZE_TIME, false, this, createExecutor(createFunctor(&MovableEntity::resynchronize)));
    11383    }
    11484
     
    11989    void MovableEntity::resynchronize()
    12090    {
     91        if (Core::isMaster() && !this->continuousResynchroTimer_)
     92        {
     93            // Resynchronise every few seconds because we only work with velocities (no positions)
     94            continuousResynchroTimer_ = new Timer<MovableEntity>(CONTINUOUS_SYNCHRONIZATION_TIME + rnd(-1, 1),
     95                true, this, createExecutor(createFunctor(&MovableEntity::resynchronize)), false);
     96        }
     97
    12198        this->overwrite_position_ = this->getPosition();
    12299        this->overwrite_orientation_ = this->getOrientation();
    123100    }
    124 
    125     void MovableEntity::setPosition(const Vector3& position)
    126     {
    127         this->node_->setPosition(position);
    128         this->overwrite_position_ = this->node_->getPosition();
    129     }
    130 
    131     void MovableEntity::translate(const Vector3& distance, Ogre::Node::TransformSpace relativeTo)
    132     {
    133         this->node_->translate(distance, relativeTo);
    134         this->overwrite_position_ = this->node_->getPosition();
    135     }
    136 
    137     void MovableEntity::setOrientation(const Quaternion& orientation)
    138     {
    139         this->node_->setOrientation(orientation);
    140         this->overwrite_orientation_ = this->node_->getOrientation();
    141     }
    142 
    143     void MovableEntity::rotate(const Quaternion& rotation, Ogre::Node::TransformSpace relativeTo)
    144     {
    145         this->node_->rotate(rotation, relativeTo);
    146         this->overwrite_orientation_ = this->node_->getOrientation();
    147     }
    148 
    149     void MovableEntity::yaw(const Degree& angle, Ogre::Node::TransformSpace relativeTo)
    150     {
    151         this->node_->yaw(angle, relativeTo);
    152         this->overwrite_orientation_ = this->node_->getOrientation();
    153     }
    154 
    155     void MovableEntity::pitch(const Degree& angle, Ogre::Node::TransformSpace relativeTo)
    156     {
    157         this->node_->pitch(angle, relativeTo);
    158         this->overwrite_orientation_ = this->node_->getOrientation();
    159     }
    160 
    161     void MovableEntity::roll(const Degree& angle, Ogre::Node::TransformSpace relativeTo)
    162     {
    163         this->node_->roll(angle, relativeTo);
    164         this->overwrite_orientation_ = this->node_->getOrientation();
    165     }
    166 
    167     void MovableEntity::lookAt(const Vector3& target, Ogre::Node::TransformSpace relativeTo, const Vector3& localDirectionVector)
    168     {
    169         this->node_->lookAt(target, relativeTo, localDirectionVector);
    170         this->overwrite_orientation_ = this->node_->getOrientation();
    171     }
    172 
    173     void MovableEntity::setDirection(const Vector3& direction, Ogre::Node::TransformSpace relativeTo, const Vector3& localDirectionVector)
    174     {
    175         this->node_->setDirection(direction, relativeTo, localDirectionVector);
    176         this->overwrite_orientation_ = this->node_->getOrientation();
    177     }
    178101}
  • code/trunk/src/orxonox/objects/worldentities/MovableEntity.h

    r2171 r2662  
    2222 *   Author:
    2323 *      Fabian 'x3n' Landau
     24 *      Reto Grieder
    2425 *   Co-authors:
    2526 *      ...
     
    3233#include "OrxonoxPrereqs.h"
    3334
    34 #include "WorldEntity.h"
    35 #include "objects/Tickable.h"
     35#include "MobileEntity.h"
    3636#include "network/ClientConnectionListener.h"
     37#include "tools/Timer.h"
    3738
    3839namespace orxonox
    3940{
    40     class _OrxonoxExport MovableEntity : public WorldEntity, public Tickable, public ClientConnectionListener
     41    class _OrxonoxExport MovableEntity : public MobileEntity, public ClientConnectionListener
    4142    {
    4243        public:
     
    4546
    4647            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    47             virtual void tick(float dt);
    4848            void registerVariables();
    4949
    5050            using WorldEntity::setPosition;
    51             using WorldEntity::translate;
    5251            using WorldEntity::setOrientation;
    53             using WorldEntity::rotate;
    54             using WorldEntity::yaw;
    55             using WorldEntity::pitch;
    56             using WorldEntity::roll;
    57             using WorldEntity::lookAt;
    58             using WorldEntity::setDirection;
    5952
    60             void setPosition(const Vector3& position);
    61             void translate(const Vector3& distance, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
    62             void setOrientation(const Quaternion& orientation);
    63             void rotate(const Quaternion& rotation, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
    64             void yaw(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
    65             void pitch(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
    66             void roll(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);
    67             void lookAt(const Vector3& target, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);
    68             void setDirection(const Vector3& direction, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);
    69 
    70             inline void setVelocity(const Vector3& velocity)
    71                 { this->velocity_ = velocity; }
    72             inline void setVelocity(float x, float y, float z)
    73                 { this->velocity_.x = x; this->velocity_.y = y; this->velocity_.z = z; }
    74             inline const Vector3& getVelocity() const
    75                 { return this->velocity_; }
    76 
    77             inline void setAcceleration(const Vector3& acceleration)
    78                 { this->acceleration_ = acceleration; }
    79             inline void setAcceleration(float x, float y, float z)
    80                 { this->acceleration_.x = x; this->acceleration_.y = y; this->acceleration_.z = z; }
    81             inline const Vector3& getAcceleration() const
    82                 { return this->acceleration_; }
    83 
    84             inline void setRotationAxis(const Vector3& axis)
    85                 { this->rotationAxis_ = axis; this->rotationAxis_.normalise(); }
    86             inline void setRotationAxis(float x, float y, float z)
    87                 { this->rotationAxis_.x = x; this->rotationAxis_.y = y; this->rotationAxis_.z = z; rotationAxis_.normalise(); }
    88             inline const Vector3& getRotationAxis() const
    89                 { return this->rotationAxis_; }
    90 
    91             inline void setRotationRate(const Degree& angle)
    92                 { this->rotationRate_ = angle; }
    93             inline void setRotationRate(const Radian& angle)
    94                 { this->rotationRate_ = angle; }
    95             inline const Degree& getRotationRate() const
    96                 { return this->rotationRate_; }
    97 
    98             inline void setMomentum(const Degree& angle)
    99                 { this->momentum_ = angle; }
    100             inline void setMomentum(const Radian& angle)
    101                 { this->momentum_ = angle; }
    102             inline const Degree& getMomentum() const
    103                 { return this->momentum_; }
     53            inline void setPosition(const Vector3& position)
     54                { MobileEntity::setPosition(position); this->overwrite_position_ = this->getPosition(); }
     55            inline void setOrientation(const Quaternion& orientation)
     56                { MobileEntity::setOrientation(orientation); this->overwrite_orientation_ = this->getOrientation(); }
    10457
    10558        private:
     
    10861            void resynchronize();
    10962
    110             void overwritePosition();
    111             void overwriteOrientation();
     63            inline void processLinearVelocity()
     64                { this->setVelocity(this->linearVelocity_); }
     65            inline void processAngularVelocity()
     66                { this->setAngularVelocity(this->angularVelocity_); }
    11267
    113             Vector3 velocity_;
    114             Vector3 acceleration_;
    115             Vector3 rotationAxis_;
    116             Degree rotationRate_;
    117             Degree momentum_;
     68            inline void overwritePosition()
     69                { this->setPosition(this->overwrite_position_); }
     70            inline void overwriteOrientation()
     71                { this->setOrientation(this->overwrite_orientation_); }
    11872
    119             Vector3 overwrite_position_;
     73            Vector3    overwrite_position_;
    12074            Quaternion overwrite_orientation_;
     75
     76            Timer<MovableEntity> resynchronizeTimer_;
     77            Timer<MovableEntity>* continuousResynchroTimer_;
    12178    };
    12279}
  • code/trunk/src/orxonox/objects/worldentities/ParticleEmitter.cc

    r2171 r2662  
    3333
    3434#include "OrxonoxStableHeaders.h"
     35#include "ParticleEmitter.h"
    3536
    36 #include "ParticleEmitter.h"
     37#include <OgreParticleSystem.h>
    3738
    3839#include "tools/ParticleInterface.h"
     
    4647    CreateFactory(ParticleEmitter);
    4748
    48     ParticleEmitter::ParticleEmitter(BaseObject* creator) : PositionableEntity(creator)
     49    ParticleEmitter::ParticleEmitter(BaseObject* creator) : StaticEntity(creator)
    4950    {
    5051        RegisterObject(ParticleEmitter);
    5152
    52         if (!this->getScene() || !this->getScene()->getSceneManager())
    53             ThrowException(AbortLoading, "Can't create Camera, no scene or no scene manager given.");
     53        if (Core::showsGraphics() && (!this->getScene() || !this->getScene()->getSceneManager()))
     54            ThrowException(AbortLoading, "Can't create ParticleEmitter, no scene or no scene manager given.");
    5455
    5556        this->particles_ = 0;
     
    6263    {
    6364        if (this->isInitialized() && this->particles_)
     65        {
     66            this->detachOgreObject(this->particles_->getParticleSystem());
    6467            delete this->particles_;
     68        }
    6569    }
    6670
     
    7579    void ParticleEmitter::registerVariables()
    7680    {
    77         REGISTERSTRING(this->source_, direction::toclient, new NetworkCallback<ParticleEmitter>(this, &ParticleEmitter::sourceChanged));
    78         REGISTERDATA  (this->LOD_,    direction::toclient, new NetworkCallback<ParticleEmitter>(this, &ParticleEmitter::LODchanged));
     81        registerVariable(this->source_, variableDirection::toclient, new NetworkCallback<ParticleEmitter>(this, &ParticleEmitter::sourceChanged));
     82        registerVariable((int&)(this->LOD_),    variableDirection::toclient, new NetworkCallback<ParticleEmitter>(this, &ParticleEmitter::LODchanged));
    7983    }
    8084
     
    98102    {
    99103        if (this->particles_)
     104        {
    100105            delete this->particles_;
     106            this->particles_ = 0;
     107        }
    101108
    102         if (this->getScene() && this->getScene()->getSceneManager())
     109        if (Core::showsGraphics() && this->getScene() && this->getScene()->getSceneManager())
    103110        {
    104111            try
    105112            {
    106113                this->particles_ = new ParticleInterface(this->getScene()->getSceneManager(), this->source_, this->LOD_);
    107                 this->particles_->addToSceneNode(this->getNode());
     114                this->attachOgreObject(this->particles_->getParticleSystem());
    108115                this->particles_->setVisible(this->isVisible());
    109116                this->particles_->setEnabled(this->isActive());
     
    115122            }
    116123        }
    117         else
    118             this->particles_ = 0;
    119124    }
    120125
  • code/trunk/src/orxonox/objects/worldentities/ParticleEmitter.h

    r2087 r2662  
    3131
    3232#include "OrxonoxPrereqs.h"
    33 #include "PositionableEntity.h"
     33#include "StaticEntity.h"
    3434
    3535namespace orxonox
    3636{
    37     class _OrxonoxExport ParticleEmitter : public PositionableEntity
     37    class _OrxonoxExport ParticleEmitter : public StaticEntity
    3838    {
    3939        public:
  • code/trunk/src/orxonox/objects/worldentities/ParticleSpawner.cc

  • code/trunk/src/orxonox/objects/worldentities/ParticleSpawner.h

  • code/trunk/src/orxonox/objects/worldentities/SpawnPoint.cc

    r2087 r2662  
    3838    CreateFactory(SpawnPoint);
    3939
    40     SpawnPoint::SpawnPoint(BaseObject* creator) : PositionableEntity(creator)
     40    SpawnPoint::SpawnPoint(BaseObject* creator) : StaticEntity(creator)
    4141    {
    4242        RegisterObject(SpawnPoint);
  • code/trunk/src/orxonox/objects/worldentities/SpawnPoint.h

    r2087 r2662  
    3434#include "core/Identifier.h"
    3535#include "core/Template.h"
    36 #include "PositionableEntity.h"
    3736#include "objects/worldentities/pawns/Pawn.h"
     37#include "objects/worldentities/StaticEntity.h"
    3838
    3939namespace orxonox
    4040{
    41     class _OrxonoxExport SpawnPoint : public PositionableEntity
     41    class _OrxonoxExport SpawnPoint : public StaticEntity
    4242    {
    4343        public:
  • code/trunk/src/orxonox/objects/worldentities/StaticEntity.cc

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/worldentities/StaticEntity.h

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • code/trunk/src/orxonox/objects/worldentities/WorldEntity.cc

    r2171 r2662  
    2222 *   Author:
    2323 *      Fabian 'x3n' Landau
     24 *      Reto Grieder (physics)
    2425 *   Co-authors:
    2526 *      ...
     
    3132
    3233#include <cassert>
     34#include <OgreSceneNode.h>
    3335#include <OgreSceneManager.h>
    34 
     36#include "BulletDynamics/Dynamics/btRigidBody.h"
     37
     38#include "util/Exception.h"
     39#include "util/Convert.h"
    3540#include "core/CoreIncludes.h"
    3641#include "core/XMLPort.h"
    37 #include "util/Convert.h"
    38 #include "util/Exception.h"
    3942
    4043#include "objects/Scene.h"
     44#include "objects/collisionshapes/WorldEntityCollisionShape.h"
    4145
    4246namespace orxonox
     
    4953    const Vector3 WorldEntity::UP    = Vector3::UNIT_Y;
    5054
     55    /**
     56    @brief
     57        Creates a new WorldEntity that may immediately be used.
     58        All the default values are being set here.
     59    */
    5160    WorldEntity::WorldEntity(BaseObject* creator) : BaseObject(creator), Synchronisable(creator)
    5261    {
     
    6473        this->node_->setOrientation(Quaternion::IDENTITY);
    6574
     75
     76        // Default behaviour does not include physics
     77        this->physicalBody_   = 0;
     78        this->bPhysicsActive_ = false;
     79        this->bPhysicsActiveSynchronised_    = false;
     80        this->bPhysicsActiveBeforeAttaching_ = false;
     81        this->collisionShape_ = new WorldEntityCollisionShape(this);
     82        this->collisionType_             = None;
     83        this->collisionTypeSynchronised_ = None;
     84        this->mass_           = 0;
     85        this->childrenMass_   = 0;
     86        // Using bullet default values
     87        this->restitution_    = 0;
     88        this->angularFactor_  = 1;
     89        this->linearDamping_  = 0;
     90        this->angularDamping_ = 0;
     91        this->friction_       = 0.5;
     92        this->bCollisionCallbackActive_ = false;
     93        this->bCollisionResponseActive_ = true;
     94
    6695        this->registerVariables();
    6796    }
    6897
     98    /**
     99    @brief
     100        Destroys the WorldEntity AND ALL its children with it.
     101    */
    69102    WorldEntity::~WorldEntity()
    70103    {
    71104        if (this->isInitialized())
    72105        {
     106            if (this->parent_)
     107                this->detachFromParent();
     108
     109            for (std::set<WorldEntity*>::const_iterator it = this->children_.begin(); it != this->children_.end(); )
     110                delete (*(it++));
     111
     112            if (this->physicalBody_)
     113            {
     114                this->deactivatePhysics();
     115                delete this->physicalBody_;
     116            }
     117            delete this->collisionShape_;
     118
    73119            this->node_->detachAllObjects();
    74             if (this->getScene()->getSceneManager())
    75                 this->getScene()->getSceneManager()->destroySceneNode(this->node_->getName());
     120            this->node_->removeAllChildren();
     121
     122            OrxAssert(this->getScene()->getSceneManager(), "No SceneManager defined in a WorldEntity.");
     123            this->getScene()->getSceneManager()->destroySceneNode(this->node_->getName());
    76124        }
    77125    }
     
    81129        SUPER(WorldEntity, XMLPort, xmlelement, mode);
    82130
    83         XMLPortParamTemplate(WorldEntity, "position", setPosition, getPosition, xmlelement, mode, const Vector3&);
     131        XMLPortParamTemplate(WorldEntity, "position",    setPosition,    getPosition,    xmlelement, mode, const Vector3&);
    84132        XMLPortParamTemplate(WorldEntity, "orientation", setOrientation, getOrientation, xmlelement, mode, const Quaternion&);
    85         XMLPortParamLoadOnly(WorldEntity, "lookat", lookAt_xmlport, xmlelement, mode);
    86         XMLPortParamLoadOnly(WorldEntity, "direction", setDirection_xmlport, xmlelement, mode);
    87         XMLPortParamLoadOnly(WorldEntity, "yaw", yaw_xmlport, xmlelement, mode);
    88         XMLPortParamLoadOnly(WorldEntity, "pitch", pitch_xmlport, xmlelement, mode);
    89         XMLPortParamLoadOnly(WorldEntity, "roll", roll_xmlport, xmlelement, mode);
    90         XMLPortParamTemplate(WorldEntity, "scale3D", setScale3D, getScale3D, xmlelement, mode, const Vector3&);
    91         XMLPortParam(WorldEntity, "scale", setScale, getScale, xmlelement, mode);
    92 
     133        XMLPortParamTemplate(WorldEntity, "scale3D",     setScale3D,     getScale3D,     xmlelement, mode, const Vector3&);
     134        XMLPortParam        (WorldEntity, "scale",       setScale,       getScale,       xmlelement, mode);
     135        XMLPortParamLoadOnly(WorldEntity, "lookat",      lookAt_xmlport,       xmlelement, mode);
     136        XMLPortParamLoadOnly(WorldEntity, "direction",   setDirection_xmlport, xmlelement, mode);
     137        XMLPortParamLoadOnly(WorldEntity, "yaw",         yaw_xmlport,          xmlelement, mode);
     138        XMLPortParamLoadOnly(WorldEntity, "pitch",       pitch_xmlport,        xmlelement, mode);
     139        XMLPortParamLoadOnly(WorldEntity, "roll",        roll_xmlport,         xmlelement, mode);
     140
     141        // Physics
     142        XMLPortParam(WorldEntity, "collisionType",     setCollisionTypeStr,  getCollisionTypeStr,  xmlelement, mode);
     143        XMLPortParam(WorldEntity, "collisionResponse", setCollisionResponse, hasCollisionResponse, xmlelement, mode);
     144        XMLPortParam(WorldEntity, "mass",              setMass,              getMass,              xmlelement, mode);
     145        XMLPortParam(WorldEntity, "restitution",       setRestitution,       getRestitution,       xmlelement, mode);
     146        XMLPortParam(WorldEntity, "angularFactor",     setAngularFactor,     getAngularFactor,     xmlelement, mode);
     147        XMLPortParam(WorldEntity, "linearDamping",     setLinearDamping,     getLinearDamping,     xmlelement, mode);
     148        XMLPortParam(WorldEntity, "angularDamping",    setAngularDamping,    getAngularDamping,    xmlelement, mode);
     149        XMLPortParam(WorldEntity, "friction",          setFriction,          getFriction,          xmlelement, mode);
     150
     151        // Other attached WorldEntities
    93152        XMLPortObject(WorldEntity, WorldEntity, "attached", attach, getAttachedObject, xmlelement, mode);
     153        // Attached collision shapes
     154        XMLPortObject(WorldEntity, CollisionShape, "collisionShapes", attachCollisionShape, getAttachedCollisionShape, xmlelement, mode);
    94155    }
    95156
    96157    void WorldEntity::registerVariables()
    97158    {
    98         REGISTERDATA(this->bActive_,  direction::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedActivity));
    99         REGISTERDATA(this->bVisible_, direction::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedVisibility));
    100 
    101         REGISTERDATA(this->getScale3D().x, direction::toclient);
    102         REGISTERDATA(this->getScale3D().y, direction::toclient);
    103         REGISTERDATA(this->getScale3D().z, direction::toclient);
    104 
    105         REGISTERDATA(this->parentID_, direction::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::updateParent));
    106     }
    107 
    108     void WorldEntity::updateParent()
     159        registerVariable(this->mainStateName_,  variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedMainState));
     160
     161        registerVariable(this->bActive_,        variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedActivity));
     162        registerVariable(this->bVisible_,       variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedVisibility));
     163
     164        registerVariable(this->getScale3D(),    variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::scaleChanged));
     165
     166        // Physics stuff
     167        registerVariable(this->mass_,           variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::massChanged));
     168        registerVariable(this->restitution_,    variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::restitutionChanged));
     169        registerVariable(this->angularFactor_,  variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::angularFactorChanged));
     170        registerVariable(this->linearDamping_,  variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::linearDampingChanged));
     171        registerVariable(this->angularDamping_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::angularDampingChanged));
     172        registerVariable(this->friction_,       variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::frictionChanged));
     173        registerVariable(this->bCollisionCallbackActive_,
     174                                                variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::collisionCallbackActivityChanged));
     175        registerVariable(this->bCollisionResponseActive_,
     176                                                variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::collisionResponseActivityChanged));
     177        registerVariable((int&)this->collisionTypeSynchronised_,
     178                                                variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::collisionTypeChanged));
     179        registerVariable(this->bPhysicsActiveSynchronised_,
     180                                                variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::physicsActivityChanged));
     181
     182        // Attach to parent if necessary
     183        registerVariable(this->parentID_,       variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::parentChanged));
     184    }
     185
     186    /**
     187    @brief
     188        Network function that object this instance to its correct parent.
     189    */
     190    void WorldEntity::parentChanged()
    109191    {
    110192        if (this->parentID_ != OBJECTID_UNKNOWN)
     
    116198    }
    117199
     200    /**
     201    @brief
     202        Attaches this object to a parent SceneNode.
     203    @Remarks
     204        Only use this method if you know exactly what you're doing!
     205        Normally, attaching works internally by attaching WE's.
     206    */
     207    void WorldEntity::attachToNode(Ogre::SceneNode* node)
     208    {
     209        Ogre::Node* parent = this->node_->getParent();
     210        if (parent)
     211            parent->removeChild(this->node_);
     212        node->addChild(this->node_);
     213    }
     214
     215    /**
     216    @brief
     217        Detaches this object from a parent SceneNode.
     218    @Remarks
     219        Only use this method if you know exactly what you're doing!
     220        Normally, attaching works internally by attaching WE's.
     221    */
     222    void WorldEntity::detachFromNode(Ogre::SceneNode* node)
     223    {
     224        node->removeChild(this->node_);
     225//        this->getScene()->getRootSceneNode()->addChild(this->node_);
     226    }
     227
     228    /**
     229    @brief
     230        Network callback for the collision type. Only change the type if it was valid.
     231    */
     232    void WorldEntity::collisionTypeChanged()
     233    {
     234        if (this->collisionTypeSynchronised_ != Dynamic &&
     235            this->collisionTypeSynchronised_ != Kinematic &&
     236            this->collisionTypeSynchronised_ != Static &&
     237            this->collisionTypeSynchronised_ != None)
     238        {
     239            CCOUT(1) << "Error when collsion Type was received over network. Unknown enum value:" << this->collisionTypeSynchronised_ << std::endl;
     240        }
     241        else if (this->collisionTypeSynchronised_ != collisionType_)
     242        {
     243            if (this->parent_)
     244                CCOUT(2) << "Warning: Network connection tried to set the collision type of an attached WE. Ignoring." << std::endl;
     245            else
     246                this->setCollisionType(this->collisionTypeSynchronised_);
     247        }
     248    }
     249
     250    //! Network callback for this->bPhysicsActive_
     251    void WorldEntity::physicsActivityChanged()
     252    {
     253        if (this->bPhysicsActiveSynchronised_)
     254            this->activatePhysics();
     255        else
     256            this->deactivatePhysics();
     257    }
     258
     259    //! Function sets whether Bullet should issue a callback on collisions
     260    void WorldEntity::collisionCallbackActivityChanged()
     261    {
     262        if (this->hasPhysics())
     263        {
     264            if (this->bCollisionCallbackActive_)
     265                this->physicalBody_->setCollisionFlags(this->physicalBody_->getCollisionFlags() |
     266                    btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
     267            else
     268                this->physicalBody_->setCollisionFlags(this->physicalBody_->getCollisionFlags() &
     269                    ~btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK);
     270        }
     271    }
     272
     273    //! Function sets whether Bullet should react itself to a collision
     274    void WorldEntity::collisionResponseActivityChanged()
     275    {
     276        if (this->hasPhysics())
     277        {
     278            if (this->bCollisionResponseActive_)
     279                this->physicalBody_->setCollisionFlags(this->physicalBody_->getCollisionFlags() &
     280                    ~btCollisionObject::CF_NO_CONTACT_RESPONSE);
     281            else
     282                this->physicalBody_->setCollisionFlags(this->physicalBody_->getCollisionFlags() |
     283                    btCollisionObject::CF_NO_CONTACT_RESPONSE);
     284        }
     285    }
     286
     287    /**
     288    @brief
     289        Attaches a child WorldEntity to this object. This calls notifyBeingAttached()
     290        of the child WE.
     291    @Note
     292        The collision shape of the child object gets attached nevertheless. That also means
     293        that you can change the collision shape of the child and it correctly cascadeds the changes to this instance.
     294        Be aware of this implication: When implementing attaching of kinematic objects to others, you have to change
     295        this behaviour because you then might not want to merge the collision shapes.
     296    */
    118297    void WorldEntity::attach(WorldEntity* object)
    119298    {
    120         if (object->getParent())
    121             object->detachFromParent();
    122         else
    123         {
    124             Ogre::Node* parent = object->node_->getParent();
    125             if (parent)
    126                 parent->removeChild(object->node_);
    127         }
    128 
    129         this->node_->addChild(object->node_);
     299        if (object == this)
     300        {
     301            COUT(2) << "Warning: Can't attach a WorldEntity to itself." << std::endl;
     302            return;
     303        }
     304
     305        if (!object->notifyBeingAttached(this))
     306            return;
     307
     308        this->attachNode(object->node_);
    130309        this->children_.insert(object);
    131         object->parent_ = this;
    132         object->parentID_ = this->getObjectID();
    133     }
    134 
     310
     311        this->attachCollisionShape(object->collisionShape_);
     312        // mass
     313        this->childrenMass_ += object->getMass();
     314        recalculateMassProps();
     315    }
     316
     317    /**
     318    @brief
     319        Function gets called when this object is being attached to a new parent.
     320
     321        This operation is only allowed if the collision types "like" each other.
     322        - You cannot a attach a non physical object to a physical one.
     323        - Dynamic object can NOT be attached at all.
     324        - It is also not possible to attach a kinematic to a dynamic one.
     325        - Attaching of kinematic objects otherwise is not yet supported.
     326    */
     327    bool WorldEntity::notifyBeingAttached(WorldEntity* newParent)
     328    {
     329        // check first whether attaching is even allowed
     330        if (this->hasPhysics())
     331        {
     332            if (!newParent->hasPhysics())
     333            {
     334                COUT(2) << "Warning: Cannot attach a physical object to a non physical one." << std::endl;
     335                return false;
     336            }
     337            else if (this->isDynamic())
     338            {
     339                COUT(2) << "Warning: Cannot attach a dynamic object to a WorldEntity." << std::endl;
     340                return false;
     341            }
     342            else if (this->isKinematic() && newParent->isDynamic())
     343            {
     344                COUT(2) << "Warning: Cannot attach a kinematic object to a dynamic one." << std::endl;
     345                return false;
     346            }
     347            else if (this->isKinematic())
     348            {
     349                COUT(2) << "Warning: Cannot attach a kinematic object to a static or kinematic one: Not yet implemented." << std::endl;
     350                return false;
     351            }
     352        }
     353
     354        if (this->isPhysicsActive())
     355            this->bPhysicsActiveBeforeAttaching_ = true;
     356        this->deactivatePhysics();
     357
     358        if (this->parent_)
     359            this->detachFromParent();
     360
     361        this->parent_ = newParent;
     362        this->parentID_ = newParent->getObjectID();
     363
     364        // apply transform to collision shape
     365        this->collisionShape_->setPosition(this->getPosition());
     366        this->collisionShape_->setOrientation(this->getOrientation());
     367        // TODO: Scale
     368       
     369        return true;
     370    }
     371
     372    /**
     373    @brief
     374        Detaches a child WorldEntity from this instance.
     375    */
    135376    void WorldEntity::detach(WorldEntity* object)
    136377    {
    137         this->node_->removeChild(object->node_);
     378        if (this->children_.find(object) == this->children_.end())
     379        {
     380            CCOUT(2) << "Warning: Cannot detach an object that is not a child." << std::endl;
     381            return;
     382        }
     383
     384        // collision shapes
     385        this->detachCollisionShape(object->collisionShape_);
     386
     387        // mass
     388        if (object->getMass() > 0.0f)
     389        {
     390            this->childrenMass_ -= object->getMass();
     391            recalculateMassProps();
     392        }
     393
     394        this->detachNode(object->node_);
    138395        this->children_.erase(object);
    139         object->parent_ = 0;
    140         object->parentID_ = OBJECTID_UNKNOWN;
    141 
    142 //        this->getScene()->getRootSceneNode()->addChild(object->node_);
    143     }
    144 
    145     WorldEntity* WorldEntity::getAttachedObject(unsigned int index) const
     396
     397        object->notifyDetached();
     398    }
     399
     400    /**
     401    @brief
     402        Function gets called when the object has been detached from its parent.
     403    */
     404    void WorldEntity::notifyDetached()
     405    {
     406        this->parent_ = 0;
     407        this->parentID_ = OBJECTID_UNKNOWN;
     408
     409        // reset orientation of the collisionShape (cannot be set within a WE usually)
     410        this->collisionShape_->setPosition(Vector3::ZERO);
     411        this->collisionShape_->setOrientation(Quaternion::IDENTITY);
     412        // TODO: Scale
     413
     414        if (this->bPhysicsActiveBeforeAttaching_)
     415        {
     416            this->activatePhysics();
     417            this->bPhysicsActiveBeforeAttaching_ = false;
     418        }
     419    }
     420
     421    //! Returns an attached object (merely for XMLPort).
     422    WorldEntity* WorldEntity::getAttachedObject(unsigned int index)
    146423    {
    147424        unsigned int i = 0;
     
    154431        return 0;
    155432    }
     433
     434    //! Attaches an Ogre::SceneNode to this WorldEntity.
     435    void WorldEntity::attachNode(Ogre::SceneNode* node)
     436    {
     437        Ogre::Node* parent = node->getParent();
     438        if (parent)
     439            parent->removeChild(node);
     440        this->node_->addChild(node);
     441    }
     442
     443    //! Detaches an Ogre::SceneNode from this WorldEntity.
     444    void WorldEntity::detachNode(Ogre::SceneNode* node)
     445    {
     446        this->node_->removeChild(node);
     447//        this->getScene()->getRootSceneNode()->addChild(node);
     448    }
     449
     450    //! Attaches an Ogre::MovableObject to this WorldEntity.
     451    void WorldEntity::attachOgreObject(Ogre::MovableObject* object)
     452    {
     453        this->node_->attachObject(object);
     454    }
     455
     456    //! Detaches an Ogre::MovableObject from this WorldEntity.
     457    void WorldEntity::detachOgreObject(Ogre::MovableObject* object)
     458    {
     459        this->node_->detachObject(object);
     460    }
     461
     462    //! Detaches an Ogre::MovableObject (by string) from this WorldEntity.
     463    Ogre::MovableObject* WorldEntity::detachOgreObject(const Ogre::String& name)
     464    {
     465        return this->node_->detachObject(name);
     466    }
     467
     468    //! Attaches a collision Shape to this object (delegated to the internal CompoundCollisionShape)
     469    void WorldEntity::attachCollisionShape(CollisionShape* shape)
     470    {
     471        this->collisionShape_->attach(shape);
     472        // Note: this->collisionShape_ already notifies us of any changes.
     473    }
     474
     475    //! Detaches a collision Shape from this object (delegated to the internal CompoundCollisionShape)
     476    void WorldEntity::detachCollisionShape(CollisionShape* shape)
     477    {
     478        // Note: The collision shapes may not be detached with this function!
     479        this->collisionShape_->detach(shape);
     480        // Note: this->collisionShape_ already notifies us of any changes.
     481    }
     482
     483    //! Returns an attached collision Shape of this object (delegated to the internal CompoundCollisionShape)
     484    CollisionShape* WorldEntity::getAttachedCollisionShape(unsigned int index)
     485    {
     486        return this->collisionShape_->getAttachedShape(index);
     487    }
     488
     489    // Note: These functions are placed in WorldEntity.h as inline functions for the release build.
     490#ifndef _NDEBUG
     491    const Vector3& WorldEntity::getPosition() const
     492    {
     493        return this->node_->getPosition();
     494    }
     495
     496    const Quaternion& WorldEntity::getOrientation() const
     497    {
     498        return this->node_->getOrientation();
     499    }
     500
     501    const Vector3& WorldEntity::getScale3D() const
     502    {
     503        return this->node_->getScale();
     504    }
     505#endif
     506
     507    //! Returns the position relative to the root space
     508    const Vector3& WorldEntity::getWorldPosition() const
     509    {
     510        return this->node_->_getDerivedPosition();
     511    }
     512
     513    //! Returns the orientation relative to the root space
     514    const Quaternion& WorldEntity::getWorldOrientation() const
     515    {
     516        return this->node_->_getDerivedOrientation();
     517    }
     518
     519    //! Returns the scaling applied relative to the root space in 3 coordinates
     520    const Vector3& WorldEntity::getWorldScale3D() const
     521    {
     522        return this->node_->_getDerivedScale();
     523    }
     524
     525    /**
     526    @brief
     527        Returns the scaling applied relative to the root space in 3 coordinates
     528    @return
     529        Returns the scaling if it is uniform, 1.0f otherwise.
     530    */
     531    float WorldEntity::getWorldScale() const
     532    {
     533        Vector3 scale = this->getWorldScale3D();
     534        return (scale.x == scale.y && scale.x == scale.z) ? scale.x : 1;
     535    }
     536
     537    /**
     538    @brief
     539        Sets the three dimensional scaling of this object.
     540    @Note
     541        Scaling physical objects has not yet been implemented and is therefore forbidden.
     542    */
     543    void WorldEntity::setScale3D(const Vector3& scale)
     544    {
     545/*
     546HACK HACK HACK
     547        if (bScalePhysics && this->hasPhysics() && scale != Vector3::UNIT_SCALE)
     548        {
     549            CCOUT(2) << "Warning: Cannot set the scale of a physical object: Not yet implemented. Ignoring scaling." << std::endl;
     550            return;
     551        }
     552HACK HACK HACK
     553*/
     554        this->node_->setScale(scale);
     555
     556        this->changedScale();
     557    }
     558
     559    /**
     560    @brief
     561        Translates this WorldEntity by a vector.
     562    @param relativeTo
     563        @see TransformSpace::Enum
     564    */
     565    void WorldEntity::translate(const Vector3& distance, TransformSpace::Enum relativeTo)
     566    {
     567        switch (relativeTo)
     568        {
     569        case TransformSpace::Local:
     570            // position is relative to parent so transform downwards
     571            this->setPosition(this->getPosition() + this->getOrientation() * distance);
     572            break;
     573        case TransformSpace::Parent:
     574            this->setPosition(this->getPosition() + distance);
     575            break;
     576        case TransformSpace::World:
     577            // position is relative to parent so transform upwards
     578            if (this->node_->getParent())
     579                setPosition(getPosition() + (node_->getParent()->_getDerivedOrientation().Inverse() * distance)
     580                    / node_->getParent()->_getDerivedScale());
     581            else
     582                this->setPosition(this->getPosition() + distance);
     583            break;
     584        }
     585    }
     586
     587    /**
     588    @brief
     589        Rotates this WorldEntity by a quaternion.
     590    @param relativeTo
     591        @see TransformSpace::Enum
     592    */
     593    void WorldEntity::rotate(const Quaternion& rotation, TransformSpace::Enum relativeTo)
     594    {
     595        switch(relativeTo)
     596        {
     597        case TransformSpace::Local:
     598            this->setOrientation(this->getOrientation() * rotation);
     599            break;
     600        case TransformSpace::Parent:
     601            // Rotations are normally relative to local axes, transform up
     602            this->setOrientation(rotation * this->getOrientation());
     603            break;
     604        case TransformSpace::World:
     605            // Rotations are normally relative to local axes, transform up
     606            this->setOrientation(this->getOrientation() * this->getWorldOrientation().Inverse()
     607                * rotation * this->getWorldOrientation());
     608            break;
     609        }
     610    }
     611
     612    /**
     613    @brief
     614        Makes this WorldEntity look a specific target location.
     615    @param relativeTo
     616        @see TransformSpace::Enum
     617    @param localDirectionVector
     618        The vector which normally describes the natural direction of the object, usually -Z.
     619    */
     620    void WorldEntity::lookAt(const Vector3& target, TransformSpace::Enum relativeTo, const Vector3& localDirectionVector)
     621    {
     622        Vector3 origin;
     623        switch (relativeTo)
     624        {
     625        case TransformSpace::Local:
     626            origin = Vector3::ZERO;
     627            break;
     628        case TransformSpace::Parent:
     629            origin = this->getPosition();
     630            break;
     631        case TransformSpace::World:
     632            origin = this->getWorldPosition();
     633            break;
     634        }
     635        this->setDirection(target - origin, relativeTo, localDirectionVector);
     636    }
     637
     638    /**
     639    @brief
     640        Makes this WorldEntity look in specific direction.
     641    @param relativeTo
     642        @see TransformSpace::Enum
     643    @param localDirectionVector
     644        The vector which normally describes the natural direction of the object, usually -Z.
     645    */
     646    void WorldEntity::setDirection(const Vector3& direction, TransformSpace::Enum relativeTo, const Vector3& localDirectionVector)
     647    {
     648        Quaternion savedOrientation(this->getOrientation());
     649        Ogre::Node::TransformSpace ogreRelativeTo;
     650        switch (relativeTo)
     651        {
     652        case TransformSpace::Local:
     653            ogreRelativeTo = Ogre::Node::TS_LOCAL; break;
     654        case TransformSpace::Parent:
     655            ogreRelativeTo = Ogre::Node::TS_PARENT; break;
     656        case TransformSpace::World:
     657            ogreRelativeTo = Ogre::Node::TS_WORLD; break;
     658        }
     659        this->node_->setDirection(direction, ogreRelativeTo, localDirectionVector);
     660        Quaternion newOrientation(this->node_->getOrientation());
     661        this->node_->setOrientation(savedOrientation);
     662        this->setOrientation(newOrientation);
     663    }
     664
     665    //! Activates physics if the CollisionType is not None.
     666    void WorldEntity::activatePhysics()
     667    {
     668        if (this->isActive() && this->hasPhysics() && !this->isPhysicsActive() && !this->parent_)
     669        {
     670            this->getScene()->addPhysicalObject(this);
     671            this->bPhysicsActive_ = true;
     672            this->bPhysicsActiveSynchronised_ = true;
     673        }
     674    }
     675
     676    //! Deactivates physics but the CollisionType does not change.
     677    void WorldEntity::deactivatePhysics()
     678    {
     679        if (this->isPhysicsActive())
     680        {
     681            this->getScene()->removePhysicalObject(this);
     682            this->bPhysicsActive_ = false;
     683            this->bPhysicsActiveSynchronised_ = false;
     684        }
     685    }
     686
     687    //! Tells whether the object has already been added to the Bullet physics World.
     688    bool WorldEntity::addedToPhysicalWorld() const
     689    {
     690        return this->physicalBody_ && this->physicalBody_->isInWorld();
     691    }
     692
     693    /**
     694    @brief
     695        Sets the CollisionType. This alters the object significantly! @see CollisionType.
     696    @Note
     697        Operation does not work on attached WorldEntities.
     698    */
     699    void WorldEntity::setCollisionType(CollisionType type)
     700    {
     701        if (this->collisionType_ == type)
     702            return;
     703
     704        // If we are already attached to a parent, this would be a bad idea..
     705        if (this->parent_)
     706        {
     707            CCOUT(2) << "Warning: Cannot set the collision type of a WorldEntity with a parent." << std::endl;
     708            return;
     709        }
     710
     711        // Check for type legality. Could be StaticEntity or MobileEntity.
     712        if (!this->isCollisionTypeLegal(type))
     713            return;
     714
     715        if (this->isPhysicsActive())
     716            this->deactivatePhysics();
     717
     718        bool bReactivatePhysics = true;
     719        if (this->hasPhysics() && !this->isPhysicsActive())
     720            bReactivatePhysics = false;
     721
     722        // Check whether we have to create or destroy.
     723        if (type != None && this->collisionType_ == None)
     724        {
     725/*
     726HACK HACK HACK
     727            // Check whether there was some scaling applied.
     728            if (!this->node_->getScale().positionEquals(Vector3(1, 1, 1), 0.001))
     729            {
     730                CCOUT(2) << "Warning: Cannot create a physical body if there is scaling applied to the node: Not yet implemented." << std::endl;
     731                return;
     732            }
     733HACK HACK HACK
     734*/
     735            // Create new rigid body
     736            btRigidBody::btRigidBodyConstructionInfo bodyConstructionInfo(0, this, this->collisionShape_->getCollisionShape());
     737            this->physicalBody_ = new btRigidBody(bodyConstructionInfo);
     738            this->physicalBody_->setUserPointer(this);
     739            this->physicalBody_->setActivationState(DISABLE_DEACTIVATION);
     740        }
     741        else if (type == None && this->collisionType_ != None)
     742        {
     743            // Destroy rigid body
     744            assert(this->physicalBody_);
     745            deactivatePhysics();
     746            delete this->physicalBody_;
     747            this->physicalBody_ = 0;
     748            this->collisionType_ = None;
     749            this->collisionTypeSynchronised_ = None;
     750            return;
     751        }
     752
     753        // Change type
     754        switch (type)
     755        {
     756        case Dynamic:
     757            this->physicalBody_->setCollisionFlags(this->physicalBody_->getCollisionFlags() & !(btCollisionObject::CF_STATIC_OBJECT | btCollisionObject::CF_KINEMATIC_OBJECT));
     758            break;
     759        case Kinematic:
     760            this->physicalBody_->setCollisionFlags(this->physicalBody_->getCollisionFlags() & !btCollisionObject::CF_STATIC_OBJECT | btCollisionObject::CF_KINEMATIC_OBJECT);
     761            break;
     762        case Static:
     763            this->physicalBody_->setCollisionFlags(this->physicalBody_->getCollisionFlags() & !btCollisionObject::CF_KINEMATIC_OBJECT | btCollisionObject::CF_STATIC_OBJECT);
     764            break;
     765        case None:
     766            assert(false); // Doesn't happen
     767            return;
     768        }
     769        this->collisionType_ = type;
     770        this->collisionTypeSynchronised_ = type;
     771
     772        // update mass and inertia tensor
     773        recalculateMassProps();
     774        internalSetPhysicsProps();
     775        collisionCallbackActivityChanged();
     776        collisionResponseActivityChanged();
     777        if (bReactivatePhysics)
     778            activatePhysics();
     779    }
     780
     781    //! Sets the CollisionType by string (used for the XMLPort)
     782    void WorldEntity::setCollisionTypeStr(const std::string& typeStr)
     783    {
     784        std::string typeStrLower = getLowercase(typeStr);
     785        CollisionType type;
     786        if (typeStrLower == "dynamic")
     787            type = Dynamic;
     788        else if (typeStrLower == "static")
     789            type = Static;
     790        else if (typeStrLower == "kinematic")
     791            type = Kinematic;
     792        else if (typeStrLower == "none")
     793            type = None;
     794        else
     795            ThrowException(ParseError, std::string("Attempting to set an unknown collision type: '") + typeStr + "'.");
     796        this->setCollisionType(type);
     797    }
     798
     799    //! Gets the CollisionType by string (used for the XMLPort)
     800    std::string WorldEntity::getCollisionTypeStr() const
     801    {
     802        switch (this->getCollisionType())
     803        {
     804            case Dynamic:
     805                return "dynamic";
     806            case Kinematic:
     807                return "kinematic";
     808            case Static:
     809                return "static";
     810            case None:
     811                return "none";
     812            default:
     813                assert(false);
     814                return "";
     815        }
     816    }
     817
     818    /**
     819    @brief
     820        Recalculates the accumulated child mass and calls recalculateMassProps()
     821        and notifies the parent of the change.
     822    @Note
     823        Called by a child WE
     824    */
     825    void WorldEntity::notifyChildMassChanged()
     826    {
     827        // Note: CollisionShape changes of a child get handled over the internal CompoundCollisionShape already
     828        // Recalculate mass
     829        this->childrenMass_ = 0.0f;
     830        for (std::set<WorldEntity*>::const_iterator it = this->children_.begin(); it != this->children_.end(); ++it)
     831            this->childrenMass_ += (*it)->getMass();
     832        recalculateMassProps();
     833        // Notify parent WE
     834        if (this->parent_)
     835            parent_->notifyChildMassChanged();
     836    }
     837
     838    /**
     839    @brief
     840        Undertakes the necessary steps to change the collision shape in Bullet, even at runtime.
     841    @Note
     842        - called by this->collisionShape_
     843        - May have a REALLY big overhead when called continuously at runtime, because then we need
     844          to remove the physical body from Bullet and add it again.
     845    */
     846    void WorldEntity::notifyCollisionShapeChanged()
     847    {
     848        if (hasPhysics())
     849        {
     850            // Bullet doesn't like sudden changes of the collision shape, so we remove and add it again
     851            if (this->addedToPhysicalWorld())
     852            {
     853                this->deactivatePhysics();
     854                this->physicalBody_->setCollisionShape(this->collisionShape_->getCollisionShape());
     855                this->activatePhysics();
     856            }
     857            else
     858                this->physicalBody_->setCollisionShape(this->collisionShape_->getCollisionShape());
     859        }
     860        recalculateMassProps();
     861    }
     862
     863    //! Updates all mass dependent parameters (mass, inertia tensor and child mass)
     864    void WorldEntity::recalculateMassProps()
     865    {
     866        // Store local inertia for faster access. Evaluates to (0,0,0) if there is no collision shape.
     867        float totalMass = this->mass_ + this->childrenMass_;
     868        this->collisionShape_->calculateLocalInertia(totalMass, this->localInertia_);
     869        if (this->hasPhysics())
     870        {
     871            if (this->isStatic())
     872            {
     873                // Just set everything to zero
     874                this->physicalBody_->setMassProps(0.0f, btVector3(0, 0, 0));
     875            }
     876            else if ((this->mass_ + this->childrenMass_) == 0.0f)
     877            {
     878                // Use default values to avoid very large or very small values
     879                CCOUT(4) << "Warning: Setting the internal physical mass to 1.0 because mass_ is 0.0" << std::endl;
     880                btVector3 inertia(0, 0, 0);
     881                this->collisionShape_->calculateLocalInertia(1.0f, inertia);
     882                this->physicalBody_->setMassProps(1.0f, inertia);
     883            }
     884            else
     885            {
     886                this->physicalBody_->setMassProps(totalMass, this->localInertia_);
     887            }
     888        }
     889    }
     890
     891    //! Copies our own parameters for restitution, angular factor, dampings and friction to the bullet rigid body.
     892    void WorldEntity::internalSetPhysicsProps()
     893    {
     894        if (this->hasPhysics())
     895        {
     896            this->physicalBody_->setRestitution(this->restitution_);
     897            this->physicalBody_->setAngularFactor(this->angularFactor_);
     898            this->physicalBody_->setDamping(this->linearDamping_, this->angularDamping_);
     899            this->physicalBody_->setFriction(this->friction_);
     900        }
     901    }
    156902}
  • code/trunk/src/orxonox/objects/worldentities/WorldEntity.h

    r2171 r2662  
    2222 *   Author:
    2323 *      Fabian 'x3n' Landau
     24 *      Reto Grieder (physics)
    2425 *   Co-authors:
    2526 *      ...
     
    3233#include "OrxonoxPrereqs.h"
    3334
    34 #define OGRE_FORCE_ANGLE_TYPES
    35 
     35#ifdef _NDEBUG
    3636#include <OgreSceneNode.h>
    37 
    38 #include "network/Synchronisable.h"
     37#else
     38#include <OgrePrerequisites.h>
     39#endif
     40#include "LinearMath/btMotionState.h"
     41
     42#include "util/Math.h"
    3943#include "core/BaseObject.h"
    40 #include "util/Math.h"
     44#include "network/synchronisable/Synchronisable.h"
    4145
    4246namespace orxonox
    4347{
    44     class _OrxonoxExport WorldEntity : public BaseObject, public Synchronisable
     48    /**
     49    @brief
     50        The WorldEntity represents everything that can be put in a Scene at a certain location.
     51
     52        It is supposed to be the base class of everything you would call an 'object' in a Scene.
     53        The class itself is abstract which means you cannot use it directly. You may use StaticEntity
     54        as the simplest derivative or (derived from MobileEntity) MovableEntity and ControllableEntity
     55        as more advanced ones.
     56
     57        The basic task of the WorldEntity is provide a location, a direction and a scaling and the possibility
     58        to create an entire hierarchy of derivated objects.
     59        It is also the basis for the physics interface to the Bullet physics engine.
     60        Every WorldEntity can have a specific collision type: @see CollisionType
     61        This would then imply that every scene object could have any collision type. To limit this, you can always
     62        override this->isCollisionTypeLegal(CollisionType). Return false if the collision type is not supported
     63        for a specific object.
     64        There is also support for attaching WorldEntities with physics to each other. Currently, the collision shape
     65        of both objects simply get merged into one larger shape (for static collision type).
     66        The phyiscal body that is internally stored and administrated has the following supported properties:
     67        - Restitution, angular factor, linear damping, angular damping, fricition, mass and collision shape.
     68        You can get more information at the corresponding set function.
     69
     70        Collision shapes: These are controlled by the internal WorldEntityCollisionShape. @see WorldEntityCollisionShape.
     71    */
     72    class _OrxonoxExport WorldEntity : public BaseObject, public Synchronisable, public btMotionState
    4573    {
     74        friend class Scene;
     75
    4676        public:
    4777            WorldEntity(BaseObject* creator);
     
    5181            void registerVariables();
    5282
    53             inline Ogre::SceneNode* getNode() const
     83            inline const Ogre::SceneNode* getNode() const
    5484                { return this->node_; }
    5585
     
    6494            inline void setPosition(float x, float y, float z)
    6595                { this->setPosition(Vector3(x, y, z)); }
    66             inline const Vector3& getPosition() const
    67                 { return this->node_->getPosition(); }
    68             inline const Vector3& getWorldPosition() const
    69                 { return this->node_->getWorldPosition(); }
    70 
    71             virtual void translate(const Vector3& distance, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL) = 0;
    72             inline void translate(float x, float y, float z, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL)
     96            const Vector3& getPosition() const;
     97            const Vector3& getWorldPosition() const;
     98
     99            void translate(const Vector3& distance, TransformSpace::Enum relativeTo = TransformSpace::Parent);
     100            inline void translate(float x, float y, float z, TransformSpace::Enum relativeTo = TransformSpace::Parent)
    73101                { this->translate(Vector3(x, y, z), relativeTo); }
     102
     103            virtual inline const Vector3& getVelocity() const
     104                { return Vector3::ZERO; }
    74105
    75106            virtual void setOrientation(const Quaternion& orientation) = 0;
     
    80111            inline void setOrientation(const Vector3& axis, const Degree& angle)
    81112                { this->setOrientation(Quaternion(angle, axis)); }
    82             inline const Quaternion& getOrientation() const
    83                 { return this->node_->getOrientation(); }
    84             inline const Quaternion& getWorldOrientation() const
    85                 { return this->node_->getWorldOrientation(); }
    86 
    87             virtual void rotate(const Quaternion& rotation, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL) = 0;
    88             inline void rotate(const Vector3& axis, const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL)
     113            const Quaternion& getOrientation() const;
     114            const Quaternion& getWorldOrientation() const;
     115
     116            void rotate(const Quaternion& rotation, TransformSpace::Enum relativeTo = TransformSpace::Local);
     117            inline void rotate(const Vector3& axis, const Degree& angle, TransformSpace::Enum relativeTo = TransformSpace::Local)
    89118                { this->rotate(Quaternion(angle, axis), relativeTo); }
    90             inline void rotate(const Vector3& axis, const Radian& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL)
    91                 { this->rotate(Quaternion(angle, axis), relativeTo); }
    92 
    93             virtual void yaw(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL) = 0;
    94             inline void yaw(const Radian& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL)
    95                 { this->yaw(Degree(angle), relativeTo); }
    96             virtual void pitch(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL) = 0;
    97             inline void pitch(const Radian& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL)
    98                 { this->pitch(Degree(angle), relativeTo); }
    99             virtual void roll(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL) = 0;
    100             inline void roll(const Radian& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL)
    101                 { this->roll(Degree(angle), relativeTo); }
    102 
    103             virtual void lookAt(const Vector3& target, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z) = 0;
    104             virtual void setDirection(const Vector3& direction, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z) = 0;
    105             inline void setDirection(float x, float y, float z, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z)
     119
     120            inline void yaw(const Degree& angle, TransformSpace::Enum relativeTo = TransformSpace::Local)
     121                { this->rotate(Quaternion(angle, Vector3::UNIT_Y), relativeTo); }
     122            inline void pitch(const Degree& angle, TransformSpace::Enum relativeTo = TransformSpace::Local)
     123                { this->rotate(Quaternion(angle, Vector3::UNIT_X), relativeTo); }
     124            inline void roll(const Degree& angle, TransformSpace::Enum relativeTo = TransformSpace::Local)
     125                { this->rotate(Quaternion(angle, Vector3::UNIT_Z), relativeTo); }
     126
     127            void lookAt(const Vector3& target, TransformSpace::Enum relativeTo = TransformSpace::Parent, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);
     128            void setDirection(const Vector3& direction, TransformSpace::Enum relativeTo = TransformSpace::Local, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);
     129            inline void setDirection(float x, float y, float z, TransformSpace::Enum relativeTo = TransformSpace::Local, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z)
    106130                { this->setDirection(Vector3(x, y, z), relativeTo, localDirectionVector); }
    107131
    108             inline void setScale3D(const Vector3& scale)
    109                 { this->node_->setScale(scale); }
     132            virtual void setScale3D(const Vector3& scale);
    110133            inline void setScale3D(float x, float y, float z)
    111                 { this->node_->setScale(x, y, z); }
    112             inline const Vector3& getScale3D(void) const
    113                 { return this->node_->getScale(); }
     134                { this->setScale3D(Vector3(x, y, z)); }
     135            const Vector3& getScale3D(void) const;
     136            const Vector3& getWorldScale3D() const;
    114137
    115138            inline void setScale(float scale)
    116                 { this->node_->setScale(scale, scale, scale); }
     139                { this->setScale3D(scale, scale, scale); }
    117140            inline float getScale() const
    118141                { Vector3 scale = this->getScale3D(); return (scale.x == scale.y && scale.x == scale.z) ? scale.x : 1; }
     142            float getWorldScale() const;
    119143
    120144            inline void scale3D(const Vector3& scale)
    121                 { this->node_->scale(scale); }
     145                { this->setScale3D(this->getScale3D() * scale); }
    122146            inline void scale3D(float x, float y, float z)
    123                 { this->node_->scale(x, y, z); }
     147                { this->scale3D(Vector3(x, y, z)); }
    124148            inline void scale(float scale)
    125                 { this->node_->scale(scale, scale, scale); }
     149                { this->scale3D(scale, scale, scale); }
     150
     151            virtual void changedScale() {}
    126152
    127153            void attach(WorldEntity* object);
    128154            void detach(WorldEntity* object);
    129             WorldEntity* getAttachedObject(unsigned int index) const;
     155            WorldEntity* getAttachedObject(unsigned int index);
    130156            inline const std::set<WorldEntity*>& getAttachedObjects() const
    131157                { return this->children_; }
     158
     159            void attachOgreObject(Ogre::MovableObject* object);
     160            void detachOgreObject(Ogre::MovableObject* object);
     161            Ogre::MovableObject* detachOgreObject(const Ogre::String& name);
    132162
    133163            inline void attachToParent(WorldEntity* parent)
     
    138168                { return this->parent_; }
    139169
     170            void attachNode(Ogre::SceneNode* node);
     171            void detachNode(Ogre::SceneNode* node);
     172            void attachToNode(Ogre::SceneNode* node);
     173            void detachFromNode(Ogre::SceneNode* node);
     174
     175            void notifyChildPropsChanged();
     176
    140177        protected:
    141178            Ogre::SceneNode* node_;
    142179
    143180        private:
    144             void updateParent();
    145 
    146181            inline void lookAt_xmlport(const Vector3& target)
    147182                { this->lookAt(target); }
     
    155190                { this->roll(angle); }
    156191
     192            // network callbacks
     193            void parentChanged();
     194            inline void scaleChanged()
     195                { this->setScale3D(this->getScale3D()); }
     196
    157197            WorldEntity* parent_;
    158198            unsigned int parentID_;
    159199            std::set<WorldEntity*> children_;
     200
     201
     202        /////////////
     203        // Physics //
     204        /////////////
     205
     206        public:
     207            /**
     208            @brief
     209                Denotes the possible types of physical objects in a Scene.
     210
     211                Dynamic:   The object is influenced by its physical environment, like for instance little ball.
     212                Kinematic: The object can only influence other dynamic objects. It's movement is coordinated by your own saying.
     213                Static:    Like kinematic but the object is not allowed to move during the simulation.
     214                None:      The object has no physics at all.
     215            */
     216            enum CollisionType
     217            {
     218                Dynamic,
     219                Kinematic,
     220                Static,
     221                None
     222            };
     223
     224            //! Tells whether the object has any connection to the Bullet physics engine. If hasPhysics() is false, the object may still have a velocity.
     225            bool hasPhysics()       const { return getCollisionType() != None     ; }
     226            //! @see CollisionType
     227            bool isStatic()         const { return getCollisionType() == Static   ; }
     228            //! @see CollisionType
     229            bool isKinematic()      const { return getCollisionType() == Kinematic; }
     230            //! @see CollisionType
     231            bool isDynamic()        const { return getCollisionType() == Dynamic  ; }
     232            //! Tells whether physics has been activated (you can temporarily deactivate it)
     233            bool isPhysicsActive()  const { return this->bPhysicsActive_; }
     234            bool addedToPhysicalWorld() const;
     235
     236            void activatePhysics();
     237            void deactivatePhysics();
     238
     239            //! Returns the CollisionType. @see CollisionType.
     240            inline CollisionType getCollisionType() const
     241                { return this->collisionType_; }
     242            void setCollisionType(CollisionType type);
     243
     244            void setCollisionTypeStr(const std::string& type);
     245            std::string getCollisionTypeStr() const;
     246
     247            //! Sets the mass of this object. Note that the total mass may be influenced by attached objects!
     248            inline void setMass(float mass)
     249                { this->mass_ = mass; recalculateMassProps(); }
     250            //! Returns the mass of this object without its children.
     251            inline float getMass() const
     252                { return this->mass_; }
     253
     254            //! Returns the total mass of this object with all its attached children.
     255            inline float getTotalMass() const
     256                { return this->mass_ + this->childrenMass_; }
     257
     258            /**
     259            @brief
     260                Returns the diagonal elements of the inertia tensor when calculated in local coordinates.
     261            @Note
     262                The local inertia tensor cannot be set, but is calculated by Bullet according to the collisionShape.
     263                With compound collision shapes, an approximation is used.
     264            */
     265            inline const btVector3& getLocalInertia() const
     266                { return this->localInertia_; }
     267
     268            /**
     269            @brief
     270                Sets how much reaction is applied in a collision.
     271               
     272                Consider two equal spheres colliding with equal velocities:
     273                Restitution 1 means that both spheres simply reverse their velocity (no loss of energy)
     274                Restitution 0 means that both spheres will immediately stop moving
     275                (maximum loss of energy without violating of the preservation of momentum)
     276            */
     277            inline void setRestitution(float restitution)
     278                { this->restitution_ = restitution; internalSetPhysicsProps(); }
     279            //! Returns the restitution parameter. @see setRestitution.
     280            inline float getRestitution() const
     281                { return this->restitution_; }
     282
     283            /**
     284            @brief
     285                Sets an artificial parameter that tells how much torque is applied when you apply a non-central force.
     286
     287                Normally the angular factor is 1, which means it's physically 'correct'. Howerver if you have a player
     288                character that should not rotate when hit sideways, you can set the angular factor to 0.
     289            */
     290            inline void setAngularFactor(float angularFactor)
     291                { this->angularFactor_ = angularFactor; internalSetPhysicsProps(); }
     292            //! Returns the angular factor. @see setAngularFactor.
     293            inline float getAngularFactor() const
     294                { return this->angularFactor_; }
     295
     296            //! Applies a mass independent damping. Velocities will simply diminish exponentially.
     297            inline void setLinearDamping(float linearDamping)
     298                { this->linearDamping_ = linearDamping; internalSetPhysicsProps(); }
     299            //! Returns the linear damping. @see setLinearDamping.
     300            inline float getLinearDamping() const
     301                { return this->linearDamping_; }
     302
     303            //! Applies a tensor independent rotation damping. Angular velocities will simply diminish exponentially.
     304            inline void setAngularDamping(float angularDamping)
     305                { this->angularDamping_ = angularDamping; internalSetPhysicsProps(); }
     306            //! Returns the angular damping. @see setAngularDamping.
     307            inline float getAngularDamping() const
     308                { return this->angularDamping_; }
     309
     310            //! Applies friction to the object. Friction occurs when two objects collide.
     311            inline void setFriction(float friction)
     312                { this->friction_ = friction; internalSetPhysicsProps(); }
     313            //! Returns the amount of friction applied to the object.
     314            inline float getFriction() const
     315                { return this->friction_; }
     316
     317            void attachCollisionShape(CollisionShape* shape);
     318            void detachCollisionShape(CollisionShape* shape);
     319            CollisionShape* getAttachedCollisionShape(unsigned int index);
     320
     321            void notifyCollisionShapeChanged();
     322            void notifyChildMassChanged();
     323
     324            /**
     325            @brief
     326                Virtual function that gets called when this object collides with another.
     327            @param otherObject
     328                The object this one has collided into.
     329            @pram contactPoint
     330                Contact point provided by Bullet. Holds more information and can me modified. See return value.
     331            @Return
     332                Returning false means that no modification to the contactPoint has been made. Return true otherwise!
     333            @Note
     334                Condition is that enableCollisionCallback() was called.
     335            */
     336            virtual inline bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
     337                { return false; } /* With false, Bullet assumes no modification to the collision objects. */
     338
     339            //! Enables the collidesAgainst(.) function. The object doesn't respond to collision otherwise!
     340            inline void enableCollisionCallback()
     341                { this->bCollisionCallbackActive_ = true; this->collisionCallbackActivityChanged(); }
     342            //! Disables the collidesAgainst(.) function. @see enableCollisionCallback()
     343            inline void disableCollisionCallback()
     344                { this->bCollisionCallbackActive_ = false; this->collisionCallbackActivityChanged(); }
     345            //! Tells whether there could be a collision callback via collidesAgainst(.)
     346            inline bool isCollisionCallbackActive() const
     347                { return this->bCollisionCallbackActive_; }
     348
     349            //! Enables or disables collision response (default is of course on)
     350            inline void setCollisionResponse(bool value)
     351                { this->bCollisionResponseActive_ = value; this->collisionResponseActivityChanged(); }
     352            //! Tells whether there could be a collision response
     353            inline bool hasCollisionResponse()
     354                { return this->bCollisionResponseActive_; }
     355
     356        protected:
     357            /**
     358            @brief
     359                Function checks whether the requested collision type is legal to this object.
     360
     361                You can override this function in a derived class to constrain the collision to e.g. None or Dynamic.
     362                A projectile may not prove very useful if there is no physical body. Simply set the CollisionType
     363                in its constructor and override this method. But be careful that a derived classe's virtual functions
     364                don't yet exist in the constructor if a base class.
     365            */
     366            virtual bool isCollisionTypeLegal(CollisionType type) const = 0;
     367
     368            btRigidBody*  physicalBody_; //!< Bullet rigid body. Everything physical is applied to this instance.
     369
     370        private:
     371            void recalculateMassProps();
     372            void internalSetPhysicsProps();
     373
     374            bool notifyBeingAttached(WorldEntity* newParent);
     375            void notifyDetached();
     376
     377            // network callbacks
     378            void collisionTypeChanged();
     379            void physicsActivityChanged();
     380            void collisionCallbackActivityChanged();
     381            void collisionResponseActivityChanged();
     382            //! Network callback workaround to call a function when the value changes.
     383            inline void massChanged()
     384                { this->setMass(this->mass_); }
     385            //! Network callback workaround to call a function when the value changes.
     386            inline void restitutionChanged()
     387                { this->setRestitution(this->restitution_); }
     388            //! Network callback workaround to call a function when the value changes.
     389            inline void angularFactorChanged()
     390                { this->setAngularFactor(this->angularFactor_); }
     391            //! Network callback workaround to call a function when the value changes.
     392            inline void linearDampingChanged()
     393                { this->setLinearDamping(this->linearDamping_); }
     394            //! Network callback workaround to call a function when the value changes.
     395            inline void angularDampingChanged()
     396                { this->setAngularDamping(this->angularDamping_); }
     397            //! Network callback workaround to call a function when the value changes.
     398            inline void frictionChanged()
     399                { this->setFriction(this->friction_); }
     400
     401            CollisionType                collisionType_;                 //!< @see setCollisionType
     402            CollisionType                collisionTypeSynchronised_;     //!< Network synchronised variable for collisionType_
     403            bool                         bPhysicsActive_;                //!< @see isPhysicsActive
     404            bool                         bPhysicsActiveSynchronised_;    //!< Network synchronised variable for bPhysicsActive_
     405            //! When attaching objects hierarchically this variable tells this object (as child) whether physics was activated before attaching (because the deactivate physics while being attached).
     406            bool                         bPhysicsActiveBeforeAttaching_;
     407            WorldEntityCollisionShape*   collisionShape_;                //!< Attached collision shapes go here
     408            btScalar                     mass_;                          //!< @see setMass
     409            btVector3                    localInertia_;                  //!< @see getLocalInertia
     410            btScalar                     restitution_;                   //!< @see setRestitution
     411            btScalar                     angularFactor_;                 //!< @see setAngularFactor
     412            btScalar                     linearDamping_;                 //!< @see setLinearDamping
     413            btScalar                     angularDamping_;                //!< @see setAngularDamping
     414            btScalar                     friction_;                      //!< @see setFriction
     415            btScalar                     childrenMass_;                  //!< Sum of all the children's masses
     416            bool                         bCollisionCallbackActive_;      //!< @see enableCollisionCallback
     417            bool                         bCollisionResponseActive_;      //!< Tells whether the object should respond to collisions
    160418    };
     419
     420    // Inline heavily used functions for release builds. In debug, we better avoid including OgreSceneNode here.
     421#ifdef _NDEBUG
     422    inline const Vector3& WorldEntity::getPosition() const
     423        { return this->node_->getPosition(); }
     424    inline const Quaternion& WorldEntity::getOrientation() const
     425        { return this->node_->getrOrientation(); }
     426    inline const Vector3& WorldEntity::getScale3D(void) const
     427        { return this->node_->getScale(); }
     428#endif
     429
     430    SUPER_FUNCTION(5, WorldEntity, changedScale, false);
    161431}
    162432
  • code/trunk/src/orxonox/objects/worldentities/pawns/Pawn.cc

    r2171 r2662  
    3030#include "Pawn.h"
    3131
     32#include "core/Core.h"
    3233#include "core/CoreIncludes.h"
    3334#include "core/XMLPort.h"
    3435#include "util/Math.h"
     36#include "PawnManager.h"
    3537#include "objects/infos/PlayerInfo.h"
    3638#include "objects/gametypes/Gametype.h"
    37 #include "objects/weaponSystem/WeaponSystem.h"
     39#include "objects/worldentities/ParticleSpawner.h"
     40#include "objects/worldentities/ExplosionChunk.h"
    3841
    3942namespace orxonox
     
    4548        RegisterObject(Pawn);
    4649
    47         this->bAlive_ = false;
     50        PawnManager::touch();
     51        this->bAlive_ = true;
     52        this->fire_ = 0x0;
     53        this->firehack_ = 0x0;
    4854
    4955        this->health_ = 0;
     
    5258
    5359        this->lastHitOriginator_ = 0;
    54         this->weaponSystem_ = 0;
    55 
    56         /*
    57         //WeaponSystem
    58         weaponSystem_ = new WeaponSystem();
    59         WeaponSet * weaponSet1 = new WeaponSet(1);
    60         this->weaponSystem_->attachWeaponSet(weaponSet1);
    61         this->weaponSystem_->getWeaponSetPointer(0)->getWeaponSlotPointer(0)->setAmmoType(true);
    62         */
     60
     61        this->spawnparticleduration_ = 3.0f;
     62
     63        this->getPickUp().setPlayer(this);
     64
     65        if (Core::isMaster())
     66        {
     67            this->weaponSystem_ = new WeaponSystem(this);
     68            this->weaponSystem_->setParentPawn(this);
     69        }
     70        else
     71            this->weaponSystem_ = 0;
     72
     73        this->setRadarObjectColour(ColourValue::Red);
     74        this->setRadarObjectShape(RadarViewable::Dot);
    6375
    6476        this->registerVariables();
     
    6779    Pawn::~Pawn()
    6880    {
     81        if (this->isInitialized())
     82        {
     83            for (ObjectList<PawnListener>::iterator it = ObjectList<PawnListener>::begin(); it != ObjectList<PawnListener>::end(); ++it)
     84                it->destroyedPawn(this);
     85
     86            if (this->weaponSystem_)
     87                delete this->weaponSystem_;
     88        }
    6989    }
    7090
     
    7393        SUPER(Pawn, XMLPort, xmlelement, mode);
    7494
    75         XMLPortParam(Pawn, "health", setHealth, getHealht, xmlelement, mode).defaultValues(100);
     95        XMLPortParam(Pawn, "health", setHealth, getHealth, xmlelement, mode).defaultValues(100);
    7696        XMLPortParam(Pawn, "maxhealth", setMaxHealth, getMaxHealth, xmlelement, mode).defaultValues(200);
    7797        XMLPortParam(Pawn, "initialhealth", setInitialHealth, getInitialHealth, xmlelement, mode).defaultValues(100);
     98        XMLPortParam(Pawn, "spawnparticlesource", setSpawnParticleSource, getSpawnParticleSource, xmlelement, mode);
     99        XMLPortParam(Pawn, "spawnparticleduration", setSpawnParticleDuration, getSpawnParticleDuration, xmlelement, mode).defaultValues(3.0f);
     100        XMLPortParam(Pawn, "explosionchunks", setExplosionChunks, getExplosionChunks, xmlelement, mode).defaultValues(7);
     101
     102        XMLPortObject(Pawn, WeaponSlot, "weaponslots", setWeaponSlot, getWeaponSlot, xmlelement, mode);
     103        XMLPortObject(Pawn, WeaponSet, "weaponsets", setWeaponSet, getWeaponSet, xmlelement, mode);
     104        XMLPortObject(Pawn, WeaponPack, "weapons", setWeaponPack, getWeaponPack, xmlelement, mode);
    78105    }
    79106
    80107    void Pawn::registerVariables()
    81108    {
    82         REGISTERDATA(this->bAlive_, direction::toclient);
    83         REGISTERDATA(this->health_, direction::toclient);
     109        registerVariable(this->bAlive_,        variableDirection::toclient);
     110        registerVariable(this->health_,        variableDirection::toclient);
     111        registerVariable(this->initialHealth_, variableDirection::toclient);
     112        registerVariable(this->fire_,          variableDirection::toserver);
    84113    }
    85114
     
    87116    {
    88117        SUPER(Pawn, tick, dt);
     118
     119        if (this->weaponSystem_)
     120        {
     121            if (this->fire_ & WeaponMode::fire)
     122                this->weaponSystem_->fire(WeaponMode::fire);
     123            if (this->fire_ & WeaponMode::altFire)
     124                this->weaponSystem_->fire(WeaponMode::altFire);
     125            if (this->fire_ & WeaponMode::altFire2)
     126                this->weaponSystem_->fire(WeaponMode::altFire2);
     127        }
     128        this->fire_ = this->firehack_;
     129        this->firehack_ = 0x0;
    89130
    90131        if (this->health_ <= 0)
     
    119160    }
    120161
    121     void Pawn::spawn()
     162    void Pawn::spawneffect()
    122163    {
    123164        // play spawn effect
     165        if (this->spawnparticlesource_ != "")
     166        {
     167            ParticleSpawner* effect = new ParticleSpawner(this->getCreator());
     168            effect->setPosition(this->getPosition());
     169            effect->setOrientation(this->getOrientation());
     170            effect->setDestroyAfterLife(true);
     171            effect->setSource(this->spawnparticlesource_);
     172            effect->setLifetime(this->spawnparticleduration_);
     173        }
    124174    }
    125175
    126176    void Pawn::death()
    127177    {
     178        // Set bAlive_ to false and wait for PawnManager to do the destruction
    128179        this->bAlive_ = false;
     180
     181        this->setDestroyWhenPlayerLeft(false);
     182
    129183        if (this->getGametype())
    130184            this->getGametype()->pawnKilled(this, this->lastHitOriginator_);
     185
    131186        if (this->getPlayer())
    132187            this->getPlayer()->stopControl(this);
    133188
    134         delete this;
    135 
     189        if (Core::isMaster())
     190            this->deatheffect();
     191    }
     192
     193    void Pawn::deatheffect()
     194    {
    136195        // play death effect
    137     }
    138 
    139     void Pawn::fire()
    140     {
    141         if (this->weaponSystem_)
    142             this->weaponSystem_->fire();
     196        {
     197            ParticleSpawner* effect = new ParticleSpawner(this->getCreator());
     198            effect->setPosition(this->getPosition());
     199            effect->setOrientation(this->getOrientation());
     200            effect->setDestroyAfterLife(true);
     201            effect->setSource("Orxonox/explosion2b");
     202            effect->setLifetime(4.0f);
     203        }
     204        {
     205            ParticleSpawner* effect = new ParticleSpawner(this->getCreator());
     206            effect->setPosition(this->getPosition());
     207            effect->setOrientation(this->getOrientation());
     208            effect->setDestroyAfterLife(true);
     209            effect->setSource("Orxonox/smoke6");
     210            effect->setLifetime(4.0f);
     211        }
     212        {
     213            ParticleSpawner* effect = new ParticleSpawner(this->getCreator());
     214            effect->setPosition(this->getPosition());
     215            effect->setOrientation(this->getOrientation());
     216            effect->setDestroyAfterLife(true);
     217            effect->setSource("Orxonox/sparks");
     218            effect->setLifetime(4.0f);
     219        }
     220        for (unsigned int i = 0; i < this->numexplosionchunks_; ++i)
     221        {
     222            ExplosionChunk* chunk = new ExplosionChunk(this->getCreator());
     223            chunk->setPosition(this->getPosition());
     224
     225        }
     226    }
     227
     228    void Pawn::fire(WeaponMode::Enum fireMode)
     229    {
     230        this->firehack_ |= fireMode;
    143231    }
    144232
     
    146234    {
    147235        this->setHealth(this->initialHealth_);
    148         this->spawn();
     236        if (Core::isMaster())
     237            this->spawneffect();
     238    }
     239
     240    void Pawn::dropItems()
     241    {
     242        pickUp.eraseAll();
     243    }
     244
     245    void Pawn::setWeaponSlot(WeaponSlot * wSlot)
     246    {
     247        this->attach(wSlot);
     248        if (this->weaponSystem_)
     249            this->weaponSystem_->attachWeaponSlot(wSlot);
     250    }
     251
     252    WeaponSlot * Pawn::getWeaponSlot(unsigned int index) const
     253    {
     254        if (this->weaponSystem_)
     255            return this->weaponSystem_->getWeaponSlotPointer(index);
     256        else
     257            return 0;
     258    }
     259
     260    void Pawn::setWeaponPack(WeaponPack * wPack)
     261    {
     262        if (this->weaponSystem_)
     263        {
     264            wPack->setParentWeaponSystem(this->weaponSystem_);
     265            wPack->setParentWeaponSystemToAllWeapons(this->weaponSystem_);
     266            this->weaponSystem_->attachWeaponPack( wPack,wPack->getFireMode() );
     267            wPack->attachNeededMunitionToAllWeapons();
     268        }
     269    }
     270
     271    WeaponPack * Pawn::getWeaponPack(unsigned int firemode) const
     272    {
     273        if (this->weaponSystem_)
     274            return this->weaponSystem_->getWeaponPackPointer(firemode);
     275        else
     276            return 0;
     277    }
     278
     279    void Pawn::setWeaponSet(WeaponSet * wSet)
     280    {
     281        if (this->weaponSystem_)
     282            this->weaponSystem_->attachWeaponSet(wSet);
     283    }
     284
     285    WeaponSet * Pawn::getWeaponSet(unsigned int index) const
     286    {
     287        if (this->weaponSystem_)
     288            return this->weaponSystem_->getWeaponSetPointer(index);
     289        else
     290            return 0;
     291    }
     292
     293
     294    ///////////////////
     295    // Pawn Listener //
     296    ///////////////////
     297    PawnListener::PawnListener()
     298    {
     299        RegisterRootObject(PawnListener);
    149300    }
    150301}
  • code/trunk/src/orxonox/objects/worldentities/pawns/Pawn.h

    r2098 r2662  
    3131
    3232#include "OrxonoxPrereqs.h"
    33 
     33#include "objects/pickup/ShipEquipment.h"
    3434#include "objects/worldentities/ControllableEntity.h"
     35#include "objects/RadarViewable.h"
     36#include "objects/weaponSystem/WeaponSystem.h"
    3537
    3638namespace orxonox
    3739{
    38     class _OrxonoxExport Pawn : public ControllableEntity
     40    class _OrxonoxExport Pawn : public ControllableEntity, public RadarViewable
    3941    {
    4042        public:
     
    5456            inline void removeHealth(float health)
    5557                { this->setHealth(this->health_ - health); }
    56             inline float getHealht() const
     58            inline float getHealth() const
    5759                { return this->health_; }
    5860
     
    7476            virtual void kill();
    7577
    76             virtual void fire();
    77 
     78            virtual void fire(WeaponMode::Enum fireMode);
    7879            virtual void postSpawn();
    7980
     81            void setWeaponSlot(WeaponSlot * wSlot);
     82            WeaponSlot * getWeaponSlot(unsigned int index) const;
     83            void setWeaponPack(WeaponPack * wPack);
     84            WeaponPack * getWeaponPack(unsigned int firemode) const;
     85            void setWeaponSet(WeaponSet * wSet);
     86            WeaponSet * getWeaponSet(unsigned int index) const;
     87
     88            inline const WorldEntity* getWorldEntity() const
     89                { return const_cast<Pawn*>(this); }
     90
     91            inline void setSpawnParticleSource(const std::string& source)
     92                { this->spawnparticlesource_ = source; }
     93            inline const std::string& getSpawnParticleSource() const
     94                { return this->spawnparticlesource_; }
     95
     96            inline void setSpawnParticleDuration(float duration)
     97                { this->spawnparticleduration_ = duration; }
     98            inline float getSpawnParticleDuration() const
     99                { return this->spawnparticleduration_; }
     100
     101            inline void setExplosionChunks(unsigned int chunks)
     102                { this->numexplosionchunks_ = chunks; }
     103            inline unsigned int getExplosionChunks() const
     104                { return this->numexplosionchunks_; }
     105
     106            inline ShipEquipment& getPickUp()
     107                {return this->pickUp;}
     108
     109            virtual void dropItems();
     110
    80111        protected:
    81             virtual void spawn();
    82112            virtual void death();
     113            virtual void deatheffect();
     114            virtual void spawneffect();
    83115
     116            ShipEquipment pickUp;
    84117            bool bAlive_;
     118
    85119
    86120            float health_;
     
    91125
    92126            WeaponSystem* weaponSystem_;
     127            unsigned int fire_;
     128            unsigned int firehack_;
     129
     130            std::string spawnparticlesource_;
     131            float spawnparticleduration_;
     132            unsigned int numexplosionchunks_;
     133    };
     134
     135    class _OrxonoxExport PawnListener : virtual public OrxonoxClass
     136    {
     137        friend class Pawn;
     138
     139        public:
     140            PawnListener();
     141            virtual ~PawnListener() {}
     142
     143        protected:
     144            virtual void destroyedPawn(Pawn* pawn) = 0;
    93145    };
    94146}
  • code/trunk/src/orxonox/objects/worldentities/pawns/SpaceShip.cc

    r2171 r2662  
    3030#include "SpaceShip.h"
    3131
     32#include "BulletDynamics/Dynamics/btRigidBody.h"
     33
     34#include "util/Math.h"
     35#include "util/Exception.h"
    3236#include "core/CoreIncludes.h"
    3337#include "core/ConfigValueIncludes.h"
     38#include "core/Template.h"
    3439#include "core/XMLPort.h"
    35 #include "util/Math.h"
     40#include "objects/items/Engine.h"
    3641
    3742namespace orxonox
    3843{
     44    const float orientationGain = 100;
    3945    CreateFactory(SpaceShip);
    4046
     
    4349        RegisterObject(SpaceShip);
    4450
    45         this->zeroDegree_ = 0;
    46 
    47         this->maxSpeed_ = 0;
    48         this->maxSecondarySpeed_ = 0;
    49         this->maxRotation_ = 0;
    50         this->translationAcceleration_ = 0;
    51         this->rotationAcceleration_ = 0;
    52         this->translationDamping_ = 0;
    53 
    54         this->yawRotation_ = 0;
    55         this->pitchRotation_ = 0;
    56         this->rollRotation_ = 0;
     51        this->primaryThrust_  = 100;
     52        this->auxilaryThrust_ =  30;
     53        this->rotationThrust_ =  10;
     54
     55        this->localLinearAcceleration_.setValue(0, 0, 0);
     56        this->localAngularAcceleration_.setValue(0, 0, 0);
     57        this->bBoost_ = false;
     58        this->bPermanentBoost_ = false;
     59        this->steering_ = Vector3::ZERO;
     60        this->engine_ = 0;
     61
    5762
    5863        this->bInvertYAxis_ = false;
    5964
    6065        this->setDestroyWhenPlayerLeft(true);
     66
     67        // SpaceShip is always a physical object per default
     68        // Be aware of this call: The collision type legality check will not reach derived classes!
     69        this->setCollisionType(WorldEntity::Dynamic);
     70        // Get notification about collisions
     71        this->enableCollisionCallback();
    6172
    6273        this->setConfigValues();
     
    6677    SpaceShip::~SpaceShip()
    6778    {
     79        if (this->isInitialized() && this->engine_)
     80            delete this->engine_;
    6881    }
    6982
     
    7285        SUPER(SpaceShip, XMLPort, xmlelement, mode);
    7386
    74         XMLPortParam(SpaceShip, "maxspeed",          setMaxSpeed,          getMaxSpeed,          xmlelement, mode);
    75         XMLPortParam(SpaceShip, "maxsecondaryspeed", setMaxSecondarySpeed, getMaxSecondarySpeed, xmlelement, mode);
    76         XMLPortParam(SpaceShip, "maxrotation",       setMaxRotation,       getMaxRotation,       xmlelement, mode);
    77         XMLPortParam(SpaceShip, "transacc",          setTransAcc,          getTransAcc,          xmlelement, mode);
    78         XMLPortParam(SpaceShip, "rotacc",            setRotAcc,            getRotAcc,            xmlelement, mode);
    79         XMLPortParam(SpaceShip, "transdamp",         setTransDamp,         getTransDamp,         xmlelement, mode);
     87        XMLPortParam(SpaceShip, "engine",            setEngineTemplate,    getEngineTemplate,    xmlelement, mode);
     88        XMLPortParamVariable(SpaceShip, "primaryThrust",  primaryThrust_,  xmlelement, mode);
     89        XMLPortParamVariable(SpaceShip, "auxilaryThrust", auxilaryThrust_, xmlelement, mode);
     90        XMLPortParamVariable(SpaceShip, "rotationThrust", rotationThrust_, xmlelement, mode);
    8091    }
    8192
    8293    void SpaceShip::registerVariables()
    8394    {
    84         REGISTERDATA(this->maxSpeed_,                direction::toclient);
    85         REGISTERDATA(this->maxSecondarySpeed_,       direction::toclient);
    86         REGISTERDATA(this->maxRotation_,             direction::toclient);
    87         REGISTERDATA(this->translationAcceleration_, direction::toclient);
    88         REGISTERDATA(this->rotationAcceleration_,    direction::toclient);
    89         REGISTERDATA(this->translationDamping_,      direction::toclient);
     95        registerVariable(this->primaryThrust_,  variableDirection::toclient);
     96        registerVariable(this->auxilaryThrust_, variableDirection::toclient);
     97        registerVariable(this->rotationThrust_, variableDirection::toclient);
    9098    }
    9199
     
    95103    }
    96104
     105    bool SpaceShip::isCollisionTypeLegal(WorldEntity::CollisionType type) const
     106    {
     107        if (type != WorldEntity::Dynamic)
     108        {
     109            CCOUT(1) << "Error: Cannot tell a SpaceShip not to be dynamic! Ignoring." << std::endl;
     110            assert(false); // Only in debug mode
     111            return false;
     112        }
     113        else
     114            return true;
     115    }
     116
    97117    void SpaceShip::tick(float dt)
    98118    {
    99         if (this->isLocallyControlled())
     119        SUPER(SpaceShip, tick, dt);
     120
     121        if (this->hasLocalController())
    100122        {
    101             // #####################################
    102             // ############# STEERING ##############
    103             // #####################################
    104 
    105             Vector3 velocity = this->getVelocity();
    106             if (velocity.x > this->maxSecondarySpeed_)
    107                 velocity.x = this->maxSecondarySpeed_;
    108             if (velocity.x < -this->maxSecondarySpeed_)
    109                 velocity.x = -this->maxSecondarySpeed_;
    110             if (velocity.y > this->maxSecondarySpeed_)
    111                 velocity.y = this->maxSecondarySpeed_;
    112             if (velocity.y < -this->maxSecondarySpeed_)
    113                 velocity.y = -this->maxSecondarySpeed_;
    114             if (velocity.z > this->maxSecondarySpeed_)
    115                 velocity.z = this->maxSecondarySpeed_;
    116             if (velocity.z < -this->maxSpeed_)
    117                 velocity.z = -this->maxSpeed_;
    118 
    119             // normalize velocity and acceleration
    120             for (size_t dimension = 0; dimension < 3; ++dimension)
     123/*
     124            this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() * getMass() * this->auxilaryThrust_);
     125            this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() * getMass() * this->auxilaryThrust_);
     126            if (this->localLinearAcceleration_.z() > 0)
     127                this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->auxilaryThrust_);
     128            else
     129                this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->primaryThrust_);
     130            this->physicalBody_->applyCentralForce(physicalBody_->getWorldTransform().getBasis() * this->localLinearAcceleration_);
     131            this->localLinearAcceleration_.setValue(0, 0, 0);
     132*/
     133            if (!this->isInMouseLook())
    121134            {
    122                 if (this->acceleration_[dimension] == 0)
     135                this->localAngularAcceleration_ *= this->getLocalInertia() * this->rotationThrust_;
     136                this->physicalBody_->applyTorque(physicalBody_->getWorldTransform().getBasis() * this->localAngularAcceleration_);
     137                this->localAngularAcceleration_.setValue(0, 0, 0);
     138            }
     139        }
     140    }
     141
     142    void SpaceShip::moveFrontBack(const Vector2& value)
     143    {
     144        this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() - value.x);
     145        this->steering_.z = -value.x;
     146    }
     147
     148    void SpaceShip::moveRightLeft(const Vector2& value)
     149    {
     150        this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() + value.x);
     151        this->steering_.x = value.x;
     152    }
     153
     154    void SpaceShip::moveUpDown(const Vector2& value)
     155    {
     156        this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() + value.x);
     157        this->steering_.y = value.x;
     158    }
     159
     160    void SpaceShip::rotateYaw(const Vector2& value)
     161    {
     162        this->localAngularAcceleration_.setY(this->localAngularAcceleration_.y() - value.x);
     163
     164        Pawn::rotateYaw(value);
     165    }
     166
     167    void SpaceShip::rotatePitch(const Vector2& value)
     168    {
     169        this->localAngularAcceleration_.setX(this->localAngularAcceleration_.x() + value.x);
     170
     171        Pawn::rotatePitch(value);
     172    }
     173
     174    void SpaceShip::rotateRoll(const Vector2& value)
     175    {
     176        this->localAngularAcceleration_.setZ(this->localAngularAcceleration_.z() + value.x);
     177
     178        Pawn::rotateRoll(value);
     179    }
     180
     181    void SpaceShip::fire()
     182    {
     183    }
     184
     185    void SpaceShip::boost()
     186    {
     187        this->bBoost_ = true;
     188    }
     189
     190    void SpaceShip::loadEngineTemplate()
     191    {
     192        if (this->enginetemplate_ != "")
     193        {
     194            Template* temp = Template::getTemplate(this->enginetemplate_);
     195
     196            if (temp)
     197            {
     198                Identifier* identifier = temp->getBaseclassIdentifier();
     199
     200                if (identifier)
    123201                {
    124                     if (velocity[dimension] > 0)
     202                    BaseObject* object = identifier->fabricate(this);
     203                    this->engine_ = dynamic_cast<Engine*>(object);
     204
     205                    if (this->engine_)
    125206                    {
    126                         velocity[dimension] -= (this->translationDamping_ * dt);
    127                         if (velocity[dimension] < 0)
    128                             velocity[dimension] = 0;
     207                        this->engine_->addTemplate(temp);
     208                        this->engine_->addToSpaceShip(this);
    129209                    }
    130                     else if (velocity[dimension] < 0)
     210                    else
    131211                    {
    132                         velocity[dimension] += (this->translationDamping_ * dt);
    133                         if (velocity[dimension] > 0)
    134                             velocity[dimension] = 0;
     212                        delete object;
    135213                    }
    136214                }
    137215            }
    138 
    139             this->setVelocity(velocity);
    140216        }
    141 
    142 
    143         SUPER(SpaceShip, tick, dt);
    144 
    145 
    146         if (this->isLocallyControlled())
    147         {
    148             this->yaw(this->yawRotation_ * dt);
    149             if (this->bInvertYAxis_)
    150                 this->pitch(Degree(-this->pitchRotation_ * dt));
    151             else
    152                 this->pitch(Degree( this->pitchRotation_ * dt));
    153             this->roll(this->rollRotation_ * dt);
    154 
    155             this->acceleration_.x = 0;
    156             this->acceleration_.y = 0;
    157             this->acceleration_.z = 0;
    158 
    159             this->yawRotation_   = this->zeroDegree_;
    160             this->pitchRotation_ = this->zeroDegree_;
    161             this->rollRotation_  = this->zeroDegree_;
    162         }
    163     }
    164 
    165     void SpaceShip::moveFrontBack(const Vector2& value)
    166     {
    167         this->acceleration_.z = -this->translationAcceleration_ * value.x;
    168     }
    169 
    170     void SpaceShip::moveRightLeft(const Vector2& value)
    171     {
    172         this->acceleration_.x = this->translationAcceleration_ * value.x;
    173     }
    174 
    175     void SpaceShip::moveUpDown(const Vector2& value)
    176     {
    177         this->acceleration_.y = this->translationAcceleration_ * value.x;
    178     }
    179 
    180     void SpaceShip::rotateYaw(const Vector2& value)
    181     {
    182         Degree temp = value.x * value.x * sgn(value.x) * this->rotationAcceleration_;
    183         if (temp > this->maxRotation_)
    184             temp = this->maxRotation_;
    185         if (temp < -this->maxRotation_)
    186             temp = -this->maxRotation_;
    187         this->yawRotation_ = Degree(temp);
    188     }
    189 
    190     void SpaceShip::rotatePitch(const Vector2& value)
    191     {
    192         Degree temp = value.x * value.x * sgn(value.x) * this->rotationAcceleration_;
    193         if (temp > this->maxRotation_)
    194             temp = this->maxRotation_;
    195         if (temp < -this->maxRotation_)
    196             temp = -this->maxRotation_;
    197         this->pitchRotation_ = Degree(temp);
    198     }
    199 
    200     void SpaceShip::rotateRoll(const Vector2& value)
    201     {
    202         Degree temp = value.x * value.x * sgn(value.x) * this->rotationAcceleration_;
    203         if (temp > this->maxRotation_)
    204             temp = this->maxRotation_;
    205         if (temp < -this->maxRotation_)
    206             temp = -this->maxRotation_;
    207         this->rollRotation_ = Degree(temp);
    208     }
    209 
    210     void SpaceShip::fire()
    211     {
     217    }
     218
     219    void SpaceShip::setEngine(Engine* engine)
     220    {
     221        this->engine_ = engine;
     222        if (engine && engine->getShip() != this)
     223            engine->addToSpaceShip(this);
    212224    }
    213225}
  • code/trunk/src/orxonox/objects/worldentities/pawns/SpaceShip.h

    r2087 r2662  
    3232#include "OrxonoxPrereqs.h"
    3333
     34#include "LinearMath/btVector3.h"
     35
    3436#include "Pawn.h"
    3537
     
    5658
    5759            virtual void fire();
     60            virtual void boost();
    5861
    59             void setMaxSpeed(float value)
    60                 { this->maxSpeed_ = value; }
    61             void setMaxSecondarySpeed(float value)
    62                 { this->maxSecondarySpeed_ = value; }
    63             void setMaxRotation(const Degree& value)
    64                 { this->maxRotation_ = value; }
    65             void setTransAcc(float value)
    66                 { this->translationAcceleration_ = value; }
    67             void setRotAcc(const Degree& value)
    68                 { this->rotationAcceleration_ = value; }
    69             void setTransDamp(float value)
    70                 { this->translationDamping_ = value; }
     62            void setEngine(Engine* engine);
     63            inline Engine* getEngine() const
     64                { return this->engine_; }
    7165
    72             inline float getMaxSpeed() const
    73                 { return this->maxSpeed_; }
    74             inline float getMaxSecondarySpeed() const
    75                 { return this->maxSecondarySpeed_; }
    76             inline float getMaxRotation() const
    77                 { return this->maxRotation_.valueDegrees(); }
    78             inline float getTransAcc() const
    79                 { return this->translationAcceleration_; }
    80             inline float getRotAcc() const
    81                 { return this->rotationAcceleration_.valueDegrees(); }
    82             inline float getTransDamp() const
    83                 { return this->translationDamping_; }
     66            inline void setSteeringDirection(const Vector3& direction)
     67                { this->steering_ = direction; }
     68            inline const Vector3& getSteeringDirection() const
     69                { return this->steering_; }
     70
     71            inline void setBoost(bool bBoost)
     72                { this->bBoost_ = bBoost; }
     73            inline bool getBoost() const
     74                { return this->bBoost_; }
     75
     76            inline void setEngineTemplate(const std::string& temp)
     77                { this->enginetemplate_ = temp; this->loadEngineTemplate(); }
     78            inline const std::string& getEngineTemplate() const
     79                { return this->enginetemplate_; }
     80
     81            inline void setPermanentBoost(bool bPermanent)
     82                { this->bPermanentBoost_ = bPermanent; }
     83            inline bool getPermanentBoost() const
     84                { return this->bPermanentBoost_; }
    8485
    8586        protected:
    8687            bool bInvertYAxis_;
    8788
    88             float maxSpeed_;
    89             float maxSecondarySpeed_;
    90             float translationAcceleration_;
    91             float translationDamping_;
     89            bool bBoost_;
     90            bool bPermanentBoost_;
     91            Vector3 steering_;
     92            float primaryThrust_;
     93            float auxilaryThrust_;
     94            float rotationThrust_;
     95            btVector3 localLinearAcceleration_;
     96            btVector3 localAngularAcceleration_;
    9297
    93             Degree maxRotation_;
    94             Degree rotationAcceleration_;
     98        private:
     99            virtual bool isCollisionTypeLegal(WorldEntity::CollisionType type) const;
    95100
    96             Degree zeroDegree_;
    97             Degree pitchRotation_;
    98             Degree yawRotation_;
    99             Degree rollRotation_;
     101        private:
     102            void loadEngineTemplate();
     103
     104            std::string enginetemplate_;
     105            Engine* engine_;
    100106    };
    101107}
  • code/trunk/src/orxonox/objects/worldentities/pawns/Spectator.cc

    r2171 r2662  
    3030#include "Spectator.h"
    3131
     32#include <OgreBillboardSet.h>
     33
    3234#include "core/CoreIncludes.h"
     35#include "core/ConfigValueIncludes.h"
    3336#include "core/Core.h"
    3437#include "objects/worldentities/Model.h"
     
    4952        RegisterObject(Spectator);
    5053
    51         this->speed_ = 100;
    52         this->rotationSpeed_ = 3;
     54        this->speed_ = 200;
    5355
    5456        this->yaw_ = 0;
    5557        this->pitch_ = 0;
    5658        this->roll_ = 0;
     59        this->localVelocity_ = Vector3::ZERO;
    5760        this->setHudTemplate("spectatorhud");
    58         this->hudmode_ = 0;
     61        this->greetingFlare_ = 0;
    5962
    6063        this->setDestroyWhenPlayerLeft(true);
    6164
    62         this->greetingFlare_ = new BillboardSet();
    63         this->greetingFlare_->setBillboardSet(this->getScene()->getSceneManager(), "Examples/Flare", ColourValue(1.0, 1.0, 0.8), Vector3(0, 20, 0), 1);
    64         if (this->greetingFlare_->getBillboardSet())
    65             this->getNode()->attachObject(this->greetingFlare_->getBillboardSet());
    66         this->greetingFlare_->setVisible(false);
     65        if (Core::showsGraphics())
     66        {
     67            this->greetingFlare_ = new BillboardSet();
     68            this->greetingFlare_->setBillboardSet(this->getScene()->getSceneManager(), "Examples/Flare", ColourValue(1.0, 1.0, 0.8), Vector3(0, 20, 0), 1);
     69            if (this->greetingFlare_->getBillboardSet())
     70                this->attachOgreObject(this->greetingFlare_->getBillboardSet());
     71            this->greetingFlare_->setVisible(false);
     72        }
     73
    6774        this->bGreetingFlareVisible_ = false;
    6875        this->bGreeting_ = false;
    6976
     77        this->setConfigValues();
    7078        this->registerVariables();
    7179    }
     
    7886            {
    7987                if (this->greetingFlare_->getBillboardSet())
    80                     this->getNode()->detachObject(this->greetingFlare_->getBillboardSet());
     88                    this->detachOgreObject(this->greetingFlare_->getBillboardSet());
     89
    8190                delete this->greetingFlare_;
    8291            }
     
    8493    }
    8594
     95    void Spectator::setConfigValues()
     96    {
     97        SetConfigValue(speed_, 200.0f);
     98    }
     99
    86100    void Spectator::registerVariables()
    87101    {
    88         REGISTERDATA(this->bGreetingFlareVisible_, direction::toclient, new NetworkCallback<Spectator>(this, &Spectator::changedFlareVisibility));
    89         REGISTERDATA(this->bGreeting_,             direction::toserver, new NetworkCallback<Spectator>(this, &Spectator::changedGreeting));
    90         REGISTERDATA(this->hudmode_,               direction::toclient);
     102        registerVariable(this->bGreetingFlareVisible_, variableDirection::toclient, new NetworkCallback<Spectator>(this, &Spectator::changedFlareVisibility));
     103        registerVariable(this->bGreeting_,             variableDirection::toserver, new NetworkCallback<Spectator>(this, &Spectator::changedGreeting));
    91104    }
    92105
     
    99112    void Spectator::changedFlareVisibility()
    100113    {
    101         this->greetingFlare_->setVisible(this->bGreetingFlareVisible_);
     114        if ( this->greetingFlare_ )
     115            this->greetingFlare_->setVisible(this->bGreetingFlareVisible_);
    102116    }
    103117
    104118    void Spectator::tick(float dt)
    105119    {
    106         this->updateHUD();
    107 
    108         if (this->isLocallyControlled())
    109         {
    110             Vector3 velocity = this->getVelocity();
    111             velocity.normalise();
    112             this->setVelocity(velocity * this->speed_);
    113 
    114             this->yaw(Radian(this->yaw_ * this->rotationSpeed_));
    115             this->pitch(Radian(this->pitch_ * this->rotationSpeed_));
    116             this->roll(Radian(this->roll_ * this->rotationSpeed_));
     120        if (this->hasLocalController())
     121        {
     122            float localSpeedSquared = this->localVelocity_.squaredLength();
     123            float localSpeed;
     124            if (localSpeedSquared > 1.0)
     125                localSpeed = this->speed_ / sqrtf(localSpeedSquared);
     126            else
     127                localSpeed = this->speed_;
     128
     129            this->localVelocity_.x *= localSpeed;
     130            this->localVelocity_.y *= localSpeed;
     131            this->localVelocity_.z *= localSpeed;
     132            this->setVelocity(this->getOrientation() * this->localVelocity_);
     133            this->localVelocity_.x = 0;
     134            this->localVelocity_.y = 0;
     135            this->localVelocity_.z = 0;
     136
     137            if (!this->isInMouseLook())
     138            {
     139                this->yaw(Radian(this->yaw_ * this->getMouseLookSpeed()));
     140                this->pitch(Radian(this->pitch_ * this->getMouseLookSpeed()));
     141                this->roll(Radian(this->roll_ * this->getMouseLookSpeed()));
     142            }
    117143
    118144            this->yaw_ = this->pitch_ = this->roll_ = 0;
     
    120146
    121147        SUPER(Spectator, tick, dt);
    122 
    123         if (this->isLocallyControlled())
    124         {
    125             this->setVelocity(Vector3::ZERO);
    126         }
    127148    }
    128149
     
    131152        ControllableEntity::setPlayer(player);
    132153
    133 //        this->setObjectMode(direction::toclient);
    134     }
    135 
    136     void Spectator::startLocalControl()
    137     {
    138         ControllableEntity::startLocalControl();
    139 //        if (this->isLocallyControlled())
    140 //            this->testmesh_->setVisible(false);
     154//        this->setObjectMode(objectDirection::toclient);
     155    }
     156
     157    void Spectator::startLocalHumanControl()
     158    {
     159        ControllableEntity::startLocalHumanControl();
    141160    }
    142161
    143162    void Spectator::moveFrontBack(const Vector2& value)
    144163    {
    145         this->setVelocity(this->getVelocity() + value.y * this->speed_ * WorldEntity::FRONT);
     164        this->localVelocity_.z -= value.x;
    146165    }
    147166
    148167    void Spectator::moveRightLeft(const Vector2& value)
    149168    {
    150         this->setVelocity(this->getVelocity() + value.y * this->speed_ * WorldEntity::RIGHT);
     169        this->localVelocity_.x += value.x;
    151170    }
    152171
    153172    void Spectator::moveUpDown(const Vector2& value)
    154173    {
    155         this->setVelocity(this->getVelocity() + value.y * this->speed_ * WorldEntity::UP);
     174        this->localVelocity_.y += value.x;
    156175    }
    157176
    158177    void Spectator::rotateYaw(const Vector2& value)
    159178    {
    160         this->yaw_ = value.y;
     179        this->yaw_ -= value.y;
     180
     181        ControllableEntity::rotateYaw(value);
    161182    }
    162183
    163184    void Spectator::rotatePitch(const Vector2& value)
    164185    {
    165         this->pitch_ = value.y;
     186        this->pitch_ += value.y;
     187
     188        ControllableEntity::rotatePitch(value);
    166189    }
    167190
    168191    void Spectator::rotateRoll(const Vector2& value)
    169192    {
    170         this->roll_ = value.y;
    171     }
    172 
    173     void Spectator::fire()
     193        this->roll_ += value.y;
     194
     195        ControllableEntity::rotateRoll(value);
     196    }
     197
     198    void Spectator::fire(WeaponMode::Enum fireMode)
    174199    {
    175200        if (this->getPlayer())
     
    187212        }
    188213    }
    189 
    190     void Spectator::updateHUD()
    191     {
    192         // <hack>
    193         if (Core::isMaster())
    194         {
    195             if (this->getPlayer() && this->getGametype())
    196             {
    197                 if (!this->getGametype()->hasStarted() && !this->getGametype()->isStartCountdownRunning())
    198                 {
    199                     if (!this->getPlayer()->isReadyToSpawn())
    200                         this->hudmode_ = 0;
    201                     else
    202                         this->hudmode_ = 1;
    203                 }
    204                 else if (!this->getGametype()->hasEnded())
    205                 {
    206                     if (this->getGametype()->isStartCountdownRunning())
    207                         this->hudmode_ = 2 + 10*(int)ceil(this->getGametype()->getStartCountdown());
    208                     else
    209                         this->hudmode_ = 3;
    210                 }
    211                 else
    212                     this->hudmode_ = 4;
    213             }
    214             else
    215                 return;
    216         }
    217 
    218         if (this->getHUD())
    219         {
    220             std::string text;
    221             int hudmode = this->hudmode_ % 10;
    222 
    223             switch (hudmode)
    224             {
    225                 case 0:
    226                     text = "Press [Fire] to start the match";
    227                     break;
    228                 case 1:
    229                     text = "Waiting for other players";
    230                     break;
    231                 case 2:
    232                     text = convertToString((this->hudmode_ - 2) / 10);
    233                     break;
    234                 case 3:
    235                     text = "Press [Fire] to respawn";
    236                     break;
    237                 case 4:
    238                     text = "Game has ended";
    239                     break;
    240                 default:;
    241             }
    242 
    243             std::map<std::string, OrxonoxOverlay*>::const_iterator it = this->getHUD()->getOverlays().begin();
    244             for (; it != this->getHUD()->getOverlays().end(); ++it)
    245             {
    246                 if (it->second->isA(Class(OverlayText)) && it->second->getName() == "state")
    247                 {
    248                     OverlayText* overlay = dynamic_cast<OverlayText*>(it->second);
    249                     if (overlay)
    250                         overlay->setCaption(text);
    251                     break;
    252                 }
    253             }
    254         }
    255         // </hack>
    256     }
    257214}
  • code/trunk/src/orxonox/objects/worldentities/pawns/Spectator.h

    r2087 r2662  
    4242            virtual ~Spectator();
    4343
     44            void setConfigValues();
    4445            void registerVariables();
    4546            virtual void tick(float dt);
    4647
    4748            virtual void setPlayer(PlayerInfo* player);
    48             virtual void startLocalControl();
     49            virtual void startLocalHumanControl();
    4950
    5051            virtual void moveFrontBack(const Vector2& value);
     
    5657            virtual void rotateRoll(const Vector2& value);
    5758
    58             virtual void fire();
     59            virtual void fire(WeaponMode::Enum fireMode);
    5960            virtual void greet();
    6061
     
    6263            void changedGreeting();
    6364            void changedFlareVisibility();
    64             void updateHUD();
    6565
    6666            BillboardSet* greetingFlare_;
     
    6969
    7070            float speed_;
    71             float rotationSpeed_;
    7271
    7372            float yaw_;
     
    7574            float roll_;
    7675
    77             int hudmode_;
     76            Vector3 localVelocity_;
    7877    };
    7978}
  • code/trunk/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc

  • code/trunk/src/orxonox/objects/worldentities/triggers/DistanceTrigger.h

  • code/trunk/src/orxonox/objects/worldentities/triggers/PlayerTrigger.cc

    r2262 r2662  
    2828
    2929/**
    30     @file PlayerTrigger.cc
     30    @file
    3131    @brief
    32         Implementation of the PlayerTrigger class.
     32    Implementation of the PlayerTrigger class.
    3333*/
    3434
     
    3838#include "core/CoreIncludes.h"
    3939
    40 namespace orxonox {
    41 
     40namespace orxonox
     41{
    4242    /**
    4343    @brief
     
    4747    {
    4848        RegisterObject(PlayerTrigger);
    49        
     49
    5050        this->player_ = NULL;
    5151        this->isForPlayer_ = true;
    5252    }
    53    
     53
    5454    /**
    5555    @brief
     
    6666    void PlayerTrigger::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    6767    {
    68         SUPER(PlayerTrigger, XMLPort, xmlelement, mode);
     68        SUPER(PlayerTrigger, XMLPort, xmlelement, mode);
    6969    }
    70 
    7170}
  • code/trunk/src/orxonox/objects/worldentities/triggers/PlayerTrigger.h

    r2262 r2662  
    2828
    2929/**
    30     @file PlayerTrigger.h
     30    @file
    3131    @brief
    32         Definition of the PlayerTrigger class.
     32    Definition of the PlayerTrigger class.
    3333*/
    3434
     
    4040#include "Trigger.h"
    4141
    42 namespace orxonox {
    43    
     42namespace orxonox
     43{
    4444    /**
    4545    @brief
     
    5050    class _OrxonoxExport PlayerTrigger : public Trigger
    5151    {
    52         public:
    53             PlayerTrigger(BaseObject* creator);
    54             virtual ~PlayerTrigger();
    55            
    56             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a PlayerTrigger object through XML.
     52    public:
     53        PlayerTrigger(BaseObject* creator);
     54        virtual ~PlayerTrigger();
     55       
     56        virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a PlayerTrigger object through XML.
     57       
     58        /**
     59        @brief Returns the player that triggered the PlayerTrigger.
     60        @return Returns a pointer to the ControllableEntity that triggered the PlayerTrigger.
     61        */
     62        inline ControllableEntity* getTriggeringPlayer(void) const
     63            { return this->player_; }
     64       
     65        /**
     66        @brief Checks whether the PlayerTrigger normally returns a ControllableEntity.
     67        @return Returns true if the PlayerTrigger normally returns a ControllableEntity.
     68        */
     69        inline bool isForPlayer(void) const
     70           { return this->isForPlayer_; }
    5771           
    58             /**
    59             @brief Returns the player that triggered the PlayerTrigger.
    60             @return Returns a pointer to the ControllableEntity that triggered the PlayerTrigger.
    61             */
    62             inline ControllableEntity* getTriggeringPlayer(void) const
    63                 { return this->player_; }
    64            
    65             /**
    66             @brief Checks whether the PlayerTrigger normally returns a ControllableEntity.
    67             @return Returns true if the PlayerTrigger normally returns a ControllableEntity.
    68             */
    69             inline bool isForPlayer(void) const
    70                { return this->isForPlayer_; }
    71            
    72         protected:
    73             virtual bool isTriggered(TriggerMode mode) = 0;
    74            
    75             /**
    76             @brief Set the player that triggered the PlayerTrigger. This is normally done by classes inheriting vom PlayerTrigger.
    77             @param player A pointer to the ControllableEntity that triggered the PlayerTrigger.
    78             */
    79             inline void setTriggeringPlayer(ControllableEntity* player)
    80                { this->player_ = player; }
     72    protected:
     73        virtual bool isTriggered(TriggerMode mode) = 0;
     74       
     75        /**
     76        @brief Set the player that triggered the PlayerTrigger. This is normally done by classes inheriting vom PlayerTrigger.
     77        @param player A pointer to the ControllableEntity that triggered the PlayerTrigger.
     78        */
     79        inline void setTriggeringPlayer(ControllableEntity* player)
     80           { this->player_ = player; }
    8181
    8282            /**
     
    8484            @param isForPlayer Should be true when the PlayerTrigger schould be set to normally be triggered by ControllableEntities, false if not.
    8585            */
    86             inline void setForPlayer(bool isForPlayer)
    87                { this->isForPlayer_ = isForPlayer; }
    88            
    89         private:
    90             ControllableEntity* player_; //!< The player that triggered the PlayerTrigger.
    91             bool isForPlayer_; //!< Is true when the PlayerTrigger schould be set to normally be triggered by ControllableEntities.
    92        
     86        inline void setForPlayer(bool isForPlayer)
     87           { this->isForPlayer_ = isForPlayer; }
     88       
     89    private:
     90        ControllableEntity* player_; //!< The player that triggered the PlayerTrigger.
     91        bool isForPlayer_; //!< Is true when the PlayerTrigger schould be set to normally be triggered by ControllableEntities.
     92   
    9393    };
    9494
  • code/trunk/src/orxonox/objects/worldentities/triggers/Trigger.cc

    r2261 r2662  
    3131
    3232#include <OgreBillboard.h>
     33#include <OgreBillboardSet.h>
    3334#include "util/Debug.h"
    3435#include "core/CoreIncludes.h"
    3536#include "core/ConsoleCommand.h"
    3637#include "core/XMLPort.h"
     38#include "core/Core.h"
    3739#include "objects/Scene.h"
    3840
     
    4446  CreateFactory(Trigger);
    4547
    46   Trigger::Trigger(BaseObject* creator) : PositionableEntity(creator)
     48  Trigger::Trigger(BaseObject* creator) : StaticEntity(creator)
    4749  {
    4850    RegisterObject(Trigger);
     
    6567//    this->bUpdating_ = false;
    6668
    67     if (this->getScene() && this->getScene()->getSceneManager())
     69    if (this->getScene() && Core::showsGraphics())
    6870    {
    6971      this->debugBillboard_.setBillboardSet(this->getScene()->getSceneManager(), "Examples/Flare", ColourValue(1.0, 0.0, 0.0), 1);
     
    7173
    7274      if (this->debugBillboard_.getBillboardSet())
    73         this->getNode()->attachObject(this->debugBillboard_.getBillboardSet());
     75          this->attachOgreObject(this->debugBillboard_.getBillboardSet());
    7476    }
    7577
     
    106108    if (!this->BaseObject::isActive())
    107109        return;
     110
     111    SUPER(Trigger, tick, dt);
    108112
    109113    bool newTriggered = this->isTriggered() ^ this->bInvertMode_;
  • code/trunk/src/orxonox/objects/worldentities/triggers/Trigger.h

    r2261 r2662  
    3636
    3737#include "objects/Tickable.h"
    38 #include "objects/worldentities/PositionableEntity.h"
     38#include "objects/worldentities/StaticEntity.h"
    3939#include "tools/BillboardSet.h"
    4040
     
    4848  };
    4949
    50   class _OrxonoxExport Trigger : public PositionableEntity, public Tickable
     50  class _OrxonoxExport Trigger : public StaticEntity, public Tickable
    5151  {
    5252    public:
  • code/trunk/src/orxonox/overlays/CMakeLists.txt

    r2131 r2662  
    88ADD_SOURCE_DIRECTORY(SRC_FILES debug)
    99ADD_SOURCE_DIRECTORY(SRC_FILES hud)
     10ADD_SOURCE_DIRECTORY(SRC_FILES notifications)
     11ADD_SOURCE_DIRECTORY(SRC_FILES stats)
    1012
    1113ADD_SOURCE_FILES(SRC_FILES)
  • code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc

    r2171 r2662  
    6161        RegisterObject(OrxonoxOverlay);
    6262
     63        this->owner_ = 0;
     64        this->group_ = 0;
     65
    6366        if (!Core::showsGraphics())
    6467            ThrowException(NoGraphics, "Can't create OrxonoxOverlay, graphics engine not initialized");
    65 
    66         // add this overlay to the static map of OrxonoxOverlays
    67         if (overlays_s.find(this->getName()) != overlays_s.end())
    68         {
    69             COUT(1) << "Overlay names should be unique or you cannnot access them via console. Name: \"" << this->getName() << "\"" << std::endl;
    70         }
    71         overlays_s[this->getName()] = this;
    7268
    7369        // create the Ogre::Overlay
     
    9288        setPosition(Vector2(0.0f, 0.0f));
    9389        setRotation(Degree(0.0));
    94         setAspectCorrection(true);
     90        setAspectCorrection(false);
    9591        setBackgroundMaterial("");
    9692    }
     
    130126
    131127        XMLPortParam(OrxonoxOverlay, "size",      setSize,      getSize,      xmlElement, mode);
    132         XMLPortParam(OrxonoxOverlay, "pickPoint", setPickPoint, getPickPoint, xmlElement, mode);
     128        XMLPortParam(OrxonoxOverlay, "pickpoint", setPickPoint, getPickPoint, xmlElement, mode);
    133129        XMLPortParam(OrxonoxOverlay, "position",  setPosition,  getPosition,  xmlElement, mode);
    134130        XMLPortParam(OrxonoxOverlay, "rotation",  setRotation,  getRotation,  xmlElement, mode);
    135         XMLPortParam(OrxonoxOverlay, "correctAspect", setAspectCorrection,   getAspectCorrection,   xmlElement, mode);
     131        XMLPortParam(OrxonoxOverlay, "correctaspect", setAspectCorrection,   getAspectCorrection,   xmlElement, mode);
    136132        XMLPortParam(OrxonoxOverlay, "background",    setBackgroundMaterial, getBackgroundMaterial, xmlElement, mode);
    137133    }
     
    139135    void OrxonoxOverlay::changedName()
    140136    {
     137        SUPER(OrxonoxOverlay, changedName);
     138
    141139        OrxonoxOverlay::overlays_s.erase(this->getOldName());
    142140
  • code/trunk/src/orxonox/overlays/OrxonoxOverlay.h

    r2087 r2662  
    125125
    126126        //! Gets the rotation angle applied to this overlay in degrees.
    127         const Radian& getRotation() const         { return this->angle_; }
     127        const Degree& getRotation() const         { return this->angle_; }
    128128
    129129        //! Rotates the overlay by angle degrees.
     
    154154        virtual void changedVisibility();
    155155
     156        inline void setOwner(ControllableEntity* owner)
     157        {
     158            if (this->owner_ != owner)
     159            {
     160                this->owner_ = owner;
     161                this->changedOwner();
     162            }
     163        }
     164        inline ControllableEntity* getOwner() const
     165            { return this->owner_; }
     166        virtual void changedOwner() {}
     167
     168        inline void setOverlayGroup(OverlayGroup* group)
     169        {
     170            if (group != this->group_)
     171            {
     172                this->group_ = group;
     173                this->changedOverlayGroup();
     174            }
     175        }
     176        inline OverlayGroup* getOverlayGroup() const
     177            { return this->group_; }
     178        virtual void changedOverlayGroup() {}
     179
    156180    protected:
    157181        virtual void angleChanged();
     
    172196        Vector2 position_;                         //!< Position of the pickPoint on the screen.
    173197        Vector2 pickPoint_;                        //!< Point on the overlay to pick when translating
    174         Radian angle_;                             //!< Rotation angle of the overlay
     198        Degree angle_;                             //!< Rotation angle of the overlay
    175199        RotationState rotState_;             //!< horizontal, vertical or inbetween
    176200
     
    182206            We could also use the ObjectList, but that doesn't guarantee XMLPort(.) was called and is slower. */
    183207        static std::map<std::string, OrxonoxOverlay*> overlays_s;
     208        ControllableEntity* owner_;
     209        OverlayGroup* group_;
    184210  };
     211
     212  SUPER_FUNCTION(7, OrxonoxOverlay, changedOwner, false);
     213  SUPER_FUNCTION(8, OrxonoxOverlay, changedOverlayGroup, false);
    185214}
    186215
  • code/trunk/src/orxonox/overlays/OverlayGroup.cc

    r2087 r2662  
    5555        RegisterObject(OverlayGroup);
    5656
     57        this->owner_ = 0;
     58
    5759        setScale(Vector2(1.0, 1.0));
    5860        setScroll(Vector2(0.0, 0.0));
     
    113115            hudElements_[element->getName()] = element;
    114116            element->setVisible(this->isVisible());
     117            if (this->owner_)
     118                element->setOwner(this->owner_);
    115119        }
    116120    }
     
    137141    }
    138142
     143    void OverlayGroup::setOwner(ControllableEntity* owner)
     144    {
     145        this->owner_ = owner;
     146
     147        for (std::map<std::string, OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
     148            (*it).second->setOwner(owner);
     149    }
    139150
    140151    //########### Console commands ############
  • code/trunk/src/orxonox/overlays/OverlayGroup.h

    r2087 r2662  
    6969        void changedVisibility();
    7070
    71     private:
     71        void setOwner(ControllableEntity* owner);
     72        inline ControllableEntity* getOwner() const
     73            { return this->owner_; }
     74
    7275        //! Scales each OrxonoxOverlay individually by scale.
    7376        void scale(const Vector2& scale) { this->setScale(scale * this->scale_); }
     
    8588        OrxonoxOverlay* getElement(unsigned int index);
    8689
     90    private:
    8791        std::map<std::string, OrxonoxOverlay*> hudElements_;    //!< Contains all the OrxonoxOverlays of the this group.
    88         Vector2 scale_;                                         //!< Current scale (independant of the elements).
     92        Vector2 scale_;                                         //!< Current scale (independent of the elements).
    8993        Vector2 scroll_;                                        //!< Current scrolling offset.
     94        ControllableEntity* owner_;                             //!< The owner of this OverlayGroup
    9095    };
    9196}
  • code/trunk/src/orxonox/overlays/OverlayText.cc

    r2087 r2662  
    5050        this->text_->setCharHeight(1.0);
    5151
    52         setFont("Monofur");
    53         setColour(ColourValue(1.0, 1.0, 1.0, 1.0));
    54         setCaption("");
    55         setTextSize(1.0f);
    56         setAlignmentString("left");
     52        this->setFont("Monofur");
     53        this->setColour(ColourValue(1.0, 1.0, 1.0, 1.0));
     54        this->setCaption("");
     55        this->setTextSize(1.0f);
     56        this->setAlignmentString("left");
    5757
    5858        this->background_->addChild(this->text_);
     
    6969        SUPER(OverlayText, XMLPort, xmlElement, mode);
    7070
    71         XMLPortParam(OverlayText, "font",     setFont,            getFont,            xmlElement, mode);
    72         XMLPortParam(OverlayText, "colour",   setColour,          getColour,          xmlElement, mode);
    73         XMLPortParam(OverlayText, "caption",  setCaption,         getCaption,         xmlElement, mode);
    74         XMLPortParam(OverlayText, "textSize", setTextSize,        getTextSize,        xmlElement, mode);
    75         XMLPortParam(OverlayText, "align",    setAlignmentString, getAlignmentString, xmlElement, mode);
     71        XMLPortParam(OverlayText, "font",       setFont,            getFont,            xmlElement, mode);
     72        XMLPortParam(OverlayText, "colour",     setColour,          getColour,          xmlElement, mode);
     73        XMLPortParam(OverlayText, "caption",    setCaption,         getCaption,         xmlElement, mode);
     74        XMLPortParam(OverlayText, "textsize",   setTextSize,        getTextSize,        xmlElement, mode);
     75        XMLPortParam(OverlayText, "align",      setAlignmentString, getAlignmentString, xmlElement, mode);
     76        XMLPortParam(OverlayText, "spacewidth", setSpaceWidth,      getSpaceWidth,      xmlElement, mode);
    7677    }
    7778
  • code/trunk/src/orxonox/overlays/OverlayText.h

    r2087 r2662  
    4747        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
    4848
    49         void setCaption(const std::string& caption) { this->text_->setCaption(caption); }
    50         std::string getCaption() const              { return this->text_->getCaption(); }
     49        inline void setCaption(const std::string& caption) { this->text_->setCaption(caption); }
     50        inline std::string getCaption() const              { return this->text_->getCaption(); }
    5151
    5252        void setFont(const std::string& font);
    53         const std::string& getFont() const { return this->text_->getFontName(); }
     53        inline const std::string& getFont() const { return this->text_->getFontName(); }
    5454
    55         void setColour(const ColourValue& colour) { this->text_->setColour(colour); }
    56         const ColourValue& getColour() const      { return this->text_->getColour(); }
     55        inline void setSpaceWidth(float width) { this->text_->setSpaceWidth(width); }
     56        inline float getSpaceWidth() const     { return this->text_->getSpaceWidth(); }
    5757
    58         void setAlignment(Ogre::TextAreaOverlayElement::Alignment alignment) { this->text_->setAlignment(alignment); }
    59         Ogre::TextAreaOverlayElement::Alignment getAlignment() const         { return this->text_->getAlignment(); }
     58        inline void setColour(const ColourValue& colour) { this->text_->setColour(colour); }
     59        inline const ColourValue& getColour() const      { return this->text_->getColour(); }
    6060
    61     protected:
    62         virtual void sizeChanged();
     61        inline void setAlignment(Ogre::TextAreaOverlayElement::Alignment alignment) { this->text_->setAlignment(alignment); }
     62        inline Ogre::TextAreaOverlayElement::Alignment getAlignment() const         { return this->text_->getAlignment(); }
    6363
    6464        void setAlignmentString(const std::string& alignment);
    6565        std::string getAlignmentString() const;
    6666
    67         void setTextSize(float size) { this->setSize(Vector2(size, size)); }
    68         float getTextSize() const    { return this->getSize().y; }
     67        inline void setTextSize(float size) { this->setSize(Vector2(size, size)); }
     68        inline float getTextSize() const    { return this->getSize().y; }
     69
     70    protected:
     71        virtual void sizeChanged();
    6972
    7073        Ogre::TextAreaOverlayElement* text_;
  • code/trunk/src/orxonox/overlays/debug/DebugFPSText.cc

    r2087 r2662  
    4949    void DebugFPSText::tick(float dt)
    5050    {
     51        SUPER(DebugFPSText, tick, dt);
     52
    5153        float fps = GraphicsEngine::getInstance().getAverageFramesPerSecond();
    5254        this->setCaption(convertToString(fps));
  • code/trunk/src/orxonox/overlays/debug/DebugRTRText.cc

    r2087 r2662  
    4949    void DebugRTRText::tick(float dt)
    5050    {
     51        SUPER(DebugRTRText, tick, dt);
     52
    5153        float rtr = GraphicsEngine::getInstance().getAverageTickTime();
    5254        this->setCaption(convertToString(rtr));
  • code/trunk/src/orxonox/overlays/hud/CMakeLists.txt

    r2131 r2662  
    44  HUDRadar.cc
    55  HUDSpeedBar.cc
     6  HUDHealthBar.cc
    67  ChatOverlay.cc
     8  GametypeStatus.cc
    79)
    810
  • code/trunk/src/orxonox/overlays/hud/HUDBar.cc

    r2087 r2662  
    5151        RegisterObject(BarColour);
    5252
    53         setColour(ColourValue(1.0, 1.0, 1.0, 1.0));
    54         setPosition(0.0);
     53        this->setColour(ColourValue(1.0, 1.0, 1.0, 1.0));
     54        this->setPosition(0.0);
    5555    }
    5656
     
    8484        this->bar_->setMaterialName(materialname);
    8585
    86         setValue(0.4567654f);
    87         setRightToLeft(false);
    88         setAutoColour(true);
     86        this->value_ = 1.0f;  // initielize with 1.0f to trigger a change when calling setValue(0.0f) on the line below
     87        this->setValue(0.0f); // <--
     88        this->setRightToLeft(false);
     89        this->setAutoColour(true);
     90        this->currentColour_ = ColourValue::White;
    8991
    9092        this->background_->addChild(bar_);
     
    101103        SUPER(HUDBar, XMLPort, xmlElement, mode);
    102104
    103         XMLPortParam(HUDBar, "initialValue", setValue,       getValue,       xmlElement, mode);
    104         XMLPortParam(HUDBar, "rightToLeft",  setRightToLeft, getRightToLeft, xmlElement, mode);
    105         XMLPortParam(HUDBar, "autoColour",   setAutoColour,  getAutoColour,  xmlElement, mode);
     105        XMLPortParam(HUDBar, "initialvalue", setValue,       getValue,       xmlElement, mode);
     106        XMLPortParam(HUDBar, "righttoleft",  setRightToLeft, getRightToLeft, xmlElement, mode);
     107        XMLPortParam(HUDBar, "autocolour",   setAutoColour,  getAutoColour,  xmlElement, mode);
     108        XMLPortParam(HUDBar, "bartexture",   setBarTexture,  getBarTexture, xmlElement, mode);
    106109        XMLPortObject(HUDBar, BarColour, "", addColour, getColour, xmlElement, mode);
    107110    }
     
    130133                {
    131134                    this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, colour2);
     135                    this->currentColour_ = colour2;
    132136                }
    133137                else if (value1 < this->value_)
    134138                {
    135139                    this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, colour1);
     140                    this->currentColour_ = colour1;
    136141                }
    137142                else
     
    139144                    //float interpolationfactor = (this->value_ - value2) / (value1 - value2);
    140145                    float interpolationfactor = interpolateSmooth((this->value_ - value2) / (value1 - value2), 0.0f, 1.0f);
    141                     this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, colour1 * interpolationfactor + colour2 * (1 - interpolationfactor));
     146                    this->currentColour_ = colour1 * interpolationfactor + colour2 * (1 - interpolationfactor);
     147                    this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, this->currentColour_);
     148
    142149                }
    143150            }
     
    181188        this->colours_.clear();
    182189    }
     190
     191    void HUDBar::setBarTexture(const std::string& texture)
     192    {
     193        this->textureUnitState_->setTextureName(texture);
     194    }
     195
     196    const std::string& HUDBar::getBarTexture() const
     197    {
     198        return this->textureUnitState_->getTextureName();
     199    }
    183200}
  • code/trunk/src/orxonox/overlays/hud/HUDBar.h

    r2087 r2662  
    7171        void clearColours();
    7272
    73         void setRightToLeft(bool r2l) { this->right2Left_ = r2l; this->valueChanged(); }
    74         bool getRightToLeft() const   { return this->right2Left_; }
     73        inline void setRightToLeft(bool r2l)
     74        {
     75            if (r2l != this->right2Left_)
     76            {
     77                this->right2Left_ = r2l;
     78                this->valueChanged();
     79            }
     80        }
     81        inline bool getRightToLeft() const
     82            { return this->right2Left_; }
    7583
    76         void setValue(float value)    { this->value_ = clamp(value, 0.0f, 1.0f); this->valueChanged(); }
    77         float getValue() const        { return this->value_; }
     84        inline void setValue(float value)
     85        {
     86            float temp = clamp(value, 0.0f, 1.0f);
     87            if (temp != this->value_)
     88            {
     89                this->value_ = temp;
     90                this->valueChanged();
     91            }
     92        }
     93        inline float getValue() const
     94            { return this->value_; }
    7895
    79         void setAutoColour(bool val)  { this->autoColour_ = val; this->valueChanged(); }
    80         bool getAutoColour() const    { return this->autoColour_; }
     96        inline void setAutoColour(bool val)
     97        {
     98            if (val != this->autoColour_)
     99            {
     100                this->autoColour_ = val;
     101                this->valueChanged();
     102
     103                if (!val)
     104                    this->currentColour_ = ColourValue::White;
     105            }
     106        }
     107        inline bool getAutoColour() const
     108            { return this->autoColour_; }
     109
     110        void setBarTexture(const std::string& texture);
     111        const std::string& getBarTexture() const;
     112
     113        inline const ColourValue& getCurrentBarColour() const
     114            { return this->currentColour_; }
    81115
    82116    protected:
     
    90124        bool autoColour_;                   //!< whether bar changes colour automatically
    91125        float value_;                       //!< progress of bar
     126        ColourValue currentColour_;
    92127
    93128        Ogre::PanelOverlayElement* bar_;
  • code/trunk/src/orxonox/overlays/hud/HUDNavigation.cc

    r2087 r2662  
    129129    void HUDNavigation::tick(float dt)
    130130    {
     131        SUPER(HUDNavigation, tick, dt);
     132
    131133        if (!Radar::getInstance().getFocus())
    132134        {
     
    149151*/
    150152        // transform to screen coordinates
    151         Vector3 pos = /*transformationMatrix * */Radar::getInstance().getFocus()->getWorldPosition();
     153        Vector3 pos = /*transformationMatrix * */Radar::getInstance().getFocus()->getRVWorldPosition();
    152154
    153155        bool outOfView;
     
    223225/*
    224226            Vector3 aimpos = transformationMatrix * getPredictedPosition(SpaceShip::getLocalShip()->getPosition(),
    225                     Projectile::getSpeed(), Radar::getInstance().getFocus()->getWorldPosition(), Radar::getInstance().getFocus()->getOrientedVelocity());
     227                    Projectile::getSpeed(), Radar::getInstance().getFocus()->getRVWorldPosition(), Radar::getInstance().getFocus()->getRVOrientedVelocity());
    226228*/
    227229            if (wasOutOfView_)
     
    250252/*
    251253        if (Radar::getInstance().getFocus())
    252             return (Radar::getInstance().getFocus()->getWorldPosition() - SpaceShip::getLocalShip()->getPosition()).length();
     254            return (Radar::getInstance().getFocus()->getRVWorldPosition() - SpaceShip::getLocalShip()->getPosition()).length();
    253255        else
    254256*/
  • code/trunk/src/orxonox/overlays/hud/HUDRadar.cc

    r2087 r2662  
    4040#include "core/XMLPort.h"
    4141#include "objects/Radar.h"
     42#include "objects/worldentities/WorldEntity.h"
     43#include "objects/worldentities/pawns/Pawn.h"
    4244#include "tools/TextureGenerator.h"
    4345
     
    5153        RegisterObject(HUDRadar);
    5254
    53         marker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
     55        this->marker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
    5456            .createOverlayElement("Panel", "HUDRadar_marker_" + getUniqueNumberString()));
    55         marker_->setMaterialName("Orxonox/RadarMarker");
    56         overlay_->add2D(marker_);
    57         marker_->hide();
     57        this->marker_->setMaterialName("Orxonox/RadarMarker");
     58        this->overlay_->add2D(this->marker_);
     59        this->marker_->hide();
    5860
    59         setRadarSensitivity(1.0f);
    60         setHalfDotSizeDistance(3000.0f);
    61         setMaximumDotSize(0.1f);
     61        this->setRadarSensitivity(1.0f);
     62        this->setHalfDotSizeDistance(3000.0f);
     63        this->setMaximumDotSize(0.1f);
    6264
    63         shapeMaterials_[RadarViewable::Dot]      = "RadarSquare.tga";
    64         shapeMaterials_[RadarViewable::Triangle] = "RadarSquare.tga";
    65         shapeMaterials_[RadarViewable::Square]   = "RadarSquare.tga";
     65        this->shapeMaterials_[RadarViewable::Dot]      = "RadarDot.tga";
     66        this->shapeMaterials_[RadarViewable::Triangle] = "RadarSquare.tga";
     67        this->shapeMaterials_[RadarViewable::Square]   = "RadarSquare.tga";
     68
     69        this->owner_ = 0;
    6670    }
    6771
     
    9094    void HUDRadar::displayObject(RadarViewable* object, bool bIsMarked)
    9195    {
    92 /*
     96        if (object == (RadarViewable*)this->owner_)
     97            return;
     98
    9399        const WorldEntity* wePointer = object->getWorldEntity();
    94100
    95101        // Just to be sure that we actually have a WorldEntity.
    96102        // We could do a dynamic_cast, but that would be a lot slower.
    97         if (!wePointer)
     103        if (!wePointer || !this->owner_)
    98104        {
    99             CCOUT(4) << "Cannot display a non-WorldEntitiy on the radar" << std::endl;
     105            if (!wePointer)
     106                CCOUT(2) << "Cannot display a non-WorldEntitiy on the radar" << std::endl;
     107            if (!this->owner_)
     108                CCOUT(2) << "No owner defined" << std::endl;
    100109            return;
    101110        }
    102 */
     111
    103112        // try to find a panel already created
    104113        Ogre::PanelOverlayElement* panel;
     
    112121            // get right material
    113122            panel->setMaterialName(TextureGenerator::getMaterialName(
    114                 shapeMaterials_[object->getRadarObjectType()], object->getRadarObjectColour()));
     123                shapeMaterials_[object->getRadarObjectShape()], object->getRadarObjectColour()));
    115124            this->overlay_->add2D(panel);
    116125            this->itRadarDots_ = this->radarDots_.end();
     
    121130            ++itRadarDots_;
    122131            std::string materialName = TextureGenerator::getMaterialName(
    123                 shapeMaterials_[object->getRadarObjectType()], object->getRadarObjectColour());
     132                shapeMaterials_[object->getRadarObjectShape()], object->getRadarObjectColour());
    124133            if (materialName != panel->getMaterialName())
    125134                panel->setMaterialName(materialName);
    126135        }
    127136        panel->show();
    128 /*
     137
    129138        // set size to fit distance...
    130         float distance = (wePointer->getWorldPosition() - SpaceShip::getLocalShip()->getPosition()).length();
     139        float distance = (wePointer->getWorldPosition() - this->owner_->getPosition()).length();
    131140        // calculate the size with 1/distance dependency for simplicity (instead of exp(-distance * lambda)
    132141        float size = maximumDotSize_ * halfDotSizeDistance_ / (halfDotSizeDistance_ + distance);
     
    134143
    135144        // calc position on radar...
    136         Vector2 coord = get2DViewcoordinates(SpaceShip::getLocalShip()->getPosition(), SpaceShip::getLocalShip()->getDir(), SpaceShip::getLocalShip()->getOrth(), wePointer->getWorldPosition());
     145        Vector2 coord = get2DViewcoordinates(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition());
    137146        coord *= Ogre::Math::PI / 3.5; // small adjustment to make it fit the texture
    138147        panel->setPosition((1.0 + coord.x - size) * 0.5, (1.0 - coord.y - size) * 0.5);
     
    144153            this->marker_->setPosition((1.0 + coord.x - size * 1.5) * 0.5, (1.0 - coord.y - size * 1.5) * 0.5);
    145154        }
    146 */
    147155    }
    148156
     
    154162        this->marker_->hide();
    155163    }
     164
     165    void HUDRadar::changedOwner()
     166    {
     167        SUPER(HUDRadar, changedOwner);
     168
     169        this->owner_ = dynamic_cast<Pawn*>(this->getOwner());
     170    }
    156171}
  • code/trunk/src/orxonox/overlays/hud/HUDRadar.h

    r2087 r2662  
    4949
    5050        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
     51        virtual void changedOwner();
    5152
    5253    private:
     
    7677
    7778        float sensitivity_;
     79
     80        Pawn* owner_;
    7881    };
    7982}
  • code/trunk/src/orxonox/overlays/hud/HUDSpeedBar.cc

    r2087 r2662  
    3131#include "HUDSpeedBar.h"
    3232#include "core/CoreIncludes.h"
     33#include "objects/worldentities/pawns/SpaceShip.h"
     34#include "objects/items/Engine.h"
    3335
    3436namespace orxonox
     
    4143        RegisterObject(HUDSpeedBar);
    4244
     45        this->owner_ = 0;
    4346    }
    4447
     
    4952    void HUDSpeedBar::tick(float dt)
    5053    {
    51 /*
    52         SpaceShip* ship = SpaceShip::getLocalShip();
    53         if (ship)
     54        SUPER(HUDSpeedBar, tick, dt);
     55
     56        if (this->owner_ && this->owner_->getEngine())
    5457        {
    55             float v = ship->getVelocity().length();
    56             float value = v / ship->getMaxSpeed();
    57             if (value != this->getValue())
    58                 this->setValue(value);
     58            float value = this->owner_->getVelocity().length() / (this->owner_->getEngine()->getMaxSpeedFront() * this->owner_->getEngine()->getSpeedFactor() * this->owner_->getEngine()->getBoostFactor());
     59            this->setValue(value);
    5960        }
    60 */
     61    }
     62
     63    void HUDSpeedBar::changedOwner()
     64    {
     65        SUPER(HUDSpeedBar, changedOwner);
     66
     67        this->owner_ = dynamic_cast<SpaceShip*>(this->getOwner());
    6168    }
    6269}
  • code/trunk/src/orxonox/overlays/hud/HUDSpeedBar.h

    r2087 r2662  
    4545
    4646        virtual void tick(float dt);
     47        virtual void changedOwner();
     48
     49    private:
     50        SpaceShip* owner_;
    4751    };
    4852}
  • code/trunk/src/orxonox/tools/BillboardSet.cc

    r2171 r2662  
    3434
    3535#include <OgreSceneManager.h>
     36#include <OgreBillboardSet.h>
    3637#include <OgreBillboard.h>
    3738
  • code/trunk/src/orxonox/tools/BillboardSet.h

    r2087 r2662  
    3333
    3434#include <string>
    35 #include <OgreBillboardSet.h>
     35#include <OgrePrerequisites.h>
    3636
    3737#include "util/Math.h"
     
    5252            inline Ogre::BillboardSet* getBillboardSet()
    5353                { return this->billboardSet_; }
     54            inline Ogre::SceneManager* getSceneManager()
     55                { return this->scenemanager_; }
    5456
    5557            const std::string& getName() const;
  • code/trunk/src/orxonox/tools/CMakeLists.txt

    r2131 r2662  
    33  Mesh.cc
    44  ParticleInterface.cc
     5  Shader.cc
    56  TextureGenerator.cc
    67  Timer.cc
  • code/trunk/src/orxonox/tools/Mesh.cc

    r2171 r2662  
    3131
    3232#include <sstream>
     33#include <OgreEntity.h>
    3334#include <OgreSceneManager.h>
    3435#include <cassert>
  • code/trunk/src/orxonox/tools/Mesh.h

    r2087 r2662  
    3333
    3434#include <string>
    35 #include <OgreEntity.h>
     35#include <OgrePrerequisites.h>
    3636
    3737namespace orxonox
  • code/trunk/src/orxonox/tools/ParticleInterface.cc

    r2171 r2662  
    5252    ParticleInterface::ParticleInterface(Ogre::SceneManager* scenemanager, const std::string& templateName, LODParticle::LOD detaillevel)
    5353    {
    54         RegisterRootObject(ParticleInterface);
     54        RegisterObject(ParticleInterface);
    5555
    5656        assert(scenemanager);
    5757
    5858        this->scenemanager_ = scenemanager;
    59         this->sceneNode_ = 0;
    6059        this->particleSystem_ = 0;
    6160
     
    6362        this->bVisible_ = true;
    6463        this->bAllowedByLOD_ = true;
     64        this->speedFactor_ = 1.0f;
    6565
    6666        if (Core::showsGraphics())
     
    6969            {
    7070                this->particleSystem_ = this->scenemanager_->createParticleSystem("particles" + getConvertedValue<unsigned int, std::string>(ParticleInterface::counter_s++), templateName);
    71                 this->particleSystem_->setSpeedFactor(1.0f);
    72 //                this->particleSystem_->setSpeedFactor(Orxonox::getInstance().getTimeFactor());
     71                this->setSpeedFactor(1.0f);
    7372            }
    7473            catch (...)
     
    8786        {
    8887            this->particleSystem_->removeAllEmitters();
    89             this->detachFromSceneNode();
    9088            this->scenemanager_->destroyParticleSystem(this->particleSystem_);
    91         }
    92     }
    93 
    94     void ParticleInterface::addToSceneNode(Ogre::SceneNode* sceneNode)
    95     {
    96         if (this->sceneNode_)
    97             this->detachFromSceneNode();
    98 
    99         if (this->particleSystem_)
    100         {
    101             this->sceneNode_ = sceneNode;
    102             this->sceneNode_->attachObject(this->particleSystem_);
    103         }
    104     }
    105 
    106     void ParticleInterface::detachFromSceneNode()
    107     {
    108         if (this->sceneNode_)
    109         {
    110             if (this->particleSystem_)
    111                 this->sceneNode_->detachObject(this->particleSystem_);
    112             this->sceneNode_ = 0;
    11389        }
    11490    }
     
    224200    void ParticleInterface::setSpeedFactor(float factor)
    225201    {
    226         if (this->particleSystem_)
    227         {
    228 //            this->particleSystem_->setSpeedFactor(Orxonox::getInstance().getTimeFactor() * factor);
    229             this->particleSystem_->setSpeedFactor(1.0f * factor);
    230         }
    231     }
    232     float ParticleInterface::getSpeedFactor() const
    233     {
    234         if (this->particleSystem_)
    235         {
    236 //            return (this->particleSystem_->getSpeedFactor() / Orxonox::getInstance().getTimeFactor());
    237             return (this->particleSystem_->getSpeedFactor() / 1.0f);
    238         }
    239         else
    240             return 1.0f;
     202        this->speedFactor_ = factor;
     203
     204        if (this->particleSystem_)
     205            this->particleSystem_->setSpeedFactor(factor * this->getTimeFactor());
     206    }
     207    void ParticleInterface::changedTimeFactor(float factor_new, float factor_old)
     208    {
     209        this->setSpeedFactor(this->speedFactor_);
    241210    }
    242211
  • code/trunk/src/orxonox/tools/ParticleInterface.h

    r2087 r2662  
    3333
    3434#include <string>
    35 #include <OgreParticleEmitter.h>
     35#include <OgrePrerequisites.h>
    3636
    3737#include "core/OrxonoxClass.h"
    3838#include "util/Math.h"
     39#include "gamestates/GSRoot.h"
    3940
    4041#define getAllEmitters() \
     
    4546namespace orxonox
    4647{
    47     class _OrxonoxExport ParticleInterface : public OrxonoxClass
     48    class _OrxonoxExport ParticleInterface : public TimeFactorListener
    4849    {
    4950        public:
     
    5354            inline Ogre::ParticleSystem* getParticleSystem() const
    5455                { return this->particleSystem_; }
    55 
    56             void addToSceneNode(Ogre::SceneNode* sceneNode);
    57             void detachFromSceneNode();
    5856
    5957            Ogre::ParticleEmitter* createNewEmitter();
     
    6967            unsigned int getNumAffectors() const;
    7068
    71             float getSpeedFactor() const;
     69            inline float getSpeedFactor() const
     70                { return this->speedFactor_; }
    7271            void setSpeedFactor(float factor);
    7372            bool getKeepParticlesInLocalSpace() const;
     
    9089                { return ParticleInterface::currentParticleInterface_s; }
    9190
     91        protected:
     92            virtual void changedTimeFactor(float factor_new, float factor_old);
     93
    9294        private:
    9395            void updateVisibility();
     
    9698            static unsigned int       counter_s;
    9799
    98             Ogre::SceneNode*          sceneNode_;
    99100            Ogre::ParticleSystem*     particleSystem_;
    100101            bool                      bVisible_;
     
    102103            bool                      bAllowedByLOD_;
    103104            unsigned int              detaillevel_;     //!< Detail level of this particle effect (0: off, 1: low, 2: normal, 3: high)
     105            float                     speedFactor_;
    104106            Ogre::SceneManager*       scenemanager_;
    105107    };
  • code/trunk/src/orxonox/tools/Timer.cc

    r2087 r2662  
    9696        this->time_ = 0;
    9797
    98         RegisterRootObject(TimerBase);
     98        RegisterObject(TimerBase);
    9999    }
    100100
     
    137137        {
    138138            // If active: Decrease the timer by the duration of the last frame
    139             this->time_ -= time.getDeltaTimeMicroseconds();
     139            this->time_ -= (long long)(time.getDeltaTimeMicroseconds() * this->getTimeFactor());
    140140
    141141            if (this->time_ <= 0)
  • code/trunk/src/orxonox/tools/Timer.h

    r2171 r2662  
    6262
    6363#include "OrxonoxPrereqs.h"
     64#include "core/Executor.h"
    6465#include "core/OrxonoxClass.h"
     66#include "gamestates/GSRoot.h"
    6567
    6668namespace orxonox
     
    7274
    7375    //! TimerBase is the parent of the Timer class.
    74     class _OrxonoxExport TimerBase : public OrxonoxClass
     76    class _OrxonoxExport TimerBase : public TimeFactorListener
    7577    {
    7678        public:
     
    159161                this->bLoop_ = bLoop;
    160162                executor->setObject(object);
    161                 this->executor_ = (Executor*)executor;
     163                this->executor_ = static_cast<Executor*>(executor);
    162164                this->bActive_ = true;
    163165
     
    197199                this->setInterval(interval);
    198200                this->bLoop_ = bLoop;
    199                 this->executor_ = (Executor*)executor;
     201                this->executor_ = executor;
    200202                this->bActive_ = true;
    201203
  • code/trunk/src/orxonox/tools/WindowEventListener.h

    r1755 r2662  
    4141    class _OrxonoxExport WindowEventListener : virtual public OrxonoxClass
    4242    {
    43     public:
    44         WindowEventListener();
    45         virtual ~WindowEventListener() { }
     43        public:
     44            WindowEventListener();
     45            virtual ~WindowEventListener() { }
    4646
    4747            /** Window has moved position */
  • code/trunk/src/tolua/tolua-5.1.pkg

  • code/trunk/src/util

  • code/trunk/src/util/Convert.h

    r2171 r2662  
    460460            else
    461461              *output = "false";
    462             return false;
     462            return true;
    463463        }
    464464    };
  • code/trunk/src/util/Exception.cc

  • code/trunk/src/util/Exception.h

    r2261 r2662  
    8282                  const char* filename, const char* functionName)                   \
    8383                  : Exception(description, lineNumber, filename, functionName)      \
    84         {                                                                           \
    85             /* Let the catcher decide whether to display the message below level 4  \
    86                Note: Don't place this code in Exception c'tor because getTypeName() \
    87                is still pure virtual at that time. */                               \
    88             COUT(4) << this->getFullDescription() << std::endl;                     \
    89         }                                                                           \
     84        { }                                                                         \
    9085                                                                                    \
    9186        ExceptionName##Exception(const std::string& description)                    \
    9287                  : Exception(description)                                          \
    93         { COUT(4) << this->getFullDescription() << std::endl; }                     \
     88        { }                                                                         \
    9489                                                                                    \
    9590        ~ExceptionName##Exception() throw() { }                                     \
     
    10398    CREATE_ORXONOX_EXCEPTION(FileNotFound);
    10499    CREATE_ORXONOX_EXCEPTION(Argument);
     100    CREATE_ORXONOX_EXCEPTION(PhysicsViolation);
     101    CREATE_ORXONOX_EXCEPTION(ParseError);
    105102    CREATE_ORXONOX_EXCEPTION(PluginsNotFound);
    106103    CREATE_ORXONOX_EXCEPTION(InitialisationFailed);
     
    111108}
    112109
    113 #define ThrowException(Type, Description) \
    114     throw Type##Exception(Description, __LINE__, __FILE__, __FUNCTIONNAME__)
     110    /**
     111    @brief
     112        Helper function that creates an exception, displays the message, but doesn't throw it.
     113    */
     114    template <class T>
     115    inline const T& InternalHandleException(const T& exception)
     116    {
     117        // let the catcher decide whether to display the message below level 4
     118        COUT(4) << exception.getFullDescription() << std::endl;
     119        return exception;
     120    }
     121
     122#define ThrowException(type, description) \
     123    throw InternalHandleException(type##Exception(description, __LINE__, __FILE__, __FUNCTIONNAME__))
    115124
    116125    // define an assert macro that can display a message
  • code/trunk/src/util/Integers.h

    r1755 r2662  
    4949typedef unsigned __int32  uint32_t;
    5050typedef unsigned __int64  uint64_t;
    51 #elif ORXONOX_COMPILER == ORXONOX_COMPILER_GCC
    52 # include "inttypes.h"
     51#else
     52# include <inttypes.h>
    5353#endif
    5454
  • code/trunk/src/util/Math.h

    r2171 r2662  
    6363namespace orxonox
    6464{
    65     typedef Ogre::Radian Radian;
    66     typedef Ogre::Degree Degree;
    67     typedef Ogre::Vector2 Vector2;
    68     typedef Ogre::Vector3 Vector3;
    69     typedef Ogre::Vector4 Vector4;
    70     typedef Ogre::Matrix3 Matrix3;
    71     typedef Ogre::Matrix4 Matrix4;
    72     typedef Ogre::Quaternion Quaternion;
    73     typedef Ogre::ColourValue ColourValue;
     65    using Ogre::Radian;
     66    using Ogre::Degree;
     67    using Ogre::Vector2;
     68    using Ogre::Vector3;
     69    using Ogre::Vector4;
     70    using Ogre::Matrix3;
     71    using Ogre::Matrix4;
     72    using Ogre::Quaternion;
     73    using Ogre::ColourValue;
     74
     75    // Also define our own transform space enum
     76    namespace TransformSpace
     77    {
     78        /**
     79        @brief
     80            Enumeration denoting the spaces which a transform can be relative to.
     81        */
     82        enum Enum
     83        {
     84            //! Transform is relative to the local space
     85            Local,
     86            //! Transform is relative to the space of the parent node
     87            Parent,
     88            //! Transform is relative to world space
     89            World
     90        };
     91    }
    7492
    7593    _UtilExport std::ostream& operator<<(std::ostream& out, const orxonox::Radian& radian);
     
    174192    inline T zeroise()
    175193    {
    176         BOOST_STATIC_ASSERT(sizeof(T) == 0);
    177         return T();
     194        // Default, raise a compiler error without including large boost header cascade.
     195        T temp();
     196        *********temp; // If you reach this code, you abused zeroise()!
     197        return temp;
    178198    }
    179199
  • code/trunk/src/util/MultiType.cc

    r2171 r2662  
    4545        switch (type)
    4646        {
     47            case MT_null:
     48                this->reset(); return true;
    4749            case MT_char:
    4850                return this->convert<char>(); break;
  • code/trunk/src/util/MultiType.h

    r2171 r2662  
    305305
    306306            /** @brief Current content gets deleted. New type is MT_null */
    307             inline void                       reset()                         { if (this->value_) this->value_->reset(); }
    308 
    309             template <typename T> inline void setType()                       { this->assignValue(T());                            } /** @brief Resets the value and changes the internal type to T. */
    310             inline void                       setType(const MultiType& other) { this->setType(other.getType());                    } /** @brief Resets the value and changes the internal type to the type of the other MultiType. */
    311             inline void                       setType(MT_Type type)           { this->reset(); this->convert(type); this->reset(); } /** @brief Resets the value and changes the internal type to the given type. */
     307            inline void                       reset()                         { if (this->value_) delete this->value_; this->value_ = 0; }
     308            /** @brief Current content gets overridden with default zero value */
     309            inline void                       resetValue()                    { if (this->value_) this->value_->reset(); }
     310
     311            template <typename T> inline void setType()                       { this->assignValue(T());                                 } /** @brief Resets the value and changes the internal type to T. */
     312            inline void                       setType(const MultiType& other) { this->setType(other.getType());                         } /** @brief Resets the value and changes the internal type to the type of the other MultiType. */
     313            inline void                       setType(MT_Type type)           { this->reset(); this->convert(type); this->resetValue(); } /** @brief Resets the value and changes the internal type to the given type. */
    312314
    313315            /** @brief Returns the current type. */
  • code/trunk/src/util/OutputHandler.cc

    r2171 r2662  
    100100        @param buffer The OutputBuffer
    101101    */
    102     void OutputHandler::setOutputBuffer(OutputBuffer& buffer)
    103     {
    104         buffer.getStream() >> this->outputBuffer_->getStream().rdbuf();
    105         this->outputBuffer_ = &buffer;
     102    void OutputHandler::setOutputBuffer(OutputBuffer* buffer)
     103    {
     104        if (buffer == NULL)
     105            this->outputBuffer_ = &this->fallbackBuffer_;
     106        else
     107        {
     108            buffer->getStream() >> this->outputBuffer_->getStream().rdbuf();
     109            this->outputBuffer_ = buffer;
     110        }
    106111    }
    107112
  • code/trunk/src/util/OutputHandler.h

    r2171 r2662  
    101101            static int getSoftDebugLevel(OutputHandler::OutputDevice device = OutputHandler::LD_All);
    102102
    103             void setOutputBuffer(OutputBuffer& buffer);
     103            void setOutputBuffer(OutputBuffer* buffer);
    104104
    105105            template <class T>
  • code/trunk/src/util/SignalHandler.cc

    r2261 r2662  
    3535#include "Debug.h"
    3636
    37 #include <cassert>
    3837#include <iostream>
    3938#include <cstdlib>
     
    4241namespace orxonox
    4342{
    44     SignalHandler * SignalHandler::singletonRef = NULL;
     43    SignalHandler* SignalHandler::singletonRef_s = NULL;
    4544}
    4645
     
    5554{
    5655    bool SignalHandler::bXAutoKeyRepeatOn_ = false;
    57 
    58     SignalHandler::SignalHandler()
    59     {
    60     }
    6156
    6257    /**
     
    133128    void SignalHandler::sigHandler( int sig )
    134129    {
    135       for ( SignalCallbackList::iterator it = SignalHandler::getInstance()->callbackList.begin(); it != SignalHandler::getInstance()->callbackList.end(); it++  )
     130      for ( SignalCallbackList::iterator it = SignalHandler::getInstance().callbackList.begin(); it != SignalHandler::getInstance().callbackList.end(); it++  )
    136131      {
    137132        (*(it->cb))( it->someData );
     
    184179      if ( sigPid == 0 )
    185180      {
    186         getInstance()->dontCatch();
     181        getInstance().dontCatch();
    187182        // wait for message from parent when it has attached gdb
    188183        int someData;
     
    237232
    238233      char cmd[256];
    239       snprintf( cmd, 256, "file %s\nattach %d\nc\n", getInstance()->appName.c_str(), sigPid );
     234      snprintf( cmd, 256, "file %s\nattach %d\nc\n", getInstance().appName.c_str(), sigPid );
    240235      write( gdbIn[1], cmd, strlen(cmd) );
    241236
     
    331326      bt.insert(0, timeString);
    332327
    333       FILE * f = fopen( getInstance()->filename.c_str(), "a" );
     328      FILE * f = fopen( getInstance().filename.c_str(), "a" );
    334329
    335330      if ( !f )
    336331      {
    337         perror( ( std::string( "could not append to " ) + getInstance()->filename ).c_str() );
     332        perror( ( std::string( "could not append to " ) + getInstance().filename ).c_str() );
    338333        exit(EXIT_FAILURE);
    339334      }
     
    341336      if ( fwrite( bt.c_str(), 1, bt.length(), f ) != bt.length() )
    342337      {
    343         COUT(0) << "could not write " << bt.length() << " byte to " << getInstance()->filename << std::endl;
     338        COUT(0) << "could not write " << bt.length() << " byte to " << getInstance().filename << std::endl;
    344339        exit(EXIT_FAILURE);
    345340      }
  • code/trunk/src/util/SignalHandler.h

    r2261 r2662  
    3737#include "UtilPrereqs.h"
    3838
     39#include <cassert>
    3940#include <list>
    4041#include <string>
     
    6869    class SignalHandler
    6970    {
    70     private:
    71         SignalHandler();
    7271    public:
    73         inline static SignalHandler* getInstance() { if (!SignalHandler::singletonRef) SignalHandler::singletonRef = new SignalHandler(); return SignalHandler::singletonRef; }
    74         ~SignalHandler(){ SignalHandler::singletonRef = NULL; }
     72        SignalHandler()  { assert(SignalHandler::singletonRef_s == 0); SignalHandler::singletonRef_s = this; }
     73        ~SignalHandler() { assert(SignalHandler::singletonRef_s != 0); SignalHandler::singletonRef_s = NULL; }
     74        inline static SignalHandler& getInstance() { assert(SignalHandler::singletonRef_s); return *SignalHandler::singletonRef_s; }
    7575
    7676        void registerCallback( SignalCallback cb, void * someData );
     
    8787        SignalCallbackList callbackList;
    8888
    89         static SignalHandler * singletonRef;
     89        static SignalHandler* singletonRef_s;
    9090
    9191        std::string appName;
     
    104104    {
    105105    public:
    106         inline static SignalHandler* getInstance() { if (!SignalHandler::singletonRef) SignalHandler::singletonRef = new SignalHandler(); return SignalHandler::singletonRef; };
    107         void doCatch( const std::string & appName, const std::string & filename ) {};
    108         void dontCatch() {};
    109         void registerCallback( SignalCallback cb, void * someData ) {};
     106        SignalHandler()  { assert(SignalHandler::singletonRef_s == 0); SignalHandler::singletonRef_s = this; }
     107        ~SignalHandler() { assert(SignalHandler::singletonRef_s != 0); SignalHandler::singletonRef_s = 0; }
     108        inline static SignalHandler& getInstance() { assert(SignalHandler::singletonRef_s); return *SignalHandler::singletonRef_s; }
     109        void doCatch( const std::string & appName, const std::string & filename ) {}
     110        void dontCatch() {}
     111        void registerCallback( SignalCallback cb, void * someData ) {}
    110112
    111113    private:
    112         static SignalHandler * singletonRef;
     114        static SignalHandler* singletonRef_s;
    113115    };
    114116}
  • code/trunk/src/util/String.cc

    r2171 r2662  
    8484    {
    8585        size_t pos1 = 0;
    86         int pos2 = str.size() - 1;
     86        int pos2 = (int)(str.size() - 1);
    8787        for (; pos1 < str.size() && (str[pos1] == ' ' || str[pos1] == '\t' || str[pos1] == '\n'); pos1++);
    8888        for (; pos2 > 0         && (str[pos2] == ' ' || str[pos2] == '\t' || str[pos2] == '\n'); pos2--);
  • code/trunk/src/util/mbool.h

    r2171 r2662  
    3636    struct _UtilExport mbool
    3737    {
     38//        friend Synchronisable::registerVariable<>()
    3839        public:
    3940            inline mbool(bool value = false)
     
    6768            inline bool operator!() const
    6869                { return (!this->value_.bool_); }
     70           
     71            inline unsigned char& getMemory(){ return value_.memory_; }
    6972
    7073        private:
  • code/trunk/visual_studio/vc8/audio.vsprops

  • code/trunk/visual_studio/vc8/base.vsprops

    r2261 r2662  
    88        <Tool
    99                Name="VCCLCompilerTool"
    10                 AdditionalIncludeDirectories="&quot;$(RootDir)&quot;;&quot;$(RootDir)src&quot;;&quot;$(RootDir)src\orxonox&quot;;&quot;$(RootDir)src\ceguilua-0.6.1&quot;;&quot;$(LibDir)ogre-1.4.9\include&quot;;&quot;$(LibDir)boost-1.35.0\include&quot;;&quot;$(LibDir)cegui-0.6.1\include&quot;;&quot;$(LibDir)enet-1.2\include&quot;;&quot;$(LibDir)libogg-1.1.3\include&quot;;&quot;$(LibDir)libvorbis-1.2.0\include&quot;;&quot;$(LibDir)openal-1.1\include&quot;;&quot;$(LibDir)freealut-1.1.0\include&quot;;&quot;$(LibDir)tcl-8.5.2\include&quot;;&quot;$(LibDir)zlib-1.2.3\include&quot;"
     10                AdditionalIncludeDirectories="&quot;$(RootDir)src&quot;;&quot;$(RootDir)src\ceguilua-0.6.1&quot;;&quot;$(RootDir)src\bullet&quot;;&quot;$(LibDir)ogre-1.4.9\include&quot;;&quot;$(LibDir)boost-1.35.0\include&quot;;&quot;$(LibDir)cegui-0.6.1\include&quot;;&quot;$(LibDir)enet-1.2\include&quot;;&quot;$(LibDir)libogg-1.1.3\include&quot;;&quot;$(LibDir)libvorbis-1.2.0\include&quot;;&quot;$(LibDir)openal-1.1\include&quot;;&quot;$(LibDir)freealut-1.1.0\include&quot;;&quot;$(LibDir)tcl-8.5.2\include&quot;;&quot;$(LibDir)zlib-1.2.3\include&quot;"
    1111                PreprocessorDefinitions="WIN32;__WIN32__;_WIN32;_WINDOWS;BOOST_ALL_DYN_LINK;OIS_DYNAMIC_LIB;ZLIB_WINAPI"
    1212                WarningLevel="3"
  • code/trunk/visual_studio/vc8/ceguilua.vsprops

  • code/trunk/visual_studio/vc8/core.vcproj

    r2087 r2662  
    101101                        <Tool
    102102                                Name="VCCLCompilerTool"
     103                                AdditionalOptions="/MP2"
    103104                        />
    104105                        <Tool
     
    153154                        </File>
    154155                        <File
     156                                RelativePath="..\..\src\core\CommandLine.cc"
     157                                >
     158                        </File>
     159                        <File
    155160                                RelativePath="..\..\src\core\ConfigFileManager.cc"
    156161                                >
     
    169174                        </File>
    170175                        <File
     176                                RelativePath="..\..\src\core\Executor.cc"
     177                                >
     178                        </File>
     179                        <File
    171180                                RelativePath="..\..\src\core\GameState.cc"
    172181                                >
     
    181190                        </File>
    182191                        <File
    183                                 RelativePath="..\..\src\core\OrxonoxClass.cc"
    184                                 >
    185                         </File>
    186                         <File
    187192                                RelativePath="..\..\src\core\RootGameState.cc"
    188                                 >
    189                         </File>
    190                         <File
    191                                 RelativePath="..\..\src\core\Template.cc"
    192                                 >
    193                         </File>
    194                         <File
    195                                 RelativePath="..\..\src\core\XMLNameListener.cc"
    196193                                >
    197194                        </File>
     
    231228                        </Filter>
    232229                        <Filter
    233                                 Name="command"
     230                                Name="commands"
    234231                                >
    235232                                <File
     
    246243                                </File>
    247244                                <File
    248                                         RelativePath="..\..\src\core\CommandLine.cc"
    249                                         >
    250                                 </File>
    251                                 <File
    252245                                        RelativePath="..\..\src\core\ConsoleCommand.cc"
    253246                                        >
     
    257250                                        >
    258251                                </File>
    259                                 <File
    260                                         RelativePath="..\..\src\core\Executor.cc"
    261                                         >
    262                                 </File>
    263252                        </Filter>
    264253                        <Filter
     
    266255                                >
    267256                                <File
     257                                        RelativePath="..\..\src\core\BaseObject.cc"
     258                                        >
     259                                </File>
     260                                <File
    268261                                        RelativePath="..\..\src\core\Factory.cc"
    269262                                        >
     
    281274                                        >
    282275                                </File>
    283                         </Filter>
    284                         <Filter
    285                                 Name="level"
    286                                 >
    287                                 <File
    288                                         RelativePath="..\..\src\core\BaseObject.cc"
    289                                         >
    290                                 </File>
     276                                <File
     277                                        RelativePath="..\..\src\core\OrxonoxClass.cc"
     278                                        >
     279                                </File>
     280                        </Filter>
     281                        <Filter
     282                                Name="loading"
     283                                >
    291284                                <File
    292285                                        RelativePath="..\..\src\core\ClassTreeMask.cc"
     
    303296                                <File
    304297                                        RelativePath="..\..\src\core\NamespaceNode.cc"
     298                                        >
     299                                </File>
     300                                <File
     301                                        RelativePath="..\..\src\core\Template.cc"
     302                                        >
     303                                </File>
     304                                <File
     305                                        RelativePath="..\..\src\core\XMLNameListener.cc"
    305306                                        >
    306307                                </File>
     
    389390                        </File>
    390391                        <File
     392                                RelativePath="..\..\src\core\CommandLine.h"
     393                                >
     394                        </File>
     395                        <File
    391396                                RelativePath="..\..\src\core\ConfigFileManager.h"
    392397                                >
     
    417422                        </File>
    418423                        <File
     424                                RelativePath="..\..\src\core\Executor.h"
     425                                >
     426                        </File>
     427                        <File
     428                                RelativePath="..\..\src\core\Functor.h"
     429                                >
     430                        </File>
     431                        <File
    419432                                RelativePath="..\..\src\core\GameState.h"
    420433                                >
     
    429442                        </File>
    430443                        <File
    431                                 RelativePath="..\..\src\core\OrxonoxClass.h"
    432                                 >
    433                         </File>
    434                         <File
    435444                                RelativePath="..\..\src\core\RootGameState.h"
    436445                                >
     
    440449                                >
    441450                        </File>
    442                         <File
    443                                 RelativePath="..\..\src\core\Template.h"
    444                                 >
    445                         </File>
    446                         <File
    447                                 RelativePath="..\..\src\core\XMLIncludes.h"
    448                                 >
    449                         </File>
    450                         <File
    451                                 RelativePath="..\..\src\core\XMLNameListener.h"
    452                                 >
    453                         </File>
    454451                        <Filter
    455452                                Name="input"
     
    509506                        </Filter>
    510507                        <Filter
    511                                 Name="command"
     508                                Name="commands"
    512509                                >
    513510                                <File
     
    532529                                </File>
    533530                                <File
    534                                         RelativePath="..\..\src\core\CommandLine.h"
    535                                         >
    536                                 </File>
    537                                 <File
    538531                                        RelativePath="..\..\src\core\ConsoleCommand.h"
    539532                                        >
     
    543536                                        >
    544537                                </File>
    545                                 <File
    546                                         RelativePath="..\..\src\core\Executor.h"
    547                                         >
    548                                 </File>
    549                                 <File
    550                                         RelativePath="..\..\src\core\Functor.h"
    551                                         >
    552                                 </File>
    553538                        </Filter>
    554539                        <Filter
     
    576561                                >
    577562                                <File
     563                                        RelativePath="..\..\src\core\BaseObject.h"
     564                                        >
     565                                </File>
     566                                <File
    578567                                        RelativePath="..\..\src\core\ClassFactory.h"
    579568                                        >
     
    611600                                        >
    612601                                </File>
    613                         </Filter>
    614                         <Filter
    615                                 Name="level"
    616                                 >
    617                                 <File
    618                                         RelativePath="..\..\src\core\BaseObject.h"
    619                                         >
    620                                 </File>
     602                                <File
     603                                        RelativePath="..\..\src\core\OrxonoxClass.h"
     604                                        >
     605                                </File>
     606                        </Filter>
     607                        <Filter
     608                                Name="loading"
     609                                >
    621610                                <File
    622611                                        RelativePath="..\..\src\core\ClassTreeMask.h"
     
    636625                                </File>
    637626                                <File
     627                                        RelativePath="..\..\src\core\Template.h"
     628                                        >
     629                                </File>
     630                                <File
    638631                                        RelativePath="..\..\src\core\XMLFile.h"
     632                                        >
     633                                </File>
     634                                <File
     635                                        RelativePath="..\..\src\core\XMLIncludes.h"
     636                                        >
     637                                </File>
     638                                <File
     639                                        RelativePath="..\..\src\core\XMLNameListener.h"
    639640                                        >
    640641                                </File>
  • code/trunk/visual_studio/vc8/core.vsprops

    r2261 r2662  
    88        <Tool
    99                Name="VCCLCompilerTool"
    10                 AdditionalOptions="/MP2"
    1110                PreprocessorDefinitions="CORE_SHARED_BUILD;LUA_BUILD_AS_DLL"
    1211        />
  • code/trunk/visual_studio/vc8/cpptcl.vsprops

  • code/trunk/visual_studio/vc8/debug.vsprops

    r2261 r2662  
    1313                BasicRuntimeChecks="3"
    1414                RuntimeLibrary="3"
    15                 DebugInformationFormat="3"
     15                DebugInformationFormat="4"
    1616        />
    1717        <Tool
  • code/trunk/visual_studio/vc8/lua.vsprops

  • code/trunk/visual_studio/vc8/network.vcproj

    r2087 r2662  
    101101                        <Tool
    102102                                Name="VCCLCompilerTool"
     103                                AdditionalOptions="/MP2"
    103104                        />
    104105                        <Tool
     
    197198                        </File>
    198199                        <File
    199                                 RelativePath="..\..\src\network\Synchronisable.cc"
     200                                RelativePath="..\..\src\network\TrafficControl.cc"
    200201                                >
    201202                        </File>
     
    229230                                <File
    230231                                        RelativePath="..\..\src\network\packet\Welcome.cc"
     232                                        >
     233                                </File>
     234                        </Filter>
     235                        <Filter
     236                                Name="synchronisable"
     237                                >
     238                                <File
     239                                        RelativePath="..\..\src\network\synchronisable\NetworkCallbackManager.cc"
     240                                        >
     241                                </File>
     242                                <File
     243                                        RelativePath="..\..\src\network\synchronisable\Synchronisable.cc"
     244                                        >
     245                                </File>
     246                                <File
     247                                        RelativePath="..\..\src\network\synchronisable\SynchronisableSpecialisations.cc"
     248                                        >
     249                                </File>
     250                                <File
     251                                        RelativePath="..\..\src\network\synchronisable\SynchronisableVariable.cc"
    231252                                        >
    232253                                </File>
     
    279300                        </File>
    280301                        <File
    281                                 RelativePath="..\..\src\network\NetworkCallback.h"
    282                                 >
    283                         </File>
    284                         <File
    285302                                RelativePath="..\..\src\network\NetworkPrereqs.h"
    286303                                >
     
    295312                        </File>
    296313                        <File
    297                                 RelativePath="..\..\src\network\Synchronisable.h"
     314                                RelativePath="..\..\src\network\TrafficControl.h"
    298315                                >
    299316                        </File>
     
    327344                                <File
    328345                                        RelativePath="..\..\src\network\packet\Welcome.h"
     346                                        >
     347                                </File>
     348                        </Filter>
     349                        <Filter
     350                                Name="synchronisable"
     351                                >
     352                                <File
     353                                        RelativePath="..\..\src\network\synchronisable\NetworkCallback.h"
     354                                        >
     355                                </File>
     356                                <File
     357                                        RelativePath="..\..\src\network\synchronisable\NetworkCallbackManager.h"
     358                                        >
     359                                </File>
     360                                <File
     361                                        RelativePath="..\..\src\network\synchronisable\Synchronisable.h"
     362                                        >
     363                                </File>
     364                                <File
     365                                        RelativePath="..\..\src\network\synchronisable\SynchronisableVariable.h"
    329366                                        >
    330367                                </File>
  • code/trunk/visual_studio/vc8/network.vsprops

    r2261 r2662  
    88        <Tool
    99                Name="VCCLCompilerTool"
    10                 AdditionalOptions="/MP2"
    1110                PreprocessorDefinitions="NETWORK_SHARED_BUILD"
    1211        />
  • code/trunk/visual_studio/vc8/ois.vsprops

    r2087 r2662  
    88        <Tool
    99                Name="VCCLCompilerTool"
    10                 AdditionalOptions="/MP2"
    1110                AdditionalIncludeDirectories="$(RootDir)src\ois"
    1211                PreprocessorDefinitions="OIS_NONCLIENT_BUILD;OIS_DYNAMIC_LIB"
  • code/trunk/visual_studio/vc8/orxonox.vcproj

    r2171 r2662  
    102102                        <Tool
    103103                                Name="VCCLCompilerTool"
     104                                AdditionalOptions="/MP2"
    104105                        />
    105106                        <Tool
     
    167168                        </File>
    168169                        <File
     170                                RelativePath="..\..\src\orxonox\PawnManager.cc"
     171                                >
     172                        </File>
     173                        <File
    169174                                RelativePath="..\..\src\orxonox\PlayerManager.cc"
    170175                                >
     
    210215                                </File>
    211216                                <File
     217                                        RelativePath="..\..\src\orxonox\objects\GlobalShader.cc"
     218                                        >
     219                                </File>
     220                                <File
    212221                                        RelativePath="..\..\src\orxonox\objects\Level.cc"
    213222                                        >
     
    247256                                                RelativePath="..\..\src\orxonox\objects\worldentities\Backlight.cc"
    248257                                                >
    249                                                 <FileConfiguration
    250                                                         Name="Debug|Win32"
    251                                                         ExcludedFromBuild="true"
    252                                                         >
    253                                                         <Tool
    254                                                                 Name="VCCLCompilerTool"
    255                                                         />
    256                                                 </FileConfiguration>
    257                                                 <FileConfiguration
    258                                                         Name="Release|Win32"
    259                                                         ExcludedFromBuild="true"
    260                                                         >
    261                                                         <Tool
    262                                                                 Name="VCCLCompilerTool"
    263                                                         />
    264                                                 </FileConfiguration>
    265258                                        </File>
    266259                                        <File
     
    285278                                        </File>
    286279                                        <File
     280                                                RelativePath="..\..\src\orxonox\objects\worldentities\ExplosionChunk.cc"
     281                                                >
     282                                        </File>
     283                                        <File
     284                                                RelativePath="..\..\src\orxonox\objects\worldentities\FadingBillboard.cc"
     285                                                >
     286                                        </File>
     287                                        <File
    287288                                                RelativePath="..\..\src\orxonox\objects\worldentities\Light.cc"
    288289                                                >
    289290                                        </File>
    290291                                        <File
     292                                                RelativePath="..\..\src\orxonox\objects\worldentities\MobileEntity.cc"
     293                                                >
     294                                        </File>
     295                                        <File
    291296                                                RelativePath="..\..\src\orxonox\objects\worldentities\Model.cc"
    292297                                                >
     
    305310                                        </File>
    306311                                        <File
    307                                                 RelativePath="..\..\src\orxonox\objects\worldentities\PositionableEntity.cc"
     312                                                RelativePath="..\..\src\orxonox\objects\worldentities\Planet.cc"
    308313                                                >
    309314                                        </File>
    310315                                        <File
    311316                                                RelativePath="..\..\src\orxonox\objects\worldentities\SpawnPoint.cc"
     317                                                >
     318                                        </File>
     319                                        <File
     320                                                RelativePath="..\..\src\orxonox\objects\worldentities\StaticEntity.cc"
    312321                                                >
    313322                                        </File>
     
    344353                                                </File>
    345354                                                <File
     355                                                        RelativePath="..\..\src\orxonox\objects\worldentities\triggers\PlayerTrigger.cc"
     356                                                        >
     357                                                </File>
     358                                                <File
    346359                                                        RelativePath="..\..\src\orxonox\objects\worldentities\triggers\Trigger.cc"
    347360                                                        >
     
    361374                                        >
    362375                                        <File
     376                                                RelativePath="..\..\src\orxonox\objects\infos\Bot.cc"
     377                                                >
     378                                        </File>
     379                                        <File
     380                                                RelativePath="..\..\src\orxonox\objects\infos\GametypeInfo.cc"
     381                                                >
     382                                        </File>
     383                                        <File
    363384                                                RelativePath="..\..\src\orxonox\objects\infos\HumanPlayer.cc"
    364385                                                >
     
    377398                                        >
    378399                                        <File
     400                                                RelativePath="..\..\src\orxonox\objects\controllers\AIController.cc"
     401                                                >
     402                                        </File>
     403                                        <File
     404                                                RelativePath="..\..\src\orxonox\objects\controllers\ArtificialController.cc"
     405                                                >
     406                                        </File>
     407                                        <File
    379408                                                RelativePath="..\..\src\orxonox\objects\controllers\Controller.cc"
    380409                                                >
     
    384413                                                >
    385414                                        </File>
     415                                        <File
     416                                                RelativePath="..\..\src\orxonox\objects\controllers\ScriptController.cc"
     417                                                >
     418                                        </File>
    386419                                </Filter>
    387420                                <Filter
     
    394427                                        <File
    395428                                                RelativePath="..\..\src\orxonox\objects\weaponSystem\Weapon.cc"
     429                                                >
     430                                        </File>
     431                                        <File
     432                                                RelativePath="..\..\src\orxonox\objects\weaponSystem\WeaponPack.cc"
    396433                                                >
    397434                                        </File>
     
    413450                                                <File
    414451                                                        RelativePath="..\..\src\orxonox\objects\weaponSystem\munitions\LaserGunMunition.cc"
     452                                                        >
     453                                                </File>
     454                                        </Filter>
     455                                        <Filter
     456                                                Name="weapons"
     457                                                >
     458                                                <File
     459                                                        RelativePath="..\..\src\orxonox\objects\weaponSystem\weapons\Fusion.cc"
     460                                                        >
     461                                                </File>
     462                                                <File
     463                                                        RelativePath="..\..\src\orxonox\objects\weaponSystem\weapons\LaserGun.cc"
     464                                                        >
     465                                                </File>
     466                                                <File
     467                                                        RelativePath="..\..\src\orxonox\objects\weaponSystem\weapons\Missile.cc"
    415468                                                        >
    416469                                                        <FileConfiguration
     
    433486                                        </Filter>
    434487                                        <Filter
    435                                                 Name="weapons"
    436                                                 >
    437                                                 <File
    438                                                         RelativePath="..\..\src\orxonox\objects\weaponSystem\weapons\LaserGun.cc"
    439                                                         >
    440                                                         <FileConfiguration
    441                                                                 Name="Debug|Win32"
    442                                                                 ExcludedFromBuild="true"
    443                                                                 >
    444                                                                 <Tool
    445                                                                         Name="VCCLCompilerTool"
    446                                                                 />
    447                                                         </FileConfiguration>
    448                                                         <FileConfiguration
    449                                                                 Name="Release|Win32"
    450                                                                 ExcludedFromBuild="true"
    451                                                                 >
    452                                                                 <Tool
    453                                                                         Name="VCCLCompilerTool"
    454                                                                 />
    455                                                         </FileConfiguration>
    456                                                 </File>
    457                                                 <File
    458                                                         RelativePath="..\..\src\orxonox\objects\weaponSystem\weapons\Missile.cc"
    459                                                         >
    460                                                         <FileConfiguration
    461                                                                 Name="Debug|Win32"
    462                                                                 ExcludedFromBuild="true"
    463                                                                 >
    464                                                                 <Tool
    465                                                                         Name="VCCLCompilerTool"
    466                                                                 />
    467                                                         </FileConfiguration>
    468                                                         <FileConfiguration
    469                                                                 Name="Release|Win32"
    470                                                                 ExcludedFromBuild="true"
    471                                                                 >
    472                                                                 <Tool
    473                                                                         Name="VCCLCompilerTool"
    474                                                                 />
    475                                                         </FileConfiguration>
     488                                                Name="projectiles"
     489                                                >
     490                                                <File
     491                                                        RelativePath="..\..\src\orxonox\objects\weaponSystem\projectiles\BillboardProjectile.cc"
     492                                                        >
     493                                                </File>
     494                                                <File
     495                                                        RelativePath="..\..\src\orxonox\objects\weaponSystem\projectiles\ParticleProjectile.cc"
     496                                                        >
     497                                                </File>
     498                                                <File
     499                                                        RelativePath="..\..\src\orxonox\objects\weaponSystem\projectiles\Projectile.cc"
     500                                                        >
    476501                                                </File>
    477502                                        </Filter>
    478                                         <Filter
    479                                                 Name="projectiles"
    480                                                 >
    481                                                 <File
    482                                                         RelativePath="..\..\src\orxonox\objects\weaponSystem\projectiles\BillboardProjectile.cc"
    483                                                         >
    484                                                         <FileConfiguration
    485                                                                 Name="Debug|Win32"
    486                                                                 ExcludedFromBuild="true"
    487                                                                 >
    488                                                                 <Tool
    489                                                                         Name="VCCLCompilerTool"
    490                                                                 />
    491                                                         </FileConfiguration>
    492                                                         <FileConfiguration
    493                                                                 Name="Release|Win32"
    494                                                                 ExcludedFromBuild="true"
    495                                                                 >
    496                                                                 <Tool
    497                                                                         Name="VCCLCompilerTool"
    498                                                                 />
    499                                                         </FileConfiguration>
    500                                                 </File>
    501                                                 <File
    502                                                         RelativePath="..\..\src\orxonox\objects\weaponSystem\projectiles\ParticleProjectile.cc"
    503                                                         >
    504                                                         <FileConfiguration
    505                                                                 Name="Debug|Win32"
    506                                                                 ExcludedFromBuild="true"
    507                                                                 >
    508                                                                 <Tool
    509                                                                         Name="VCCLCompilerTool"
    510                                                                 />
    511                                                         </FileConfiguration>
    512                                                         <FileConfiguration
    513                                                                 Name="Release|Win32"
    514                                                                 ExcludedFromBuild="true"
    515                                                                 >
    516                                                                 <Tool
    517                                                                         Name="VCCLCompilerTool"
    518                                                                 />
    519                                                         </FileConfiguration>
    520                                                 </File>
    521                                                 <File
    522                                                         RelativePath="..\..\src\orxonox\objects\weaponSystem\projectiles\Projectile.cc"
    523                                                         >
    524                                                         <FileConfiguration
    525                                                                 Name="Debug|Win32"
    526                                                                 ExcludedFromBuild="true"
    527                                                                 >
    528                                                                 <Tool
    529                                                                         Name="VCCLCompilerTool"
    530                                                                 />
    531                                                         </FileConfiguration>
    532                                                         <FileConfiguration
    533                                                                 Name="Release|Win32"
    534                                                                 ExcludedFromBuild="true"
    535                                                                 >
    536                                                                 <Tool
    537                                                                         Name="VCCLCompilerTool"
    538                                                                 />
    539                                                         </FileConfiguration>
    540                                                 </File>
    541                                         </Filter>
     503                                </Filter>
     504                                <Filter
     505                                        Name="collisionShapes"
     506                                        >
     507                                        <File
     508                                                RelativePath="..\..\src\orxonox\objects\collisionshapes\BoxCollisionShape.cc"
     509                                                >
     510                                        </File>
     511                                        <File
     512                                                RelativePath="..\..\src\orxonox\objects\collisionshapes\CollisionShape.cc"
     513                                                >
     514                                        </File>
     515                                        <File
     516                                                RelativePath="..\..\src\orxonox\objects\collisionshapes\CompoundCollisionShape.cc"
     517                                                >
     518                                        </File>
     519                                        <File
     520                                                RelativePath="..\..\src\orxonox\objects\collisionshapes\ConeCollisionShape.cc"
     521                                                >
     522                                        </File>
     523                                        <File
     524                                                RelativePath="..\..\src\orxonox\objects\collisionshapes\PlaneCollisionShape.cc"
     525                                                >
     526                                        </File>
     527                                        <File
     528                                                RelativePath="..\..\src\orxonox\objects\collisionshapes\SphereCollisionShape.cc"
     529                                                >
     530                                        </File>
     531                                        <File
     532                                                RelativePath="..\..\src\orxonox\objects\collisionshapes\WorldEntityCollisionShape.cc"
     533                                                >
     534                                        </File>
     535                                </Filter>
     536                                <Filter
     537                                        Name="items"
     538                                        >
     539                                        <File
     540                                                RelativePath="..\..\src\orxonox\objects\items\Engine.cc"
     541                                                >
     542                                        </File>
     543                                        <File
     544                                                RelativePath="..\..\src\orxonox\objects\items\Item.cc"
     545                                                >
     546                                        </File>
     547                                        <File
     548                                                RelativePath="..\..\src\orxonox\objects\items\MultiStateEngine.cc"
     549                                                >
     550                                        </File>
    542551                                </Filter>
    543552                                <Filter
     
    589598                                        </File>
    590599                                        <File
     600                                                RelativePath="..\..\src\orxonox\objects\quest\QuestEffectBeacon.cc"
     601                                                >
     602                                        </File>
     603                                        <File
    591604                                                RelativePath="..\..\src\orxonox\objects\quest\QuestHint.cc"
    592605                                                >
     
    597610                                        </File>
    598611                                        <File
     612                                                RelativePath="..\..\src\orxonox\objects\quest\QuestListener.cc"
     613                                                >
     614                                        </File>
     615                                        <File
    599616                                                RelativePath="..\..\src\orxonox\objects\quest\QuestManager.cc"
    600617                                                >
     
    602619                                        <File
    603620                                                RelativePath="..\..\src\orxonox\objects\quest\Rewardable.cc"
     621                                                >
     622                                        </File>
     623                                </Filter>
     624                                <Filter
     625                                        Name="pickup"
     626                                        >
     627                                        <File
     628                                                RelativePath="..\..\src\orxonox\objects\pickup\BaseItem.cc"
     629                                                >
     630                                        </File>
     631                                        <File
     632                                                RelativePath="..\..\src\orxonox\objects\pickup\PickupSpawner.cc"
     633                                                >
     634                                        </File>
     635                                        <File
     636                                                RelativePath="..\..\src\orxonox\objects\pickup\ShipEquipment.cc"
     637                                                >
     638                                        </File>
     639                                        <File
     640                                                RelativePath="..\..\src\orxonox\objects\pickup\Turbo.cc"
    604641                                                >
    605642                                        </File>
     
    619656                                <File
    620657                                        RelativePath="..\..\src\orxonox\tools\ParticleInterface.cc"
     658                                        >
     659                                </File>
     660                                <File
     661                                        RelativePath="..\..\src\orxonox\tools\Shader.cc"
    621662                                        >
    622663                                </File>
     
    715756                                        </File>
    716757                                        <File
     758                                                RelativePath="..\..\src\orxonox\overlays\hud\GametypeStatus.cc"
     759                                                >
     760                                        </File>
     761                                        <File
    717762                                                RelativePath="..\..\src\orxonox\overlays\hud\HUDBar.cc"
    718763                                                >
    719764                                        </File>
    720765                                        <File
     766                                                RelativePath="..\..\src\orxonox\overlays\hud\HUDHealthBar.cc"
     767                                                >
     768                                        </File>
     769                                        <File
    721770                                                RelativePath="..\..\src\orxonox\overlays\hud\HUDNavigation.cc"
    722771                                                >
     
    740789                                        <File
    741790                                                RelativePath="..\..\src\orxonox\overlays\debug\DebugRTRText.cc"
     791                                                >
     792                                        </File>
     793                                </Filter>
     794                                <Filter
     795                                        Name="stats"
     796                                        >
     797                                        <File
     798                                                RelativePath="..\..\src\orxonox\overlays\stats\CreateLines.cc"
     799                                                >
     800                                        </File>
     801                                        <File
     802                                                RelativePath="..\..\src\orxonox\overlays\stats\Scoreboard.cc"
     803                                                >
     804                                        </File>
     805                                        <File
     806                                                RelativePath="..\..\src\orxonox\overlays\stats\Stats.cc"
     807                                                >
     808                                        </File>
     809                                        <File
     810                                                RelativePath="..\..\src\orxonox\overlays\stats\StatsTest.cc"
     811                                                >
     812                                        </File>
     813                                </Filter>
     814                                <Filter
     815                                        Name="notifications"
     816                                        >
     817                                        <File
     818                                                RelativePath="..\..\src\orxonox\overlays\notifications\Notification.cc"
     819                                                >
     820                                        </File>
     821                                        <File
     822                                                RelativePath="..\..\src\orxonox\overlays\notifications\NotificationManager.cc"
     823                                                >
     824                                        </File>
     825                                        <File
     826                                                RelativePath="..\..\src\orxonox\overlays\notifications\NotificationQueue.cc"
    742827                                                >
    743828                                        </File>
     
    831916                        </File>
    832917                        <File
     918                                RelativePath="..\..\src\orxonox\PawnManager.h"
     919                                >
     920                        </File>
     921                        <File
    833922                                RelativePath="..\..\src\orxonox\PlayerManager.h"
    834923                                >
     
    854943                                </File>
    855944                                <File
     945                                        RelativePath="..\..\src\orxonox\objects\GlobalShader.h"
     946                                        >
     947                                </File>
     948                                <File
    856949                                        RelativePath="..\..\src\orxonox\objects\Level.h"
    857950                                        >
     
    9131006                                        </File>
    9141007                                        <File
     1008                                                RelativePath="..\..\src\orxonox\objects\worldentities\ExplosionChunk.h"
     1009                                                >
     1010                                        </File>
     1011                                        <File
     1012                                                RelativePath="..\..\src\orxonox\objects\worldentities\FadingBillboard.h"
     1013                                                >
     1014                                        </File>
     1015                                        <File
    9151016                                                RelativePath="..\..\src\orxonox\objects\worldentities\Light.h"
    9161017                                                >
    9171018                                        </File>
    9181019                                        <File
     1020                                                RelativePath="..\..\src\orxonox\objects\worldentities\MobileEntity.h"
     1021                                                >
     1022                                        </File>
     1023                                        <File
    9191024                                                RelativePath="..\..\src\orxonox\objects\worldentities\Model.h"
    9201025                                                >
     
    9331038                                        </File>
    9341039                                        <File
    935                                                 RelativePath="..\..\src\orxonox\objects\worldentities\PositionableEntity.h"
     1040                                                RelativePath="..\..\src\orxonox\objects\worldentities\Planet.h"
    9361041                                                >
    9371042                                        </File>
    9381043                                        <File
    9391044                                                RelativePath="..\..\src\orxonox\objects\worldentities\SpawnPoint.h"
     1045                                                >
     1046                                        </File>
     1047                                        <File
     1048                                                RelativePath="..\..\src\orxonox\objects\worldentities\StaticEntity.h"
    9401049                                                >
    9411050                                        </File>
     
    9721081                                                </File>
    9731082                                                <File
     1083                                                        RelativePath="..\..\src\orxonox\objects\worldentities\triggers\PlayerTrigger.h"
     1084                                                        >
     1085                                                </File>
     1086                                                <File
    9741087                                                        RelativePath="..\..\src\orxonox\objects\worldentities\triggers\Trigger.h"
    9751088                                                        >
     
    9891102                                        >
    9901103                                        <File
     1104                                                RelativePath="..\..\src\orxonox\objects\infos\Bot.h"
     1105                                                >
     1106                                        </File>
     1107                                        <File
     1108                                                RelativePath="..\..\src\orxonox\objects\infos\GametypeInfo.h"
     1109                                                >
     1110                                        </File>
     1111                                        <File
     1112                                                RelativePath="..\..\src\orxonox\objects\infos\HumanPlayer.h"
     1113                                                >
     1114                                        </File>
     1115                                        <File
    9911116                                                RelativePath="..\..\src\orxonox\objects\infos\Info.h"
    9921117                                                >
     
    10011126                                        >
    10021127                                        <File
     1128                                                RelativePath="..\..\src\orxonox\objects\controllers\AIController.h"
     1129                                                >
     1130                                        </File>
     1131                                        <File
     1132                                                RelativePath="..\..\src\orxonox\objects\controllers\ArtificialController.h"
     1133                                                >
     1134                                        </File>
     1135                                        <File
    10031136                                                RelativePath="..\..\src\orxonox\objects\controllers\Controller.h"
    10041137                                                >
     
    10081141                                                >
    10091142                                        </File>
     1143                                        <File
     1144                                                RelativePath="..\..\src\orxonox\objects\controllers\ScriptController.h"
     1145                                                >
     1146                                        </File>
    10101147                                </Filter>
    10111148                                <Filter
     
    10571194                                        </File>
    10581195                                        <File
     1196                                                RelativePath="..\..\src\orxonox\objects\quest\QuestEffectBeacon.h"
     1197                                                >
     1198                                        </File>
     1199                                        <File
    10591200                                                RelativePath="..\..\src\orxonox\objects\quest\QuestHint.h"
    10601201                                                >
     
    10621203                                        <File
    10631204                                                RelativePath="..\..\src\orxonox\objects\quest\QuestItem.h"
     1205                                                >
     1206                                        </File>
     1207                                        <File
     1208                                                RelativePath="..\..\src\orxonox\objects\quest\QuestListener.h"
    10641209                                                >
    10651210                                        </File>
     
    10991244                                                Name="weapons"
    11001245                                                >
     1246                                                <File
     1247                                                        RelativePath="..\..\src\orxonox\objects\weaponSystem\weapons\Fusion.h"
     1248                                                        >
     1249                                                </File>
    11011250                                                <File
    11021251                                                        RelativePath="..\..\src\orxonox\objects\weaponSystem\weapons\LaserGun.h"
     
    11331282                                        </Filter>
    11341283                                </Filter>
     1284                                <Filter
     1285                                        Name="collisionShapes"
     1286                                        >
     1287                                        <File
     1288                                                RelativePath="..\..\src\orxonox\objects\collisionshapes\BoxCollisionShape.h"
     1289                                                >
     1290                                        </File>
     1291                                        <File
     1292                                                RelativePath="..\..\src\orxonox\objects\collisionshapes\CollisionShape.h"
     1293                                                >
     1294                                        </File>
     1295                                        <File
     1296                                                RelativePath="..\..\src\orxonox\objects\collisionshapes\CompoundCollisionShape.h"
     1297                                                >
     1298                                        </File>
     1299                                        <File
     1300                                                RelativePath="..\..\src\orxonox\objects\collisionshapes\ConeCollisionShape.h"
     1301                                                >
     1302                                        </File>
     1303                                        <File
     1304                                                RelativePath="..\..\src\orxonox\objects\collisionshapes\PlaneCollisionShape.h"
     1305                                                >
     1306                                        </File>
     1307                                        <File
     1308                                                RelativePath="..\..\src\orxonox\objects\collisionshapes\SphereCollisionShape.h"
     1309                                                >
     1310                                        </File>
     1311                                        <File
     1312                                                RelativePath="..\..\src\orxonox\objects\collisionshapes\WorldEntityCollisionShape.h"
     1313                                                >
     1314                                        </File>
     1315                                </Filter>
     1316                                <Filter
     1317                                        Name="items"
     1318                                        >
     1319                                        <File
     1320                                                RelativePath="..\..\src\orxonox\objects\items\Engine.h"
     1321                                                >
     1322                                        </File>
     1323                                        <File
     1324                                                RelativePath="..\..\src\orxonox\objects\items\Item.h"
     1325                                                >
     1326                                        </File>
     1327                                        <File
     1328                                                RelativePath="..\..\src\orxonox\objects\items\MultiStateEngine.h"
     1329                                                >
     1330                                        </File>
     1331                                </Filter>
     1332                                <Filter
     1333                                        Name="pickup"
     1334                                        >
     1335                                        <File
     1336                                                RelativePath="..\..\src\orxonox\objects\pickup\BaseItem.h"
     1337                                                >
     1338                                        </File>
     1339                                        <File
     1340                                                RelativePath="..\..\src\orxonox\objects\pickup\PickupSpawner.h"
     1341                                                >
     1342                                        </File>
     1343                                        <File
     1344                                                RelativePath="..\..\src\orxonox\objects\pickup\ShipEquipment.h"
     1345                                                >
     1346                                        </File>
     1347                                        <File
     1348                                                RelativePath="..\..\src\orxonox\objects\pickup\ShipEquipmentClasses.h"
     1349                                                >
     1350                                        </File>
     1351                                        <File
     1352                                                RelativePath="..\..\src\orxonox\objects\pickup\ShipItem.h"
     1353                                                >
     1354                                        </File>
     1355                                        <File
     1356                                                RelativePath="..\..\src\orxonox\objects\pickup\Turbo.h"
     1357                                                >
     1358                                        </File>
     1359                                        <File
     1360                                                RelativePath="..\..\src\orxonox\objects\pickup\Usable.h"
     1361                                                >
     1362                                        </File>
     1363                                </Filter>
    11351364                        </Filter>
    11361365                        <Filter
     
    11421371                                </File>
    11431372                                <File
     1373                                        RelativePath="..\..\src\orxonox\tools\BulletConversions.h"
     1374                                        >
     1375                                </File>
     1376                                <File
    11441377                                        RelativePath="..\..\src\orxonox\tools\Mesh.h"
    11451378                                        >
     
    11471380                                <File
    11481381                                        RelativePath="..\..\src\orxonox\tools\ParticleInterface.h"
     1382                                        >
     1383                                </File>
     1384                                <File
     1385                                        RelativePath="..\..\src\orxonox\tools\Shader.h"
    11491386                                        >
    11501387                                </File>
     
    11931430                                        </File>
    11941431                                        <File
     1432                                                RelativePath="..\..\src\orxonox\overlays\hud\GametypeStatus.h"
     1433                                                >
     1434                                        </File>
     1435                                        <File
    11951436                                                RelativePath="..\..\src\orxonox\overlays\hud\HUDBar.h"
    11961437                                                >
    11971438                                        </File>
    11981439                                        <File
     1440                                                RelativePath="..\..\src\orxonox\overlays\hud\HUDHealthBar.h"
     1441                                                >
     1442                                        </File>
     1443                                        <File
    11991444                                                RelativePath="..\..\src\orxonox\overlays\hud\HUDNavigation.h"
    12001445                                                >
     
    12261471                                        <File
    12271472                                                RelativePath="..\..\src\orxonox\overlays\debug\DebugRTRText.h"
     1473                                                >
     1474                                        </File>
     1475                                </Filter>
     1476                                <Filter
     1477                                        Name="stats"
     1478                                        >
     1479                                        <File
     1480                                                RelativePath="..\..\src\orxonox\overlays\stats\CreateLines.h"
     1481                                                >
     1482                                        </File>
     1483                                        <File
     1484                                                RelativePath="..\..\src\orxonox\overlays\stats\Scoreboard.h"
     1485                                                >
     1486                                        </File>
     1487                                        <File
     1488                                                RelativePath="..\..\src\orxonox\overlays\stats\Stats.h"
     1489                                                >
     1490                                        </File>
     1491                                        <File
     1492                                                RelativePath="..\..\src\orxonox\overlays\stats\StatsTest.h"
     1493                                                >
     1494                                        </File>
     1495                                </Filter>
     1496                                <Filter
     1497                                        Name="notifications"
     1498                                        >
     1499                                        <File
     1500                                                RelativePath="..\..\src\orxonox\overlays\notifications\Notification.h"
     1501                                                >
     1502                                        </File>
     1503                                        <File
     1504                                                RelativePath="..\..\src\orxonox\overlays\notifications\NotificationManager.h"
     1505                                                >
     1506                                        </File>
     1507                                        <File
     1508                                                RelativePath="..\..\src\orxonox\overlays\notifications\NotificationQueue.h"
    12281509                                                >
    12291510                                        </File>
  • code/trunk/visual_studio/vc8/orxonox.vsprops

    r2261 r2662  
    88        <Tool
    99                Name="VCCLCompilerTool"
    10                 AdditionalOptions="/MP2 /Zm200"
     10                AdditionalOptions="/Zm200"
     11                AdditionalIncludeDirectories="$(RootDir)src\orxonox"
    1112                PreprocessorDefinitions="ORXONOX_NO_EXPORTS;ORXONOX_ENABLE_PCH;LUA_BUILD_AS_DLL"
    1213                UsePrecompiledHeader="2"
  • code/trunk/visual_studio/vc8/orxonox_vc8.sln

    r2261 r2662  
    88        EndProjectSection
    99        ProjectSection(ProjectDependencies) = postProject
    10                 {4BBBB49F-3203-4BB4-AAE3-48BCA96FCB4F} = {4BBBB49F-3203-4BB4-AAE3-48BCA96FCB4F}
     10                {35575B59-E1AE-40E8-89C4-2862B5B09B68} = {35575B59-E1AE-40E8-89C4-2862B5B09B68}
     11                {63B3E57A-4382-42F3-85EC-E869CFCCA88F} = {63B3E57A-4382-42F3-85EC-E869CFCCA88F}
     12                {2240ECD7-2F48-4431-8E1B-25466A384CCC} = {2240ECD7-2F48-4431-8E1B-25466A384CCC}
    1113                {F101C2F0-1CB9-4A57-827B-6C399A99B28F} = {F101C2F0-1CB9-4A57-827B-6C399A99B28F}
    1214                {271715F3-5B90-4110-A552-70C788084A86} = {271715F3-5B90-4110-A552-70C788084A86}
    13                 {2240ECD7-2F48-4431-8E1B-25466A384CCC} = {2240ECD7-2F48-4431-8E1B-25466A384CCC}
    14                 {35575B59-E1AE-40E8-89C4-2862B5B09B68} = {35575B59-E1AE-40E8-89C4-2862B5B09B68}
    15                 {4733BD1A-E04C-458D-8BFB-5010250EA497} = {4733BD1A-E04C-458D-8BFB-5010250EA497}
    16                 {63B3E57A-4382-42F3-85EC-E869CFCCA88F} = {63B3E57A-4382-42F3-85EC-E869CFCCA88F}
     15                {C8659D22-3CB7-41C9-A1BC-B40DB70A31A5} = {C8659D22-3CB7-41C9-A1BC-B40DB70A31A5}
     16                {41481057-47FD-4BEF-853B-7EF5F975F05E} = {41481057-47FD-4BEF-853B-7EF5F975F05E}
     17                {BA753941-F455-43A2-925C-7F3E02F6A995} = {BA753941-F455-43A2-925C-7F3E02F6A995}
     18                {4BBBB49F-3203-4BB4-AAE3-48BCA96FCB4F} = {4BBBB49F-3203-4BB4-AAE3-48BCA96FCB4F}
     19                {71FC0211-5EB5-4637-BE8A-A48EC3CC27D0} = {71FC0211-5EB5-4637-BE8A-A48EC3CC27D0}
    1720                {35E36A06-0A5C-4A0D-9AB6-5A05EAA87626} = {35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}
     21        EndProjectSection
     22EndProject
     23Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cpptcl", "cpptcl.vcproj", "{53C56131-E2AA-4A27-B460-7AC05D61A0E6}"
     24        ProjectSection(WebsiteProperties) = preProject
     25                Debug.AspNetCompiler.Debug = "True"
     26                Release.AspNetCompiler.Debug = "False"
     27        EndProjectSection
     28EndProject
     29Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyxml", "tinyxml.vcproj", "{F101C2F0-1CB9-4A57-827B-6C399A99B28F}"
     30        ProjectSection(WebsiteProperties) = preProject
     31                Debug.AspNetCompiler.Debug = "True"
     32                Release.AspNetCompiler.Debug = "False"
     33        EndProjectSection
     34EndProject
     35Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tolua", "tolua.vcproj", "{35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}"
     36        ProjectSection(WebsiteProperties) = preProject
     37                Debug.AspNetCompiler.Debug = "True"
     38                Release.AspNetCompiler.Debug = "False"
     39        EndProjectSection
     40        ProjectSection(ProjectDependencies) = postProject
     41                {63B3E57A-4382-42F3-85EC-E869CFCCA88F} = {63B3E57A-4382-42F3-85EC-E869CFCCA88F}
     42        EndProjectSection
     43EndProject
     44Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "toluagen_orxonox", "toluagen_orxonox.vcproj", "{71FC0211-5EB5-4637-BE8A-A48EC3CC27D0}"
     45        ProjectSection(WebsiteProperties) = preProject
     46                Debug.AspNetCompiler.Debug = "True"
     47                Release.AspNetCompiler.Debug = "False"
     48        EndProjectSection
     49        ProjectSection(ProjectDependencies) = postProject
     50                {A0724246-CB7C-420B-BCF0-68EF205AFE34} = {A0724246-CB7C-420B-BCF0-68EF205AFE34}
     51                {C6692661-9160-49E6-B109-A155F9485402} = {C6692661-9160-49E6-B109-A155F9485402}
     52                {8F5B7ED0-D380-4B4F-A744-3A568718176C} = {8F5B7ED0-D380-4B4F-A744-3A568718176C}
     53        EndProjectSection
     54EndProject
     55Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "toluagen", "toluagen.vcproj", "{A0724246-CB7C-420B-BCF0-68EF205AFE34}"
     56        ProjectSection(WebsiteProperties) = preProject
     57                Debug.AspNetCompiler.Debug = "True"
     58                Release.AspNetCompiler.Debug = "False"
     59        EndProjectSection
     60        ProjectSection(ProjectDependencies) = postProject
     61                {C6692661-9160-49E6-B109-A155F9485402} = {C6692661-9160-49E6-B109-A155F9485402}
     62                {8F5B7ED0-D380-4B4F-A744-3A568718176C} = {8F5B7ED0-D380-4B4F-A744-3A568718176C}
     63        EndProjectSection
     64EndProject
     65Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "util", "util.vcproj", "{2240ECD7-2F48-4431-8E1B-25466A384CCC}"
     66        ProjectSection(WebsiteProperties) = preProject
     67                Debug.AspNetCompiler.Debug = "True"
     68                Release.AspNetCompiler.Debug = "False"
     69        EndProjectSection
     70EndProject
     71Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "core", "core.vcproj", "{271715F3-5B90-4110-A552-70C788084A86}"
     72        ProjectSection(WebsiteProperties) = preProject
     73                Debug.AspNetCompiler.Debug = "True"
     74                Release.AspNetCompiler.Debug = "False"
     75        EndProjectSection
     76        ProjectSection(ProjectDependencies) = postProject
    1877                {71FC0211-5EB5-4637-BE8A-A48EC3CC27D0} = {71FC0211-5EB5-4637-BE8A-A48EC3CC27D0}
    19         EndProjectSection
    20 EndProject
    21 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cpptcl", "cpptcl.vcproj", "{53C56131-E2AA-4A27-B460-7AC05D61A0E6}"
    22         ProjectSection(WebsiteProperties) = preProject
    23                 Debug.AspNetCompiler.Debug = "True"
    24                 Release.AspNetCompiler.Debug = "False"
    25         EndProjectSection
    26 EndProject
    27 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyxml", "tinyxml.vcproj", "{F101C2F0-1CB9-4A57-827B-6C399A99B28F}"
    28         ProjectSection(WebsiteProperties) = preProject
    29                 Debug.AspNetCompiler.Debug = "True"
    30                 Release.AspNetCompiler.Debug = "False"
    31         EndProjectSection
    32 EndProject
    33 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tolua", "tolua.vcproj", "{35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}"
    34         ProjectSection(WebsiteProperties) = preProject
    35                 Debug.AspNetCompiler.Debug = "True"
    36                 Release.AspNetCompiler.Debug = "False"
    37         EndProjectSection
    38         ProjectSection(ProjectDependencies) = postProject
    39                 {63B3E57A-4382-42F3-85EC-E869CFCCA88F} = {63B3E57A-4382-42F3-85EC-E869CFCCA88F}
    40         EndProjectSection
    41 EndProject
    42 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "toluagen_orxonox", "toluagen_orxonox.vcproj", "{71FC0211-5EB5-4637-BE8A-A48EC3CC27D0}"
    43         ProjectSection(WebsiteProperties) = preProject
    44                 Debug.AspNetCompiler.Debug = "True"
    45                 Release.AspNetCompiler.Debug = "False"
    46         EndProjectSection
    47         ProjectSection(ProjectDependencies) = postProject
    48                 {8F5B7ED0-D380-4B4F-A744-3A568718176C} = {8F5B7ED0-D380-4B4F-A744-3A568718176C}
    49                 {C6692661-9160-49E6-B109-A155F9485402} = {C6692661-9160-49E6-B109-A155F9485402}
    50                 {A0724246-CB7C-420B-BCF0-68EF205AFE34} = {A0724246-CB7C-420B-BCF0-68EF205AFE34}
    51         EndProjectSection
    52 EndProject
    53 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "toluagen", "toluagen.vcproj", "{A0724246-CB7C-420B-BCF0-68EF205AFE34}"
    54         ProjectSection(WebsiteProperties) = preProject
    55                 Debug.AspNetCompiler.Debug = "True"
    56                 Release.AspNetCompiler.Debug = "False"
    57         EndProjectSection
    58         ProjectSection(ProjectDependencies) = postProject
    59                 {8F5B7ED0-D380-4B4F-A744-3A568718176C} = {8F5B7ED0-D380-4B4F-A744-3A568718176C}
    60                 {C6692661-9160-49E6-B109-A155F9485402} = {C6692661-9160-49E6-B109-A155F9485402}
    61         EndProjectSection
    62 EndProject
    63 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "util", "util.vcproj", "{2240ECD7-2F48-4431-8E1B-25466A384CCC}"
    64         ProjectSection(WebsiteProperties) = preProject
    65                 Debug.AspNetCompiler.Debug = "True"
    66                 Release.AspNetCompiler.Debug = "False"
    67         EndProjectSection
    68 EndProject
    69 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "core", "core.vcproj", "{271715F3-5B90-4110-A552-70C788084A86}"
    70         ProjectSection(WebsiteProperties) = preProject
    71                 Debug.AspNetCompiler.Debug = "True"
    72                 Release.AspNetCompiler.Debug = "False"
    73         EndProjectSection
    74         ProjectSection(ProjectDependencies) = postProject
     78                {63B3E57A-4382-42F3-85EC-E869CFCCA88F} = {63B3E57A-4382-42F3-85EC-E869CFCCA88F}
     79                {35E36A06-0A5C-4A0D-9AB6-5A05EAA87626} = {35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}
     80                {53C56131-E2AA-4A27-B460-7AC05D61A0E6} = {53C56131-E2AA-4A27-B460-7AC05D61A0E6}
     81                {2240ECD7-2F48-4431-8E1B-25466A384CCC} = {2240ECD7-2F48-4431-8E1B-25466A384CCC}
     82                {F101C2F0-1CB9-4A57-827B-6C399A99B28F} = {F101C2F0-1CB9-4A57-827B-6C399A99B28F}
    7583                {EA969DF2-70AF-46E6-BBE2-E03112E04CB8} = {EA969DF2-70AF-46E6-BBE2-E03112E04CB8}
    76                 {F101C2F0-1CB9-4A57-827B-6C399A99B28F} = {F101C2F0-1CB9-4A57-827B-6C399A99B28F}
    77                 {2240ECD7-2F48-4431-8E1B-25466A384CCC} = {2240ECD7-2F48-4431-8E1B-25466A384CCC}
    78                 {53C56131-E2AA-4A27-B460-7AC05D61A0E6} = {53C56131-E2AA-4A27-B460-7AC05D61A0E6}
     84        EndProjectSection
     85EndProject
     86Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "audio", "audio.vcproj", "{4733BD1A-E04C-458D-8BFB-5010250EA497}"
     87        ProjectSection(WebsiteProperties) = preProject
     88                Debug.AspNetCompiler.Debug = "True"
     89                Release.AspNetCompiler.Debug = "False"
     90        EndProjectSection
     91        ProjectSection(ProjectDependencies) = postProject
     92                {2240ECD7-2F48-4431-8E1B-25466A384CCC} = {2240ECD7-2F48-4431-8E1B-25466A384CCC}
     93                {271715F3-5B90-4110-A552-70C788084A86} = {271715F3-5B90-4110-A552-70C788084A86}
     94        EndProjectSection
     95EndProject
     96Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "network", "network.vcproj", "{35575B59-E1AE-40E8-89C4-2862B5B09B68}"
     97        ProjectSection(WebsiteProperties) = preProject
     98                Debug.AspNetCompiler.Debug = "True"
     99                Release.AspNetCompiler.Debug = "False"
     100        EndProjectSection
     101        ProjectSection(ProjectDependencies) = postProject
     102                {2240ECD7-2F48-4431-8E1B-25466A384CCC} = {2240ECD7-2F48-4431-8E1B-25466A384CCC}
     103                {271715F3-5B90-4110-A552-70C788084A86} = {271715F3-5B90-4110-A552-70C788084A86}
     104        EndProjectSection
     105EndProject
     106Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lua", "lua.vcproj", "{63B3E57A-4382-42F3-85EC-E869CFCCA88F}"
     107        ProjectSection(WebsiteProperties) = preProject
     108                Debug.AspNetCompiler.Debug = "True"
     109                Release.AspNetCompiler.Debug = "False"
     110        EndProjectSection
     111EndProject
     112Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ceguilua", "ceguilua.vcproj", "{4BBBB49F-3203-4BB4-AAE3-48BCA96FCB4F}"
     113        ProjectSection(WebsiteProperties) = preProject
     114                Debug.AspNetCompiler.Debug = "True"
     115                Release.AspNetCompiler.Debug = "False"
     116        EndProjectSection
     117        ProjectSection(ProjectDependencies) = postProject
     118                {63B3E57A-4382-42F3-85EC-E869CFCCA88F} = {63B3E57A-4382-42F3-85EC-E869CFCCA88F}
    79119                {35E36A06-0A5C-4A0D-9AB6-5A05EAA87626} = {35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}
    80                 {63B3E57A-4382-42F3-85EC-E869CFCCA88F} = {63B3E57A-4382-42F3-85EC-E869CFCCA88F}
    81                 {71FC0211-5EB5-4637-BE8A-A48EC3CC27D0} = {71FC0211-5EB5-4637-BE8A-A48EC3CC27D0}
    82         EndProjectSection
    83 EndProject
    84 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "audio", "audio.vcproj", "{4733BD1A-E04C-458D-8BFB-5010250EA497}"
    85         ProjectSection(WebsiteProperties) = preProject
    86                 Debug.AspNetCompiler.Debug = "True"
    87                 Release.AspNetCompiler.Debug = "False"
    88         EndProjectSection
    89         ProjectSection(ProjectDependencies) = postProject
    90                 {271715F3-5B90-4110-A552-70C788084A86} = {271715F3-5B90-4110-A552-70C788084A86}
    91                 {2240ECD7-2F48-4431-8E1B-25466A384CCC} = {2240ECD7-2F48-4431-8E1B-25466A384CCC}
    92         EndProjectSection
    93 EndProject
    94 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "network", "network.vcproj", "{35575B59-E1AE-40E8-89C4-2862B5B09B68}"
    95         ProjectSection(WebsiteProperties) = preProject
    96                 Debug.AspNetCompiler.Debug = "True"
    97                 Release.AspNetCompiler.Debug = "False"
    98         EndProjectSection
    99         ProjectSection(ProjectDependencies) = postProject
    100                 {271715F3-5B90-4110-A552-70C788084A86} = {271715F3-5B90-4110-A552-70C788084A86}
    101                 {2240ECD7-2F48-4431-8E1B-25466A384CCC} = {2240ECD7-2F48-4431-8E1B-25466A384CCC}
    102         EndProjectSection
    103 EndProject
    104 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lua", "lua.vcproj", "{63B3E57A-4382-42F3-85EC-E869CFCCA88F}"
    105         ProjectSection(WebsiteProperties) = preProject
    106                 Debug.AspNetCompiler.Debug = "True"
    107                 Release.AspNetCompiler.Debug = "False"
    108         EndProjectSection
    109 EndProject
    110 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ceguilua", "ceguilua.vcproj", "{4BBBB49F-3203-4BB4-AAE3-48BCA96FCB4F}"
    111         ProjectSection(WebsiteProperties) = preProject
    112                 Debug.AspNetCompiler.Debug = "True"
    113                 Release.AspNetCompiler.Debug = "False"
    114         EndProjectSection
    115         ProjectSection(ProjectDependencies) = postProject
    116                 {35E36A06-0A5C-4A0D-9AB6-5A05EAA87626} = {35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}
    117                 {63B3E57A-4382-42F3-85EC-E869CFCCA88F} = {63B3E57A-4382-42F3-85EC-E869CFCCA88F}
    118120        EndProjectSection
    119121EndProject
     
    137139EndProject
    138140Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lua_static", "lua_static.vcproj", "{8F5B7ED0-D380-4B4F-A744-3A568718176C}"
     141        ProjectSection(WebsiteProperties) = preProject
     142                Debug.AspNetCompiler.Debug = "True"
     143                Release.AspNetCompiler.Debug = "False"
     144        EndProjectSection
     145EndProject
     146Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bullet_collision", "bullet_collision.vcproj", "{BA753941-F455-43A2-925C-7F3E02F6A995}"
     147        ProjectSection(WebsiteProperties) = preProject
     148                Debug.AspNetCompiler.Debug = "True"
     149                Release.AspNetCompiler.Debug = "False"
     150        EndProjectSection
     151EndProject
     152Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bullet_dynamics", "bullet_dynamics.vcproj", "{41481057-47FD-4BEF-853B-7EF5F975F05E}"
     153        ProjectSection(WebsiteProperties) = preProject
     154                Debug.AspNetCompiler.Debug = "True"
     155                Release.AspNetCompiler.Debug = "False"
     156        EndProjectSection
     157EndProject
     158Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bullet_linearmath", "bullet_linearmath.vcproj", "{C8659D22-3CB7-41C9-A1BC-B40DB70A31A5}"
    139159        ProjectSection(WebsiteProperties) = preProject
    140160                Debug.AspNetCompiler.Debug = "True"
     
    148168        EndGlobalSection
    149169        GlobalSection(ProjectConfigurationPlatforms) = postSolution
     170                {0B6C5CFD-F91B-432A-80A3-2610F61E060B}.Debug|Win32.ActiveCfg = Debug|Win32
     171                {0B6C5CFD-F91B-432A-80A3-2610F61E060B}.Debug|Win32.Build.0 = Debug|Win32
     172                {0B6C5CFD-F91B-432A-80A3-2610F61E060B}.Release|Win32.ActiveCfg = Release|Win32
     173                {0B6C5CFD-F91B-432A-80A3-2610F61E060B}.Release|Win32.Build.0 = Release|Win32
    150174                {53C56131-E2AA-4A27-B460-7AC05D61A0E6}.Debug|Win32.ActiveCfg = Debug|Win32
    151175                {53C56131-E2AA-4A27-B460-7AC05D61A0E6}.Debug|Win32.Build.0 = Debug|Win32
     
    177201                {271715F3-5B90-4110-A552-70C788084A86}.Release|Win32.Build.0 = Release|Win32
    178202                {4733BD1A-E04C-458D-8BFB-5010250EA497}.Debug|Win32.ActiveCfg = Debug|Win32
    179                 {4733BD1A-E04C-458D-8BFB-5010250EA497}.Debug|Win32.Build.0 = Debug|Win32
    180203                {4733BD1A-E04C-458D-8BFB-5010250EA497}.Release|Win32.ActiveCfg = Release|Win32
    181                 {4733BD1A-E04C-458D-8BFB-5010250EA497}.Release|Win32.Build.0 = Release|Win32
    182204                {35575B59-E1AE-40E8-89C4-2862B5B09B68}.Debug|Win32.ActiveCfg = Debug|Win32
    183205                {35575B59-E1AE-40E8-89C4-2862B5B09B68}.Debug|Win32.Build.0 = Debug|Win32
    184206                {35575B59-E1AE-40E8-89C4-2862B5B09B68}.Release|Win32.ActiveCfg = Release|Win32
    185207                {35575B59-E1AE-40E8-89C4-2862B5B09B68}.Release|Win32.Build.0 = Release|Win32
    186                 {0B6C5CFD-F91B-432A-80A3-2610F61E060B}.Debug|Win32.ActiveCfg = Debug|Win32
    187                 {0B6C5CFD-F91B-432A-80A3-2610F61E060B}.Debug|Win32.Build.0 = Debug|Win32
    188                 {0B6C5CFD-F91B-432A-80A3-2610F61E060B}.Release|Win32.ActiveCfg = Release|Win32
    189                 {0B6C5CFD-F91B-432A-80A3-2610F61E060B}.Release|Win32.Build.0 = Release|Win32
    190208                {63B3E57A-4382-42F3-85EC-E869CFCCA88F}.Debug|Win32.ActiveCfg = Debug|Win32
    191209                {63B3E57A-4382-42F3-85EC-E869CFCCA88F}.Debug|Win32.Build.0 = Debug|Win32
     
    208226                {8F5B7ED0-D380-4B4F-A744-3A568718176C}.Release|Win32.ActiveCfg = Release|Win32
    209227                {8F5B7ED0-D380-4B4F-A744-3A568718176C}.Release|Win32.Build.0 = Release|Win32
     228                {BA753941-F455-43A2-925C-7F3E02F6A995}.Debug|Win32.ActiveCfg = Debug|Win32
     229                {BA753941-F455-43A2-925C-7F3E02F6A995}.Debug|Win32.Build.0 = Debug|Win32
     230                {BA753941-F455-43A2-925C-7F3E02F6A995}.Release|Win32.ActiveCfg = Release|Win32
     231                {BA753941-F455-43A2-925C-7F3E02F6A995}.Release|Win32.Build.0 = Release|Win32
     232                {41481057-47FD-4BEF-853B-7EF5F975F05E}.Debug|Win32.ActiveCfg = Debug|Win32
     233                {41481057-47FD-4BEF-853B-7EF5F975F05E}.Debug|Win32.Build.0 = Debug|Win32
     234                {41481057-47FD-4BEF-853B-7EF5F975F05E}.Release|Win32.ActiveCfg = Release|Win32
     235                {41481057-47FD-4BEF-853B-7EF5F975F05E}.Release|Win32.Build.0 = Release|Win32
     236                {C8659D22-3CB7-41C9-A1BC-B40DB70A31A5}.Debug|Win32.ActiveCfg = Debug|Win32
     237                {C8659D22-3CB7-41C9-A1BC-B40DB70A31A5}.Debug|Win32.Build.0 = Debug|Win32
     238                {C8659D22-3CB7-41C9-A1BC-B40DB70A31A5}.Release|Win32.ActiveCfg = Release|Win32
     239                {C8659D22-3CB7-41C9-A1BC-B40DB70A31A5}.Release|Win32.Build.0 = Release|Win32
    210240        EndGlobalSection
    211241        GlobalSection(SolutionProperties) = preSolution
     
    223253                {C6692661-9160-49E6-B109-A155F9485402} = {B9D56701-B4DB-43F8-9920-241CA418C1CE}
    224254                {8F5B7ED0-D380-4B4F-A744-3A568718176C} = {B9D56701-B4DB-43F8-9920-241CA418C1CE}
     255                {BA753941-F455-43A2-925C-7F3E02F6A995} = {B9D56701-B4DB-43F8-9920-241CA418C1CE}
     256                {41481057-47FD-4BEF-853B-7EF5F975F05E} = {B9D56701-B4DB-43F8-9920-241CA418C1CE}
     257                {C8659D22-3CB7-41C9-A1BC-B40DB70A31A5} = {B9D56701-B4DB-43F8-9920-241CA418C1CE}
    225258        EndGlobalSection
    226259EndGlobal
  • code/trunk/visual_studio/vc8/release.vsprops

  • code/trunk/visual_studio/vc8/tinyxml.vcproj

  • code/trunk/visual_studio/vc8/tinyxml.vsprops

  • code/trunk/visual_studio/vc8/tolua.vsprops

  • code/trunk/visual_studio/vc8/toluagen.vcproj

  • code/trunk/visual_studio/vc8/toluagen.vsprops

  • code/trunk/visual_studio/vc8/toluagen_orxonox.vcproj

  • code/trunk/visual_studio/vc8/toluagen_orxonox.vsprops

  • code/trunk/visual_studio/vc8/util.vcproj

    r2171 r2662  
    247247                        </File>
    248248                        <File
     249                                RelativePath="..\..\src\util\OrxEnum.h"
     250                                >
     251                        </File>
     252                        <File
    249253                                RelativePath="..\..\src\util\OrxonoxPlatform.h"
    250254                                >
  • code/trunk/visual_studio/vc8/util.vsprops

    r2261 r2662  
    88        <Tool
    99                Name="VCCLCompilerTool"
    10                 AdditionalOptions="/MP2"
    1110                PreprocessorDefinitions="UTIL_SHARED_BUILD"
    1211        />
Note: See TracChangeset for help on using the changeset viewer.