Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8706 for code/trunk/src


Ignore:
Timestamp:
Jun 14, 2011, 8:53:28 PM (13 years ago)
Author:
dafrick
Message:

Merging presentation branch back into trunk.
There are many new features and also a lot of other changes and bugfixes, if you want to know, digg through the svn log.
Not everything is yet working as it should, but it should be fairly stable. If you habe any bug reports, just send me an email.

Location:
code/trunk
Files:
6 deleted
145 edited
46 copied

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/core/BaseObject.cc

    r7401 r8706  
    195195    void BaseObject::addTemplate(Template* temp)
    196196    {
     197        // network
     198        if (temp->isLink())
     199        {
     200            this->networkTemplateNames_.insert(temp->getLink());
     201           
     202            Template* link;
     203            assert(!(link = Template::getTemplate(temp->getLink())) || !link->isLink());
     204            link = NULL;
     205        }
     206        else
     207            this->networkTemplateNames_.insert(temp->getName());
     208
     209        // add template
    197210        this->templates_.insert(temp);
    198         if( temp->isLink() )
    199         {
    200           this->networkTemplateNames_.insert(temp->getLink());
    201           assert( !Template::getTemplate(temp->getLink())->isLink() );
    202         }
    203         else
    204           this->networkTemplateNames_.insert(temp->getName());
    205211        temp->applyOn(this);
    206212    }
  • code/trunk/src/libraries/core/ConfigValueContainer.h

    r7401 r8706  
    109109            */
    110110            template <class D, class V>
    111             ConfigValueContainer(ConfigFileType::Value type, Identifier* identifier, const std::string& sectionname, const std::string& varname, const D& defvalue, const V& value)
     111            ConfigValueContainer(ConfigFileType::Value type, Identifier* identifier, const std::string& sectionname, const std::string& varname, const D& defvalue, const V&)
    112112            {
    113113                this->init(type, identifier, sectionname, varname);
     
    125125            */
    126126            template <class D, class V>
    127             ConfigValueContainer(ConfigFileType::Value type, Identifier* identifier, const std::string& sectionname, const std::string& varname, const std::vector<D>& defvalue, const std::vector<V>& value)
     127            ConfigValueContainer(ConfigFileType::Value type, Identifier* identifier, const std::string& sectionname, const std::string& varname, const std::vector<D>& defvalue, const std::vector<V>&)
    128128            {
    129129                this->init(type, identifier, sectionname, varname);
  • code/trunk/src/libraries/core/CoreIncludes.h

    r7401 r8706  
    171171    */
    172172    template <class T>
    173     inline Identifier* ClassByObjectType(const T* object)
     173    inline Identifier* ClassByObjectType(const T*)
    174174    {
    175175        return ClassIdentifier<T>::getIdentifier();
  • code/trunk/src/libraries/core/GUIManager.cc

    r8530 r8706  
    3838#include <CEGUIDefaultLogger.h>
    3939#include <CEGUIExceptions.h>
     40#include <CEGUIFontManager.h>
    4041#include <CEGUIInputEvent.h>
    4142#include <CEGUIMouseCursor.h>
     
    4445#include <CEGUIWindow.h>
    4546#include <CEGUIWindowManager.h>
     47#include <CEGUIXMLAttributes.h>
    4648#include <elements/CEGUIListbox.h>
    4749#include <elements/CEGUIListboxItem.h>
     
    260262        COUT(3) << "Initialising CEGUI." << std::endl;
    261263
     264        this->oldCEGUI_ = false;
     265       
    262266        // Note: No SceneManager specified yet
    263267#ifdef ORXONOX_OLD_CEGUI
    264268        guiRenderer_ = new OgreCEGUIRenderer(GraphicsManager::getInstance().getRenderWindow(), Ogre::RENDER_QUEUE_OVERLAY, false, 3000);
    265269        resourceProvider_ = guiRenderer_->createResourceProvider();
     270        this->oldCEGUI_ = true;
    266271#else
    267272        guiRenderer_ = &OgreRenderer::create(*GraphicsManager::getInstance().getRenderWindow());
     
    729734    }
    730735
     736    /**
     737    @brief
     738        Adds a new freetype font to the CEGUI system.
     739    @param name
     740        The name of the new font.
     741    @param size
     742        The font size of the new font in pixels.
     743        @param fontName
     744        The filename of the font.
     745    */
     746    /*static*/ void GUIManager::addFontHelper(const std::string& name, int size, const std::string& fontName)
     747    {
     748#ifdef ORXONOX_OLD_CEGUI
     749        if(CEGUI::FontManager::getSingleton().isFontPresent(name)) // If a font with that name already exists.
     750            return;
     751
     752        CEGUI::Font* font = NULL;
     753        CEGUI::XMLAttributes xmlAttributes;
     754
     755        // Attributes specified within CEGUIFont
     756        xmlAttributes.add("Name", name);
     757        xmlAttributes.add("Filename", fontName);
     758        xmlAttributes.add("ResourceGroup", "");
     759        xmlAttributes.add("AutoScaled", "true");
     760        xmlAttributes.add("NativeHorzRes", "800");
     761        xmlAttributes.add("NativeVertRes", "600");
     762
     763        // Attributes specified within CEGUIXMLAttributes
     764        xmlAttributes.add("Size", multi_cast<std::string>(size));
     765        xmlAttributes.add("AntiAlias", "true");
     766
     767        font = CEGUI::FontManager::getSingleton().createFont("FreeType", xmlAttributes);
     768        if(font != NULL)
     769            font->load();
     770#else
     771        if(CEGUI::FontManager::getSingleton().isDefined(name)) // If a font with that name already exists.
     772            return;
     773
     774        CEGUI::FontManager::getSingleton().createFreeTypeFont(name, (float)size, true, fontName, "", true, 800.0f, 600.0f);
     775#endif
     776    }
     777
    731778}
  • code/trunk/src/libraries/core/GUIManager.h

    r8530 r8706  
    128128
    129129        // TODO: Temporary hack because the tolua exported CEGUI method does not seem to work
    130         static void subscribeEventHelper(CEGUI::Window* window, const std::string& event, const std::string& function); //tolua_export
    131         static void setTooltipTextHelper(CEGUI::ListboxItem* item, const std::string& toooltip); //tolua_export
    132         static void setItemTooltipsEnabledHelper(CEGUI::Listbox* listbox, bool enabled); //tolua_export
     130        static void subscribeEventHelper(CEGUI::Window* window, const std::string& event, const std::string& function); // tolua_export
     131        static void setTooltipTextHelper(CEGUI::ListboxItem* item, const std::string& toooltip); // tolua_export
     132        static void setItemTooltipsEnabledHelper(CEGUI::Listbox* listbox, bool enabled); // tolua_export
     133        static void addFontHelper(const std::string& name, int size, const std::string& fontName); // tolua_export
    133134
    134135        static GUIManager& getInstance() { return Singleton<GUIManager>::getInstance(); } // tolua_export
     136
     137        /**
     138        @brief Check whether CEGUI is version < 0.7.
     139        @return Returns true if the CEGUI version is < 0.7. False otherwise.
     140        */
     141        inline bool usingOldCEGUI(void) { return this->oldCEGUI_; } // tolua_export
    135142
    136143    private:
     
    185192        static const std::string defaultScheme_;
    186193        std::string guiScheme_;
    187 
     194        bool oldCEGUI_;
     195       
    188196        int numScrollLines_; ///< How many lines to scroll in a list if the scroll wheel is used
    189197
  • code/trunk/src/libraries/core/Game.cc

    r8423 r8706  
    556556    {
    557557        this->bChangingState_ = true;
    558         LOKI_ON_BLOCK_EXIT_OBJ(*this, &Game::resetChangingState);
     558        LOKI_ON_BLOCK_EXIT_OBJ(*this, &Game::resetChangingState); (void)LOKI_ANONYMOUS_VARIABLE(scopeGuard);
    559559
    560560        // If state requires graphics, load it
  • code/trunk/src/libraries/core/GraphicsManager.h

    r8423 r8706  
    109109        // event from Ogre::LogListener
    110110        void messageLogged(const std::string& message, Ogre::LogMessageLevel lml,
    111             bool maskDebug, const std::string& logName);
     111        bool maskDebug, const std::string& logName);
    112112
    113113        // console commands
  • code/trunk/src/libraries/core/Identifier.h

    r8351 r8706  
    119119
    120120            /// Returns the network ID to identify a class through the network.
    121             inline const uint32_t getNetworkID() const { return this->networkID_; }
     121            inline uint32_t getNetworkID() const { return this->networkID_; }
    122122            void setNetworkID(uint32_t id);
    123123
  • code/trunk/src/libraries/core/Super.h

    r8351 r8706  
    100100            } \
    101101            \
    102             static void apply(void* temp) {} \
     102            static void apply(void*) {} \
    103103            \
    104             static void apply(baseclass* temp) \
     104            static void apply(baseclass*) \
    105105            { \
    106106                ClassIdentifier<T>* identifier = ClassIdentifier<T>::getIdentifier(); \
     
    312312        struct SuperFunctionInitialization
    313313        {
    314             static void initialize(ClassIdentifier<T>* identifier) {}
     314            static void initialize(ClassIdentifier<T>*) {}
    315315        };
    316316
     
    321321        struct SuperFunctionDestruction
    322322        {
    323             static void destroy(ClassIdentifier<T>* identifier) {}
     323            static void destroy(ClassIdentifier<T>*) {}
    324324        };
    325325
  • code/trunk/src/libraries/core/ThreadWin.cc

    • Property svn:eol-style set to native
  • code/trunk/src/libraries/core/command/Functor.h

    r7871 r8706  
    411411        // Helper class, used to call a function-pointer with a given object and parameters and to return its return-value (if available)
    412412        template <class R, class O, bool isconst, class P1, class P2, class P3, class P4, class P5> struct FunctorCaller                                              { static inline MultiType call(typename detail::FunctionPointer<R, O, isconst, P1, P2, P3, P4, P5>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { return (object->*functionPointer)(param1, param2, param3, param4, param5); } };
    413         template <class R, class O, bool isconst, class P1, class P2, class P3, class P4>           struct FunctorCaller<R, O, isconst, P1, P2, P3, P4, void>         { static inline MultiType call(typename detail::FunctionPointer<R, O, isconst, P1, P2, P3, P4, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { return (object->*functionPointer)(param1, param2, param3, param4); } };
    414         template <class R, class O, bool isconst, class P1, class P2, class P3>                     struct FunctorCaller<R, O, isconst, P1, P2, P3, void, void>       { static inline MultiType call(typename detail::FunctionPointer<R, O, isconst, P1, P2, P3, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { return (object->*functionPointer)(param1, param2, param3); } };
    415         template <class R, class O, bool isconst, class P1, class P2>                               struct FunctorCaller<R, O, isconst, P1, P2, void, void, void>     { static inline MultiType call(typename detail::FunctionPointer<R, O, isconst, P1, P2, void, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { return (object->*functionPointer)(param1, param2); } };
    416         template <class R, class O, bool isconst, class P1>                                         struct FunctorCaller<R, O, isconst, P1, void, void, void, void>   { static inline MultiType call(typename detail::FunctionPointer<R, O, isconst, P1, void, void, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { return (object->*functionPointer)(param1); } };
    417         template <class R, class O, bool isconst>                                                   struct FunctorCaller<R, O, isconst, void, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<R, O, isconst, void, void, void, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { return (object->*functionPointer)(); } };
     413        template <class R, class O, bool isconst, class P1, class P2, class P3, class P4>           struct FunctorCaller<R, O, isconst, P1, P2, P3, P4, void>         { static inline MultiType call(typename detail::FunctionPointer<R, O, isconst, P1, P2, P3, P4, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType&) { return (object->*functionPointer)(param1, param2, param3, param4); } };
     414        template <class R, class O, bool isconst, class P1, class P2, class P3>                     struct FunctorCaller<R, O, isconst, P1, P2, P3, void, void>       { static inline MultiType call(typename detail::FunctionPointer<R, O, isconst, P1, P2, P3, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType&, const MultiType&) { return (object->*functionPointer)(param1, param2, param3); } };
     415        template <class R, class O, bool isconst, class P1, class P2>                               struct FunctorCaller<R, O, isconst, P1, P2, void, void, void>     { static inline MultiType call(typename detail::FunctionPointer<R, O, isconst, P1, P2, void, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType&, const MultiType&, const MultiType&) { return (object->*functionPointer)(param1, param2); } };
     416        template <class R, class O, bool isconst, class P1>                                         struct FunctorCaller<R, O, isconst, P1, void, void, void, void>   { static inline MultiType call(typename detail::FunctionPointer<R, O, isconst, P1, void, void, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { return (object->*functionPointer)(param1); } };
     417        template <class R, class O, bool isconst>                                                   struct FunctorCaller<R, O, isconst, void, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<R, O, isconst, void, void, void, void, void>::Type functionPointer, O* object, const MultiType&, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { return (object->*functionPointer)(); } };
    418418        template <class O, bool isconst, class P1, class P2, class P3, class P4, class P5> struct FunctorCaller<void, O, isconst, P1, P2, P3, P4, P5>           { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, P2, P3, P4, P5>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (object->*functionPointer)(param1, param2, param3, param4, param5); return MT_Type::Null; } };
    419         template <class O, bool isconst, class P1, class P2, class P3, class P4>           struct FunctorCaller<void, O, isconst, P1, P2, P3, P4, void>         { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, P2, P3, P4, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (object->*functionPointer)(param1, param2, param3, param4); return MT_Type::Null; } };
    420         template <class O, bool isconst, class P1, class P2, class P3>                     struct FunctorCaller<void, O, isconst, P1, P2, P3, void, void>       { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, P2, P3, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (object->*functionPointer)(param1, param2, param3); return MT_Type::Null; } };
    421         template <class O, bool isconst, class P1, class P2>                               struct FunctorCaller<void, O, isconst, P1, P2, void, void, void>     { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, P2, void, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (object->*functionPointer)(param1, param2); return MT_Type::Null; } };
    422         template <class O, bool isconst, class P1>                                         struct FunctorCaller<void, O, isconst, P1, void, void, void, void>   { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, void, void, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (object->*functionPointer)(param1); return MT_Type::Null; } };
    423         template <class O, bool isconst>                                                   struct FunctorCaller<void, O, isconst, void, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, void, void, void, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (object->*functionPointer)(); return MT_Type::Null; } };
     419        template <class O, bool isconst, class P1, class P2, class P3, class P4>           struct FunctorCaller<void, O, isconst, P1, P2, P3, P4, void>         { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, P2, P3, P4, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType&) { (object->*functionPointer)(param1, param2, param3, param4); return MT_Type::Null; } };
     420        template <class O, bool isconst, class P1, class P2, class P3>                     struct FunctorCaller<void, O, isconst, P1, P2, P3, void, void>       { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, P2, P3, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType&, const MultiType&) { (object->*functionPointer)(param1, param2, param3); return MT_Type::Null; } };
     421        template <class O, bool isconst, class P1, class P2>                               struct FunctorCaller<void, O, isconst, P1, P2, void, void, void>     { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, P2, void, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType& param2, const MultiType&, const MultiType&, const MultiType&) { (object->*functionPointer)(param1, param2); return MT_Type::Null; } };
     422        template <class O, bool isconst, class P1>                                         struct FunctorCaller<void, O, isconst, P1, void, void, void, void>   { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, P1, void, void, void, void>::Type functionPointer, O* object, const MultiType& param1, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { (object->*functionPointer)(param1); return MT_Type::Null; } };
     423        template <class O, bool isconst>                                                   struct FunctorCaller<void, O, isconst, void, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<void, O, isconst, void, void, void, void, void>::Type functionPointer, O* object, const MultiType&, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { (object->*functionPointer)(); return MT_Type::Null; } };
    424424        template <class R, bool isconst, class P1, class P2, class P3, class P4, class P5> struct FunctorCaller<R, void, isconst, P1, P2, P3, P4, P5>           { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, P1, P2, P3, P4, P5>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { return (*functionPointer)(param1, param2, param3, param4, param5); } };
    425         template <class R, bool isconst, class P1, class P2, class P3, class P4>           struct FunctorCaller<R, void, isconst, P1, P2, P3, P4, void>         { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, P1, P2, P3, P4, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { return (*functionPointer)(param1, param2, param3, param4); } };
    426         template <class R, bool isconst, class P1, class P2, class P3>                     struct FunctorCaller<R, void, isconst, P1, P2, P3, void, void>       { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, P1, P2, P3, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { return (*functionPointer)(param1, param2, param3); } };
    427         template <class R, bool isconst, class P1, class P2>                               struct FunctorCaller<R, void, isconst, P1, P2, void, void, void>     { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, P1, P2, void, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { return (*functionPointer)(param1, param2); } };
    428         template <class R, bool isconst, class P1>                                         struct FunctorCaller<R, void, isconst, P1, void, void, void, void>   { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, P1, void, void, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { return (*functionPointer)(param1); } };
    429         template <class R, bool isconst>                                                   struct FunctorCaller<R, void, isconst, void, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, void, void, void, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { return (*functionPointer)(); } };
     425        template <class R, bool isconst, class P1, class P2, class P3, class P4>           struct FunctorCaller<R, void, isconst, P1, P2, P3, P4, void>         { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, P1, P2, P3, P4, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType&) { return (*functionPointer)(param1, param2, param3, param4); } };
     426        template <class R, bool isconst, class P1, class P2, class P3>                     struct FunctorCaller<R, void, isconst, P1, P2, P3, void, void>       { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, P1, P2, P3, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType&, const MultiType&) { return (*functionPointer)(param1, param2, param3); } };
     427        template <class R, bool isconst, class P1, class P2>                               struct FunctorCaller<R, void, isconst, P1, P2, void, void, void>     { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, P1, P2, void, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType&, const MultiType&, const MultiType&) { return (*functionPointer)(param1, param2); } };
     428        template <class R, bool isconst, class P1>                                         struct FunctorCaller<R, void, isconst, P1, void, void, void, void>   { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, P1, void, void, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { return (*functionPointer)(param1); } };
     429        template <class R, bool isconst>                                                   struct FunctorCaller<R, void, isconst, void, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<R, void, isconst, void, void, void, void, void>::Type functionPointer, void*, const MultiType&, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { return (*functionPointer)(); } };
    430430        template <bool isconst, class P1, class P2, class P3, class P4, class P5> struct FunctorCaller<void, void, isconst, P1, P2, P3, P4, P5>           { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, P2, P3, P4, P5>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (*functionPointer)(param1, param2, param3, param4, param5); return MT_Type::Null; } };
    431         template <bool isconst, class P1, class P2, class P3, class P4>           struct FunctorCaller<void, void, isconst, P1, P2, P3, P4, void>         { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, P2, P3, P4, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (*functionPointer)(param1, param2, param3, param4); return MT_Type::Null; } };
    432         template <bool isconst, class P1, class P2, class P3>                     struct FunctorCaller<void, void, isconst, P1, P2, P3, void, void>       { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, P2, P3, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (*functionPointer)(param1, param2, param3); return MT_Type::Null; } };
    433         template <bool isconst, class P1, class P2>                               struct FunctorCaller<void, void, isconst, P1, P2, void, void, void>     { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, P2, void, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (*functionPointer)(param1, param2); return MT_Type::Null; } };
    434         template <bool isconst, class P1>                                         struct FunctorCaller<void, void, isconst, P1, void, void, void, void>   { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, void, void, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (*functionPointer)(param1); return MT_Type::Null; } };
    435         template <bool isconst>                                                   struct FunctorCaller<void, void, isconst, void, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, void, void, void, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) { (*functionPointer)(); return MT_Type::Null; } };
     431        template <bool isconst, class P1, class P2, class P3, class P4>           struct FunctorCaller<void, void, isconst, P1, P2, P3, P4, void>         { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, P2, P3, P4, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType&) { (*functionPointer)(param1, param2, param3, param4); return MT_Type::Null; } };
     432        template <bool isconst, class P1, class P2, class P3>                     struct FunctorCaller<void, void, isconst, P1, P2, P3, void, void>       { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, P2, P3, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType&, const MultiType&) { (*functionPointer)(param1, param2, param3); return MT_Type::Null; } };
     433        template <bool isconst, class P1, class P2>                               struct FunctorCaller<void, void, isconst, P1, P2, void, void, void>     { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, P2, void, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType& param2, const MultiType&, const MultiType&, const MultiType&) { (*functionPointer)(param1, param2); return MT_Type::Null; } };
     434        template <bool isconst, class P1>                                         struct FunctorCaller<void, void, isconst, P1, void, void, void, void>   { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, P1, void, void, void, void>::Type functionPointer, void*, const MultiType& param1, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { (*functionPointer)(param1); return MT_Type::Null; } };
     435        template <bool isconst>                                                   struct FunctorCaller<void, void, isconst, void, void, void, void, void> { static inline MultiType call(typename detail::FunctionPointer<void, void, isconst, void, void, void, void, void>::Type functionPointer, void*, const MultiType&, const MultiType&, const MultiType&, const MultiType&, const MultiType&) { (*functionPointer)(); return MT_Type::Null; } };
    436436
    437437        // Helper class, used to identify the header of a function-pointer (independent of its class)
  • code/trunk/src/libraries/core/command/Shell.cc

    r8079 r8706  
    265265            return;
    266266
    267         size_t previous_offset = mod(this->historyOffset_ - 1, this->maxHistoryLength_);
     267        size_t previous_offset = mod(static_cast<int>(this->historyOffset_) - 1, this->maxHistoryLength_);
    268268        if (previous_offset < this->commandHistory_.size() && command == this->commandHistory_[previous_offset])
    269269            return;
  • code/trunk/src/libraries/network/LANDiscovery.cc

    r8351 r8706  
    3838namespace orxonox
    3939{
    40   ManageScopedSingleton(LANDiscovery, ScopeID::Root, true);
     40  ManageScopedSingleton(LANDiscovery, ScopeID::Graphics, true);
    4141
    4242  LANDiscovery::LANDiscovery()
     
    4949  LANDiscovery::~LANDiscovery()
    5050  {
    51     enet_host_destroy(this->host_);
     51    if (this->host_ != NULL)
     52      enet_host_destroy(this->host_);
    5253  }
    5354
  • code/trunk/src/libraries/network/Server.cc

    r8351 r8706  
    413413   
    414414    COUT(4) << "sending welcome" << std::endl;
    415     packet::Welcome *w = new packet::Welcome(clientID, OBJECTID_UNKNOWN);
     415    packet::Welcome *w = new packet::Welcome(clientID);
    416416    w->setPeerID(clientID);
    417417    b = w->send( static_cast<Host*>(this) );
  • code/trunk/src/libraries/network/packet/Welcome.cc

    r7801 r8706  
    4444#define _ENDIANTEST           _CLIENTID + sizeof(uint32_t)
    4545
    46   Welcome::Welcome( uint32_t clientID, uint32_t shipID )
     46  Welcome::Welcome( uint32_t clientID )
    4747 : Packet()
    4848{
  • code/trunk/src/libraries/network/packet/Welcome.h

    r7801 r8706  
    4141{
    4242public:
    43   Welcome( uint32_t clientID, uint32_t shipID );
     43  Welcome( uint32_t clientID );
    4444  Welcome( uint8_t* data, uint32_t clientID );
    4545  virtual ~Welcome();
  • code/trunk/src/libraries/network/synchronisable/Serialise.h

    r7284 r8706  
    8484
    8585    /** @brief returns the size of the objectID needed to synchronise the pointer */
    86     template <class T> inline uint32_t returnSize( const SmartPtr<T>& variable )
     86    template <class T> inline uint32_t returnSize( const SmartPtr<T>& )
    8787    {
    8888        return sizeof(uint32_t);
  • code/trunk/src/libraries/network/synchronisable/Synchronisable.cc

    r8329 r8706  
    383383  /**
    384384   * This function determines, wheter the object should be saved to the bytestream (according to its syncmode/direction)
    385    * @param id gamestate id
    386385   * @param mode Synchronisation mode (toclient, toserver or bidirectional)
    387386   * @return true/false
     
    397396  /**
    398397   * This function determines, wheter the object should accept data from the bytestream (according to its syncmode/direction)
    399    * @param id gamestate id
    400398   * @param mode Synchronisation mode (toclient, toserver or bidirectional)
    401399   * @return true/false
  • code/trunk/src/libraries/network/synchronisable/Synchronisable.h

    r8329 r8706  
    5050  namespace ObjectDirection{
    5151    enum Value{
     52      None=0x0,
    5253      ToClient=0x1,
    5354      ToServer=0x2,
  • code/trunk/src/libraries/util/Convert.h

    r8351 r8706  
    143143    struct ConverterFallback
    144144    {
    145         ORX_FORCEINLINE static bool convert(ToType* output, const FromType& input)
     145        ORX_FORCEINLINE static bool convert(ToType* /*output*/, const FromType& /*input*/)
    146146        {
    147147            COUT(2) << "Could not convert value of type " << typeid(FromType).name()
  • code/trunk/src/libraries/util/Exception.h

    r7401 r8706  
    110110        virtual const std::string& getDescription()     const { return this->description_; }
    111111        //! Returns the line number on which the exception occurred.
    112         virtual const unsigned int getLineNumber()      const { return this->lineNumber_; }
     112        virtual unsigned int getLineNumber()            const { return this->lineNumber_; }
    113113        //! Returns the function in which the exception occurred.
    114114        virtual const std::string& getFunctionName()    const { return this->functionName_; }
  • code/trunk/src/libraries/util/Math.h

    r8351 r8706  
    174174            return (x % max);
    175175        else
    176             return ((x % max) + max);
     176        {
     177            T temp = x % max;
     178            return (temp < 0) ? (temp + max) : temp;
     179        }
    177180    }
    178181
  • code/trunk/src/libraries/util/MultiTypeValue.h

    r7401 r8706  
    255255        return 4*returnSize(this->value_.x);
    256256    }
    257     template <> inline void MT_Value<void*>::importData( uint8_t*& mem )
     257    template <> inline void MT_Value<void*>::importData( uint8_t*& /*mem*/ )
    258258    {
    259259        assert(0);
    260260    }
    261     template <> inline void MT_Value<void*>::exportData( uint8_t*& mem ) const
     261    template <> inline void MT_Value<void*>::exportData( uint8_t*& /*mem*/ ) const
    262262    {
    263263        assert(0);
  • code/trunk/src/libraries/util/ScopedSingletonManager.h

    r7401 r8706  
    247247
    248248        //! Destroys the singleton instance - overloaded for OrxonoxClass, calls OrxonoxClass::destroy()
    249         void destroy(OrxonoxClass* ptr)
     249        void destroy(OrxonoxClass*)
    250250        {
    251251            singletonPtr_->destroy();
    252252        }
    253253        //! Destroys the singleton instance - overloaded for void*, calls delete
    254         void destroy(void* ptr)
     254        void destroy(void*)
    255255        {
    256256            delete singletonPtr_;
  • code/trunk/src/libraries/util/Serialise.h

    r7401 r8706  
    8787// =========== bool
    8888
    89     template <> inline uint32_t returnSize( const bool& variable )
     89    template <> inline uint32_t returnSize( const bool& )
    9090    {
    9191        return sizeof(uint8_t);
     
    111111// =========== char
    112112
    113     template <> inline uint32_t returnSize( const char& variable )
     113    template <> inline uint32_t returnSize( const char& )
    114114    {
    115115        return sizeof(uint8_t);
     
    135135// =========== unsigned char
    136136
    137     template <> inline uint32_t returnSize( const unsigned char& variable )
     137    template <> inline uint32_t returnSize( const unsigned char& )
    138138    {
    139139        return sizeof(uint8_t);
     
    159159// =========== short
    160160
    161     template <> inline uint32_t returnSize( const short& variable )
     161    template <> inline uint32_t returnSize( const short& )
    162162    {
    163163        return sizeof(int16_t);
     
    183183// =========== unsigned short
    184184
    185     template <> inline uint32_t returnSize( const unsigned short& variable )
     185    template <> inline uint32_t returnSize( const unsigned short& )
    186186    {
    187187        return sizeof(uint16_t);
     
    207207// =========== int
    208208
    209     template <> inline uint32_t returnSize( const int& variable )
     209    template <> inline uint32_t returnSize( const int& )
    210210    {
    211211        return sizeof(int32_t);
     
    231231// =========== unsigned int
    232232
    233     template <> inline uint32_t returnSize( const unsigned int& variable )
     233    template <> inline uint32_t returnSize( const unsigned int& )
    234234    {
    235235        return sizeof(uint32_t);
     
    255255// =========== long
    256256
    257     template <> inline uint32_t returnSize( const long& variable )
     257    template <> inline uint32_t returnSize( const long& )
    258258    {
    259259        return sizeof(int32_t);
     
    279279// =========== unsigned long
    280280
    281     template <> inline uint32_t returnSize( const unsigned long& variable )
     281    template <> inline uint32_t returnSize( const unsigned long& )
    282282    {
    283283        return sizeof(uint32_t);
     
    303303// =========== long long
    304304
    305     template <> inline uint32_t returnSize( const long long& variable )
     305    template <> inline uint32_t returnSize( const long long& )
    306306    {
    307307        return sizeof(int64_t);
     
    327327// =========== unsigned long long
    328328
    329     template <> inline uint32_t returnSize( const unsigned long long& variable )
     329    template <> inline uint32_t returnSize( const unsigned long long& )
    330330    {
    331331        return sizeof(uint64_t);
     
    351351// =========== float
    352352
    353     template <> inline uint32_t returnSize( const float& variable )
     353    template <> inline uint32_t returnSize( const float& )
    354354    {
    355355        return sizeof(uint32_t);
     
    375375// =========== double
    376376
    377     template <> inline uint32_t returnSize( const double& variable )
     377    template <> inline uint32_t returnSize( const double& )
    378378    {
    379379        return sizeof(uint64_t);
     
    399399// =========== long double
    400400
    401     template <> inline uint32_t returnSize( const long double& variable )
     401    template <> inline uint32_t returnSize( const long double& )
    402402    {
    403403        return sizeof(uint64_t);
     
    452452// =========== Degree
    453453
    454     template <> inline uint32_t returnSize( const Degree& variable )
     454    template <> inline uint32_t returnSize( const Degree& )
    455455    {
    456456        return sizeof(Ogre::Real);
     
    479479// =========== Radian
    480480
    481     template <> inline uint32_t returnSize( const Radian& variable )
     481    template <> inline uint32_t returnSize( const Radian& )
    482482    {
    483483        return sizeof(Ogre::Real);
  • code/trunk/src/libraries/util/SubString.h

    r7401 r8706  
    110110            SL_COMMENT,           //!< In Comment mode.
    111111            SL_PARENTHESES,       //!< Between parentheses (usually '{' and '}')
    112             SL_PARENTHESESESCAPE, //!< Between parentheses with the internal escape character, that escapes even the closing paranthesis character.
     112            SL_PARENTHESESESCAPE, //!< Between parentheses with the internal escape character, that escapes even the closing parenthesis character.
    113113        };
    114114
     
    169169        /// Returns the number of tokens stored in this SubString
    170170        inline unsigned int size() const { return this->tokens_.size(); }
    171         /// Returns the i'th token from the subset of strings @param index The index of the requested doken
     171        /// Returns the i'th token from the subset of strings @param index The index of the requested token
    172172        inline const std::string& operator[](unsigned int index) const { return this->tokens_[index]; }
    173173        /// Returns the i'th token from the subset of strings @param index The index of the requested token
     
    209209                                          SPLIT_LINE_STATE start_state = SL_NORMAL);
    210210
    211         std::vector<std::string>  tokens_;              ///< The tokens after spliting the input line
     211        std::vector<std::string>  tokens_;              ///< The tokens after splitting the input line
    212212        std::vector<bool>         bTokenInSafemode_;    ///< Saves for each token if it was in safe mode (between quotation marks or parenthesis)
    213213    };
  • code/trunk/src/modules/CMakeLists.txt

    r8457 r8706  
    2727
    2828ADD_SUBDIRECTORY(designtools)
     29ADD_SUBDIRECTORY(gametypes)
    2930ADD_SUBDIRECTORY(notifications)
    3031ADD_SUBDIRECTORY(objects)
     
    3435ADD_SUBDIRECTORY(portals)
    3536ADD_SUBDIRECTORY(questsystem)
     37ADD_SUBDIRECTORY(tetris)
    3638ADD_SUBDIRECTORY(weapons)
     39ADD_SUBDIRECTORY(docking)
  • code/trunk/src/modules/notifications/CMakeLists.txt

    r7403 r8706  
    11SET_SOURCE_FILES(NOTIFICATIONS_SRC_FILES
    2   Notification.cc
    32  NotificationDispatcher.cc
    43  NotificationManager.cc
    54  NotificationQueue.cc
     5  NotificationQueueCEGUI.cc
    66)
    77
     
    1313  TOLUA_FILES
    1414    NotificationManager.h
    15     NotificationQueue.h
     15    NotificationQueueCEGUI.h
    1616  PCH_FILE
    1717    NotificationsPrecompiledHeaders.h
  • code/trunk/src/modules/notifications/NotificationDispatcher.cc

    r7552 r8706  
    4141
    4242#include "infos/PlayerInfo.h"
     43#include "interfaces/NotificationListener.h"
    4344#include "interfaces/PlayerTrigger.h"
    4445#include "worldentities/pawns/Pawn.h"
    45 
    46 #include "NotificationManager.h"
    4746
    4847namespace orxonox
     
    6160        RegisterObject(NotificationDispatcher);
    6261
    63         this->sender_ = NotificationManager::NONE;
     62        this->sender_ = NotificationListener::NONE;
    6463        this->registerVariables();
    6564    }
     
    114113        {
    115114            const std::string message = this->createNotificationMessage();
    116             NotificationManager::sendNotification(message, clientId, this->getSender());
     115            // TODO: Make the type configurable.
     116            NotificationListener::sendNotification(message, this->getSender(), notificationMessageType::info, notificationSendMode::network, clientId);
    117117        }
    118118        else if(GameMode::isServer())
     
    140140
    141141        PlayerTrigger* pTrigger = orxonox_cast<PlayerTrigger*>(trigger);
    142         Pawn* pawn = NULL;
     142        PlayerInfo* player = NULL;
    143143
    144144        // If the trigger is a PlayerTrigger.
     
    148148                return false;
    149149            else
    150                 pawn = pTrigger->getTriggeringPlayer();
     150                player = pTrigger->getTriggeringPlayer();
    151151        }
    152152        else
    153153            return false;
    154154
    155         if(pawn == NULL)
     155        if(player == NULL)
    156156        {
    157157            COUT(4) << "The NotificationDispatcher was triggered by an entity other than a Pawn. (" << trigger->getIdentifier()->getName() << ")" << std::endl;
    158             return false;
    159         }
    160 
    161         // Extract the PlayerInfo from the Pawn.
    162         PlayerInfo* player = pawn->getPlayer();
    163 
    164         if(player == NULL)
    165         {
    166             COUT(3) << "The PlayerInfo* is NULL." << std::endl;
    167158            return false;
    168159        }
  • code/trunk/src/modules/notifications/NotificationManager.cc

    r8079 r8706  
    3636#include "core/command/ConsoleCommand.h"
    3737#include "core/CoreIncludes.h"
    38 #include "core/GUIManager.h"
    3938#include "core/LuaState.h"
    40 #include "network/Host.h"
    41 #include "network/NetworkFunction.h"
    4239#include "util/ScopedSingletonManager.h"
    4340
    4441#include "interfaces/NotificationListener.h"
    4542
    46 #include "Notification.h"
    4743#include "NotificationQueue.h"
    48 
    49 #include "ToluaBindNotifications.h"
     44#include "NotificationQueueCEGUI.h"
    5045
    5146namespace orxonox
    5247{
    5348
    54     const std::string NotificationManager::ALL("all");
    55     const std::string NotificationManager::NONE("none");
    56 
    57     // Register tolua_open function when loading the library.
    58     DeclareToluaInterface(Notifications);
    59 
    6049    ManageScopedSingleton(NotificationManager, ScopeID::Root, false);
    6150
    62     // Setting console command to enter the edit mode.
    63     SetConsoleCommand("enterEditMode", &NotificationManager::enterEditMode);
    64 
    65     registerStaticNetworkFunction(NotificationManager::sendNotification);
    66 
    6751    /**
    6852    @brief
     
    7357        RegisterRootObject(NotificationManager);
    7458
    75         this->highestIndex_ = 0;
    76 
    77         ModifyConsoleCommand("enterEditMode").setObject(this);
    78 
    7959        COUT(3) << "NotificatioManager created." << std::endl;
    8060    }
     
    8666    NotificationManager::~NotificationManager()
    8767    {
    88         ModifyConsoleCommand("enterEditMode").setObject(NULL);
    89 
    9068        // Destroys all Notifications.
    9169        for(std::multimap<std::time_t, Notification*>::iterator it = this->allNotificationsList_.begin(); it!= this->allNotificationsList_.end(); it++)
     
    10684        while(it != this->queues_.end())
    10785        {
    108             it->second->destroy(true);
     86            it->second->destroy();
    10987            it = this->queues_.begin();
    11088        }
     
    11593    /**
    11694    @brief
    117         Sends a Notification with the specified message to the specified client from the specified sender.
     95        Creates and registers a Notification with the input message from the input sender.
     96        This is called by the NotificationListener, whenever a new notification arrives.
    11897    @param message
    119         The message that should be sent.
    120     @param clientId
    121         The id of the client the notification should be sent to.
     98        The message of the new Notification.
    12299    @param sender
    123         The sender that sent the notification.
    124     @param isLocal
    125         If this is set to true (false is default), then the Notification is sent to the client where this function is executed, meaning the Notification is sent locally.
    126     */
    127     /*static*/ void NotificationManager::sendNotification(const std::string& message, unsigned int clientId, const std::string& sender, bool isLocal)
    128     {
    129         // If we're in standalone mode or we're already no the right client we create and send the Notification.
    130         if(GameMode::isStandalone() || isLocal || Host::getPlayerID() == clientId)
    131         {
    132             Notification* notification = new Notification(message, sender);
    133             if(NotificationManager::getInstance().registerNotification(notification))
    134                 COUT(3) << "Notification \"" << notification->getMessage() << "\" sent." << std::endl;
    135         }
    136         // If we're on the server (and the server is not the intended recipient of the Notification) we send it over the network.
    137         else if(GameMode::isServer())
    138         {
    139             callStaticNetworkFunction(NotificationManager::sendNotification, clientId, message, clientId, sender);
    140         }
    141     }
    142 
    143     /**
    144     @brief
    145         Registers a Notification within the NotificationManager and makes sure that the Notification is sent to all the NotificationListeners associated with its sender.
     100        The name of the entity (of the collective) that sent the new Notification.
     101    @param type
     102        The type of the new Notification.
     103    @return
     104        Returns true if successful.
     105    */
     106    bool NotificationManager::registerNotification(const std::string& message, const std::string& sender, notificationMessageType::Value type)
     107    {
     108        // TODO: Do something with the type.
     109        Notification* notification = new Notification(message, sender, type);
     110        return this->registerNotification(notification);
     111    }
     112
     113    /**
     114    @brief
     115        Executes the input command from the input sender.
     116        This is called by the NotificationListener, whenever a new command arrives.
     117    @param command
     118        The command to be executed,
     119    @param sender
     120        The The name of the entity (of the collective) that sent the command.
     121    @return
     122        Returns true if the command was successfully executed.
     123    */
     124    bool NotificationManager::executeCommand(notificationCommand::Value command, const std::string& sender)
     125    {
     126        bool commandExecuted = false;
     127        if(command == notificationCommand::clear)
     128        {
     129            if(this->commandClear(sender))
     130                commandExecuted = true;
     131        }
     132
     133        if(commandExecuted)
     134            COUT(3) << "Notification command \"" << NotificationListener::command2Str(command) << "\" executed." << endl;
     135
     136        return commandExecuted;
     137    }
     138
     139    /**
     140    @brief
     141        The clear command. Clears all NotificationQueues that have its sender as a target.
     142    @param sender
     143        The sender of the clear command.
     144    @return
     145        Returns true if the command was successfully executed by at least one NotificationQueue, false if it was not executed.
     146    */
     147    bool NotificationManager::commandClear(const std::string& sender)
     148    {
     149        bool all = (sender == NotificationListener::ALL);
     150        bool executed = false;
     151        // Clear all NotificationQueues that have the input sender as target.
     152        for(std::map<const std::string, NotificationQueue*>::iterator it = this->queues_.begin(); it != this->queues_.end(); it++) // Iterate through all NotificationQueues.
     153        {
     154            const std::set<std::string>& set = it->second->getTargetsSet();
     155            // If either the sender is 'all', the NotificationQueue has as target all or the NotificationQueue has the input sender as a target.
     156            if(all || set.find(NotificationListener::ALL) != set.end() || set.find(sender) != set.end())
     157                executed = it->second->tidy() || executed;
     158        }
     159
     160        return executed;
     161    }
     162   
     163    /**
     164    @brief
     165        Registers a Notification within the NotificationManager and makes sure that the Notification is sent to all the NotificationQueues associated with its sender.
    146166    @param notification
    147167        The Notification to be registered.
     
    158178        this->allNotificationsList_.insert(std::pair<std::time_t, Notification*>(time, notification));
    159179
    160         if(notification->getSender() == NotificationManager::NONE) // If the sender has no specific name, then the Notification is only added to the list of all Notifications.
     180        if(notification->getSender() == NotificationListener::NONE) // If the sender has no specific name, then the Notification is only added to the list of all Notifications.
    161181            return true;
    162182
    163         bool all = false;
    164         if(notification->getSender() == NotificationManager::ALL) // If all are the sender, then the Notifications is added to every NotificationListener.
    165             all = true;
    166 
    167         // Insert the Notification in all NotificationListeners that have its sender as target.
    168         for(std::map<NotificationListener*, unsigned int>::iterator it = this->listenerList_.begin(); it != this->listenerList_.end(); it++) // Iterate through all NotificationListeners.
    169         {
    170             const std::set<std::string>& set = it->first->getTargetsSet();
    171             bool bAll = set.find(NotificationManager::ALL) != set.end();
    172             // If either the Notification has as sender 'all', the NotificationListener displays all Notifications or the NotificationListener has the sender of the Notification as target.
     183        // If all are the sender, then the Notifications is added to every NotificationQueue.
     184        bool all = (notification->getSender() == NotificationListener::ALL);
     185
     186        // Insert the Notification in all NotificationQueues that have its sender as target.
     187        for(std::map<const std::string, NotificationQueue*>::iterator it = this->queues_.begin(); it != this->queues_.end(); it++) // Iterate through all NotificationQueues.
     188        {
     189            const std::set<std::string>& set = it->second->getTargetsSet();
     190            bool bAll = set.find(NotificationListener::ALL) != set.end();
     191            // If either the Notification has as sender 'all', the NotificationQueue displays all Notifications or the NotificationQueue has the sender of the Notification as target.
    173192            if(all || bAll || set.find(notification->getSender()) != set.end())
    174193            {
    175194                if(!bAll)
    176                     this->notificationLists_[it->second]->insert(std::pair<std::time_t, Notification*>(time, notification)); // Insert the Notification in the notifications list of the current NotificationListener.
    177                 it->first->update(notification, time); // Update the NotificationListener.
     195                    this->notificationLists_[it->second->getName()]->insert(std::pair<std::time_t, Notification*>(time, notification)); // Insert the Notification in the notifications list of the current NotificationQueue.
     196                it->second->update(notification, time); // Update the NotificationQueue.
    178197            }
    179198        }
     
    186205    /**
    187206    @brief
    188         Unregisters a Notification within the NotificationManager for a given NotificationListener.
     207        Unregisters a Notification within the NotificationManager for a given NotificationQueue.
    189208    @param notification
    190209        A pointer to the Notification to be unregistered.
    191     @param listener
    192         A pointer to the NotificationListener the Notification is unregistered for.
    193     */
    194     void NotificationManager::unregisterNotification(Notification* notification, NotificationListener* listener)
     210    @param queue
     211        A pointer to the NotificationQueue the Notification is unregistered for.
     212    */
     213    void NotificationManager::unregisterNotification(Notification* notification, NotificationQueue* queue)
    195214    {
    196215        assert(notification);
    197         assert(listener);
    198 
    199         // Remove the Notification from the list of Notifications of the input NotificationListener.
    200         this->removeNotification(notification, *(this->notificationLists_.find(this->listenerList_.find(listener)->second)->second));
    201 
    202         COUT(4) << "Notification (&" << notification << ") unregistered with the NotificationManager from listener (&" << listener << ")" << std::endl;
     216        assert(queue);
     217
     218        // Remove the Notification from the list of Notifications of the input NotificationQueue.
     219        this->removeNotification(notification, *(this->notificationLists_.find(queue->getName())->second));
     220
     221        COUT(4) << "Notification (&" << notification << ") unregistered with the NotificationManager from NotificationQueue " << queue->getName() << "." << std::endl;
    203222    }
    204223
     
    230249    /**
    231250    @brief
    232         Registers a NotificationListener within the NotificationManager.
    233     @param listener
    234         The NotificationListener to be registered.
    235     @return
    236         Returns true if successful.  Fales if the NotificationListener is already registered.
    237     */
    238     bool NotificationManager::registerListener(NotificationListener* listener)
    239     {
    240         assert(listener);
    241 
    242         // If the NotificationListener is already registered.
    243         if(this->listenerList_.find(listener) != this->listenerList_.end())
    244             return false;
    245 
    246         this->highestIndex_ += 1;
    247         unsigned int index = this->highestIndex_; // An identifier that identifies each registered NotificationListener uniquely.
    248 
    249         this->listenerList_[listener] = index; // Add the NotificationListener to the list of NotificationListeners.
    250 
    251         const std::set<std::string>& set = listener->getTargetsSet();
    252 
    253         // If all senders are the target of the NotificationListener, then the list of Notifications for that specific NotificationListener is the same as the list of all Notifications.
    254         bool bAll = set.find(NotificationManager::ALL) != set.end();
    255         std::multimap<std::time_t, Notification*>* map = NULL;
    256         if(bAll)
    257             this->notificationLists_[index] = &this->allNotificationsList_;
    258         // Else a new list (resp. multimap) is created and added to the list of Notification lists for NotificationListeners.
    259         else
    260         {
    261             this->notificationLists_[index] = new std::multimap<std::time_t, Notification*>;
    262             map = this->notificationLists_[index];
    263         }
    264 
    265         // Iterate through all Notifications to determine whether any of them should belong to the newly registered NotificationListener.
    266         for(std::multimap<std::time_t, Notification*>::iterator it = this->allNotificationsList_.begin(); it != this->allNotificationsList_.end(); it++)
    267         {
    268             if(!bAll && set.find(it->second->getSender()) != set.end()) // Checks whether the listener has the sender of the current Notification as target.
    269                 map->insert(std::pair<std::time_t, Notification*>(it->first, it->second));
    270         }
    271 
    272         listener->update(); // Update the listener.
    273 
    274         COUT(4) << "NotificationListener registered with the NotificationManager." << std::endl;
    275 
    276         return true;
    277     }
    278 
    279     /**
    280     @brief
    281         Unregisters a NotificationListener within the NotificationManager.
    282     @param listener
    283         The NotificationListener to be unregistered.
    284     */
    285     void NotificationManager::unregisterListener(NotificationListener* listener)
    286     {
    287         assert(listener);
    288 
    289         unsigned int identifier = this->listenerList_.find(listener)->second;
    290         std::multimap<std::time_t, Notification*>* map = this->notificationLists_.find(identifier)->second;
    291 
    292         // If the map is not the map of all Notifications, make sure all Notifications are unregistered.
    293         std::multimap<std::time_t, Notification*>::iterator it = map->begin();
    294         if(map != &this->allNotificationsList_)
    295         {
    296             while(it != map->end())
    297             {
    298                 this->unregisterNotification(it->second, listener);
    299                 it = map->begin();
    300             }
    301             delete map;
    302         }
    303 
    304         COUT(4) << "NotificationListener '" << identifier << "' unregistered with the NotificationManager." << std::endl;
    305 
    306         // Remove the NotificationListener from the list of NotificationListeners.
    307         this->listenerList_.erase(listener);
    308         // Remove the Notifications list that was associated with the input NotificationListener.
    309         this->notificationLists_.erase(identifier);
    310     }
    311 
    312     /**
    313     @brief
    314         Fetches the Notifications for a specific NotificationListener in a specified timeframe and stores them in the input map.
    315     @param listener
    316         The NotificationListener the Notifications are fetched for.
     251        Fetches the Notifications for a specific NotificationQueue in a specified timeframe and stores them in the input map.
     252    @param queue
     253        The NotificationQueue the Notifications are fetched for.
    317254    @param map
    318255        A pointer to a multimap, in which the notifications are stored. The map needs to have been allocated.
     
    324261        Returns true if successful.
    325262    */
    326     void NotificationManager::getNotifications(NotificationListener* listener, std::multimap<std::time_t,Notification*>* map, const std::time_t & timeFrameStart, const std::time_t & timeFrameEnd)
    327     {
    328         assert(listener);
     263    void NotificationManager::getNotifications(NotificationQueue* queue, std::multimap<std::time_t,Notification*>* map, const std::time_t & timeFrameStart, const std::time_t & timeFrameEnd)
     264    {
     265        assert(queue);
    329266        assert(map);
    330267
    331         std::multimap<std::time_t, Notification*>* notifications = this->notificationLists_[this->listenerList_[listener]]; // All the Notifications for the input NotificationListener.
     268        std::multimap<std::time_t, Notification*>* notifications = this->notificationLists_[queue->getName()]; // All the Notifications for the input NotificationQueue.
    332269
    333270        std::multimap<std::time_t,Notification*>::iterator it, itLowest, itHighest;
     
    342279    /**
    343280    @brief
    344         Enters the edit mode of the NotificationLayer.
    345     */
    346     void NotificationManager::enterEditMode(void)
    347     {
    348         if(GameMode::showsGraphics())
    349         {
    350             GUIManager::getInstance().hideGUI("NotificationLayer");
    351             GUIManager::getInstance().showGUI("NotificationLayer", false, false);
    352             GUIManager::getInstance().getLuaState()->doString("NotificationLayer.enterEditMode()");
     281        Fetches the newest Notifications for a specific NotificationQueue and stores them in the input map.
     282    @param queue
     283        The NotificationQueue the Notifications are fetched for.
     284    @param map
     285        A pointer to a multimap, in which the notifications are stored. The map needs to have been allocated.
     286    @param numberOfNotifications
     287        The number of newest Notifications to be got.
     288    @return
     289        Returns true if successful.
     290    */
     291    void NotificationManager::getNewestNotifications(NotificationQueue* queue, std::multimap<std::time_t, Notification*>* map, int numberOfNotifications)
     292    {
     293        assert(queue);
     294        assert(map);
     295
     296        std::multimap<std::time_t, Notification*>* notifications = this->notificationLists_[queue->getName()]; // All the Notifications for the input NotificationQueue.
     297
     298        if(!notifications->empty()) // If the list of Notifications is not empty.
     299        {
     300            std::multimap<std::time_t,Notification*>::iterator it = notifications->end();
     301            for(int i = 0; i < numberOfNotifications; i++) // Iterate through the Notifications from the newest until we have the specified number of notifications.
     302            {
     303                it--;
     304                map->insert(std::pair<std::time_t, Notification*>(it->first, it->second)); // Add the found Notifications to the map.
     305                if(it == notifications->begin())
     306                    break;
     307            }
    353308        }
    354309    }
     
    357312    @brief
    358313        Registers a NotificationQueue.
    359         This makes sure that the NotificationQueue can be attained through lua by name. It also makes sure that the NotificationQueue is destroyed upon destruction of the NotificationManager.
     314        This makes sure that the NotificationQueue can be accessed through lua by name. It also makes sure that the NotificationQueue is destroyed upon destruction of the NotificationManager.
    360315    @param queue
    361316        A pointer to the NotificationQueue to be registered.
     
    365320    bool NotificationManager::registerQueue(NotificationQueue* queue)
    366321    {
     322        assert(queue);
     323
     324        // If the NotificationQueue is already registered.
     325        if(this->queues_.find(queue->getName()) != this->queues_.end())
     326            return false;
     327
     328        this->queues_.insert(std::pair<const std::string, NotificationQueue*>(queue->getName(), queue)); // Add the NotificationQueue to the list of NotificationQueues.
     329
     330        const std::set<std::string>& set = queue->getTargetsSet();
     331
     332        // If all senders are the target of the NotificationQueue, then the list of Notifications for that specific NotificationQueue is the same as the list of all Notifications.
     333        bool bAll = set.find(NotificationListener::ALL) != set.end();
     334        std::multimap<std::time_t, Notification*>* map = NULL;
     335        if(bAll)
     336            this->notificationLists_[queue->getName()] = &this->allNotificationsList_;
     337        // Else a new list (resp. multimap) is created and added to the list of Notification lists for NotificationQueues.
     338        else
     339        {
     340            this->notificationLists_[queue->getName()] = new std::multimap<std::time_t, Notification*>;
     341            map = this->notificationLists_[queue->getName()];
     342        }
     343
     344        // Iterate through all Notifications to determine whether any of them should belong to the newly registered NotificationQueue.
     345        for(std::multimap<std::time_t, Notification*>::iterator it = this->allNotificationsList_.begin(); it != this->allNotificationsList_.end(); it++)
     346        {
     347            if(!bAll && set.find(it->second->getSender()) != set.end()) // Checks whether the listener has the sender of the current Notification as target.
     348                map->insert(std::pair<std::time_t, Notification*>(it->first, it->second));
     349        }
     350
     351        queue->update(); // Update the queue.
     352       
    367353        COUT(4) << "NotificationQueue '" << queue->getName() << "' registered with the NotificationManager." << std::endl;
    368         return this->queues_.insert(std::pair<const std::string, NotificationQueue*>(queue->getName(), queue)).second;
     354        return true;
    369355    }
    370356
     
    377363    void NotificationManager::unregisterQueue(NotificationQueue* queue)
    378364    {
     365        assert(queue);
     366
     367        std::multimap<std::time_t, Notification*>* map = this->notificationLists_.find(queue->getName())->second;
     368
     369        // If the map is not the map of all Notifications, make sure all Notifications are unregistered.
     370        std::multimap<std::time_t, Notification*>::iterator it = map->begin();
     371        if(map != &this->allNotificationsList_)
     372        {
     373            while(it != map->end())
     374            {
     375                this->unregisterNotification(it->second, queue);
     376                it = map->begin();
     377            }
     378            delete map;
     379        }
     380
     381        // Remove the NotificationQueue from the list of NotificationQueues.
     382        this->queues_.erase(queue->getName());
     383        // Remove the Notifications list that was associated with the input NotificationQueue.
     384        this->notificationLists_.erase(queue->getName());
     385       
    379386        COUT(4) << "NotificationQueue '" << queue->getName() << "' unregistered with the NotificationManager." << std::endl;
    380         this->queues_.erase(queue->getName());
    381     }
    382 
    383     /**
    384     @brief
    385         Loads all the NotificationQueues that should exist.
    386     */
    387     void NotificationManager::loadQueues(void)
    388     {
    389         new NotificationQueue("all");
    390     }
    391 
    392     /**
    393     @brief
    394         Creates a new NotificationQueue.
    395         This is used in lua.
    396     @param name
    397         The name of the new NotificationQueue.
    398     */
    399     void NotificationManager::createQueue(const std::string& name)
    400     {
    401         new NotificationQueue(name);
    402387    }
    403388
     
    420405    }
    421406
     407    /**
     408    @brief
     409        Loads all the NotificationQueues that should exist.
     410    */
     411    void NotificationManager::loadQueues(void)
     412    {
     413        /*NotificationQueueCEGUI* allQueue = new NotificationQueueCEGUI("all");
     414        allQueue->setDisplaySize(Vector2(0.5, 0));
     415        allQueue->setPosition(Vector4(0.0, 10, 0.3, 0));
     416
     417        NotificationQueueCEGUI* infoQueue = new NotificationQueueCEGUI("info", "gameinfo", 1, -1);
     418        infoQueue->setPosition(Vector4(0.2, 0, 0.8, 0));
     419        infoQueue->setFontSize(24);
     420        infoQueue->setFontColor(Vector4(1.0, 1.0, 0.0, 0.8));
     421        infoQueue->setAlignment("HorzCentred");
     422        infoQueue->setDisplaySize(Vector2(0.6, 0.0));*/
     423    }
     424
     425    // Notification class
     426
     427    /**
     428    @brief
     429        Constructor. Creates a Notification with the input message and sender.
     430    @param message
     431        The message of the Notification.
     432    @param sender
     433        The sender of the Notification.
     434    @param type
     435
     436    */
     437    Notification::Notification(const std::string& message, const std::string& sender, notificationMessageType::Value type)
     438    {
     439        this->initialize();
     440        this->message_ = message;
     441        this->sender_ = sender;
     442        this->type_ = type;
     443    }
     444
     445    /**
     446    @brief
     447        Destructor.
     448    */
     449    Notification::~Notification()
     450    {
     451
     452    }
     453
     454    /**
     455    @brief
     456        Registers the object and sets some default values.
     457    */
     458    void Notification::initialize(void)
     459    {
     460        this->message_.clear();
     461        this->sender_ = NotificationListener::NONE;
     462    }
     463
    422464}
  • code/trunk/src/modules/notifications/NotificationManager.h

    r7552 r8706  
    4242#include <string>
    4343
     44#include "core/OrxonoxClass.h"
    4445#include "util/Singleton.h"
    45 #include "core/OrxonoxClass.h"
     46#include "interfaces/NotificationListener.h"
    4647
    4748namespace orxonox // tolua_export
     
    5051    /**
    5152    @brief
    52         The Singleton NotificationManager functions as a gateway between @ref orxonox::Notification "Notifications" and @ref orxonox::NotificationListener "NotificationListeners".
    53         It receives, organizes @ref orxonox::Notification "Notifications" and the redistributes them to the specific @ref orxonox::NotificationListener "NotificationListeners".
    54         It also provides a static function to send @ref orxonox::Notification "Notifications" and works as a liaison between the @ref orxonox::NotificationQueue "NotificationQueues" and the GUI that displays notification, called NotificationLayer.
     53        A Notification represents a short message used to inform the player about something that just happened. With the @ref orxonox::NotificationManager "NotificationManager" a Notification can be sent from any part of orxonox and is then displayed by the proper @ref orxonox::NotificationQueue "NotificationQueue(s)" (depending on which senders the specific @ref orxonox::NotificationQueue "NotificationQueues" accepts).
     54
     55        A Notification is just a data structure that is used internally by the Notifications module.
     56
     57    @author
     58        Damian 'Mozork' Frick
     59
     60    @ingroup Notifications
     61    */
     62    class _NotificationsExport Notification
     63    {
     64        public:
     65            Notification(const std::string& message, const std::string& sender, notificationMessageType::Value type);
     66            virtual ~Notification();
     67
     68            /**
     69            @brief Destroys the Notification.
     70            */
     71            void destroy(void)
     72                { delete this; }
     73
     74            /**
     75            @brief Get the message of the Notification.
     76            @return Returns the message of the Notification.
     77            */
     78            inline const std::string & getMessage(void) const
     79                { return this->message_; }
     80
     81            /**
     82            @brief Get the sender of the Notification.
     83            @return Returns the sender of the Notification.
     84            */
     85            inline const std::string & getSender(void) const
     86                { return this->sender_; }
     87
     88            /**
     89            @brief Get the type of the Notification.
     90            @return Returns an enum with the type of the Notification.
     91            */
     92            inline notificationMessageType::Value getType(void) const
     93                { return this->type_; }
     94
     95        private:
     96            std::string message_; //!< The Notification message.
     97            std::string sender_; //!< The sender of the notification.
     98            notificationMessageType::Value type_; //!< The type of the notification.
     99
     100            void initialize(void); //!< Registers the object and sets some default values.
     101
     102    };
     103
     104    /**
     105    @brief
     106        The Singleton NotificationManager is a NotificationListener and functions as a gateway between @ref orxonox::Notification "Notifications" and @ref orxonox::NotificationQueue "NotificationQueues".
     107        It receives, organizes @ref orxonox::Notification "Notifications" and the redistributes them to the specific @ref orxonox::NotificationQueue "NotificationQueues".
     108        It also works as a liaison between the @ref orxonox::NotificationQueue "NotificationQueues" and the GUI that displays notification, called NotificationLayer.
    55109
    56110    @author
     
    60114    */
    61115    class _NotificationsExport NotificationManager // tolua_export
    62         : public Singleton<NotificationManager>, public OrxonoxClass
     116        : public Singleton<NotificationManager>, public NotificationListener
    63117    { // tolua_export
    64118            friend class Singleton<NotificationManager>;
     
    67121            virtual ~NotificationManager();
    68122
    69             virtual void preDestroy(void); //!< Is called before the object is destroyed.
     123            virtual void preDestroy(void); // Is called before the object is destroyed.
    70124
    71125            /**
     
    75129            static NotificationManager& getInstance() { return Singleton<NotificationManager>::getInstance(); } // tolua_export
    76130
    77             static const std::string ALL; //!< Static string to indicate a sender that sends to all NotificationListeners.
    78             static const std::string NONE; //!< Static string to indicare a sender that sends to no specific NotificationListener.
     131            virtual bool registerNotification(const std::string& message, const std::string& sender, notificationMessageType::Value type);
     132            virtual bool executeCommand(notificationCommand::Value command, const std::string& sender);
    79133
    80             //! Sends a Notification with the specified message to the specified client from the specified sender.
    81             static void sendNotification(const std::string& message, unsigned int clientId, const std::string& sender = NotificationManager::NONE, bool isLocal = false);
     134            bool registerNotification(Notification* notification); // Registers a Notification within the NotificationManager.
     135            void unregisterNotification(Notification* notification, NotificationQueue* queue); // Unregisters a Notification within the NotificationManager for a given NotificationQueue.
    82136
    83             bool registerNotification(Notification* notification); //!< Registers a Notification within the NotificationManager.
    84             void unregisterNotification(Notification* notification, NotificationListener* listener); //!< Unregisters a Notification within the NotificationManager for a given NotificationListener.
    85             bool registerListener(NotificationListener* listener); //!< Registers a NotificationListener within the NotificationManager.
    86             void unregisterListener(NotificationListener* listener); //!< Unregisters a NotificationListener withing the NotificationManager.
    87 
    88             void getNotifications(NotificationListener* listener, std::multimap<std::time_t, Notification*>* map, const std::time_t & timeFrameStart, const std::time_t & timeFrameEnd); //!< Fetches the Notifications for a specific NotificationListener in a specified timeframe and stores them in the input map.
     137            void getNotifications(NotificationQueue* queue, std::multimap<std::time_t, Notification*>* map, const std::time_t & timeFrameStart, const std::time_t & timeFrameEnd); // Fetches the Notifications for a specific NotificationQueue in a specified timeframe and stores them in the input map.
    89138
    90139            /**
    91             @brief Fetches the Notifications for a specific NotificationListener in a timeframe from now-timeDelay to now and stores them in the input map.
    92             @param listener The NotificationListener the Notifications are fetched for.
     140            @brief Fetches the Notifications for a specific NotificationQueue in a timeframe from (now-timeDelay) to now and stores them in the input map.
     141            @param queue The NotificationQueue the Notifications are fetched for.
    93142            @param map A pointer to a multimap, in which the notifications are stored. The map needs to have been allocated.
    94143            @param timeDelay The timespan.
    95144            @return Returns true if successful.
    96145            */
    97             void getNotifications(NotificationListener* listener, std::multimap<std::time_t, Notification*>* map, int timeDelay)
    98                 { this->getNotifications(listener, map, std::time(0)-timeDelay, std::time(0)); }
     146            void getNotifications(NotificationQueue* queue, std::multimap<std::time_t, Notification*>* map, int timeDelay)
     147                { this->getNotifications(queue, map, std::time(0)-timeDelay, std::time(0)); }
    99148
    100             void enterEditMode(void); //!< Enters the edit mode of the NotificationLayer.
     149            void getNewestNotifications(NotificationQueue* queue, std::multimap<std::time_t, Notification*>* map, int numberOfNotifications); // Fetches the newest Notifications for a specific NotificationQueue and stores them in the input map.
    101150
    102             bool registerQueue(NotificationQueue* queue); //!< Registers a NotificationQueue.
    103             void unregisterQueue(NotificationQueue* queue); //!< Unregisters a NotificationQueue.
     151            bool registerQueue(NotificationQueue* queue); // Registers a NotificationQueue.
     152            void unregisterQueue(NotificationQueue* queue); // Unregisters a NotificationQueue.
    104153
    105             // tolua_begin
    106             void loadQueues(void); //!< Loads all the NotificationQueues that should exist.
    107             void createQueue(const std::string& name); //!< Creates a new NotificationQueue.
    108             orxonox::NotificationQueue* getQueue(const std::string & name); //!< Get the NotificationQueue with the input name.
    109             // tolua_end
     154            void loadQueues(void); // tolua_export // Loads all the NotificationQueues that should exist.
     155
     156            NotificationQueue* getQueue(const std::string & name); // Get the NotificationQueue with the input name.
    110157
    111158        private:
    112159            static NotificationManager* singletonPtr_s;
    113160
    114             unsigned int highestIndex_; //!< This variable holds the highest index (resp. key) in notificationLists_s, to secure that no key appears twice.
    115 
    116161            std::multimap<std::time_t, Notification*> allNotificationsList_; //!< Container where all Notifications are stored.
    117             std::map<NotificationListener*, unsigned int> listenerList_; //!< Container where all NotificationListeners are stored with a number as identifier.
    118             std::map<int,std::multimap<std::time_t, Notification*>*> notificationLists_; //!< Container where all Notifications, for each identifier (associated with a NotificationListener), are stored.
     162            std::map<const std::string, std::multimap<std::time_t, Notification*>*> notificationLists_; //!< Container where all Notifications, for each identifier (associated with a NotificationQueue), are stored.
    119163
    120164            std::map<const std::string, NotificationQueue*> queues_; //!< The list of NotificationQueues created by the NotificationManager.
    121165
    122             bool removeNotification(Notification* notification, std::multimap<std::time_t, Notification*>& map); //!< Helper method that removes an input Notification form an input map.
     166            bool removeNotification(Notification* notification, std::multimap<std::time_t, Notification*>& map); // Helper method that removes an input Notification form an input map.
     167           
     168            // Commands
     169            bool commandClear(const std::string& sender); // The clear command. Clears all NotificationQueues that have its sender as a target.
    123170
    124171    }; // tolua_export
  • code/trunk/src/modules/notifications/NotificationQueue.cc

    r8079 r8706  
    3838
    3939#include "core/CoreIncludes.h"
    40 #include "core/GameMode.h"
    41 #include "core/GUIManager.h"
    42 #include "core/LuaState.h"
    43 #include "util/Convert.h"
     40#include "core/XMLPort.h"
    4441#include "util/SubString.h"
    45 
    46 #include "Notification.h"
    4742
    4843namespace orxonox
    4944{
    5045
    51     /**
    52     @brief
    53         Constructor. Creates and initializes the object.
     46    CreateFactory(NotificationQueue);
     47   
     48    /**
     49    @brief
     50        Default constructor. Registers and initializes the object.
     51    @param creator
     52        The creator of the NotificationQueue.
     53    */
     54    NotificationQueue::NotificationQueue(BaseObject* creator) : BaseObject(creator), Synchronisable(creator), registered_(false)
     55    {
     56        RegisterObject(NotificationQueue);
     57
     58        this->size_ = 0;
     59        this->tickTime_ = 0.0f;
     60        this->maxSize_ = NotificationQueue::DEFAULT_SIZE;
     61        this->displayTime_ = NotificationQueue::DEFAULT_DISPLAY_TIME;
     62
     63        this->creationTime_ = std::time(0);
     64       
     65        this->registerVariables();
     66    }
     67
     68    // TODO move to docu.
     69    /**
     70    @brief
     71        Constructor. Registers and initializes the object.
     72    @param creator
     73        The creator of the NotificationQueue
    5474    @param name
    5575        The name of the new NotificationQueue. It needs to be unique
     
    6282        The time during which a Notification is (at most) displayed.
    6383    */
    64     NotificationQueue::NotificationQueue(const std::string& name, const std::string& senders, unsigned int size, unsigned int displayTime)
    65     {
    66         this->registered_ = false;
    67 
    68         RegisterRootObject(NotificationQueue);
    69 
    70         // Initialize.
    71         this->size_ = 0;
    72         this->tickTime_ = 0.0f;
    73 
    74         // Sets the input values.
    75         this->setTargets(senders);
    76         this->name_ = name;
    77         this->maxSize_ = size;
    78         this->setDisplayTime(displayTime);
    79 
     84
     85    /**
     86    @brief
     87        Destructor.
     88    */
     89    NotificationQueue::~NotificationQueue()
     90    {
     91        this->targets_.clear();
     92
     93        if(this->isRegistered()) // If the NotificationQueue is registered.
     94        {
     95            this->clear(true);
     96
     97            // Unregister with the NotificationManager.
     98            NotificationManager::getInstance().unregisterQueue(this);
     99        }
     100    }
     101
     102    /**
     103    @brief
     104        Is called when the name of the NotificationQueue has changed.
     105        Clears and re-creates the NotificationQueue.
     106    */
     107    void NotificationQueue::changedName(void)
     108    {
     109        SUPER(NotificationQueue, changedName);
     110
     111        if(this->isRegistered())
     112            this->clear();
     113           
     114        this->create();
     115
     116        this->targetsChanged();
     117        this->maxSizeChanged();
     118        this->displayTimeChanged();
     119    }
     120
     121    /**
     122    @brief
     123        Creates the NotificationQueue.
     124    */
     125    void NotificationQueue::create(void)
     126    {
    80127        // Register the NotificationQueue with the NotificationManager.
    81128        bool queueRegistered = NotificationManager::getInstance().registerQueue(this);
     
    88135        }
    89136
    90         this->create(); // Creates the NotificationQueue in lua.
    91 
    92         // Register the NotificationQueue as NotificationListener with the NotificationManager.
    93         bool listenerRegistered = NotificationManager::getInstance().registerListener(this);
    94         if(!listenerRegistered) // If the registration has failed.
    95         {
    96             this->registered_ = false;
    97             // Remove the NotificationQueue in lua.
    98             if(GameMode::showsGraphics())
    99                 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.removeQueue(\"" + this->getName() +  "\")");
    100             NotificationManager::getInstance().unregisterQueue(this);
    101             COUT(1) << "Error: NotificationQueue '" << this->getName() << "' could not be registered." << std::endl;
    102             return;
    103         }
    104 
    105137        COUT(3) << "NotificationQueue '" << this->getName() << "' created." << std::endl;
    106     }
    107 
    108     /**
    109     @brief
    110         Destructor.
    111     */
    112     NotificationQueue::~NotificationQueue()
    113     {
    114         this->targets_.clear();
    115 
    116         if(this->registered_) // If the NotificationQueue is registered.
    117         {
    118             this->clear(true);
    119 
    120             // Unregister with the NotificationManager.
    121             NotificationManager::getInstance().unregisterListener(this);
    122             NotificationManager::getInstance().unregisterQueue(this);
    123         }
    124     }
    125 
    126     /**
    127     @brief
    128         Destroys the NotificationQueue.
    129         Used in lua and NotificationManager.
    130     @param noGraphics
    131         If this is set to true (false is default), then the queue is not removed in lua. This is used to destroy the queue, after the GUIManager has been destroyed.
    132     */
    133     void NotificationQueue::destroy(bool noGraphics)
    134     {
    135         // Remove the NotificationQueue in lua.
    136         if(GameMode::showsGraphics() && !noGraphics)
    137             GUIManager::getInstance().getLuaState()->doString("NotificationLayer.removeQueue(\"" + this->getName() +  "\")");
    138 
    139         COUT(3) << "NotificationQueue '" << this->getName() << "' destroyed." << std::endl;
    140 
    141         this->OrxonoxClass::destroy();
    142     }
    143 
    144     /**
    145     @brief
    146         Creates the NotificationQueue in lua.
    147     */
    148     void NotificationQueue::create(void)
    149     {
    150         if(GameMode::showsGraphics())
    151             GUIManager::getInstance().getLuaState()->doString("NotificationLayer.createQueue(\"" + this->getName() +  "\", " + multi_cast<std::string>(this->getMaxSize()) + ")");
    152138    }
    153139
     
    161147    {
    162148        this->tickTime_ += dt; // Add the time interval that has passed to the time counter.
    163         if(this->tickTime_ >= 1.0) // If the time counter is greater than 1s all Notifications that have expired are removed, if it is smaller we wait to the next tick.
    164         {
    165             this->timeLimit_.time = std::time(0)-this->displayTime_; // Container containig the current time.
     149        if(this->displayTime_ != INF && this->tickTime_ >= 1.0) // If the time counter is greater than 1 s all Notifications that have expired are removed, if it is smaller we wait to the next tick.
     150        {
     151            this->timeLimit_.time = std::time(0)-this->displayTime_; // Container containing the current time.
    166152
    167153            std::multiset<NotificationContainer*, NotificationContainerCompare>::iterator it = this->ordering_.begin();
     
    177163    }
    178164
     165    void NotificationQueue::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     166    {
     167        SUPER(NotificationQueue, XMLPort, xmlelement, mode);
     168
     169        XMLPortParam(NotificationQueue, "targets", setTargets, getTargets, xmlelement, mode).defaultValues(NotificationListener::ALL);
     170        XMLPortParam(NotificationQueue, "size", setMaxSize, getMaxSize, xmlelement, mode);
     171        XMLPortParam(NotificationQueue, "displayTime", setDisplayTime, getDisplayTime, xmlelement, mode);
     172    }
     173   
     174   
     175    /**
     176    @brief
     177        Registers Variables to be Synchronised.
     178        Registers Variables which have to be synchronised to the network system.
     179      */
     180    void NotificationQueue::registerVariables()
     181    {
     182        registerVariable( this->name_, VariableDirection::ToClient, new NetworkCallback<NotificationQueue>(this, &NotificationQueue::changedName));
     183        registerVariable( this->maxSize_, VariableDirection::ToClient, new NetworkCallback<NotificationQueue>(this, &NotificationQueue::maxSizeChanged));
     184        registerVariable( this->targets_, VariableDirection::ToClient, new NetworkCallback<NotificationQueue>(this, &NotificationQueue::targetsChanged));
     185        registerVariable( this->displayTime_, VariableDirection::ToClient, new NetworkCallback<NotificationQueue>(this, &NotificationQueue::displayTimeChanged));
     186    }
     187
    179188    /**
    180189    @brief
    181190        Updates the NotificationQueue.
    182191        Updates by clearing the queue and requesting all relevant Notifications from the NotificationManager and inserting them into the queue.
     192        This is called by the NotificationManager when the Notifications have changed so much, that the NotificationQueue may have to re-initialize his operations.
    183193    */
    184194    void NotificationQueue::update(void)
     
    188198        std::multimap<std::time_t, Notification*>* notifications = new std::multimap<std::time_t, Notification*>;
    189199        // Get the Notifications sent in the interval from now to now minus the display time.
    190         NotificationManager::getInstance().getNotifications(this, notifications, this->displayTime_);
     200        if(this->displayTime_ == INF)
     201            NotificationManager::getInstance().getNewestNotifications(this, notifications, this->getMaxSize());
     202        else
     203            NotificationManager::getInstance().getNotifications(this, notifications, this->displayTime_);
    191204
    192205        if(!notifications->empty())
    193206        {
    194             // Add all Notifications.
     207            // Add all Notifications that have been created after this NotificationQueue was created.
    195208            for(std::multimap<std::time_t, Notification*>::iterator it = notifications->begin(); it != notifications->end(); it++)
    196                 this->push(it->second, it->first);
     209            {
     210                if(it->first >= this->creationTime_)
     211                    this->push(it->second, it->first);
     212            }
    197213        }
    198214
     
    222238    @brief
    223239        Adds (pushes) a Notification to the NotificationQueue.
    224         It inserts it into the storage containers, creates a corresponding container and pushes the Notification message to the GUI.
     240        It inserts it into the storage containers, creates a corresponding container and pushes the notification message to the GUI.
    225241    @param notification
    226242        The Notification to be pushed.
     
    246262        this->notifications_.insert(this->notifications_.begin(), container);
    247263
    248         // Push the Notification to the GUI.
    249         if(GameMode::showsGraphics())
    250             GUIManager::getInstance().getLuaState()->doString("NotificationLayer.pushNotification(\"" + this->getName() + "\", \"" + notification->getMessage() + "\")");
     264        // Inform that a Notification was pushed.
     265        this->notificationPushed(notification);
    251266
    252267        COUT(5) << "Notification \"" << notification->getMessage() << "\" pushed to NotificationQueue '" << this->getName() << "'" << endl;
     268        COUT(3) << "NotificationQueue \"" << this->getName() << "\": " << notification->getMessage() << endl;
    253269    }
    254270
     
    279295        delete container;
    280296
    281         // Pops the Notification from the GUI.
    282         if(GameMode::showsGraphics())
    283             GUIManager::getInstance().getLuaState()->doString("NotificationLayer.popNotification(\"" + this->getName() + "\")");
     297        // Inform that a Notification was popped.
     298        this->notificationPopped();
    284299    }
    285300
     
    305320        delete *containerIterator;
    306321
    307         // Removes the Notification from the GUI.
    308         if(GameMode::showsGraphics())
    309             GUIManager::getInstance().getLuaState()->doString("NotificationLayer.removeNotification(\"" + this->getName() + "\", " + multi_cast<std::string>(index) + ")");
     322        // TODO: index automatically cast?
     323        // Inform that a Notification was removed.
     324        this->notificationRemoved(index);
    310325    }
    311326
     
    314329        Clears the NotificationQueue by removing all NotificationContainers.
    315330    @param noGraphics
    316         If this is eset to true the GUI is not informed of the clearing of the NotificationQueue. This is needed only internally.
     331        If this is set to true the GUI is not informed of the clearing of the NotificationQueue. This is needed only internally.
    317332    */
    318333    void NotificationQueue::clear(bool noGraphics)
     
    326341        this->notifications_.clear();
    327342        this->size_ = 0;
    328 
    329         // Clear the NotificationQueue in the GUI.
    330         if(GameMode::showsGraphics() && !noGraphics)
    331             GUIManager::getInstance().getLuaState()->doString("NotificationLayer.clearQueue(\"" + this->getName() + "\")");
    332343    }
    333344
     
    354365            return;
    355366
     367        if(size == 0)
     368        {
     369            COUT(2) << "Trying to set maximal size of NotificationQueue '" << this->getName() << "' to 0. Ignoring..." << endl;
     370            return;
     371        }
     372       
    356373        this->maxSize_ = size;
    357 
    358         if(this->registered_)
     374        this->maxSizeChanged();
     375    }
     376
     377    /**
     378    @brief
     379        Is called when the maximum number of displayed Notifications has changed.
     380    */
     381    void NotificationQueue::maxSizeChanged(void)
     382    {
     383        if(this->isRegistered())
    359384            this->update();
    360385    }
     
    364389        Sets the maximum number of seconds a Notification is displayed.
    365390    @param time
    366         The number of seconds the Notifications is displayed.
    367     @return
    368         Returns true if successful.
    369     */
    370     void NotificationQueue::setDisplayTime(unsigned int time)
     391        The number of seconds a Notification is displayed.
     392    */
     393    void NotificationQueue::setDisplayTime(int time)
    371394    {
    372395        if(this->displayTime_ == time)
    373396            return;
    374397
     398        if(time != NotificationQueue::INF && time <= 0)
     399        {
     400            COUT(2) << "Trying to set display time of NotificationQueue '" << this->getName() << "' to non-positive value. Ignoring..." << endl;
     401        }
     402           
    375403        this->displayTime_ = time;
    376 
    377         if(this->registered_)
     404        this->displayTimeChanged();
     405    }
     406
     407    /**
     408    @brief
     409        Is called when the maximum number of seconds a Notification is displayed has changed.
     410    */
     411    void NotificationQueue::displayTimeChanged(void)
     412    {
     413        if(this->isRegistered())
    378414            this->update();
    379415    }
     
    381417    /**
    382418    @brief
    383         Produces all targets of the NotificationQueue concatinated as string, with commas (',') as seperators.
     419        Produces all targets of the NotificationQueue concatenated as string, with commas (',') as separators.
    384420    @return
    385421        Returns the targets as a string.
     
    407443        The targets are the senders whose Notifications are displayed in this queue.
    408444    @param targets
    409         Accepts a string of targets, each seperated by commas (','), spaces are ignored.
     445        Accepts a string of targets, each separated by commas (','), spaces are ignored.
    410446    */
    411447    void NotificationQueue::setTargets(const std::string & targets)
     
    417453            this->targets_.insert(string[i]);
    418454
    419         if(this->registered_)
    420         {
    421             NotificationManager::getInstance().unregisterListener(this);
    422             NotificationManager::getInstance().registerListener(this);
    423         }
     455        this->targetsChanged();
     456    }
     457
     458    /**
     459    @brief
     460        Is called when the NotificationQueue's targets have changed.
     461    */
     462    void NotificationQueue::targetsChanged(void)
     463    {
     464        // TODO: Why?
     465        if(this->isRegistered())
     466        {
     467            NotificationManager::getInstance().unregisterQueue(this);
     468            NotificationManager::getInstance().registerQueue(this);
     469        }
     470    }
     471
     472    /**
     473    @brief
     474        Pops all Notifications from the NotificationQueue.
     475    @return
     476        Returns true if successful, false if not.
     477    */
     478    bool NotificationQueue::tidy(void)
     479    {
     480        while(this->size_ > 0)
     481            this->pop();
     482        return true;
    424483    }
    425484
  • code/trunk/src/modules/notifications/NotificationQueue.h

    r7552 r8706  
    4545#include "NotificationManager.h"
    4646
     47#include "core/BaseObject.h"
    4748#include "tools/interfaces/Tickable.h"
    48 #include "interfaces/NotificationListener.h"
    49 
    50 namespace orxonox // tolua_export
    51 { // tolua_export
     49#include "network/synchronisable/Synchronisable.h"
     50
     51namespace orxonox
     52{
    5253
    5354    /**
     
    7879        Displays @ref orxonox::Notification "Notifications" from specific senders.
    7980
    80         There are quite some parameters that influence the behaviour of the NotificationQueue:
     81        There are quite some parameters that influence the behavior of the NotificationQueue:
    8182        - @b name The name of the NotificationQueue. It needs to be unique.
    8283        - @b senders The senders that are targets of this NotificationQueue, i.e. the names of senders whose Notifications this NotificationQueue displays.
     
    8990    @ingroup Notifications
    9091    */
    91     class _NotificationsExport NotificationQueue // tolua_export
    92         : public Tickable, public NotificationListener
    93     { // tolua_export
     92    class _NotificationsExport NotificationQueue : public BaseObject, public Tickable, public Synchronisable
     93    {
    9494
    9595        public:
    96             NotificationQueue(const std::string& name, const std::string& senders = NotificationManager::ALL, unsigned int size = NotificationQueue::DEFAULT_SIZE, unsigned int displayTime = NotificationQueue::DEFAULT_DISPLAY_TIME);
     96            NotificationQueue(BaseObject* creator);
    9797            virtual ~NotificationQueue();
    9898
    99             //! Destroys the NotificationQueue.
    100             void destroy(bool noGraphics = false); // tolua_export
    101 
    102             virtual void tick(float dt); //!< To update from time to time.
    103 
    104             void update(void); //!< Updates the NotificationQueue.
    105             void update(Notification* notification, const std::time_t & time); //!< Updates the NotificationQueue by adding an new Notification.
     99            virtual void tick(float dt); // To update from time to time.
     100            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     101
     102            virtual void changedName(void);
     103           
     104            void update(void); // Updates the NotificationQueue.
     105            void update(Notification* notification, const std::time_t & time); // Updates the NotificationQueue by adding an new Notification.
    106106
    107107            // tolua_begin
     
    110110            @return Returns the name.
    111111            */
    112             inline const std::string& getName() const
    113                 { return this->name_; }
    114 
    115             void setMaxSize(unsigned int size); //!< Sets the maximum number of displayed Notifications.
     112            inline const std::string& getName(void) const
     113                { return this->BaseObject::getName(); }
     114
     115            void setMaxSize(unsigned int size); // Sets the maximum number of displayed Notifications.
    116116            /**
    117117            @brief Returns the maximum number of Notifications displayed.
    118118            @return Returns maximum size.
    119119            */
    120             inline unsigned int getMaxSize() const
     120            inline unsigned int getMaxSize(void) const
    121121                { return this->maxSize_; }
    122122
    123             void setDisplayTime(unsigned int time); //!< Sets the maximum number of seconds a Notification is displayed.
     123            void setDisplayTime(int time); // Sets the maximum number of seconds a Notification is displayed.
    124124            /**
    125125            @brief Returns the time interval the Notification is displayed.
    126126            @return Returns the display time.
    127127            */
    128             inline unsigned int getDisplayTime() const
     128            inline int getDisplayTime(void) const
    129129                { return this->displayTime_; }
    130130            // tolua_end
     131            void maxSizeChanged(void); // Is called when the maximum number of displayed Notifications has changed.
     132            void displayTimeChanged(void);
    131133
    132134            /**
     
    134136            @return Returns the size of the NotificationQueue.
    135137            */
    136             inline unsigned int getSize() const
     138            inline unsigned int getSize(void) const
    137139                { return this->size_; }
    138140
     
    141143            @return Returns a set of strings holding the different targets.
    142144            */
    143             inline const std::set<std::string> & getTargetsSet()
     145            inline const std::set<std::string> & getTargetsSet(void)
    144146                { return this->targets_; }
    145147
    146             // tolua_begin
    147             void setTargets(const std::string & targets); //!< Set the targets of this NotificationQueue.
    148             const std::string& getTargets(void) const; //!< Returns a string consisting of the concatination of the targets.
    149             // tolua_end
    150 
    151         private:
     148            void setTargets(const std::string & targets); // Set the targets of this NotificationQueue.
     149            const std::string& getTargets(void) const; // Returns a string consisting of the concatenation of the targets.
     150            void targetsChanged(void); // Is called when the NotificationQueue's targets have changed.
     151
     152            /**
     153            @brief Check whether the NotificationQueue is registered with the NotificationManager.
     154            @return Returns true if it is registered, false if not.
     155            */
     156            inline bool isRegistered(void)
     157                { return this->registered_; }
     158
     159            bool tidy(void); // Pops all Notifications from the NotificationQueue.
     160           
     161        protected:
     162            void registerVariables();
     163           
     164            /**
     165            @brief Is called when a notification was pushed.
     166            @param notification The Notification that was pushed.
     167            */
     168            virtual void notificationPushed(Notification* notification) {}
     169            /**
     170            @brief Is called when a notification was popped.
     171            */
     172            virtual void notificationPopped(void) {}
     173            /**
     174            @brief Is called when a notification was removed.
     175            @param index The index the removed notification was at.
     176            */
     177            virtual void notificationRemoved(unsigned int index) {}
     178           
     179            virtual void clear(bool noGraphics = false); // Clears the NotificationQueue by removing all NotificationContainers.
     180
     181        protected:
    152182            static const unsigned int DEFAULT_SIZE = 5; //!< The default maximum number of Notifications displayed.
    153183            static const unsigned int DEFAULT_DISPLAY_TIME = 30; //!< The default display time.
    154 
    155             std::string name_; //!< The name of the NotificationQueue.
    156 
     184            static const int INF = -1; //!< Constant denoting infinity.
     185
     186            virtual void create(void); // Creates the NotificationQueue.
     187
     188        private:
     189            time_t creationTime_; //!< The time this NotificationQueue was created.
     190           
    157191            unsigned int maxSize_; //!< The maximal number of Notifications displayed.
    158192            unsigned int size_; //!< The number of Notifications displayed.
    159             unsigned int displayTime_; //!< The time a Notification is displayed.
     193            int displayTime_; //!< The time a Notification is displayed.
    160194
    161195            bool registered_; //!< Helper variable to remember whether the NotificationQueue is registered already.
     
    169203            NotificationContainer timeLimit_; //!< Helper object to check against to determine whether Notifications have expired.
    170204
    171             void create(void); //!< Creates the NotificationQueue in lua.
    172 
    173205            void setName(const std::string& name); //!< Sets the name of the NotificationQueue.
    174206
    175             void push(Notification* notification, const std::time_t & time); //!< Adds (pushes) a Notification to the NotificationQueue.
    176             void pop(void); //!< Removes (pops) the least recently added Notification form the NotificationQueue.
    177             void remove(const std::multiset<NotificationContainer*, NotificationContainerCompare>::iterator& containerIterator); //!< Removes the Notification that is stored in the input NotificationContainer.
    178 
    179             void clear(bool noGraphics = false); //!< Clears the NotificationQueue by removing all NotificationContainers.
    180 
    181     }; // tolua_export
    182 
    183 } // tolua_export
    184 
    185 #endif /* _NotificationOverlay_H__ */
     207            void push(Notification* notification, const std::time_t & time); // Adds (pushes) a Notification to the NotificationQueue.
     208            void pop(void); // Removes (pops) the least recently added Notification form the NotificationQueue.
     209            void remove(const std::multiset<NotificationContainer*, NotificationContainerCompare>::iterator& containerIterator); // Removes the Notification that is stored in the input NotificationContainer.
     210
     211    };
     212
     213}
     214
     215#endif /* _NotificationQueue_H__ */
  • code/trunk/src/modules/notifications/dispatchers/SimpleNotification.cc

    r7474 r8706  
    5151        this->setSender("simpleNotification");
    5252
    53         this->setSyncMode(0x0);
     53        this->setSyncMode(ObjectDirection::None);
    5454    }
    5555
  • code/trunk/src/modules/objects/CMakeLists.txt

    r7163 r8706  
    44  Planet.cc
    55  Script.cc
     6  SpaceBoundaries.cc
    67)
    78
  • code/trunk/src/modules/objects/ObjectsPrereqs.h

    r8351 r8706  
    7272    class Planet;
    7373    class Script;
     74    class SpaceBoundaries;
    7475
    7576    // collisionshapes
  • code/trunk/src/modules/objects/Script.cc

    r7493 r8706  
    140140
    141141        PlayerTrigger* pTrigger = orxonox_cast<PlayerTrigger*>(trigger);
    142         Pawn* pawn = NULL;
     142        PlayerInfo* player = NULL;
    143143
    144144        // If the trigger is a PlayerTrigger.
     
    148148                return false;
    149149            else
    150                 pawn = pTrigger->getTriggeringPlayer();
     150                player = pTrigger->getTriggeringPlayer();
    151151        }
    152152        else
    153153            return false;
    154154
    155         if(pawn == NULL)  //TODO: Will this ever happen? If not, change in NotificationDispatcher as well.
     155        if(player == NULL)  //TODO: Will this ever happen? If not, change in NotificationDispatcher as well.
    156156        {
    157157            COUT(4) << "The Script was triggered by an entity other than a Pawn. (" << trigger->getIdentifier()->getName() << ")" << std::endl;
    158             return false;
    159         }
    160 
    161         // Extract the PlayerInfo from the Pawn.
    162         PlayerInfo* player = pawn->getPlayer();
    163 
    164         if(player == NULL)
    165         {
    166             COUT(3) << "The PlayerInfo* is NULL." << std::endl;
    167158            return false;
    168159        }
  • code/trunk/src/modules/objects/collisionshapes/BoxCollisionShape.cc

    r6417 r8706  
    2727 */
    2828
     29/**
     30    @file BoxCollisionShape.cc
     31    @brief Implementation of the BoxCollisionShape class.
     32*/
     33
    2934#include "BoxCollisionShape.h"
    3035
     
    3944    CreateFactory(BoxCollisionShape);
    4045
     46    /**
     47    @brief
     48        Constructor. Registers and initializes the object.
     49    */
    4150    BoxCollisionShape::BoxCollisionShape(BaseObject* creator) : CollisionShape(creator)
    4251    {
     
    4453
    4554        this->halfExtents_ = Vector3(1, 1, 1);
    46         updateShape();
     55        this->updateShape();
    4756
    4857        this->registerVariables();
     
    5160    BoxCollisionShape::~BoxCollisionShape()
    5261    {
     62        // TODO: Move to CollisionShape?
    5363        if (this->isInitialized())
    5464            delete this->collisionShape_;
     
    7080    }
    7181
     82    /**
     83    @brief
     84        Is called when the scale of the BoxCollisionShape has changed.
     85    */
     86    void BoxCollisionShape::changedScale()
     87    {
     88        CollisionShape::changedScale();
     89
     90        // Resize the internal collision shape
     91        // TODO: Assuming setLocalScaling works.
     92        // this->collisionShape_->setLocalScaling(multi_cast<btVector3>(this->getScale3D()));
     93        if(!this->hasUniformScaling())
     94        {
     95            CCOUT(1) << "Error: Non-uniform scaling is not yet supported." << endl;
     96            return;
     97        }
     98
     99        this->setHalfExtents(this->halfExtents_ * this->getScale());
     100    }
     101
     102    /**
     103    @brief
     104        Creates a new internal collision shape for the BoxCollisionShape.
     105    @return
     106        Returns a pointer to the newly created btBoxShape.
     107    */
    72108    btCollisionShape* BoxCollisionShape::createNewShape() const
    73109    {
  • code/trunk/src/modules/objects/collisionshapes/BoxCollisionShape.h

    r7601 r8706  
    4343namespace orxonox
    4444{
     45
     46    /**
     47    @brief
     48        Wrapper for the bullet box collision shape class btBoxShape.
     49
     50    @author
     51        Reto Grieder
     52
     53    @see btBoxShape
     54    @ingroup Collisionshapes
     55    */
    4556    class _ObjectsExport BoxCollisionShape : public CollisionShape
    4657    {
     
    5162            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    5263
    53             inline void setHalfExtents(const Vector3& extents)
    54                 { this->halfExtents_ = extents; updateShape(); }
     64            /**
     65            @brief Set the half extents of the BoxCollisionShape.
     66                   If the half extent changes, this causes the internal collision shape to be recreated.
     67            @param extents A vector with the half extents.
     68                   The x-component is half the length, the y-component is half the height and the z-component is half the width.
     69            @return Returns true if the half extent has changed, false if not.
     70            */
     71            inline bool setHalfExtents(const Vector3& extents)
     72                { if(this->halfExtents_ == extents) return false; this->halfExtents_ = extents; updateShape(); return true; }
     73            /**
     74            @brief Get the half extents of the BoxCollisionShape.
     75            @return Returns a vector containing the half extents.
     76            */
    5577            inline const Vector3& getHalfExtents() const
    5678                { return halfExtents_;}
    5779
    58             inline void setWidth(float value)
    59                 { this->halfExtents_.z = value / 2; updateShape(); }
     80            /**
     81            @brief Set the width of the BoxCollisionShape.
     82                   If the width changes, this causes the internal collision shape to be recreated.
     83            @param value The width to be set.
     84            @return Returns true if the width has changed, false if not.
     85            */
     86            inline bool setWidth(float value)
     87                { if(this->halfExtents_.z == value/2.0f) return false; this->halfExtents_.z = value / 2.0f; updateShape(); return true; }
     88            /**
     89            @brief Get the width of the BoxCollisionShape.
     90            @return Returns the width of the BoxCollisionShape.
     91            */
    6092            inline float getWidth() const
    61                 { return this->halfExtents_.z * 2; }
     93                { return this->halfExtents_.z * 2.0f; }
    6294
    63             inline void setHeight(float value)
    64                 { this->halfExtents_.y = value / 2; updateShape(); }
     95            /**
     96            @brief Set the height of the BoxCollisionShape.
     97                   If the height changes, this causes the internal collision shape to be recreated.
     98            @param value The height to be set.
     99            @return Returns true if the height has changed, false if not.
     100            */
     101            inline bool setHeight(float value)
     102                { if(this->halfExtents_.y == value/2.0f) return false; this->halfExtents_.y = value / 2.0f; updateShape(); return true; }
     103            /**
     104            @brief Get the height of the BoxCollisionShape.
     105            @return Returns the height of the BoxCollisionShape.
     106            */
    65107            inline float getHeight() const
    66                 { return this->halfExtents_.y * 2; }
     108                { return this->halfExtents_.y * 2.0f; }
    67109
    68             inline void setLength(float value)
    69                 { this->halfExtents_.x = value / 2; updateShape(); }
     110            /**
     111            @brief Set the length of the BoxCollisionShape.
     112                   If the length changes, this causes the internal collision shape to be recreated.
     113            @param value The length to be set.
     114            @return Returns true if the length has changed, false if not.
     115            */
     116            inline bool setLength(float value)
     117                { if(this->halfExtents_.x == value/2.0f) return false; this->halfExtents_.x = value / 2.0f; updateShape(); return true; }
     118            /**
     119            @brief Get the length of the BoxCollisionShape.
     120            @return Returns the length of the BoxCollisionShape.
     121            */
    70122            inline float getLength() const
    71                 { return this->halfExtents_.x * 2; }
     123                { return this->halfExtents_.x * 2.0f; }
     124
     125            virtual void changedScale(); // Is called when the scale of the BoxCollisionShape has changed.
    72126
    73127        private:
    74128            void registerVariables();
    75129
    76             btCollisionShape* createNewShape() const;
     130            btCollisionShape* createNewShape() const; // Creates a new internal collision shape for the BoxCollisionShape.
    77131
    78             Vector3 halfExtents_;
     132            Vector3 halfExtents_; //!< The half extents of the BoxCollisionShape. The x-component is half the length, the y-component is half the height and the z-component is half the width.
    79133     };
    80134}
  • code/trunk/src/modules/objects/collisionshapes/ConeCollisionShape.cc

    r6417 r8706  
    2727 */
    2828
     29/**
     30    @file ConeCollisionShape.cc
     31    @brief Implementation of the ConeCollisionShape class.
     32*/
     33
    2934#include "ConeCollisionShape.h"
    3035
     
    3338#include "core/CoreIncludes.h"
    3439#include "core/XMLPort.h"
     40#include "tools/BulletConversions.h"
    3541
    3642namespace orxonox
     
    3844    CreateFactory(ConeCollisionShape);
    3945
     46    /**
     47    @brief
     48        Constructor. Registers and initializes the object.
     49    */
    4050    ConeCollisionShape::ConeCollisionShape(BaseObject* creator) : CollisionShape(creator)
    4151    {
     
    6979    }
    7080
     81    /**
     82    @brief
     83        Is called when the scale of the ConeCollisionShape has changed.
     84    */
     85    void ConeCollisionShape::changedScale()
     86    {
     87        CollisionShape::changedScale();
     88
     89        // Resize the internal collision shape
     90        // TODO: Assuming setLocalScaling works.
     91        //this->collisionShape_->setLocalScaling(multi_cast<btVector3>(this->getScale3D()));
     92        if(!this->hasUniformScaling())
     93        {
     94            CCOUT(1) << "Error: Non-uniform scaling is not yet supported." << endl;
     95            return;
     96        }
     97
     98        this->radius_ *= this->getScale();
     99        this->height_ *= this->getScale();
     100        this->updateShape();
     101    }
     102
     103    /**
     104    @brief
     105        Creates a new internal collision shape for the ConeCollisionShape.
     106    @return
     107        Returns a pointer to the newly created btConeShape.
     108    */
    71109    btCollisionShape* ConeCollisionShape::createNewShape() const
    72110    {
  • code/trunk/src/modules/objects/collisionshapes/ConeCollisionShape.h

    r7601 r8706  
    4141namespace orxonox
    4242{
     43
     44    /**
     45    @brief
     46        Wrapper for the bullet cone collision shape class btConeShape.
     47
     48    @author
     49        Reto Grieder
     50
     51    @see btConeShape
     52    @ingroup Collisionshapes
     53    */
    4354    class _ObjectsExport ConeCollisionShape : public CollisionShape
    4455    {
     
    4960            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    5061
    51             inline void setRadius(float value)
    52                 { this->radius_ = value; updateShape(); }
     62            /**
     63            @brief Set the radius of the ConeCollisionShape.
     64                   If the radius changes, this causes the internal collision shape to be recreated.
     65            @param value The radius to be set.
     66            @return Returns true if the radius has changed, false if not.
     67            */
     68            inline bool setRadius(float value)
     69                { if(this->radius_ == value) return false; this->radius_ = value; updateShape(); return true; }
     70            /**
     71            @brief Get the radius of the ConeCollisionShape.
     72            @return Returns the radius of the ConeCollisionShape.
     73            */
    5374            inline float getRadius() const
    5475                { return radius_; }
    5576
    56             inline void setHeight(float value)
    57                 { this->height_ = value; updateShape(); }
     77            /**
     78            @brief Set the height of the ConeCollisionShape.
     79                   If the height changes, this causes the internal collision shape to be recreated.
     80            @param value The height to be set.
     81            @return Returns true if the height has changed, false if not.
     82            */
     83            inline bool setHeight(float value)
     84                { if(this->height_ == value) return false; this->height_ = value; updateShape(); return true; }
     85            /**
     86            @brief Get the height of the ConeCollisionShape.
     87            @return Returns the height of the ConeCollisionShape.
     88            */
    5889            inline float getHeight() const
    5990                { return this->height_; }
     91
     92            virtual void changedScale(); // Is called when the scale of the ConeCollisionShape has changed.
    6093
    6194        private:
    6295            void registerVariables();
    6396
    64             btCollisionShape* createNewShape() const;
     97            btCollisionShape* createNewShape() const; // Creates a new internal collision shape for the ConeCollisionShape.
    6598
    66             float radius_;
    67             float height_;
     99            float radius_; //!< The radius of the ConeCollisionShape.
     100            float height_; //!< The height of the ConeCollisionShape.
    68101     };
    69102}
  • code/trunk/src/modules/objects/collisionshapes/PlaneCollisionShape.cc

    r6417 r8706  
    2727 */
    2828
     29/**
     30    @file PlaneCollisionShape.cc
     31    @brief Implementation of the PlaneCollisionShape class.
     32*/
     33
    2934#include "PlaneCollisionShape.h"
    3035
     
    3944    CreateFactory(PlaneCollisionShape);
    4045
     46    /**
     47    @brief
     48        Constructor. Registers and initializes the object.
     49    */
    4150    PlaneCollisionShape::PlaneCollisionShape(BaseObject* creator) : CollisionShape(creator)
    4251    {
     
    7079    }
    7180
     81    /**
     82    @brief
     83        Is called when the scale of the PlaneCollisionShape has changed.
     84    */
     85    void PlaneCollisionShape::changedScale()
     86    {
     87        CollisionShape::changedScale();
     88
     89        // Resize the internal collision shape
     90        // TODO: Assuming setLocalScaling works.
     91        //this->collisionShape_->setLocalScaling(multi_cast<btVector3>(this->getScale3D()));
     92        if(!this->hasUniformScaling())
     93        {
     94            CCOUT(1) << "Error: Non-uniform scaling is not yet supported." << endl;
     95            return;
     96        }
     97
     98        this->setOffset(this->offset_*this->getScale());
     99    }
     100
     101    /**
     102    @brief
     103        Creates a new internal collision shape for the PlaneCollisionShape.
     104    @return
     105        Returns a pointer to the newly created btStaticPlaneShape.
     106    */
    72107    btCollisionShape* PlaneCollisionShape::createNewShape() const
    73108    {
  • code/trunk/src/modules/objects/collisionshapes/PlaneCollisionShape.h

    r7601 r8706  
    4343namespace orxonox
    4444{
     45
     46    /**
     47    @brief
     48        Wrapper for the bullet plane collision shape class btStaticPlaneShape.
     49
     50    @author
     51        Martin Stypinski
     52
     53    @see btStaticPlaneShape
     54    @ingroup Collisionshapes
     55    */
    4556    class _ObjectsExport PlaneCollisionShape : public CollisionShape
    4657    {
     
    5162            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    5263
    53             inline void setNormal(const Vector3& normal)
    54                 { this->normal_ = normal; updateShape(); }
    55             inline const Vector3& getNormal()
     64            /**
     65            @brief Set the normal of the PlaneCollisionShape.
     66                   If the normal changes, this causes the internal collision shape to be recreated.
     67            @param normal The normal vector to be set.
     68            @return Returns true if the normal has changed, false if not.
     69            */
     70            inline bool setNormal(const Vector3& normal)
     71                { if(this->normal_ == normal) return false; this->normal_ = normal; updateShape(); return true; }
     72            /**
     73            @brief Get the normal of the PlaneCollisionShape.
     74            @return Returns the normal vector of the PlaneCollisionShape.
     75            */
     76            inline const Vector3& getNormal() const
    5677                { return normal_;}
    5778
    58             inline void setOffset(float offset)
    59                 { this->offset_ = offset; updateShape(); }
    60             inline float getOffset()
     79            /**
     80            @brief Set the offset of the PlaneCollisionShape.
     81                   If the offset changes, this causes the internal collision shape to be recreated.
     82            @param offset The offset to be set.
     83            @return Returns true if the offset has changed, false if not.
     84            */
     85            inline bool setOffset(float offset)
     86                { if(this->offset_ == offset) return false; this->offset_ = offset; updateShape(); return true; }
     87            /**
     88            @brief Get the offset of the PlaneCollisionShape.
     89            @return Returns the offset of the PlaneCollisionShape.
     90            */
     91            inline float getOffset() const
    6192                { return this->offset_;}
     93
     94            virtual void changedScale(); // Is called when the scale of the PlaneCollisionShape has changed.
    6295
    6396        private:
    6497            void registerVariables();
    6598
    66             btCollisionShape* createNewShape()const;
     99            btCollisionShape* createNewShape() const; // Creates a new internal collision shape for the PlaneCollisionShape.
    67100
    68             Vector3 normal_;
    69             float   offset_;
     101            Vector3 normal_; //!< The normal vector of the PlaneCollisionShape.
     102            float   offset_; //!< The offset of the PlaneCollisionShape.
    70103     };
    71104}
  • code/trunk/src/modules/objects/collisionshapes/SphereCollisionShape.cc

    r5781 r8706  
    2727 */
    2828
     29/**
     30    @file SphereCollisionShape.cc
     31    @brief Implementation of the SphereCollisionShape class.
     32*/
     33
    2934#include "SphereCollisionShape.h"
    3035
     
    3338#include "core/CoreIncludes.h"
    3439#include "core/XMLPort.h"
     40#include "tools/BulletConversions.h"
    3541
    3642namespace orxonox
     
    3844    CreateFactory(SphereCollisionShape);
    3945
     46    /**
     47    @brief
     48        Constructor. registers and initializes the object.
     49    */
    4050    SphereCollisionShape::SphereCollisionShape(BaseObject* creator) : CollisionShape(creator)
    4151    {
     
    6676    }
    6777
     78    /**
     79    @brief
     80        Is called when the scale of the SphereCollisionShape has changed.
     81    */
     82    void SphereCollisionShape::changedScale()
     83    {
     84        CollisionShape::changedScale();
     85
     86        // Resize the internal collision shape
     87        // TODO: Assuming setLocalScaling works.
     88        //this->collisionShape_->setLocalScaling(multi_cast<btVector3>(this->getScale3D()));
     89        if(!this->hasUniformScaling())
     90        {
     91            CCOUT(1) << "Error: Non-uniform scaling is not yet supported." << endl;
     92            return;
     93        }
     94
     95        this->setRadius(this->radius_*this->getScale());
     96    }
     97
     98    /**
     99    @brief
     100        Creates a new internal collision shape for the SphereCollisionShape.
     101    @return
     102        Returns a pointer to the newly created btSphereShape.
     103    */
    68104    btCollisionShape* SphereCollisionShape::createNewShape() const
    69105    {
  • code/trunk/src/modules/objects/collisionshapes/SphereCollisionShape.h

    r7601 r8706  
    4141namespace orxonox
    4242{
     43
     44    /**
     45    @brief
     46        Wrapper for the bullet sphere collision shape class btSphereShape.
     47
     48    @author
     49        Reto Grieder
     50
     51    @see btSphereShape
     52    @ingroup Collisionshapes
     53    */
    4354    class _ObjectsExport SphereCollisionShape : public CollisionShape
    4455    {
     
    4960            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    5061
    51             inline void setRadius(float radius)
    52                 { this->radius_ = radius; updateShape(); }
     62            /**
     63            @brief Set the radius of the SphereCollisionShape.
     64                   If the radius changes, this causes the internal collision shape to be recreated.
     65            @param radius The radius to be set.
     66            @return Returns true if the radius has changed, false if not.
     67            */
     68            inline bool setRadius(float radius)
     69                { if(this->radius_ == radius) return false; this->radius_ = radius; updateShape(); return true; }
     70            /**
     71            @brief Get the radius of the SphereCollisionShape.
     72            @return Returns the radius of the SphereCollisionShape.
     73            */
    5374            inline float getRadius() const
    5475                { return this->radius_; }
     76
     77            virtual void changedScale(); // Is called when the scale of the SphereCollisionShape has changed.
    5578
    5679        private:
     
    5982            btCollisionShape* createNewShape() const;
    6083
    61             float radius_;
     84            float radius_; //!< The radius of the SphereCollisionShape.
    6285    };
    6386}
  • code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.cc

    r8213 r8706  
    5353        Default Constructor. Registers the object and initializes default values.
    5454    */
    55     DistanceMultiTrigger::DistanceMultiTrigger(BaseObject* creator) : MultiTrigger(creator), beaconMask_(NULL)
     55    DistanceMultiTrigger::DistanceMultiTrigger(BaseObject* creator) : MultiTrigger(creator)
    5656    {
    5757        RegisterObject(DistanceMultiTrigger);
     
    6060        this->setBeaconModeDirect(distanceMultiTriggerBeaconMode::off);
    6161        this->targetName_ = "";
     62        this->beaconMask_.exclude(Class(BaseObject));
     63        this->beaconMask_.include(Class(DistanceTriggerBeacon));
    6264    }
    6365
     
    6870    DistanceMultiTrigger::~DistanceMultiTrigger()
    6971    {
    70         if(this->beaconMask_ != NULL)
    71             delete this->beaconMask_;
     72
    7273    }
    7374
     
    135136        // If we are in identify-mode another target mask has to be applies to find the DistanceTriggerBeacons.
    136137        if(this->beaconMode_ == distanceMultiTriggerBeaconMode::identify)
    137             targetMask = *this->beaconMask_;
     138            targetMask = this->beaconMask_;
    138139
    139140        // Iterate through all objects that are targets of the DistanceMultiTrigger.
     
    207208    {
    208209        this->beaconMode_ = mode;
    209         if(this->beaconMode_ == distanceMultiTriggerBeaconMode::identify && this->beaconMask_ == NULL)
    210         {
    211             this->beaconMask_ = new ClassTreeMask();
    212             this->beaconMask_->exclude(Class(BaseObject));
    213             this->beaconMask_->include(Class(DistanceTriggerBeacon));
    214         }
    215210    }
    216211   
  • code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.h

    r8213 r8706  
    152152            distanceMultiTriggerBeaconMode::Value beaconMode_; //!< The beacon mode, the DistanceMultiTrigger is in.
    153153            std::string targetName_; //!< The target name, used in <em>single-target</em> mode.
    154             ClassTreeMask* beaconMask_; //!< A mask, that only accepts DistanceTriggerBeacons.
     154            ClassTreeMask beaconMask_; //!< A mask, that only accepts DistanceTriggerBeacons.
    155155
    156156            std::map<WorldEntity*, WeakPtr<WorldEntity>* > range_; //!< The set of entities that currently are in range of the DistanceMultiTrigger.
  • code/trunk/src/modules/objects/triggers/DistanceTrigger.cc

    r8213 r8706  
    5757        The creator of this trigger.
    5858    */
    59     DistanceTrigger::DistanceTrigger(BaseObject* creator) : Trigger(creator), beaconMask_(NULL)
     59    DistanceTrigger::DistanceTrigger(BaseObject* creator) : Trigger(creator)
    6060    {
    6161        RegisterObject(DistanceTrigger);
     
    6464        this->targetMask_.exclude(Class(BaseObject));
    6565        this->targetName_ = "";
     66        this->beaconMask_.exclude(Class(BaseObject));
     67        this->beaconMask_.include(Class(DistanceTriggerBeacon));
    6668    }
    6769
     
    7274    DistanceTrigger::~DistanceTrigger()
    7375    {
    74         // Delete the beacon mask if it exists.
    75         if(this->beaconMask_ != NULL)
    76             delete this->beaconMask_;
     76
    7777    }
    7878
     
    159159        // If we are in identify-mode another target mask has to be applies to find the DistanceTriggerBeacons.
    160160        if(this->beaconMode_ == distanceTriggerBeaconMode::identify)
    161             targetMask = *this->beaconMask_;
     161            targetMask = this->beaconMask_;
    162162
    163163        // Iterate through all objects that are targets of the DistanceTrigger.
     
    205205                        entity = entity->getParent();
    206206
    207                     Pawn* player = orxonox_cast<Pawn*>(entity);
    208                     this->setTriggeringPlayer(player);
     207                    Pawn* pawn = orxonox_cast<Pawn*>(entity);
     208                    if(pawn != NULL)
     209                        this->setTriggeringPawn(pawn);
     210                    else
     211                        CCOUT(2) << "Pawn was NULL." << endl;
    209212                }
    210213               
     
    228231    {
    229232        this->beaconMode_ = mode;
    230         if(this->beaconMode_ == distanceTriggerBeaconMode::identify && this->beaconMask_ == NULL)
    231         {
    232             this->beaconMask_ = new ClassTreeMask();
    233             this->beaconMask_->exclude(Class(BaseObject));
    234             this->beaconMask_->include(Class(DistanceTriggerBeacon));
    235         }
    236233    }
    237234
     
    280277        Check whether the DistanceTrigger is triggered.
    281278        It is triggered if it is triggered according only to its mode (i.e. its sub-triggers) and if a target is in range.
    282     @param
     279    @param mode
     280        The mode for which it is tested, whether the DistanceTrigger is triggered.
     281    @return
    283282        Returns true if it is triggered ,false if not.
    284283    */
  • code/trunk/src/modules/objects/triggers/DistanceTrigger.h

    r8213 r8706  
    7171        - @b target Which specifies the class of objects that can trigger the DistanceTrigger. Default is <code>"Pawn"</code>.
    7272        - @b beaconMode Which specifies, whether the DistanceTrigger operates on @ref orxonox::DistanceTriggerBeacon "DistanceTriggerBeacons" or not. If <em>off</em> the DistanceMultiTrigger works as usual. If set to <em>identify</em> the DistanceTrigger is only triggered by objects that have a @ref orxonox::DistanceTriggerBeacon "DistanceTriggerBeacon", with the same name as specified in <em>targetname</em>, attached to them. If set to <em>exclude</em> the DistanceTrigger is only triggered by objects that don't have a @ref orxonox::DistanceTriggerBeacon "DistanceTriggerBeacon", with the same name as specified in <em>targetname</em>, attached to them. Default is <em>off</em>.
    73         - @b targetname Which specifies the name @ref oroxnox::DistanceTriggerBeacon "DistanceTriggerBeacons" need to have to make the DistanceTrigger react to them if it is in <em>beacon-mode</em> (the beaconMode is not <em>off</em>).
     73        - @b targetname Which specifies the name @ref orxonox::DistanceTriggerBeacon "DistanceTriggerBeacons" need to have to make the DistanceTrigger react to them if it is in <em>beacon-mode</em> (the beaconMode is not <em>off</em>).
    7474
    7575        A simple DistanceTrigger could look like this:
     
    162162            distanceTriggerBeaconMode::Value beaconMode_; //!< The beacon mode.
    163163            std::string targetName_; //!< The name a DistanceTriggerBeacon needs to have to make the DistanceTrigger react to it if in beacon-mode.
    164             ClassTreeMask* beaconMask_; //!< A mask, that only accepts DistanceTriggerBeacons.
     164            ClassTreeMask beaconMask_; //!< A mask, that only accepts DistanceTriggerBeacons.
    165165           
    166166            WeakPtr<WorldEntity> cache_; //!< Caches the entity that triggered the DistanceTrigger last.
  • code/trunk/src/modules/objects/triggers/EventTrigger.h

    r8213 r8706  
    6060
    6161    @see Trigger
    62         For more information on @ref oroxnox::Trigger "Triggers".
     62        For more information on @ref orxonox::Trigger "Triggers".
    6363
    6464    @author
  • code/trunk/src/modules/objects/triggers/MultiTrigger.cc

    r8213 r8706  
    6363        this->bMultiTrigger_ = true;
    6464
    65         this->setSyncMode(0x0);
     65        this->setSyncMode(ObjectDirection::None);
    6666    }
    6767
     
    198198                        if(bActive ^ this->isActive(state->originator))
    199199                        {
    200 
    201200                            bool bFire = true;
    202201
     
    312311
    313312        // We only want WorldEntities
    314         //TODO: Really?
    315313        ClassTreeMask WEMask;
    316314        WEMask.include(Class(WorldEntity));
  • code/trunk/src/modules/objects/triggers/MultiTriggerContainer.cc

    r7601 r8706  
    7373        {
    7474            this->setForPlayer(true);
    75             this->setTriggeringPlayer(pawn);
     75            this->setTriggeringPawn(pawn);
    7676        }
    7777    }
  • code/trunk/src/modules/objects/triggers/Trigger.cc

    r8213 r8706  
    7676        }
    7777
    78         this->setSyncMode(0x0);
     78        this->setSyncMode(ObjectDirection::None);
    7979    }
    8080
  • code/trunk/src/modules/objects/triggers/TriggerBase.cc

    r7652 r8706  
    7171        this->bMultiTrigger_ = false;
    7272
    73         this->setSyncMode(0x0);
     73        this->setSyncMode(ObjectDirection::None);
    7474    }
    7575
  • code/trunk/src/modules/objects/triggers/TriggerBase.h

    r8213 r8706  
    133133            inline int getActivations(void) const
    134134                { return this->remainingActivations_; }
     135            /**
     136            @brief Check whether the trigger has still at least one remaining activation.
     137            @return Returns true if the trigger has remaining activations (i.e. the number of remaining activations is not zero).
     138            */
     139            inline bool hasRemainingActivations(void) const
     140                { return this->remainingActivations_ > 0 || this->remainingActivations_ == INF_s; }
    135141
    136142            /**
  • code/trunk/src/modules/overlays/OverlaysPrereqs.h

    r8351 r8706  
    8989    class HUDRadar;
    9090    class HUDSpeedBar;
     91    class HUDBoostBar;
    9192    class HUDTimer;
    9293    class KillMessage;
  • code/trunk/src/modules/overlays/hud/CMakeLists.txt

    r8178 r8706  
    44  HUDRadar.cc
    55  HUDSpeedBar.cc
     6  HUDBoostBar.cc
    67  HUDHealthBar.cc
    78  HUDTimer.cc
    89  ChatOverlay.cc
    9   GametypeStatus.cc
    1010  AnnounceMessage.cc
    1111  KillMessage.cc
  • code/trunk/src/modules/overlays/hud/HUDBar.cc

    r7801 r8706  
    2626 *      Fabian 'x3n' Landau
    2727 *      Reto Grieder
     28 *      Benjamin Knecht
    2829 *
    2930 */
  • code/trunk/src/modules/overlays/hud/HUDBar.h

    r7401 r8706  
    2626 *      Fabian 'x3n' Landau
    2727 *      Reto Grieder
     28 *      Benjamin Knecht
    2829 *
    2930 */
  • code/trunk/src/modules/overlays/hud/HUDNavigation.cc

    r7801 r8706  
    342342    text->hide();
    343343
    344     ObjectInfo tempStruct = {panel, text, false};
     344    ObjectInfo tempStruct = {panel, text, false /*, TODO: initialize wasOutOfView_ */};
    345345    activeObjectList_[object] = tempStruct;
    346346
  • code/trunk/src/modules/overlays/hud/HUDSpeedBar.cc

    r5781 r8706  
    5454        SUPER(HUDSpeedBar, tick, dt);
    5555
    56         if (this->owner_ && this->owner_->getEngine())
     56        if (this->owner_)
    5757        {
    58             float value = this->owner_->getVelocity().length() / (this->owner_->getEngine()->getMaxSpeedFront() * this->owner_->getEngine()->getSpeedFactor() * this->owner_->getEngine()->getBoostFactor());
     58            float value = this->owner_->getVelocity().length() / (this->owner_->getMaxSpeedFront() * this->owner_->getSpeedFactor() * this->owner_->getBoostFactor());
    5959            this->setValue(value);
    6060        }
  • code/trunk/src/modules/pickup/PickupManager.h

    r7547 r8706  
    148148            @return Returns true if the input Pickupable is still valid, false if not.
    149149            */
    150             const bool isValidPickup(uint32_t pickup) const
     150            bool isValidPickup(uint32_t pickup) const
    151151                { return this->pickups_.find(pickup) != this->pickups_.end(); }
    152152            // tolua_end
  • code/trunk/src/modules/pickup/PickupPrereqs.h

    r8351 r8706  
    8585    class SpeedPickup;
    8686    class ShieldPickup;
     87    class ShrinkPickup;
    8788
    8889}
  • code/trunk/src/modules/pickup/PickupRepresentation.cc

    r8079 r8706  
    5757
    5858        this->initialize();
    59         this->setSyncMode(0x0); // The default PickupRperesentation created by each PickupManager is not synchronised, since it only exists locally.
     59        this->setSyncMode(ObjectDirection::None); // The default PickupRperesentation created by each PickupManager is not synchronised, since it only exists locally.
    6060    }
    6161
  • code/trunk/src/modules/pickup/items/CMakeLists.txt

    r7163 r8706  
    66  SpeedPickup.cc
    77  ShieldPickup.cc
     8  ShrinkPickup.cc
    89)
  • code/trunk/src/modules/pong/PongBat.h

    r8108 r8706  
    100100                { this->length_ = length; }
    101101            /**
    102             @brief get the length of the bat.
     102            @brief Get the length of the bat.
    103103            @return Returns the length of the bat (in z-direction) as percentage of the height of the playing field.
    104104            */
  • code/trunk/src/modules/portals/CMakeLists.txt

    • Property svn:eol-style set to native
  • code/trunk/src/modules/portals/PortalEndPoint.cc

    • Property svn:executable deleted
    • Property svn:eol-style set to native
    r8471 r8706  
     1/*
     2 *   ORXONOX - the hottest 3D action shooter ever to exist
     3 *                    > www.orxonox.net <
     4 *
     5 *
     6 *   License notice:
     7 *
     8 *   This program is free software; you can redistribute it and/or
     9 *   modify it under the terms of the GNU General Public License
     10 *   as published by the Free Software Foundation; either version 2
     11 *   of the License, or (at your option) any later version.
     12 *
     13 *   This program is distributed in the hope that it will be useful,
     14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 *   GNU General Public License for more details.
     17 *
     18 *   You should have received a copy of the GNU General Public License
     19 *   along with this program; if not, write to the Free Software
     20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     21 *
     22 *   Author:
     23 *      Andreas Büchel
     24 *   Co-authors:
     25 *      ...
     26 *
     27 */
     28
    129#include "PortalEndPoint.h"
    230#include "core/XMLPort.h"
     
    432#include "portals/PortalLink.h"
    533#include "worldentities/MobileEntity.h"
    6 
     34#include <ctime>
    735
    836namespace orxonox
     
    1442    std::map<unsigned int, PortalEndPoint *> PortalEndPoint::idMap_s;
    1543
    16     PortalEndPoint::PortalEndPoint(BaseObject* creator) : StaticEntity(creator), id_(0), trigger_(NULL)
     44    PortalEndPoint::PortalEndPoint(BaseObject* creator) : StaticEntity(creator), RadarViewable(creator, static_cast<WorldEntity*>(this)), id_(0), trigger_(NULL), reenterDelay_(0)
    1745    {
    1846        RegisterObject(PortalEndPoint);
     47       
    1948        this->trigger_ = new DistanceMultiTrigger(this);
    2049        this->trigger_->setName("portal");
    2150        this->attach(trigger_);
     51
     52        this->setRadarObjectColour(ColourValue::White);
     53        this->setRadarObjectShape(RadarViewable::Dot);
     54        this->setRadarVisibility(true);
    2255    }
    2356   
    2457    PortalEndPoint::~PortalEndPoint()
    2558    {
    26         delete this->trigger_;
     59        if(this->isInitialized() && this->trigger_ != NULL)
     60            delete this->trigger_;
    2761    }
    2862
     
    3367        XMLPortParam(PortalEndPoint, "id", setID, getID, xmlelement, mode);
    3468        XMLPortParam(PortalEndPoint, "design", setTemplate, getTemplate, xmlelement, mode);
     69        XMLPortParam(PortalEndPoint, "reenterDelay", setReenterDelay, getReenterDelay, xmlelement, mode);
    3570        XMLPortParamExtern(PortalEndPoint, DistanceMultiTrigger, this->trigger_, "distance", setDistance, getDistance, xmlelement, mode);
    3671        XMLPortParamLoadOnly(PortalEndPoint, "target", setTarget, xmlelement, mode).defaultValues("Pawn");
     
    6499        if(originatingTrigger == 0)
    65100        {
    66             COUT(1) << "originator no DistanceMultiTrigger\n" << std::endl;
    67101            return true;
    68102        }
     
    74108        if(bTriggered)
    75109        {
    76             if(this->recentlyJumpedOut_.find(entity) == this->recentlyJumpedOut_.end())  // only enter the portal if not just jumped out of it
     110            if(this->letsEnter(entity))  // only enter the portal if not just (this very moment) jumped out of it, or if the reenterDelay expired
    77111            {
    78112                PortalLink::use(entity, this);
     
    87121    }
    88122
     123    void PortalEndPoint::changedActivity(void)
     124    {
     125        SUPER(PortalEndPoint, changedActivity);
     126       
     127        this->setRadarVisibility(this->isActive());
     128    }
     129
     130    bool PortalEndPoint::letsEnter(MobileEntity* entity)
     131    {
     132        // not allowed to enter if reenterDelay hasn't expired yet
     133        std::map<MobileEntity *, time_t>::const_iterator time = this->jumpOutTimes_.find(entity);
     134        if(time != this->jumpOutTimes_.end() && std::difftime(std::time(0),time->second) < this->reenterDelay_)
     135            return false;
     136
     137        // not allowed to enter if jumped out of this portal and not left its activation radius yet
     138        std::set<MobileEntity *>::const_iterator recent = this->recentlyJumpedOut_.find(entity);
     139        if(recent != this->recentlyJumpedOut_.end())
     140            return false;
     141       
     142        return true;
     143    }
     144
    89145    void PortalEndPoint::jumpOut(MobileEntity* entity)
    90146    {
     147        this->jumpOutTimes_[entity] = std::time(0);
    91148        this->recentlyJumpedOut_.insert(entity);
    92        
     149
     150        // adjust
    93151        entity->setPosition(this->getWorldPosition());
    94152        entity->rotate(this->getWorldOrientation());
    95153        entity->setVelocity(this->getWorldOrientation() * entity->getVelocity());
    96         entity->setVelocity(entity->getVelocity() * 1.5);
    97154    }
    98155
  • code/trunk/src/modules/portals/PortalEndPoint.h

    • Property svn:executable deleted
    • Property svn:eol-style set to native
    r8457 r8706  
     1/*
     2 *   ORXONOX - the hottest 3D action shooter ever to exist
     3 *                    > www.orxonox.net <
     4 *
     5 *
     6 *   License notice:
     7 *
     8 *   This program is free software; you can redistribute it and/or
     9 *   modify it under the terms of the GNU General Public License
     10 *   as published by the Free Software Foundation; either version 2
     11 *   of the License, or (at your option) any later version.
     12 *
     13 *   This program is distributed in the hope that it will be useful,
     14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 *   GNU General Public License for more details.
     17 *
     18 *   You should have received a copy of the GNU General Public License
     19 *   along with this program; if not, write to the Free Software
     20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     21 *
     22 *   Author:
     23 *      Andreas Büchel
     24 *   Co-authors:
     25 *      ...
     26 *
     27 */
     28
     29/**
     30 *  @file PortalEndPoint.h
     31 *  @brief Declaration of the PortalEndPoint class.
     32 *  @ingroup Portals
     33 */
     34
    135#ifndef _PortalEndPoint_H__
    236#define _PortalEndPoint_H__
     
    943
    1044#include "worldentities/StaticEntity.h"
     45#include "interfaces/RadarViewable.h"
    1146#include "graphics/Billboard.h"
    1247#include "objects/triggers/DistanceMultiTrigger.h"
    1348#include "core/EventIncludes.h"
     49#include <ctime>
    1450
    1551namespace orxonox
    1652{
    17     class _PortalsExport PortalEndPoint : public StaticEntity
     53    /**
     54     @brief
     55     A PortalEndPoint serves as portal entrance and/or exit.
     56     
     57     @ingroup Portals
     58     */
     59   
     60    class _PortalsExport PortalEndPoint : public StaticEntity, public RadarViewable
    1861    {
    1962        public:
    2063            PortalEndPoint(BaseObject* creator);
    2164            virtual ~PortalEndPoint();
     65           
    2266            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
     67            virtual void changedActivity(void);
     68           
    2369            inline void setTarget(const std::string & target)                 //!< add types which are allowed to activate the PortalEndPoint
    24             {
    25                 this->trigger_->addTarget(target);
    26             }
     70                { this->trigger_->addTarget(target); }
    2771           
    2872            void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
    2973            static std::map<unsigned int, PortalEndPoint *> idMap_s; //!< Maps the id of each PortalEndPoint to a pointer to that PortalEndPoint
     74            inline void setReenterDelay(unsigned int seconds)
     75                { this->reenterDelay_ = seconds; }
     76            inline unsigned int getReenterDelay()
     77                { return this->reenterDelay_; }
    3078            inline void setID(unsigned int id)
    31             {
    32                 this->id_ = id;
    33             }
     79                { this->id_ = id; }
    3480           
    3581            inline unsigned int getID() const
    36             {
    37                 return this->id_;
    38             }
     82                { return this->id_; }
    3983           
    4084            /// \brief Set templateName_ (the name of the design Template) and add that Template to this Object
    4185            inline void setTemplate(const std::string & name)
    42             {
    43                 this->templateName_ = name;
    44                 this->addTemplate(name);
    45             }
     86                { this->templateName_ = name; this->addTemplate(name); }
    4687
    4788            /// \brief Get the name of the attached design template
    4889            inline const std::string & getTemplate()
    49             {
    50                 return this->templateName_;
    51             }
     90                { return this->templateName_; }
    5291
    5392            /*! \brief This function is called each time the DistanceMultiTrigger of this PortalEndPoint changed
    54              * \param bTriggered true if the trigger was triggered on, false if the trigger has switched to off
    55              * \param trigger the MultiTriggerContainer containing the triggering BaseObject (and trigger_ the portal's MultiDistanceTrigger which we already know)
    56              *
    57              * if bTriggered is \c true the triggering entity enters this portal (if it is an entrance)
    58              * otherwise the triggering entity is removed from the set of entities who recently jumped out of this portal */
     93                \param bTriggered true if the trigger was triggered on, false if the trigger has switched to off
     94                \param trigger the MultiTriggerContainer containing the triggering BaseObject (and trigger_ the portal's MultiDistanceTrigger which we already know)
     95            */
    5996            bool execute(bool bTriggered, BaseObject* trigger);
    6097
     
    6299             * \param entity The Entity which should jump out of this portal */
    63100            void jumpOut(MobileEntity * entity);
     101           
     102            /** \brief Tells wether a certain Entity is allowed to enter the PortalEndPoint?
     103                @return @c true if the entity not just came out of this portal and the reenterDelay has expired for it, @c false otherwise
     104            */
     105            bool letsEnter(MobileEntity* entity);
    64106        protected:
    65107           
     
    71113            std::string templateName_;            //!< The name of the design template used for this endpoint
    72114
    73             std::set<MobileEntity *> recentlyJumpedOut_; //!< Entities which recently jumped out of this EndPoint, hence they shouldn't be pulled in again if the endpoint is the beginning of a link
     115            int reenterDelay_;
     116            std::map<MobileEntity *, time_t> jumpOutTimes_;   //!< Stores the time at which a certain MobileEntity @ref jumpOut "jumped out" of this PortalEndPoint
     117            std::set<MobileEntity *> recentlyJumpedOut_;   //!< Stores the entities witch recently jumped out of this PortalEndPoint and haven't left the activation radius yet. This is needed in order to prevent them from beeing pulled into the PortalEndPoint they have just come out of.
    74118    };
    75119
  • code/trunk/src/modules/portals/PortalLink.cc

    • Property svn:executable deleted
    • Property svn:eol-style set to native
    r8457 r8706  
     1/*
     2 *   ORXONOX - the hottest 3D action shooter ever to exist
     3 *                    > www.orxonox.net <
     4 *
     5 *
     6 *   License notice:
     7 *
     8 *   This program is free software; you can redistribute it and/or
     9 *   modify it under the terms of the GNU General Public License
     10 *   as published by the Free Software Foundation; either version 2
     11 *   of the License, or (at your option) any later version.
     12 *
     13 *   This program is distributed in the hope that it will be useful,
     14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 *   GNU General Public License for more details.
     17 *
     18 *   You should have received a copy of the GNU General Public License
     19 *   along with this program; if not, write to the Free Software
     20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     21 *
     22 *   Author:
     23 *      Andreas Büchel
     24 *   Co-authors:
     25 *      ...
     26 *
     27 */
     28
    129#include "PortalLink.h"
    230#include "core/XMLPort.h"
     
    1745    PortalLink::~PortalLink()
    1846    {
     47       
    1948    }
    2049   
     
    3766        if(entrance == 0)
    3867        {
    39             // TODO COUT
    4068            return;
    4169        }
    4270       
    43         std::map<PortalEndPoint *, PortalEndPoint *>::iterator endpoint = PortalLink::links_s.find(entrance);
     71        std::map<PortalEndPoint *, PortalEndPoint *>::iterator endpoints = PortalLink::links_s.find(entrance);
    4472       
    45         if(endpoint == PortalLink::links_s.end())  // entrance has no corresponding exit
     73        if(endpoints == PortalLink::links_s.end())  // entrance has no corresponding exit
    4674            return;
    47        
    48         endpoint->second->jumpOut(entity);
     75
     76        endpoints->second->jumpOut(entity);
    4977    }
    50 
    51 
    5278}
  • code/trunk/src/modules/portals/PortalLink.h

    • Property svn:executable deleted
    • Property svn:eol-style set to native
    r8457 r8706  
     1/*
     2 *   ORXONOX - the hottest 3D action shooter ever to exist
     3 *                    > www.orxonox.net <
     4 *
     5 *
     6 *   License notice:
     7 *
     8 *   This program is free software; you can redistribute it and/or
     9 *   modify it under the terms of the GNU General Public License
     10 *   as published by the Free Software Foundation; either version 2
     11 *   of the License, or (at your option) any later version.
     12 *
     13 *   This program is distributed in the hope that it will be useful,
     14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 *   GNU General Public License for more details.
     17 *
     18 *   You should have received a copy of the GNU General Public License
     19 *   along with this program; if not, write to the Free Software
     20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     21 *
     22 *   Author:
     23 *      Andreas Büchel
     24 *   Co-authors:
     25 *      ...
     26 *
     27 */
     28
     29/**
     30    @file PortalLink.h
     31    @brief Declaration of the PortalLink class
     32    @ingroup Portals
     33 */
     34
    135#ifndef _PortalLink_H__
    236#define _PortalLink_H__
     
    1246namespace orxonox
    1347{
     48    /**
     49        @brief
     50            A PortalLink represents the connection between two @ref orxonox::PortalEndPoint "PortalEndPoints"
     51        @ingroup Portals
     52     */
    1453    class _PortalsExport PortalLink : public BaseObject
    1554    {
     
    3473                return this->toID_;
    3574            }
    36             static void use(MobileEntity * entity, PortalEndPoint * entrance);   //
     75            /*! \brief Let an entity enter a certain PortalEndPoint
     76                \param entity pointer to the entity which is entering a PortalEndPoint
     77                \param entrance pointer to the PortalEndPoint to enter
     78             */
     79            static void use(MobileEntity * entity, PortalEndPoint * entrance);   //!< let entity enter the PortalEndPoint pointed to by entrance
    3780        protected:
    3881        private:
    39             static std::map<PortalEndPoint *, PortalEndPoint *> links_s;
    40             unsigned int fromID_;
    41             unsigned int toID_;
    42             PortalEndPoint* from_;
    43             PortalEndPoint* to_;
    44             float activationRadius_;
    45             bool isNowPortable(WorldEntity * ent);
     82            static std::map<PortalEndPoint *, PortalEndPoint *> links_s;   //!< maps entrances to exits
     83            unsigned int fromID_;   //!< id of the entrance of this Link
     84            unsigned int toID_;   //!< id of the exit of this Link
     85            PortalEndPoint* from_;   //!< pointer to this Link's entrance
     86            PortalEndPoint* to_;   //!< pointer to this Link's exit
    4687    };
    47 
    4888}
    4989
  • code/trunk/src/modules/portals/PortalsPrecompiledHeaders.h

    • Property svn:eol-style set to native
  • code/trunk/src/modules/portals/PortalsPrereqs.h

    • Property svn:eol-style set to native
  • code/trunk/src/modules/questsystem/QuestDescription.cc

    r7474 r8706  
    4040#include "infos/PlayerInfo.h"
    4141
    42 #include "notifications/NotificationManager.h"
     42#include "interfaces/NotificationListener.h"
    4343
    4444namespace orxonox
     
    119119        }
    120120
    121         NotificationManager::sendNotification(message, player->getClientID(), QuestDescription::SENDER);
     121        NotificationListener::sendNotification(message, QuestDescription::SENDER, notificationMessageType::info, notificationSendMode::network, player->getClientID());
    122122        return true;
    123123    }
  • code/trunk/src/modules/questsystem/QuestEffectBeacon.cc

    r8351 r8706  
    113113
    114114        PlayerTrigger* pTrigger = orxonox_cast<PlayerTrigger*>(trigger);
    115         Pawn* pawn = NULL;
     115        PlayerInfo* player = NULL;
    116116
    117117        // If the trigger is a PlayerTrigger.
     
    121121                return false;
    122122            else
    123                 pawn = pTrigger->getTriggeringPlayer();
     123                player = pTrigger->getTriggeringPlayer();
    124124        }
    125125        else
    126126            return false;
    127127
    128         if(pawn == NULL)
     128        if(player == NULL)
    129129        {
    130130            COUT(4) << "The QuestEffectBeacon was triggered by an entity other than a Pawn. (" << trigger->getIdentifier()->getName() << ")" << std::endl;
    131             return false;
    132         }
    133 
    134         // Extract the PlayerInfo from the Pawn.
    135         PlayerInfo* player = pawn->getPlayer();
    136 
    137         if(player == NULL)
    138         {
    139             COUT(3) << "The PlayerInfo* is NULL." << std::endl;
    140131            return false;
    141132        }
  • code/trunk/src/modules/questsystem/QuestManager.cc

    r8079 r8706  
    274274    int QuestManager::getNumSubQuests(Quest* quest, PlayerInfo* player)
    275275    {
     276        if(quest == NULL)
     277            return this->getNumRootQuests(player);
     278
    276279        std::list<Quest*> quests = quest->getSubQuestList();
    277280        int numQuests = 0;
     
    296299    Quest* QuestManager::getSubQuest(Quest* quest, PlayerInfo* player, int index)
    297300    {
     301        if(quest == NULL)
     302            return this->getRootQuest(player, index);
     303
    298304        std::list<Quest*> quests = quest->getSubQuestList();
    299305        for(std::list<Quest*>::iterator it = quests.begin(); it != quests.end(); it++)
     
    312318    @param player
    313319        The player.
    314     @return Returns the number of QuestHints of the input Quest for the input player.
     320    @return
     321        Returns the number of QuestHints of the input Quest for the input player.
    315322    */
    316323    int QuestManager::getNumHints(Quest* quest, PlayerInfo* player)
     
    335342    @param index
    336343        The index of the QuestHint.
     344    @return
     345        Returns a pointer to the index-th QuestHint of the input Quest for the input player.
    337346    */
    338347    QuestHint* QuestManager::getHints(Quest* quest, PlayerInfo* player, int index)
     
    345354        }
    346355        return NULL;
     356    }
     357
     358    /**
     359    @brief
     360        Get the parent-quest of the input Quest.
     361    @param quest
     362        The Quest to get the parent-quest of.
     363    @return
     364        Returns a pointer to the parent-quest of the input Quest.
     365    */
     366    Quest* QuestManager::getParentQuest(Quest* quest)
     367    {
     368        return quest->getParentQuest();
    347369    }
    348370
     
    375397    /**
    376398    @brief
     399        Get the id of the input Quest.
     400    @param item
     401        The Quest to get the id of.
     402    @return
     403        Returns the id of the input Quest.
     404    */
     405    const std::string QuestManager::getId(Quest* item) const
     406    {
     407        return item->getId();
     408    }
     409
     410    /**
     411    @brief
     412        Get the id of the input QuestHint.
     413    @param item
     414        The QuestHint to get the id of.
     415    @return
     416        Returns the id of the input QuestHint.
     417    */
     418    const std::string QuestManager::getId(QuestHint* item) const
     419    {
     420        return item->getId();
     421    }
     422
     423    /**
     424    @brief
    377425        Retrieve the player for a certain GUI.
    378426    @param guiName
  • code/trunk/src/modules/questsystem/QuestManager.h

    r7552 r8706  
    8181            QuestHint* getHints(Quest* quest, orxonox::PlayerInfo* player, int index); //!< Get the index-th QuestHint of the input Quest for the input player.
    8282
    83             QuestDescription* getDescription(Quest* item);
    84             QuestDescription* getDescription(QuestHint* item);
     83            Quest* getParentQuest(Quest* quest); //!< Get the parent-quest of the input Quest.
     84
     85            QuestDescription* getDescription(Quest* item); //!< Get the QuestDescription of the input Quest.
     86            QuestDescription* getDescription(QuestHint* item); //!< Get the QuestDescription of the input QuestHint.
     87
     88            const std::string getId(Quest* item) const; //!< Get the id of the input Quest.
     89            const std::string getId(QuestHint* item) const; //!< Get the id of the input QuestHint.
    8590            // tolua_end
    8691
  • code/trunk/src/modules/weapons/projectiles/CMakeLists.txt

    r7163 r8706  
    66  Rocket.cc
    77  SimpleRocket.cc
     8  BasicProjectile.cc
    89)
  • code/trunk/src/modules/weapons/projectiles/Projectile.cc

    r7284 r8706  
    2323 *      Fabian 'x3n' Landau
    2424 *   Co-authors:
    25  *      ...
     25 *      simonmie
    2626 *
    2727 */
     
    4141    CreateFactory(Projectile);
    4242
    43     Projectile::Projectile(BaseObject* creator) : MovableEntity(creator)
     43    Projectile::Projectile(BaseObject* creator) : MovableEntity(creator), BasicProjectile()
    4444    {
    4545        RegisterObject(Projectile);
    4646
    4747        this->setConfigValues();
    48         this->bDestroy_ = false;
    4948        this->owner_ = 0;
    50         this->damage_ = 15;
    5149
    5250        // Get notification about collisions
    53 
    5451        if (GameMode::isMaster())
    5552        {
     
    8481            return;
    8582
    86         if (this->bDestroy_)
     83        if (this->getBDestroy())
    8784            this->destroy(); // TODO: use a scheduler instead of deleting the object right here in tick()
    8885    }
     
    9491    }
    9592
     93    /* Calls the collidesAgainst function of BasicProjectile
     94     */
    9695    bool Projectile::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
    9796    {
    98         if (!this->bDestroy_ && GameMode::isMaster())
    99         {
    100             if (otherObject == this->owner_)
    101                 return false;
    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 = orxonox_cast<Pawn*>(otherObject);
    126             if (victim)
    127                 victim->hit(this->owner_, contactPoint, this->damage_);
    128         }
    129         return false;
     97        return BasicProjectile::basicCollidesAgainst(otherObject,contactPoint,this->getOwner(),this);
    13098    }
    13199
  • code/trunk/src/modules/weapons/projectiles/Projectile.h

    r5929 r8706  
    2323 *      Fabian 'x3n' Landau
    2424 *   Co-authors:
    25  *      ...
     25 *      simonmie
    2626 *
    2727 */
     
    3535#include "worldentities/MovableEntity.h"
    3636
     37#include "BasicProjectile.h"
     38
    3739namespace orxonox
    3840{
    39     class _WeaponsExport Projectile : public MovableEntity
     41    class _WeaponsExport Projectile : public MovableEntity, public BasicProjectile
    4042    {
    4143        public:
     
    4951            virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);
    5052
    51             inline void setDamage(float damage)
    52                 { this->damage_ = damage; }
    53             inline float getDamage() const
    54                 { return this->damage_; }
    55 
    5653            void setOwner(Pawn* owner);
    5754            inline Pawn* getOwner() const
    5855                { return this->owner_; }
    5956
     57
    6058        private:
    6159            WeakPtr<Pawn> owner_;
    6260            float lifetime_;
    63             float damage_;
    64             bool bDestroy_;
    6561            Timer destroyTimer_;
    6662    };
  • code/trunk/src/modules/weapons/projectiles/Rocket.cc

    r7848 r8706  
    2323 *      Oliver Scheuss
    2424 *   Co-authors:
    25  *      ...
     25 *      simonmie
    2626 *
    2727 */
     
    5252        Constructor. Registers the object and initializes some default values.
    5353    */
    54     Rocket::Rocket(BaseObject* creator) : ControllableEntity(creator)
     54    Rocket::Rocket(BaseObject* creator) : ControllableEntity(creator), BasicProjectile()
    5555    {
    5656        RegisterObject(Rocket);// - register the Rocket class to the core
    5757
    5858        this->localAngularVelocity_ = 0;
    59         this->bDestroy_ = false;
    6059        this->lifetime_ = 100;
    6160
     
    146145    {
    147146        this->owner_ = owner;
    148         this->player_ = this->owner_->getPlayer();
    149         this->owner_->getPlayer()->startTemporaryControl(this);
     147        this->player_ = this->getOwner()->getPlayer();
     148        this->getOwner()->getPlayer()->startTemporaryControl(this);
    150149
    151150        if( GameMode::isMaster() )
     
    175174        if( GameMode::isMaster() )
    176175        {
    177             if( this->bDestroy_ )
     176            if( this->getBDestroy() )
    178177                this->destroy();
    179178
     
    181180    }
    182181
     182    /* Calls the collidesAgainst function of BasicProjectile
     183     */
    183184    bool Rocket::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
    184185    {
    185         if (!this->bDestroy_ && GameMode::isMaster())
    186         {
    187             if (otherObject == this->owner_)
    188                 return false;
    189 
    190             this->bDestroy_ = true;
    191 
    192             if (this->owner_)
    193             {
    194                 {
    195                     ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator());
    196                     effect->setPosition(this->getPosition());
    197                     effect->setOrientation(this->getOrientation());
    198                     effect->setDestroyAfterLife(true);
    199                     effect->setSource("Orxonox/explosion4");
    200                     effect->setLifetime(2.0f);
    201                 }
    202 
    203                 {
    204                     ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator());
    205                     effect->setPosition(this->getPosition());
    206                     effect->setOrientation(this->getOrientation());
    207                     effect->setDestroyAfterLife(true);
    208                     effect->setSource("Orxonox/smoke4");
    209                     effect->setLifetime(3.0f);
    210                 }
    211             }
    212 
    213             Pawn* victim = orxonox_cast<Pawn*>(otherObject);
    214             if (victim)
    215                 victim->hit(this->owner_, contactPoint, this->damage_);
    216 //             this->destroy();
    217         }
    218         return false;
     186        return BasicProjectile::basicCollidesAgainst(otherObject,contactPoint,this->getOwner(),this);
    219187    }
    220188
     
    233201    void Rocket::fired(unsigned int firemode)
    234202    {
    235 //         if (this->owner_)
    236 //         {
    237             this->destroy();
    238 //         }
     203        this->destroy();
    239204    }
    240205
     
    242207    {
    243208        ParticleSpawner *effect1, *effect2;
    244         if( this->owner_ )
    245         {
    246             effect1 = new ParticleSpawner(this->owner_->getCreator());
    247             effect2 = new ParticleSpawner(this->owner_->getCreator());
     209        if( this->getOwner() )
     210        {
     211            effect1 = new ParticleSpawner(this->getOwner()->getCreator());
     212            effect2 = new ParticleSpawner(this->getOwner()->getCreator());
    248213        }
    249214        else
  • code/trunk/src/modules/weapons/projectiles/Rocket.h

    r7163 r8706  
    2323 *      Oliver Scheuss
    2424 *   Co-authors:
    25  *      ...
     25 *      simonmie
    2626 *
    2727 */
     
    3434#include "tools/Timer.h"
    3535#include "worldentities/ControllableEntity.h"
     36
     37#include "BasicProjectile.h"
    3638
    3739namespace orxonox
     
    4648        Oli Scheuss
    4749    */
    48     class _WeaponsExport Rocket : public ControllableEntity
     50    class _WeaponsExport Rocket : public ControllableEntity, public BasicProjectile
    4951    {
    5052        public:
     
    109111                { return this->owner_; }
    110112
    111             inline void setDamage(float damage)
    112                 { this->damage_ = damage; }
    113             inline float getDamage() const
    114                 { return this->damage_; }
    115113            virtual void fired(unsigned int firemode);
    116114
     
    118116            WeakPtr<Pawn> owner_;
    119117            Vector3 localAngularVelocity_;
    120             float damage_;
    121             bool bDestroy_;
    122118
    123119            WeakPtr<PlayerInfo> player_;
  • code/trunk/src/modules/weapons/projectiles/SimpleRocket.cc

    r7163 r8706  
    2323 *      Oliver Scheuss
    2424 *   Co-authors:
    25  *      ...
     25 *      simonmie
    2626 *
    2727 */
     
    4848    CreateFactory(SimpleRocket);
    4949
    50     SimpleRocket::SimpleRocket(BaseObject* creator) : ControllableEntity(creator)
     50    SimpleRocket::SimpleRocket(BaseObject* creator) : ControllableEntity(creator), BasicProjectile()
    5151    {
    5252        RegisterObject(SimpleRocket);// - register the SimpleRocket class to the core
    5353
    5454        this->localAngularVelocity_ = 0;
    55         this->bDestroy_ = false;
    5655        this->lifetime_ = 120;
    5756
    5857        this->setMass(15);
    59         COUT(4) << "simplerocket constructed\n";
     58//        COUT(4) << "simplerocket constructed\n";
    6059
    6160        if (GameMode::isMaster())
     
    115114                this->disableFire();
    116115
    117             if( this->bDestroy_ )
     116            if( this->getBDestroy() )
    118117                this->destroy();
    119118        }
     
    159158    {
    160159        this->owner_ = owner;
    161         this->player_ = this->owner_->getPlayer();
    162     }
    163 
    164 
    165 
    166 
     160        this->player_ = this->getOwner()->getPlayer();
     161    }
     162
     163
     164    /* Calls the collidesAgainst function of BasicProjectile
     165     */
    167166    bool SimpleRocket::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
    168167    {
    169         if (!this->bDestroy_ && GameMode::isMaster())
    170         {
    171             if (otherObject == this->owner_)
    172                 return false;
    173 
    174             this->bDestroy_ = true;
    175 
    176             if (this->owner_)
    177             {
    178                 {
    179                     ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator());
    180                     effect->setPosition(this->getPosition());
    181                     effect->setOrientation(this->getOrientation());
    182                     effect->setDestroyAfterLife(true);
    183                     effect->setSource("Orxonox/explosion4");
    184                     effect->setLifetime(2.0f);
    185                 }
    186 
    187                 {
    188                     ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator());
    189                     effect->setPosition(this->getPosition());
    190                     effect->setOrientation(this->getOrientation());
    191                     effect->setDestroyAfterLife(true);
    192                     effect->setSource("Orxonox/smoke4");
    193                     effect->setLifetime(3.0f);
    194                 }
    195             }
    196 
    197             float dmg = this->damage_;
    198 //             if (this->owner_)
    199 //                 dmg = this->owner_->getPickups().processModifiers(ModifierType::Damage, dmg, false);
    200 
    201             Pawn* victim = orxonox_cast<Pawn*>(otherObject);
    202             if (victim)
    203                 victim->hit(this->owner_, contactPoint, dmg);
    204         }
    205         return false;
     168        return BasicProjectile::basicCollidesAgainst(otherObject,contactPoint,this->getOwner(),this);
    206169    }
    207170
  • code/trunk/src/modules/weapons/projectiles/SimpleRocket.h

    r7163 r8706  
    2323 *      Oliver Scheuss
    2424 *   Co-authors:
    25  *      ...
     25 *      simonmie
    2626 *
    2727 */
     
    3636#include "graphics/ParticleSpawner.h"
    3737
     38#include "BasicProjectile.h"
     39
    3840namespace orxonox
    3941{
     
    4648       Gabriel Nadler (Original file: Oli Scheuss)
    4749    */
    48     class _WeaponsExport SimpleRocket : public ControllableEntity
     50    class _WeaponsExport SimpleRocket : public ControllableEntity, public BasicProjectile
    4951    {
    5052        public:
     
    111113            inline Pawn* getOwner() const
    112114                { return this->owner_; }
     115
    113116            inline bool hasFuel() const
    114117            { return this->fuel_; }
    115 
    116             inline void setDamage(float damage)
    117                 { this->damage_ = damage; }
    118             inline float getDamage() const
    119                 { return this->damage_; }
    120118
    121119
     
    123121            WeakPtr<Pawn> owner_;
    124122            Vector3 localAngularVelocity_;
    125             float damage_;
    126             bool bDestroy_;
    127123            bool fuel_; //!< Bool is true while the rocket "has fuel"
    128124
  • code/trunk/src/modules/weapons/weaponmodes/EnergyDrink.cc

    r7284 r8706  
    2323 *      Hagen Seifert
    2424 *   Co-authors:
    25  *      ...
     25 *      simonmie
    2626 *
    2727 */
     
    5050
    5151        this->reloadTime_ = 0.25;
    52         this->damage_ = 15;
     52        this->damage_ = 0; //default 15
    5353        this->speed_ = 2500;
    5454        this->delay_ = 0;
     
    9797    }
    9898
     99    /* Creates the projectile object, sets its properties to the EnergyDrink properties, calls muendungsfeuer()
     100     */
    99101    void EnergyDrink::shot()
    100102    {
     
    112114        projectile->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
    113115        projectile->setDamage(this->getDamage());
     116        projectile->setShieldDamage(this->getShieldDamage());
     117        projectile->setHealthDamage(this->getHealthDamage());
    114118
    115119        EnergyDrink::muendungsfeuer();
  • code/trunk/src/modules/weapons/weaponmodes/FusionFire.cc

    r6732 r8706  
    2323 *      Martin Polak
    2424 *   Co-authors:
    25  *      ...
     25 *      simonmie
    2626 *
    2727 */
     
    4848        this->reloadTime_ = 1.0;
    4949        this->bParallelReload_ = false;
    50         this->damage_ = 40;
     50        this->damage_ = 0; //default 40
    5151        this->speed_ = 1250;
    5252
     
    5454    }
    5555
     56    /* Creates the projectile (BillboardProjectile) object, sets its properties to the FusionFire properties
     57     */
    5658    void FusionFire::fire()
    5759    {
     
    6567        projectile->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
    6668        projectile->setDamage(this->getDamage());
     69        projectile->setShieldDamage(this->getShieldDamage());
     70        projectile->setHealthDamage(this->getHealthDamage());
     71
    6772        projectile->setColour(ColourValue(1.0f, 0.7f, 0.3f, 1.0f));
    6873    }
  • code/trunk/src/modules/weapons/weaponmodes/HsW01.cc

    r7284 r8706  
    2323 *      Hagen Seifert
    2424 *   Co-authors:
    25  *      ...
     25 *      simonmie
    2626 *
    2727 */
     
    5151
    5252        this->reloadTime_ = 0.25;
    53         this->damage_ = 15;
     53        this->damage_ = 0; //default 15
    5454        this->speed_ = 2500;
    5555        this->delay_ = 0;
     
    109109    }
    110110
     111    /* Creates the projectile object, sets its properties to the HsW01 properties, calls muendungsfeuer()
     112     */
    111113    void HsW01::shot()
    112114    {
     
    126128        projectile->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
    127129        projectile->setDamage(this->getDamage());
     130        projectile->setShieldDamage(this->getShieldDamage());
     131        projectile->setHealthDamage(this->getHealthDamage());
    128132
    129133        HsW01::muendungsfeuer();
  • code/trunk/src/modules/weapons/weaponmodes/LaserFire.cc

    r6732 r8706  
    2323 *      Martin Polak
    2424 *   Co-authors:
    25  *      ...
     25 *      simonmie
    2626 *
    2727 */
     
    4545
    4646        this->reloadTime_ = 0.25;
    47         this->damage_ = 15;
     47        this->damage_ = 0; //default 15
    4848        this->speed_ = 1250;
    4949
     
    5151    }
    5252
     53    /* Creates the projectile object, sets its properties to the LaserFire properties
     54     */
    5355    void LaserFire::fire()
    5456    {
     
    6163        projectile->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
    6264        projectile->setDamage(this->getDamage());
     65        projectile->setShieldDamage(this->getShieldDamage());
     66        projectile->setHealthDamage(this->getHealthDamage());
    6367    }
    6468}
  • code/trunk/src/modules/weapons/weaponmodes/LightningGun.cc

    r6732 r8706  
    2323 *      Joel Smely
    2424 *   Co-authors:
    25  *      ...
     25 *      simonmie
    2626 *
    2727 */
     
    4545
    4646        this->reloadTime_ = 1;
    47         this->damage_ = 100;
     47        this->damage_ = 0; //default 100
    4848        this->speed_ = 150;
    4949
     
    5656    }
    5757
     58    /* Creates the projectile (LightningGunProjectile) object, sets its properties to the LightningGun properties
     59     */
    5860    void LightningGun::fire()
    5961    {
     
    6971        projectile->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
    7072        projectile->setDamage(this->getDamage());
     73        projectile->setShieldDamage(this->getShieldDamage());
     74        projectile->setHealthDamage(this->getHealthDamage());
    7175    }
    7276}
  • code/trunk/src/modules/weapons/weaponmodes/RocketFire.cc

    r7846 r8706  
    2323 *      Oliver Scheuss
    2424 *   Co-authors:
    25  *      ...
     25 *      simonmie
    2626 *
    2727 */
     
    4848        this->reloadTime_ = 0.20f;
    4949        this->bParallelReload_ = false;
    50         this->damage_ = 100;
     50        this->damage_ = 0;
    5151        this->speed_ = 500;
    5252
     
    5959    }
    6060
     61    /* Creates the Rocket object, sets its properties to the RocketFire properties
     62     */
    6163    void RocketFire::fire()
    6264    {
     
    7173        rocket->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
    7274        rocket->setDamage(this->getDamage());
     75        rocket->setShieldDamage(this->getShieldDamage());
     76        rocket->setHealthDamage(this->getHealthDamage());
    7377    }
    7478}
  • code/trunk/src/modules/weapons/weaponmodes/SimpleRocketFire.cc

    r7846 r8706  
    2323 *      Oliver Scheuss
    2424 *   Co-authors:
    25  *      ...
     25 *      simonmie
    2626 *
    2727 */
     
    5050        this->reloadTime_ = 1;
    5151        this->bParallelReload_ = false;
    52         this->damage_ = 100;
     52        this->damage_ = 0;
    5353        this->speed_ = 500;
    5454
     
    6262    }
    6363
     64    /* Creates the Rocket (RocketController) object, sets its properties to the SimpleRocketFire properties, sets target
     65     */
    6466    void SimpleRocketFire::fire()
    6567    {
     
    7173        rocket->setVelocity(this->getMuzzleDirection()*this->speed_);
    7274        rocket->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
     75
    7376        rocket->setDamage(this->damage_);
     77        rocket->setShieldDamage(this->getShieldDamage());
     78        rocket->setHealthDamage(this->getHealthDamage());
     79
    7480        WorldEntity* pawnn=static_cast<ControllableEntity*>(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn())->getTarget();
    7581        if (pawnn) con->setTarget(pawnn);
  • code/trunk/src/orxonox/LevelManager.cc

    r8079 r8706  
    222222                this->nextLevel_ = this->availableLevels_.begin();
    223223            }
     224
    224225            while(this->nextIndex_ != index)
    225226            {
  • code/trunk/src/orxonox/MoodManager.cc

    r8351 r8706  
    9393
    9494
    95     std::string MoodListener::mood_s;
    96 
    9795    MoodListener::MoodListener()
    9896    {
     
    102100    /*static*/ void MoodListener::changedMood(const std::string& mood)
    103101    {
    104         mood_s = mood;
    105102        for (ObjectList<MoodListener>::iterator it = ObjectList<MoodListener>::begin(); it; ++it)
    106             it->moodChanged(mood_s);
     103            it->moodChanged(mood);
    107104    }
    108105}
  • code/trunk/src/orxonox/MoodManager.h

    r7163 r8706  
    5050            virtual ~MoodListener() {}
    5151
    52             const std::string& getMood() const { return mood_s; }
    53 
    5452        private:
    5553            virtual void moodChanged(const std::string& mood) = 0;
    5654
    5755            static void changedMood(const std::string& mood);
    58             static std::string mood_s;
    5956    };
    6057
  • code/trunk/src/orxonox/collisionshapes/CollisionShape.cc

    r7401 r8706  
    2626 *
    2727 */
     28
     29/**
     30    @file CollisionShape.cc
     31    @brief Implementation of the CollisionShape class.
     32*/
    2833
    2934#include "CollisionShape.h"
     
    3944namespace orxonox
    4045{
     46
     47    /**
     48    @brief
     49        Constructor. Registers and initializes the object.
     50    */
    4151    CollisionShape::CollisionShape(BaseObject* creator)
    4252        : BaseObject(creator)
     
    5161        this->orientation_ = Quaternion::IDENTITY;
    5262        this->scale_ = Vector3::UNIT_SCALE;
     63        this->uniformScale_ = true;
    5364
    5465        this->registerVariables();
    5566    }
    5667
     68    /**
     69    @brief
     70        Destructor. Detaches the CollisionShape from its parent.
     71    */
    5772    CollisionShape::~CollisionShape()
    5873    {
    59         // Detach from parent
     74        // Detach from parent CompoundCollisionShape.
    6075        if (this->isInitialized() && this->parent_)
    6176            this->parent_->detach(this);
     
    7590    }
    7691
     92    /**
     93    @brief
     94        Register variables that need synchronizing over the network.
     95    */
    7796    void CollisionShape::registerVariables()
    7897    {
     98        // Keep the shape's parent (can be either a CompoundCollisionShape or a WorldEntity) consistent over the network.
    7999        registerVariable(this->parentID_, VariableDirection::ToClient, new NetworkCallback<CollisionShape>(this, &CollisionShape::parentChanged));
    80100    }
    81101
     102    /**
     103    @brief
     104        Notifies the CollisionShape of being attached to a CompoundCollisionShape.
     105    @param newParent
     106        A pointer to the CompoundCollisionShape the CollisionShape was attached to.
     107    @return
     108        Returns
     109    */
     110    bool CollisionShape::notifyBeingAttached(CompoundCollisionShape* newParent)
     111    {
     112        // If the CollisionShape is attached to a CompoundCollisionShapes, detach it.
     113        if (this->parent_)
     114            this->parent_->detach(this);
     115
     116        this->parent_ = newParent;
     117
     118        // If the new parent is a WorldEntityCollisionShape, the parentID is set to the objectID of the WorldEntity that is its owner.
     119        // TODO: Why?
     120        WorldEntityCollisionShape* parentWECCS = orxonox_cast<WorldEntityCollisionShape*>(newParent);
     121        if (parentWECCS)
     122            this->parentID_ = parentWECCS->getWorldEntityOwner()->getObjectID();
     123        // Else it is set to the objectID of the CompoundCollisionShape.
     124        else
     125            this->parentID_ = newParent->getObjectID();
     126
     127        return true;
     128    }
     129
     130    /**
     131    @brief
     132        Notifies the CollisionShape of being detached from a CompoundCollisionShape.
     133    */
     134    void CollisionShape::notifyDetached()
     135    {
     136        this->parent_ = 0;
     137        this->parentID_ = OBJECTID_UNKNOWN;
     138    }
     139
     140    /**
     141    @brief
     142        Updates the CompoundCollisionShape the CollisionShape belongs to (if it belongs to one), after the CollisionShape has changed.
     143    */
     144    void CollisionShape::updateParent()
     145    {
     146        if (this->parent_)
     147            this->parent_->updateAttachedShape(this);
     148    }
     149
     150    /**
     151    @brief
     152        Is called when the parentID of the CollisionShape has changed.
     153        Attaches it to the object with the changed parentID, which can either be a CompoundCollisionShape or a WorldEntity.
     154    */
    82155    void CollisionShape::parentChanged()
    83156    {
     157        // Get the parent object from the network.
    84158        Synchronisable* parent = Synchronisable::getSynchronisable(this->parentID_);
     159
    85160        // Parent can either be a WorldEntity or a CompoundCollisionShape. The reason is that the
    86161        // internal collision shape (which is compound) of a WE doesn't get synchronised.
    87162        CompoundCollisionShape* parentCCS = orxonox_cast<CompoundCollisionShape*>(parent);
     163
     164        // If the parent is a CompoundCollisionShape, attach the CollisionShape to it.
    88165        if (parentCCS)
    89166            parentCCS->attach(this);
    90167        else
    91168        {
     169            // If the parent is a WorldEntity, attach the CollisionShape to its collision shapes.
    92170            WorldEntity* parentWE = orxonox_cast<WorldEntity*>(parent);
    93171            if (parentWE)
     
    96174    }
    97175
    98     bool CollisionShape::notifyBeingAttached(CompoundCollisionShape* newParent)
    99     {
    100         if (this->parent_)
    101             this->parent_->detach(this);
    102 
    103         this->parent_ = newParent;
    104 
    105         WorldEntityCollisionShape* parentWECCS = orxonox_cast<WorldEntityCollisionShape*>(newParent);
    106         if (parentWECCS)
    107             this->parentID_ = parentWECCS->getWorldEntityOwner()->getObjectID();
    108         else
    109             this->parentID_ = newParent->getObjectID();
    110 
    111         return true;
    112     }
    113 
    114     void CollisionShape::notifyDetached()
    115     {
    116         this->parent_ = 0;
    117         this->parentID_ = OBJECTID_UNKNOWN;
    118     }
    119 
    120     void CollisionShape::updateParent()
    121     {
    122         if (this->parent_)
    123             this->parent_->updateAttachedShape(this);
    124     }
    125 
     176    /**
     177    @brief
     178        Check whether the CollisionShape has been either moved or rotated or both. (i.e. it doesn't have position zero and identity orientation any more)
     179    @return
     180        Returns true if it has been moved.
     181    */
    126182    bool CollisionShape::hasTransform() const
    127183    {
     
    130186    }
    131187
     188    /**
     189    @brief
     190        Set the scale of the CollisionShape.
     191        Since the scale is a vector the CollisionShape can be scaled independently in each direction, allowing for linear distortions.
     192        If the scale changes, this causes the parent CompoundCollisionShape (if there is one) to be updated.
     193        Beware, non-uniform scaling (i.e. distortions) might not be supported by all CollisionShapes.
     194    @param scale
     195        The new scale to be set. Vector3::UNIT_SCALE is the initial scale.
     196    */
    132197    void CollisionShape::setScale3D(const Vector3& scale)
    133198    {
    134         CCOUT(2) << "Warning: Cannot set the scale of a collision shape: Not yet implemented." << std::endl;
    135     }
    136 
     199        if(this->scale_ == scale)
     200            return;
     201
     202        // If the vectors are not in the same direction, then this is no longer a uniform scaling.
     203        if(scale_.crossProduct(scale).squaredLength() != 0.0f)
     204        {
     205            CCOUT(2) << "Warning: Non-uniform scaling is not yet supported." << endl;
     206            return;
     207        }
     208
     209        this->scale_ = scale;
     210
     211        this->changedScale();
     212        this->updateParent();
     213    }
     214
     215    /**
     216    @brief
     217        Set the (uniform) scale of the CollisionShape.
     218        If the scale changes, this causes the parent CompoundCollisionShape (if there is one) to be updated.
     219    @param scale
     220        The scale to scale the CollisionShape with. 1.0f is the initial scale.
     221    */
    137222    void CollisionShape::setScale(float scale)
    138223    {
    139         CCOUT(2) << "Warning: Cannot set the scale of a collision shape: Not yet implemented." << std::endl;
    140     }
    141 
     224        if(this->scale_.length() == scale)
     225            return;
     226
     227        this->scale_ = Vector3::UNIT_SCALE*scale;
     228
     229        this->changedScale();
     230        this->updateParent();
     231    }
     232
     233    /**
     234    @brief
     235        Is called when the scale of the CollisionShape has changed.
     236    */
     237    void CollisionShape::changedScale()
     238    {
     239        // Adjust the position of the CollisionShape.
     240        this->position_ *= this->getScale3D();
     241    }
     242
     243    /**
     244    @brief
     245        Updates the shape.
     246        Is called when the internal parameters of the shape have changed such that a new shape needs to be created.
     247    */
    142248    void CollisionShape::updateShape()
    143249    {
    144250        btCollisionShape* oldShape = this->collisionShape_;
    145251        this->collisionShape_ = this->createNewShape();
     252        // If the CollisionShape has been rescaled, scale the shape to fit the current scale.
     253        if(this->scale_ != Vector3::UNIT_SCALE)
     254            this->changedScale();
    146255        // When we recreate the shape, we have to inform the parent about this to update the shape
    147256        this->updateParent();
     
    150259    }
    151260
     261    /**
     262    @brief
     263        Calculates the local inertia of the collision shape.
     264    @todo
     265        Document.
     266    */
    152267    void CollisionShape::calculateLocalInertia(float mass, btVector3& inertia) const
    153268    {
  • code/trunk/src/orxonox/collisionshapes/CollisionShape.h

    r7163 r8706  
    2727 */
    2828
     29/**
     30    @file CollisionShape.h
     31    @brief Definition of the CollisionShape class.
     32    @ingroup Collisionshapes
     33*/
     34
    2935#ifndef _CollisionShape_H__
    3036#define _CollisionShape_H__
     
    3844namespace orxonox
    3945{
     46
     47    /**
     48    @brief
     49        Wrapper for bullet collision shape class btCollisionShape.
     50
     51    @author
     52        Reto Grieder
     53
     54    @see btCollisionShape
     55    @ingroup Collisionshapes
     56    */
    4057    class _OrxonoxExport CollisionShape : public BaseObject, public Synchronisable
    4158    {
     
    4663            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    4764
     65            /**
     66            @brief Set the position of the CollisionShape.
     67                   If the position changes, this causes the parent CompoundCollisionShape (if there is one) to be updated.
     68            @param position A vector indicating the new position.
     69            */
    4870            inline void setPosition(const Vector3& position)
    49                 { this->position_ = position; this->updateParent(); }
     71                { if(this->position_ == position) return; this->position_ = position; this->updateParent(); }
     72            /**
     73            @brief Get the position of the CollisionShape.
     74            @return Returns the position of the CollisionShape as a vector.
     75            */
    5076            inline const Vector3& getPosition() const
    5177                { return this->position_; }
    5278
     79            /**
     80            @brief Set the orientation of the CollisionShape.
     81                   If the orientation changes, this causes the parent CompoundCollisionShape (if there is one) to be updated.
     82            @param orientation A quaternion indicating the new orientation.
     83            */
    5384            inline void setOrientation(const Quaternion& orientation)
    54                 { this->orientation_ = orientation; this->updateParent(); }
     85                { if(this->orientation_ == orientation) return; this->orientation_ = orientation; this->updateParent(); }
     86            /**
     87            @brief Get the orientation of the CollisionShape.
     88            @return Returns the orientation of the CollisionShape as a quaternion.
     89            */
    5590            inline const Quaternion& getOrientation() const
    5691                { return this->orientation_; }
    5792
    58             void yaw(const Degree& angle)   { this->setOrientation(this->orientation_ * Quaternion(angle, Vector3::UNIT_Y)); }
    59             void pitch(const Degree& angle) { this->setOrientation(this->orientation_ * Quaternion(angle, Vector3::UNIT_X)); }
    60             void roll(const Degree& angle)  { this->setOrientation(this->orientation_ * Quaternion(angle, Vector3::UNIT_Z)); }
     93            /**
     94            @brief Rotate the CollisionShape around the y-axis by the specified angle.
     95                   If the orientation changes, this causes the parent CompoundCollisionShape (if there is one) to be updated.
     96            @param angle The angle by which the CollisionShape is rotated.
     97            */
     98            void yaw(const Degree& angle)
     99                { this->setOrientation(this->orientation_ * Quaternion(angle, Vector3::UNIT_Y)); }
     100            /**
     101            @brief Rotate the CollisionShape around the x-axis by the specified angle.
     102                   If the orientation changes, this causes the parent CompoundCollisionShape (if there is one) to be updated.
     103            @param angle The angle by which the CollisionShape is rotated.
     104            */
     105            void pitch(const Degree& angle)
     106                { this->setOrientation(this->orientation_ * Quaternion(angle, Vector3::UNIT_X)); }
     107            /**
     108            @brief Rotate the CollisionShape around the z-axis by the specified angle.
     109                   If the orientation changes, this causes the parent CompoundCollisionShape (if there is one) to be updated.
     110            @param angle The angle by which the CollisionShape is rotated.
     111            */
     112            void roll(const Degree& angle)
     113                { this->setOrientation(this->orientation_ * Quaternion(angle, Vector3::UNIT_Z)); }
    61114
    62             virtual void setScale3D(const Vector3& scale);
    63             virtual void setScale(float scale);
     115            /**
     116            @brief Scale the CollisionShape by the input vector.
     117                   Since the scale is a vector the CollisionShape can be scaled independently in each direction, allowing for linear distortions.
     118                   If the scale changes, this causes the parent CompoundCollisionShape (if there is one) to be updated.
     119                   Beware, non-uniform scaling (i.e. distortions) might not be supported by all CollisionShapes.
     120            @param scale The scaling vector by which the CollisionShape is scaled.
     121            */
     122            inline void scale3D(const Vector3& scale)
     123                { this->setScale3D(this->getScale3D()*scale); }
     124            void setScale3D(const Vector3& scale); // Set the scale of the CollisionShape.
     125            /**
     126            @brief Get the scale of the CollisionShape.
     127            @return Returns a vector indicating the scale of the CollisionShape.
     128            */
    64129            inline const Vector3& getScale3D() const
    65130                { return this->scale_; }
    66131
    67             void updateShape();
     132            /**
     133            @brief (Uniformly) scale the CollisionShape by the input scale.
     134                   If the scale changes, this causes the parent CompoundCollisionShape (if there is one) to be updated.
     135            @param scale The value by which the CollisionShape is scaled.
     136            */
     137            inline void scale(float scale)
     138                { this->setScale3D(this->getScale3D()*scale); }
     139            void setScale(float scale); // Set the (uniform) scale of the CollisionShape.
     140            /**
     141            @brief Get the (uniform) scale of the CollisionShape.
     142                   This is only meaningful if the CollisionShape has uniform scaling.
     143            @return Returns the (uniform) scale of the CollisionShape. Returns 0.0f if the scaling is non-uniform.
     144            */
     145            inline float getScale()
     146                { if(this->hasUniformScaling()) return this->scale_.x; return 0.0f; }
    68147
    69             void calculateLocalInertia(float mass, btVector3& inertia) const;
     148            /**
     149            @brief Check whether the CollisionShape is uniformly scaled.
     150            @return Returns true if the CollisionShape is uniformly scaled, false if not.
     151            */
     152            inline bool hasUniformScaling()
     153                { return this->uniformScale_; }
     154            virtual void changedScale(); // Is called when the scale of the CollisionShape has changed.
    70155
     156            void updateShape(); // Updates the shape.
     157
     158            void calculateLocalInertia(float mass, btVector3& inertia) const; // Calculates the local inertia of the collision shape.
     159
     160            /**
     161            @brief Get the bullet collision shape of this CollisionShape.
     162            @return Returns a pointer to the bullet collision shape of this CollisionShape.
     163            */
    71164            inline btCollisionShape* getCollisionShape() const
    72165                { return this->collisionShape_; }
    73166
    74             bool hasTransform() const;
     167            bool hasTransform() const; // Check whether the CollisionShape has been either moved or rotated or both.
    75168
    76             bool notifyBeingAttached(CompoundCollisionShape* newParent);
    77             void notifyDetached();
     169            bool notifyBeingAttached(CompoundCollisionShape* newParent); // Notifies the CollisionShape of being attached to a CompoundCollisionShape.
     170            void notifyDetached(); // Notifies the CollisionShape of being detached from a CompoundCollisionShape.
    78171
    79172        protected:
    80             virtual void updateParent();
    81             virtual void parentChanged();
     173            virtual void updateParent(); // Updates the CompoundCollisionShape the CollisionShape belongs to, after the CollisionShape has changed.
     174            virtual void parentChanged(); // Is called when the parentID of the CollisionShape has changed.
     175
     176            /**
     177            @brief Create a new bullet collision shape depending on the internal parameters of the specific CollisionShape.
     178            @return Returns a pointer to the new bullet collision shape.
     179            */
    82180            virtual btCollisionShape* createNewShape() const = 0;
    83181
    84             btCollisionShape*       collisionShape_;
    85             CompoundCollisionShape* parent_;
    86             unsigned int            parentID_;
     182            btCollisionShape*       collisionShape_; //!< The bullet collision shape of this CollisionShape.
     183            CompoundCollisionShape* parent_; //!< The CompoundCollisionShape this CollisionShape belongs to, NULL if it doesn't belong to one.
     184            unsigned int            parentID_; //!< The objectID of the parent of this CollisionShape, which can either be a CompoundCollisionShape or a WorldEntity.
    87185
    88186        private:
    89187            void registerVariables();
    90188
    91             Vector3                 position_;
    92             Quaternion              orientation_;
    93             Vector3                 scale_;
     189            Vector3                 position_; //!< The position of the CollisionShape.
     190            Quaternion              orientation_; //!< The orientation of the CollisionShape.
     191            Vector3                 scale_; //!< The scale of the CollisionShape.
     192            bool                    uniformScale_; //!< Whether the scale is uniform.
    94193    };
    95194}
  • code/trunk/src/orxonox/collisionshapes/CompoundCollisionShape.cc

    r5929 r8706  
    2727 */
    2828
     29/**
     30    @file CompoundCollisionShape.cc
     31    @brief Implementation of the CompoundCollisionShape class.
     32*/
     33
    2934#include "CompoundCollisionShape.h"
    3035
     
    3944    CreateFactory(CompoundCollisionShape);
    4045
     46    /**
     47    @brief
     48        Constructor. Registers and initializes the object.
     49    */
    4150    CompoundCollisionShape::CompoundCollisionShape(BaseObject* creator) : CollisionShape(creator)
    4251    {
     
    4655    }
    4756
     57    /**
     58    @brief
     59        Destructor.
     60        Deletes all its children.
     61    */
    4862    CompoundCollisionShape::~CompoundCollisionShape()
    4963    {
     
    7084    }
    7185
     86    /**
     87    @brief
     88        Attach the input CollisionShape to the CompoundCollisionShape.
     89    @param shape
     90        A pointer to the CollisionShape that is to be attached.
     91    */
    7292    void CompoundCollisionShape::attach(CollisionShape* shape)
    7393    {
     94        // If either the input shape is NULL or we try to attach the CollisionShape to itself.
    7495        if (!shape || static_cast<CollisionShape*>(this) == shape)
    7596            return;
     97
    7698        if (this->attachedShapes_.find(shape) != this->attachedShapes_.end())
    7799        {
     
    80102        }
    81103
     104        // Notify the CollisionShape that it is being attached to the CompoundCollisionShape.
    82105        if (!shape->notifyBeingAttached(this))
    83106            return;
    84107
     108        // Attach it.
    85109        this->attachedShapes_[shape] = shape->getCollisionShape();
    86110
     111        // Only actually attach if we didn't pick a CompoundCollisionShape with no content.
    87112        if (shape->getCollisionShape())
    88113        {
    89             // Only actually attach if we didn't pick a CompoundCollisionShape with no content
    90114            btTransform transf(multi_cast<btQuaternion>(shape->getOrientation()), multi_cast<btVector3>(shape->getPosition()));
     115            // Add the btCollisionShape of the CollisionShape as a child shape to the btCompoundShape of the CompoundCollisionShape.
    91116            this->compoundShape_->addChildShape(transf, shape->getCollisionShape());
    92117
     
    95120    }
    96121
     122    /**
     123    @brief
     124        Detach the input CollisionShape form the CompoundCollisionShape.
     125    @param shape
     126        A pointer to the CollisionShape to be detached.
     127    */
    97128    void CompoundCollisionShape::detach(CollisionShape* shape)
    98129    {
     130        // If the input CollisionShape is actually attached.
    99131        if (this->attachedShapes_.find(shape) != this->attachedShapes_.end())
    100132        {
    101133            this->attachedShapes_.erase(shape);
    102134            if (shape->getCollisionShape())
    103                 this->compoundShape_->removeChildShape(shape->getCollisionShape());
     135                this->compoundShape_->removeChildShape(shape->getCollisionShape()); // TODO: Apparently this is broken?
    104136            shape->notifyDetached();
    105137
     
    110142    }
    111143
     144    /**
     145    @brief
     146        Detach all attached CollisionShapes.
     147    */
    112148    void CompoundCollisionShape::detachAll()
    113149    {
     
    116152    }
    117153
     154    /**
     155    @brief
     156        Update the input CollisionShape that is attached to the CompoundCollisionShape.
     157        This is called when the input shape's internal collision shape (a btCollisionShape) has changed.
     158    @param shape
     159        A pointer to the CollisionShape to be updated.
     160    */
    118161    void CompoundCollisionShape::updateAttachedShape(CollisionShape* shape)
    119162    {
    120163        if (!shape)
    121164            return;
     165
    122166        std::map<CollisionShape*, btCollisionShape*>::iterator it = this->attachedShapes_.find(shape);
     167        // Check whether the input shape belongs to this CompoundCollisionShape.
    123168        if (it == this->attachedShapes_.end())
    124169        {
     
    129174        // Remove old btCollisionShape, stored in the children map
    130175        if (it->second)
    131             this->compoundShape_->removeChildShape(it->second);
     176            this->compoundShape_->removeChildShape(it->second); // TODO: Apparently this is broken?
     177
     178        // Only actually attach if we didn't pick a CompoundCollisionShape with no content
    132179        if (shape->getCollisionShape())
    133180        {
    134             // Only actually attach if we didn't pick a CompoundCollisionShape with no content
    135181            btTransform transf(multi_cast<btQuaternion>(shape->getOrientation()), multi_cast<btVector3>(shape->getPosition()));
    136182            this->compoundShape_->addChildShape(transf, shape->getCollisionShape());
     
    141187    }
    142188
     189    /**
     190    @brief
     191        Updates the public shape, the collision shape this CompoundCollisionShape has to the outside.
     192    */
    143193    void CompoundCollisionShape::updatePublicShape()
    144194    {
    145         btCollisionShape* primitive = 0;
    146         bool bPrimitive = true;
    147         bool bEmpty = true;
     195        btCollisionShape* primitive = 0; // The primitive shape, if there is one.
     196        bool bPrimitive = true; // Whether the CompoundCollisionShape has just one non-empty CollisionShape. And that shape also has no transformation.
     197        bool bEmpty = true; // Whether the CompoundCollisionShape is empty.
     198        // Iterate over all CollisionShapes that belong to this CompoundCollisionShape.
    148199        for (std::map<CollisionShape*, btCollisionShape*>::const_iterator it = this->attachedShapes_.begin(); it != this->attachedShapes_.end(); ++it)
    149200        {
     201            // TODO: Make sure this is correct.
    150202            if (it->second)
    151203            {
    152204                bEmpty = false;
    153                 if (!it->first->hasTransform() && !bPrimitive)
     205                if (!it->first->hasTransform() && bPrimitive)
    154206                    primitive = it->second;
    155207                else
     208                {
    156209                    bPrimitive = false;
     210                    break;
     211                }
    157212            }
    158213        }
     214
     215        // If there is no non-empty CollisionShape.
    159216        if (bEmpty)
    160217        {
     218            // If there was none all along, nothing needs to be changed.
    161219            if (this->collisionShape_ == 0)
    162             {
    163                 this->collisionShape_ = 0;
    164220                return;
    165             }
    166221            this->collisionShape_ = 0;
    167222        }
     223        // If the CompoundCollisionShape is just a primitive.
     224        // Only one shape to be added, no transform; return it directly.
    168225        else if (bPrimitive)
    169         {
    170             // --> Only one shape to be added, no transform; return it directly
    171226            this->collisionShape_ = primitive;
    172         }
     227        // Make sure we use the compound shape when returning a btCollisionShape.
    173228        else
    174         {
    175             // Make sure we use the compound shape when returning a btCollisionShape
    176229            this->collisionShape_ = this->compoundShape_;
    177         }
     230
    178231        this->updateParent();
    179232    }
    180233
     234    /**
     235    @brief
     236        Get the attached CollisionShape at the given index.
     237    @param index
     238        The index of the desired CollisionShape.
     239    @return
     240        Returns a pointer to the attached CollisionShape at the given index.
     241    */
    181242    CollisionShape* CompoundCollisionShape::getAttachedShape(unsigned int index) const
    182243    {
     
    190251        return 0;
    191252    }
     253
     254    /**
     255    @brief
     256        Is called when the scale of the CompoundCollisionShape has changed.
     257        Iterates over all attached CollisionShapes and scales them, then recomputes their compound shape.
     258    */
     259    void CompoundCollisionShape::changedScale()
     260    {
     261        CollisionShape::changedScale();
     262
     263        std::vector<CollisionShape*> shapes;
     264        // Iterate through all attached CollisionShapes and add them to the list of shapes.
     265        for(std::map<CollisionShape*, btCollisionShape*>::iterator it = this->attachedShapes_.begin(); it != this->attachedShapes_.end(); it++)
     266            shapes.push_back(it->first);
     267
     268        // Delete the compound shape and create a new one.
     269        delete this->compoundShape_;
     270        this->compoundShape_ = new btCompoundShape();
     271
     272        // Re-attach all CollisionShapes.
     273        for(std::vector<CollisionShape*>::iterator it = shapes.begin(); it != shapes.end(); it++)
     274        {
     275            CollisionShape* shape = *it;
     276            shape->setScale3D(this->getScale3D());
     277            // Only actually attach if we didn't pick a CompoundCollisionShape with no content.
     278            if (shape->getCollisionShape())
     279            {
     280                btTransform transf(multi_cast<btQuaternion>(shape->getOrientation()), multi_cast<btVector3>(shape->getPosition()));
     281                // Add the btCollisionShape of the CollisionShape as a child shape to the btCompoundShape of the CompoundCollisionShape.
     282                this->compoundShape_->addChildShape(transf, shape->getCollisionShape());
     283            }
     284        }
     285
     286        this->updatePublicShape();
     287
     288        /*
     289        // Iterate through all attached CollisionShapes
     290        for(std::map<CollisionShape*, btCollisionShape*>::const_iterator it = this->attachedShapes_.begin(); it != this->attachedShapes_.end(); it++)
     291        {
     292            // Rescale the CollisionShape.
     293            it->first->setScale3D(this->getScale3D());
     294            this->updateAttachedShape(it->first);
     295        }
     296
     297        this->updatePublicShape();*/
     298    }
    192299}
  • code/trunk/src/orxonox/collisionshapes/CompoundCollisionShape.h

    r5781 r8706  
    2727 */
    2828
     29/**
     30    @file CompoundCollisionShape.h
     31    @brief Definition of the CompoundCollisionShape class.
     32    @ingroup Collisionshapes
     33*/
     34
    2935#ifndef _CompoundCollisionShape_H__
    3036#define _CompoundCollisionShape_H__
     
    3844namespace orxonox
    3945{
     46
     47    /**
     48    @brief
     49        Wrapper for the bullet compound collision shape class btCompoundShape.
     50
     51    @author
     52        Reto Grieder
     53
     54    @see btCompoundShape
     55    @ingroup Collisionshapes
     56    */
    4057    class _OrxonoxExport CompoundCollisionShape : public CollisionShape
    4158    {
     
    5370            void updateAttachedShape(CollisionShape* shape);
    5471
     72            virtual void changedScale();
     73
    5574        private:
    5675            void updatePublicShape();
  • code/trunk/src/orxonox/collisionshapes/WorldEntityCollisionShape.cc

    r5929 r8706  
    4343        this->worldEntityOwner_ = creator;
    4444        // suppress synchronisation
    45         this->setSyncMode(0x0);
     45        this->setSyncMode(ObjectDirection::None);
    4646    }
    4747
  • code/trunk/src/orxonox/controllers/ArtificialController.cc

    r8351 r8706  
    381381            }
    382382        }
     383
     384        if (distance < 10)
     385        {
     386            this->positionReached();
     387        }
    383388    }
    384389
     
    387392        this->moveToPosition(this->targetPosition_);
    388393    }
    389 
    390394
    391395    /**
  • code/trunk/src/orxonox/controllers/ArtificialController.h

    r7163 r8706  
    9797            void moveToTargetPosition();
    9898
     99            virtual void positionReached() {}
     100
    99101            void removeFromFormation();
    100102            void unregisterSlave();
  • code/trunk/src/orxonox/controllers/Controller.h

    r6417 r8706  
    5050                { return this->player_; }
    5151
    52             virtual inline void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage) {};
     52            virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage) {};
     53
     54/* Override needed for different visual effects (e.g. in "NewHumanController.cc") depending on
     55   the DIFFERENT AMOUNT OF DAMAGE done to the shield and to the health of "victim" (see Projectile.cc, Pawn.cc)
     56
     57//            virtual inline void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage, float healthdamage, float shielddamage) {};
     58*/
    5359
    5460            void setGodMode( bool mode ){ this->bGodMode_ = mode; }
  • code/trunk/src/orxonox/controllers/HumanController.cc

    r8079 r8706  
    4242    extern const std::string __CC_fire_name = "fire";
    4343    extern const std::string __CC_suicide_name = "suicide";
     44    const std::string __CC_boost_name = "boost";
    4445
    4546    SetConsoleCommand("HumanController", "moveFrontBack",          &HumanController::moveFrontBack ).addShortcut().setAsInputCommand();
     
    5152    SetConsoleCommand("HumanController", __CC_fire_name,           &HumanController::fire          ).addShortcut().keybindMode(KeybindMode::OnHold);
    5253    SetConsoleCommand("HumanController", "reload",                 &HumanController::reload        ).addShortcut();
    53     SetConsoleCommand("HumanController", "boost",                  &HumanController::boost         ).addShortcut().keybindMode(KeybindMode::OnHold);
     54    SetConsoleCommand("HumanController", __CC_boost_name,          &HumanController::keepBoost     ).addShortcut().keybindMode(KeybindMode::OnHold);
    5455    SetConsoleCommand("HumanController", "greet",                  &HumanController::greet         ).addShortcut();
    5556    SetConsoleCommand("HumanController", "switchCamera",           &HumanController::switchCamera  ).addShortcut();
     
    6667
    6768    HumanController* HumanController::localController_s = 0;
     69    /*static*/ const float HumanController::BOOSTING_TIME = 0.1f;
    6870
    6971    HumanController::HumanController(BaseObject* creator) : Controller(creator)
     
    7173        RegisterObject(HumanController);
    7274
    73         controlPaused_ = false;
     75        this->controlPaused_ = false;
     76        this->boosting_ = false;
     77        this->boosting_ = false;
    7478
    7579        HumanController::localController_s = this;
     80        this->boostingTimeout_.setTimer(HumanController::BOOSTING_TIME, false, createExecutor(createFunctor(&HumanController::terminateBoosting, this)));
     81        this->boostingTimeout_.stopTimer();
    7682    }
    7783
     
    163169    }
    164170
    165     void HumanController::boost()
    166     {
    167         if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
    168             HumanController::localController_s->controllableEntity_->boost();
     171    /**
     172    @brief
     173        Static method,keeps boosting.
     174    */
     175    /*static*/ void HumanController::keepBoost()
     176    {
     177        if (HumanController::localController_s && HumanController::localController_s->controllableEntity_)
     178            HumanController::localController_s->keepBoosting();
     179    }
     180   
     181    /**
     182    @brief
     183        Starts, or keeps the boosting mode.
     184        Resets the boosting timeout and ells the ControllableEntity to boost (or not boost anymore).
     185    */
     186    void HumanController::keepBoosting(void)
     187    {
     188        if(this->boostingTimeout_.isActive())
     189        {
     190            this->boostingTimeout_.stopTimer();
     191            this->boostingTimeout_.startTimer();
     192        }
     193        else
     194        {
     195            this->boosting_ = true;
     196            this->boostingTimeout_.startTimer();
     197           
     198            this->controllableEntity_->boost(this->boosting_);
     199            COUT(4) << "Start boosting" << endl;
     200        }
     201    }
     202
     203    /**
     204    @brief
     205        Terminates the boosting mode.
     206    */
     207    void HumanController::terminateBoosting(void)
     208    {
     209        this->boosting_ = false;
     210        this->boostingTimeout_.stopTimer();
     211
     212        this->controllableEntity_->boost(this->boosting_);
     213        COUT(4) << "Stop boosting" << endl;
    169214    }
    170215
  • code/trunk/src/orxonox/controllers/HumanController.h

    r8079 r8706  
    3232#include "OrxonoxPrereqs.h"
    3333
     34#include "tools/Timer.h"
    3435#include "tools/interfaces/Tickable.h"
    3536#include "Controller.h"
     
    6465            static void reload();
    6566
    66             static void boost();
     67            static void keepBoost(); // Static method, keeps boosting.
     68            /**
     69            @brief Check whether the HumanController is in boosting mode.
     70            @return Returns true if it is, false if not.
     71            */
     72            inline bool isBoosting(void)
     73                { return this->boosting_; }
     74            void keepBoosting(void);
     75            void terminateBoosting(void);
     76           
    6777            static void greet();
    6878            static void switchCamera();
     
    92102            static HumanController* localController_s;
    93103            bool controlPaused_;
     104       
     105        private:
     106            bool boosting_; // Whether the HumanController is in boosting mode or not.
     107            Timer boostingTimeout_; // A timer to check whether the player is no longer boosting.
     108            static const float BOOSTING_TIME; // The time after it is checked, whether the player is no longer boosting.
     109
    94110    }; // tolua_export
    95111} // tolua_export
  • code/trunk/src/orxonox/gamestates/GSRoot.cc

    r8327 r8706  
    4545
    4646    static const std::string __CC_setTimeFactor_name = "setTimeFactor";
     47    static const std::string __CC_getTimeFactor_name = "getTimeFactor";
    4748    static const std::string __CC_setPause_name = "setPause";
    4849    static const std::string __CC_pause_name = "pause";
     
    5253    SetConsoleCommand("printObjects", &GSRoot::printObjects).hide();
    5354    SetConsoleCommand(__CC_setTimeFactor_name, &GSRoot::setTimeFactor).accessLevel(AccessLevel::Master).defaultValues(1.0);
     55    SetConsoleCommand(__CC_getTimeFactor_name, &GSRoot::getTimeFactor).accessLevel(AccessLevel::Master);
    5456    SetConsoleCommand(__CC_setPause_name,      &GSRoot::setPause     ).accessLevel(AccessLevel::Master).hide();
    5557    SetConsoleCommand(__CC_pause_name,         &GSRoot::pause        ).accessLevel(AccessLevel::Master);
     
    8991
    9092        ModifyConsoleCommand(__CC_setTimeFactor_name).setObject(this);
     93        ModifyConsoleCommand(__CC_getTimeFactor_name).setObject(this);
    9194        ModifyConsoleCommand(__CC_setPause_name).setObject(this);
    9295        ModifyConsoleCommand(__CC_pause_name).setObject(this);
     
    9699    {
    97100        ModifyConsoleCommand(__CC_setTimeFactor_name).setObject(0);
     101        ModifyConsoleCommand(__CC_getTimeFactor_name).setObject(0);
    98102        ModifyConsoleCommand(__CC_setPause_name).setObject(0);
    99103        ModifyConsoleCommand(__CC_pause_name).setObject(0);
     
    151155                this->timeFactorPauseBackup_ = factor;
    152156        }
     157    }
     158
     159    float GSRoot::getTimeFactor()
     160    {
     161        return TimeFactorListener::getTimeFactor();
    153162    }
    154163
  • code/trunk/src/orxonox/gamestates/GSRoot.h

    r8079 r8706  
    5454        void pause();
    5555
     56        float getTimeFactor();
     57
    5658        static void delayedStartMainMenu(void);
    5759
  • code/trunk/src/orxonox/gametypes/Dynamicmatch.cc

    r8327 r8706  
    151151                //Give new pig boost
    152152                SpaceShip* spaceship = dynamic_cast<SpaceShip*>(victim);
    153                 if (spaceship && spaceship->getEngine())
    154                 {
    155                     spaceship->getEngine()->setSpeedFactor(5);
    156                     WeakPtr<Engine>* ptr = new WeakPtr<Engine>(spaceship->getEngine());
    157                     ExecutorPtr executor = createExecutor(createFunctor(&Dynamicmatch::resetSpeedFactor, this));
    158                     executor->setDefaultValue(0, ptr);
    159                     new Timer(10, false, executor, true);
    160                 }
     153                grantPigBoost(spaceship);
    161154            }
    162155
     
    252245                //Give new pig boost
    253246                SpaceShip* spaceship = dynamic_cast<SpaceShip*>(victim);
    254                 if (spaceship && spaceship->getEngine())
    255                 {
    256                     spaceship->getEngine()->setSpeedFactor(5);
    257                     WeakPtr<Engine>* ptr = new WeakPtr<Engine>(spaceship->getEngine());
    258                     ExecutorPtr executor = createExecutor(createFunctor(&Dynamicmatch::resetSpeedFactor, this));
    259                     executor->setDefaultValue(0, ptr);
    260                     new Timer(10, false, executor, true);
    261                 }
    262 
     247                grantPigBoost(spaceship);
    263248            }
    264249            // killer vs piggy
     
    321306    }
    322307
     308    void Dynamicmatch::grantPigBoost(orxonox::SpaceShip* spaceship)
     309    {
     310        // Give pig boost
     311        if (spaceship)
     312        {
     313            spaceship->setSpeedFactor(5);
     314            WeakPtr<SpaceShip>* ptr = new WeakPtr<SpaceShip>(spaceship);
     315            ExecutorPtr executor = createExecutor(createFunctor(&Dynamicmatch::resetSpeedFactor, this));
     316            executor->setDefaultValue(0, ptr);
     317            new Timer(10, false, executor, true);
     318        }
     319    }
     320
    323321    void Dynamicmatch::playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn) //set party + colouring
    324322    {
     
    597595    }
    598596
    599     void Dynamicmatch::resetSpeedFactor(WeakPtr<Engine>* ptr)// helper function
     597    void Dynamicmatch::resetSpeedFactor(WeakPtr<SpaceShip>* ptr)// helper function
    600598    {
    601599        if (*ptr)
  • code/trunk/src/orxonox/gametypes/Dynamicmatch.h

    r7163 r8706  
    7373            virtual void furtherInstructions();*/
    7474            virtual void rewardPig();
    75             void resetSpeedFactor(WeakPtr<Engine>* ptr);
     75            void grantPigBoost(SpaceShip* spaceship); // Added this, since it's used twice on different occasions.
     76            void resetSpeedFactor(WeakPtr<SpaceShip>* ptr);
    7677            void tick (float dt);// used to end the game
    7778            SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const;
  • code/trunk/src/orxonox/gametypes/Gametype.cc

    r8327 r8706  
    121121        }
    122122
    123         if (this->gtinfo_->bStartCountdownRunning_ && !this->gtinfo_->bStarted_)
    124             this->gtinfo_->startCountdown_ -= dt;
    125 
    126         if (!this->gtinfo_->bStarted_)
     123        if (this->gtinfo_->isStartCountdownRunning() && !this->gtinfo_->hasStarted())
     124            this->gtinfo_->countdownStartCountdown(dt);
     125
     126        if (!this->gtinfo_->hasStarted())
     127        {
     128            for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
     129            {
     130                // Inform the GametypeInfo that the player is ready to spawn.
     131                if(it->first->isHumanPlayer() && it->first->isReadyToSpawn())
     132                    this->gtinfo_->playerReadyToSpawn(it->first);
     133            }
     134                   
    127135            this->checkStart();
    128         else if (!this->gtinfo_->bEnded_)
     136        }
     137        else if (!this->gtinfo_->hasEnded())
    129138            this->spawnDeadPlayersIfRequested();
    130139
     
    136145        this->addBots(this->numberOfBots_);
    137146
    138         this->gtinfo_->bStarted_ = true;
     147        this->gtinfo_->start();
    139148
    140149        this->spawnPlayersIfRequested();
     
    143152    void Gametype::end()
    144153    {
    145         this->gtinfo_->bEnded_ = true;
     154        this->gtinfo_->end();
    146155
    147156        for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
     
    173182    {
    174183        this->players_[player].state_ = PlayerState::Joined;
     184        this->gtinfo_->playerEntered(player);
    175185    }
    176186
     
    270280                }
    271281
     282                if(victim->getPlayer()->isHumanPlayer())
     283                    this->gtinfo_->pawnKilled(victim->getPlayer());
     284
    272285                ControllableEntity* entity = this->defaultControllableEntity_.fabricate(victim->getCreator());
    273286                if (victim->getCamera())
     
    306319    SpawnPoint* Gametype::getBestSpawnPoint(PlayerInfo* player) const
    307320    {
     321        // If there is at least one SpawnPoint.
    308322        if (this->spawnpoints_.size() > 0)
    309323        {
     324            // Fallback spawn point if there is no active one, choose a random one.
    310325            SpawnPoint* fallbackSpawnPoint = NULL;
    311326            unsigned int randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(this->spawnpoints_.size())));
    312327            unsigned int index = 0;
    313             std::set<SpawnPoint*> activeSpawnPoints = this->spawnpoints_;
     328            std::vector<SpawnPoint*> activeSpawnPoints;
    314329            for (std::set<SpawnPoint*>::const_iterator it = this->spawnpoints_.begin(); it != this->spawnpoints_.end(); ++it)
    315330            {
     
    317332                    fallbackSpawnPoint = (*it);
    318333
    319                 if (!(*it)->isActive())
    320                     activeSpawnPoints.erase(*it);
     334                if (*it != NULL && (*it)->isActive())
     335                    activeSpawnPoints.push_back(*it);
    321336
    322337                ++index;
    323338            }
    324339
    325             randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(this->spawnpoints_.size())));
    326             index = 0;
    327             for (std::set<SpawnPoint*>::const_iterator it = activeSpawnPoints.begin(); it != activeSpawnPoints.end(); ++it)
    328             {
    329                 if (index == randomspawn)
    330                     return (*it);
    331 
    332                 ++index;
    333             }
    334 
     340            if(activeSpawnPoints.size() > 0)
     341            {
     342                randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(activeSpawnPoints.size())));
     343                return activeSpawnPoints[randomspawn];
     344            }
     345
     346            COUT(2) << "Warning: Fallback SpawnPoint was used, because there were no active SpawnPoints." << endl;
    335347            return fallbackSpawnPoint;
    336348        }
     
    346358                it->second.state_ = PlayerState::Dead;
    347359
    348                 if (!it->first->isReadyToSpawn() || !this->gtinfo_->bStarted_)
     360                if (!it->first->isReadyToSpawn() || !this->gtinfo_->hasStarted())
    349361                {
    350362                    this->spawnPlayerAsDefaultPawn(it->first);
     
    357369    void Gametype::checkStart()
    358370    {
    359         if (!this->gtinfo_->bStarted_)
    360         {
    361             if (this->gtinfo_->bStartCountdownRunning_)
    362             {
    363                 if (this->gtinfo_->startCountdown_ <= 0)
    364                 {
    365                     this->gtinfo_->bStartCountdownRunning_ = false;
    366                     this->gtinfo_->startCountdown_ = 0;
     371        if (!this->gtinfo_->hasStarted())
     372        {
     373            if (this->gtinfo_->isStartCountdownRunning())
     374            {
     375                if (this->gtinfo_->getStartCountdown() <= 0.0f)
     376                {
     377                    this->gtinfo_->stopStartCountdown();
     378                    this->gtinfo_->setStartCountdown(0.0f);;
    367379                    this->start();
    368380                }
     
    389401                        // If in developer's mode, there is no start countdown.
    390402                        if(Core::getInstance().inDevMode())
    391                             this->gtinfo_->startCountdown_ = 0;
     403                            this->start();
    392404                        else
    393                             this->gtinfo_->startCountdown_ = this->initialStartCountdown_;
    394                         this->gtinfo_->bStartCountdownRunning_ = true;
     405                            this->gtinfo_->setStartCountdown(this->initialStartCountdown_);
     406                        this->gtinfo_->startStartCountdown();
    395407                    }
    396408                }
     
    402414    {
    403415        for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)
     416        {
    404417            if (it->first->isReadyToSpawn() || this->bForceSpawn_)
    405418                this->spawnPlayer(it->first);
     419        }
    406420    }
    407421
     
    422436            player->startControl(spawnpoint->spawn());
    423437            this->players_[player].state_ = PlayerState::Alive;
     438
     439            if(player->isHumanPlayer())
     440                this->gtinfo_->playerSpawned(player);
     441           
    424442            this->playerPostSpawn(player);
    425443        }
  • code/trunk/src/orxonox/gametypes/Gametype.h

    r8178 r8706  
    7878
    7979            inline bool hasStarted() const
    80                 { return this->gtinfo_->bStarted_; }
     80                { return this->gtinfo_->hasStarted(); }
    8181            inline bool hasEnded() const
    82                 { return this->gtinfo_->bEnded_; }
     82                { return this->gtinfo_->hasEnded(); }
    8383
    8484            virtual void start();
     
    114114
    115115            inline bool isStartCountdownRunning() const
    116                 { return this->gtinfo_->bStartCountdownRunning_; }
     116                { return this->gtinfo_->isStartCountdownRunning(); }
    117117            inline float getStartCountdown() const
    118                 { return this->gtinfo_->startCountdown_; }
     118                { return this->gtinfo_->getStartCountdown(); }
    119119
    120120            inline void setHUDTemplate(const std::string& name)
    121                 { this->gtinfo_->hudtemplate_ = name; }
     121                { this->gtinfo_->setHUDTemplate(name); }
    122122            inline const std::string& getHUDTemplate() const
    123                 { return this->gtinfo_->hudtemplate_; }
     123                { return this->gtinfo_->getHUDTemplate(); }
    124124
    125125            void addBots(unsigned int amount);
  • code/trunk/src/orxonox/gametypes/LastTeamStanding.cc

    r8351 r8706  
    5555        this->setHUDTemplate("lastTeamStandingHUD");
    5656    }
    57    
     57
    5858    LastTeamStanding::~LastTeamStanding()
    5959    {
    60     }   
     60    }
    6161
    6262    void LastTeamStanding::playerEntered(PlayerInfo* player)
     
    6969        else
    7070            playerLives_[player]=getMinLives();//new players only get minimum of lives */
    71        
     71
    7272        this->timeToAct_[player] = timeRemaining;
    7373        this->playerDelayTime_[player] = respawnDelay;
    7474        this->inGame_[player] = true;
    7575        unsigned int team = getTeam(player);
    76         if( team < 0|| team > teams_) // make sure getTeam returns a regular value
     76        if(team >= eachTeamsPlayers.size()) // make sure getTeam returns a regular value
    7777            return;
    7878        if(this->eachTeamsPlayers[team]==0) //if a player is the first in his group, a new team is alive
     
    9191            this->inGame_.erase(player);
    9292            unsigned int team = getTeam(player);
    93             if( team < 0|| team > teams_) // make sure getTeam returns a regular value
     93            if(team >= eachTeamsPlayers.size()) // make sure getTeam returns a regular value
    9494                return valid_player;
    9595            this->eachTeamsPlayers[team]--;       // a player left the team
     
    107107        bool allow = TeamDeathmatch::allowPawnDeath(victim, originator);
    108108        if(!allow) {return allow;}
    109        
     109
    110110        playerLives_[victim->getPlayer()] = playerLives_[victim->getPlayer()] - 1; //player lost a live
    111111        this->inGame_[victim->getPlayer()] = false; //if player dies, he isn't allowed to respawn immediately
     
    113113        {
    114114            unsigned int team = getTeam(victim->getPlayer());
    115             if(team < 0|| team > teams_) // make sure getTeam returns a regular value
     115            if(team >= eachTeamsPlayers.size()) // make sure getTeam returns a regular value
    116116                return allow;
    117117            this->eachTeamsPlayers[team]--;
     
    140140                const std::string& message = ""; // resets Camper-Warning-message
    141141                this->gtinfo_->sendFadingMessage(message,it->first->getClientID());
    142             }   
     142            }
    143143        }
    144144        return allow;
     
    163163            return;
    164164        TeamDeathmatch::playerStartsControllingPawn(player,pawn);
    165        
     165
    166166        this->timeToAct_[player] = timeRemaining + 3.0f + respawnDelay;//reset timer
    167167        this->playerDelayTime_[player] = respawnDelay;
    168        
     168
    169169        std::map<PlayerInfo*, Player>::iterator it = this->players_.find(player);
    170170        if (it != this->players_.end())
     
    174174            const std::string& message = ""; // resets Camper-Warning-message
    175175            this->gtinfo_->sendFadingMessage(message,it->first->getClientID());
    176         } 
     176        }
    177177    }
    178178
     
    187187            }
    188188            for (std::map<PlayerInfo*, float>::iterator it = this->timeToAct_.begin(); it != this->timeToAct_.end(); ++it)
    189             {   
     189            {
    190190                if (playerGetLives(it->first) <= 0)//Players without lives shouldn't be affected by time.
    191                     continue;     
     191                    continue;
    192192                it->second -= dt;//Decreases punishment time.
    193                 if (!inGame_[it->first])//Manages respawn delay - player is forced to respawn after the delaytime is used up. 
     193                if (!inGame_[it->first])//Manages respawn delay - player is forced to respawn after the delaytime is used up.
    194194                {
    195195                    playerDelayTime_[it->first] -= dt;
     
    309309            return 0;
    310310    }
    311    
     311
    312312    void LastTeamStanding::setConfigValues()
    313313    {
  • code/trunk/src/orxonox/graphics/Billboard.cc

    r7492 r8706  
    2323 *      Fabian 'x3n' Landau
    2424 *   Co-authors:
    25  *      ...
     25 *      Maurus Kaufmann
    2626 *
    2727 */
     
    3030
    3131#include "OgreBillboard.h"
    32 #include "OgreBillboardSet.h"
    3332
    3433#include "core/CoreIncludes.h"
     
    4645
    4746        this->colour_ = ColourValue::White;
    48         //this->rotation_ = 0;
     47        this->rotation_ = 0;
    4948
    5049        this->registerVariables();
     
    6665        XMLPortParam(Billboard, "material", setMaterial, getMaterial, xmlelement, mode);
    6766        XMLPortParam(Billboard, "colour",   setColour,   getColour,   xmlelement, mode).defaultValues(ColourValue::White);
    68         //XMLPortParam(Billboard, "rotation", setRotation, getRotation, xmlelement, mode).defaultValues(0);
     67        XMLPortParam(Billboard, "rotation", setRotation, getRotation, xmlelement, mode).defaultValues(0);
    6968    }
    7069
     
    7372        registerVariable(this->material_, VariableDirection::ToClient, new NetworkCallback<Billboard>(this, &Billboard::changedMaterial));
    7473        registerVariable(this->colour_,   VariableDirection::ToClient, new NetworkCallback<Billboard>(this, &Billboard::changedColour));
    75         //registerVariable(this->rotation_, VariableDirection::ToClient, new NetworkCallback<Billboard>(this, &Billboard::changedRotation));
     74        registerVariable(this->rotation_, VariableDirection::ToClient, new NetworkCallback<Billboard>(this, &Billboard::changedRotation));
    7675    }
    7776
     
    8988                     this->attachOgreObject(this->billboard_.getBillboardSet());
    9089                this->billboard_.setVisible(this->isVisible());
    91                 //this->changedRotation();
     90                this->changedRotation();
    9291            }
    9392        }
     
    114113    }
    115114
    116 /*
     115
    117116    void Billboard::changedRotation()
    118117    {
     
    128127        }
    129128    }
    130 */
     129
    131130
    132131    void Billboard::changedVisibility()
     
    136135        this->billboard_.setVisible(this->isVisible());
    137136    }
     137   
     138    void Billboard::setBillboardType(Ogre::BillboardType bbt)
     139    {
     140        Ogre::BillboardSet* bSet = this->billboard_.getBillboardSet();
     141        if( bSet != NULL )
     142        {
     143            bSet->setBillboardType(bbt);
     144        }
     145    }
     146   
     147    void Billboard::setCommonDirection(Vector3 vec)
     148    {
     149        Ogre::BillboardSet* bSet = this->billboard_.getBillboardSet();
     150        if( bSet != NULL )
     151        {
     152            bSet->setCommonDirection( vec );
     153        }
     154    }
     155           
     156    void Billboard::setCommonUpVector(Vector3 vec)
     157    {
     158        Ogre::BillboardSet* bSet = this->billboard_.getBillboardSet();
     159        if( bSet != NULL )
     160        {
     161            bSet->setCommonUpVector( vec );
     162        }
     163    }
     164   
     165    void Billboard::setDefaultDimensions(float width, float height)
     166    {
     167        Ogre::BillboardSet* bSet = this->billboard_.getBillboardSet();
     168        if( bSet != NULL )
     169        {
     170            bSet->setDefaultDimensions(width, height);
     171        }
     172    }
    138173}
  • code/trunk/src/orxonox/graphics/Billboard.h

    r7492 r8706  
    2323 *      Fabian 'x3n' Landau
    2424 *   Co-authors:
    25  *      ...
     25 *      Maurus Kaufmann
    2626 *
    2727 */
     
    3131
    3232#include "OrxonoxPrereqs.h"
     33
     34#include "OgreBillboardSet.h"
    3335
    3436#include "util/Math.h"
     
    6264                { return this->colour_; }
    6365
    64 /*
     66
    6567            inline void setRotation(const Radian& rotation)
    6668                { this->rotation_ = rotation; this->changedRotation(); }
    6769            inline const Radian& getRotation() const
    6870                { return this->rotation_; }
    69 */
     71
    7072
    7173            virtual void setTeamColour(const ColourValue& colour)
    7274                { this->setColour(colour); }
     75               
     76            void setBillboardType(Ogre::BillboardType bbt);
     77           
     78            void setCommonDirection(Vector3 vec); //!< normalised Vector vec as argument
     79           
     80            void setCommonUpVector(Vector3 vec); //!< normalised Vector vec as argument
     81           
     82            void setDefaultDimensions(float width, float height);
     83
    7384
    7485        protected:
     
    8192            void registerVariables();
    8293            void changedMaterial();
    83             //void changedRotation();
     94            void changedRotation();
    8495
    8596            BillboardSet billboard_;
    8697            std::string material_;
    8798            ColourValue colour_;
    88             //Radian rotation_;
     99            Radian rotation_;
    89100    };
    90101}
  • code/trunk/src/orxonox/graphics/Camera.cc

    r8079 r8706  
    7171        this->lastDtLagged_ = false;
    7272
    73         this->setSyncMode(0x0);
     73        this->setSyncMode(ObjectDirection::None);
    7474
    7575        this->setConfigValues();
  • code/trunk/src/orxonox/graphics/Camera.h

    r8079 r8706  
    4040namespace orxonox
    4141{
    42     class _OrxonoxExport Camera : public StaticEntity, public Tickable, public TimeFactorListener, public WindowEventListener
     42
     43    class _OrxonoxExport Camera : public StaticEntity, public Tickable,  public TimeFactorListener, public WindowEventListener
    4344    {
    4445        friend class CameraManager;
  • code/trunk/src/orxonox/infos/GametypeInfo.cc

    r8327 r8706  
    2323 *      Fabian 'x3n' Landau
    2424 *   Co-authors:
    25  *      ...
     25 *      Damian 'Mozork' Frick
    2626 *
    2727 */
     28
     29/**
     30    @file GametypeInfo.cc
     31    @brief Implementation of the GametypeInfo class
     32*/
    2833
    2934#include "GametypeInfo.h"
     
    3136#include "core/CoreIncludes.h"
    3237#include "core/GameMode.h"
     38#include "network/Host.h"
    3339#include "network/NetworkFunction.h"
    34 #include "network/Host.h"
     40#include "util/Convert.h"
     41
     42#include "controllers/HumanController.h"
    3543#include "interfaces/GametypeMessageListener.h"
     44#include "interfaces/NotificationListener.h"
     45
     46#include "PlayerInfo.h"
    3647
    3748namespace orxonox
     
    4556    registerMemberNetworkFunction(GametypeInfo, dispatchFadingMessage);
    4657
     58    registerMemberNetworkFunction(GametypeInfo, changedReadyToSpawn);
     59    registerMemberNetworkFunction(GametypeInfo, changedSpawned);
     60
     61    /*static*/ const std::string GametypeInfo::NOTIFICATION_SENDER("gameinfo");
     62
     63    /**
     64    @brief
     65        Registers and initializes the object.
     66    */
    4767    GametypeInfo::GametypeInfo(BaseObject* creator) : Info(creator)
    4868    {
    4969        RegisterObject(GametypeInfo);
    50 
     70       
    5171        this->bStarted_ = false;
    5272        this->bEnded_ = false;
    53         this->startCountdown_ = 0;
     73        this->startCountdown_ = 0.0f;
    5474        this->bStartCountdownRunning_ = false;
     75        this->counter_ = 0;
     76        this->spawned_ = false;
     77        this->readyToSpawn_ = false;
    5578
    5679        this->registerVariables();
     
    6386    void GametypeInfo::registerVariables()
    6487    {
    65         registerVariable(this->bStarted_,               VariableDirection::ToClient);
    66         registerVariable(this->bEnded_,                 VariableDirection::ToClient);
     88        registerVariable(this->bStarted_,               VariableDirection::ToClient, new NetworkCallback<GametypeInfo>(this, &GametypeInfo::changedStarted));
     89        registerVariable(this->bEnded_,                 VariableDirection::ToClient, new NetworkCallback<GametypeInfo>(this, &GametypeInfo::changedEnded));
     90        registerVariable(this->bStartCountdownRunning_, VariableDirection::ToClient, new NetworkCallback<GametypeInfo>(this, &GametypeInfo::changedStartCountdownRunning));
    6791        registerVariable(this->startCountdown_,         VariableDirection::ToClient);
    68         registerVariable(this->bStartCountdownRunning_, VariableDirection::ToClient);
     92        registerVariable(this->counter_,                VariableDirection::ToClient, new NetworkCallback<GametypeInfo>(this, &GametypeInfo::changedCountdownCounter));
    6993        registerVariable(this->hudtemplate_,            VariableDirection::ToClient);
    7094    }
     95
     96    /**
     97    @brief
     98        Is called when the game has changed to started.
     99    */
     100    void GametypeInfo::changedStarted(void)
     101    {
     102        NotificationListener::sendCommand("clear", GametypeInfo::NOTIFICATION_SENDER);
     103    }
     104
     105    /**
     106    @brief
     107        Is called when the game has changed to ended.
     108    */
     109    void GametypeInfo::changedEnded(void)
     110    {
     111        // If the game has ended, a "Game has ended" notification is displayed.
     112        if(this->hasEnded())
     113            NotificationListener::sendNotification("Game has ended", GametypeInfo::NOTIFICATION_SENDER);
     114    }
     115
     116    /**
     117    @brief
     118        Is called when the start countdown has been either started or stopped.
     119    */
     120    void GametypeInfo::changedStartCountdownRunning(void)
     121    {
     122        // Send first countdown notification if the countdown has started.
     123        if(this->isReadyToSpawn() && !this->hasStarted() && this->isStartCountdownRunning() && !this->hasEnded())
     124            NotificationListener::sendNotification(multi_cast<std::string>(this->counter_), GametypeInfo::NOTIFICATION_SENDER);
     125    }
     126
     127    /**
     128    @brief
     129        Is called when the start countdown counter has changed.
     130    */
     131    void GametypeInfo::changedCountdownCounter(void)
     132    {
     133        // Send countdown notification if the counter has gone down.
     134        if(this->isReadyToSpawn() &&  !this->hasStarted() && this->isStartCountdownRunning() && !this->hasEnded())
     135            NotificationListener::sendNotification(multi_cast<std::string>(this->counter_), GametypeInfo::NOTIFICATION_SENDER);
     136    }
     137
     138    /**
     139    @brief
     140        Inform the GametypeInfo that the local player has changed its ready to spawn status.
     141    @param ready
     142        Whether the player has become ready to spawn or not.
     143    */
     144    void GametypeInfo::changedReadyToSpawn(bool ready)
     145    {
     146        if(this->readyToSpawn_ == ready)
     147            return;
     148
     149        this->readyToSpawn_ = ready;
     150
     151        // Send "Waiting for other players" if the player is ready to spawn but the game has not yet started nor is the countdown running.
     152        if(this->readyToSpawn_ && !this->hasStarted() && !this->isStartCountdownRunning() && !this->hasEnded())
     153            NotificationListener::sendNotification("Waiting for other players", GametypeInfo::NOTIFICATION_SENDER);
     154        // Send current countdown if the player is ready to spawn and the countdown has already started.
     155        else if(this->readyToSpawn_ && !this->hasStarted() && this->isStartCountdownRunning() && !this->hasEnded())
     156            NotificationListener::sendNotification(multi_cast<std::string>(this->counter_), GametypeInfo::NOTIFICATION_SENDER);
     157    }
     158
     159    /**
     160    @brief
     161        Inform the GametypeInfo that the game has started.
     162    */
     163    void GametypeInfo::start(void)
     164    {
     165        if(this->bStarted_)
     166            return;
     167       
     168        this->bStarted_ = true;
     169        this->changedStarted();
     170    }
     171
     172    /**
     173    @brief
     174        Inform the GametypeInfo that the game has ended.
     175    */
     176    void GametypeInfo::end(void)
     177    {
     178        if(this->bEnded_)
     179            return;
     180
     181        this->bEnded_ = true;
     182        this->changedEnded();
     183    }
     184
     185    /**
     186    @brief
     187        Set the start countdown to the input value.
     188    @param countdown
     189        The countdown to be set.
     190    */
     191    void GametypeInfo::setStartCountdown(float countdown)
     192    {
     193        if(this->startCountdown_ == countdown || countdown < 0.0f)
     194            return;
     195       
     196        this->startCountdown_ = countdown;
     197        // Set the counter to the ceiling of the current countdown.
     198        this->counter_ = std::ceil(countdown);
     199        this->changedCountdownCounter();
     200    }
     201
     202    /**
     203    @brief
     204        Count down the start countdown by the specified value.
     205    @param countDown
     206        The amount by which we count down.
     207    */
     208    void GametypeInfo::countdownStartCountdown(float countDown)
     209    {
     210        float newCountdown = this->startCountdown_ - countDown;
     211        // If we have switched integers or arrived at zero, we also count down the start countdown counter.
     212        if(ceil(newCountdown) != ceil(this->startCountdown_) || newCountdown <= 0.0f)
     213            this->countDown();
     214        this->startCountdown_ = newCountdown;
     215    }
     216
     217    /**
     218    @brief
     219        Count down the start countdown counter.
     220    */
     221    void GametypeInfo::countDown()
     222    {
     223        if(this->counter_ == 0)
     224            return;
     225       
     226        this->counter_--;
     227        this->changedCountdownCounter();
     228    }
     229
     230    /**
     231    @brief
     232        Inform the GametypeInfo about the start of the start countdown.
     233    */
     234    void GametypeInfo::startStartCountdown(void)
     235    {
     236        if(GameMode::isMaster())
     237        {
     238            if(this->bStartCountdownRunning_)
     239                return;
     240
     241            this->bStartCountdownRunning_ = true;
     242            this->changedStartCountdownRunning();
     243        }
     244    }
     245
     246    /**
     247    @brief
     248        Inform the GametypeInfo about the stop of the start countdown.
     249    */
     250    void GametypeInfo::stopStartCountdown(void)
     251    {
     252        if(GameMode::isMaster())
     253        {
     254            if(!this->bStartCountdownRunning_)
     255                return;
     256
     257            this->bStartCountdownRunning_ = false;
     258            this->changedStartCountdownRunning();
     259        }
     260    }
     261
     262    /**
     263    @brief
     264        Inform the GametypeInfo about a player that is ready to spawn.
     265    @param player
     266        The player that is ready to spawn.
     267    */
     268    void GametypeInfo::playerReadyToSpawn(PlayerInfo* player)
     269    {
     270        if(GameMode::isMaster())
     271        {
     272            // If the player has spawned already.
     273            if(this->spawnedPlayers_.find(player) != this->spawnedPlayers_.end())
     274                return;
     275
     276            this->spawnedPlayers_.insert(player);
     277            this->setReadyToSpawnHelper(player, true);
     278        }
     279    }
     280
     281    /**
     282    @brief
     283        Inform the GametypeInfo about a player whose Pawn has been killed.
     284    @param player
     285        The player whose Pawn has been killed.
     286    */
     287    void GametypeInfo::pawnKilled(PlayerInfo* player)
     288    {
     289        if(GameMode::isMaster())
     290        {
     291            NotificationListener::sendNotification("Press [Fire] to respawn", GametypeInfo::NOTIFICATION_SENDER, notificationMessageType::info, notificationSendMode::network, player->getClientID());
     292            // Remove the player from the list of players that have spawned, since it currently is not.
     293            this->spawnedPlayers_.erase(player);
     294            this->setReadyToSpawnHelper(player, false);
     295            this->setSpawnedHelper(player, false);
     296        }
     297    }
     298
     299    /**
     300    @brief
     301        Inform the GametypeInfo about a player that has spawned.
     302    @param player
     303        The player that has spawned.
     304    */
     305    void GametypeInfo::playerSpawned(PlayerInfo* player)
     306    {
     307        if(GameMode::isMaster())
     308        {
     309            if(this->hasStarted() && !this->hasEnded())
     310
     311                this->setSpawnedHelper(player, true);
     312        }
     313    }
     314
     315    /**
     316    @brief
     317        Inform the GametypeInfo that the local player has changed its spawned status.
     318    @param spawned
     319        Whether the local player has changed to spawned or to not spawned.
     320    */
     321    void GametypeInfo::changedSpawned(bool spawned)
     322    {
     323        if(this->spawned_ == spawned)
     324            return;
     325       
     326        this->spawned_ = spawned;
     327        // Clear the notifications if the Player has spawned.
     328        if(this->spawned_ && !this->hasEnded())
     329            NotificationListener::sendCommand("clear", GametypeInfo::NOTIFICATION_SENDER);
     330    }
     331
     332    /**
     333    @brief
     334        Inform the GametypeInfo about a player that has entered,
     335    @param player
     336        The player that has entered.
     337    */
     338    void GametypeInfo::playerEntered(PlayerInfo* player)
     339    {
     340        if(GameMode::isMaster())
     341        {
     342            if( player->isHumanPlayer() )
     343            {
     344                // Display "Press [Fire] to start the match" if the game has not yet ended.
     345                if(!this->hasEnded())
     346                    NotificationListener::sendNotification("Press [Fire] to start the match", GametypeInfo::NOTIFICATION_SENDER, notificationMessageType::info, notificationSendMode::network, player->getClientID());
     347                // Else display "Game has ended".
     348                else
     349                    NotificationListener::sendNotification("Game has ended", GametypeInfo::NOTIFICATION_SENDER, notificationMessageType::info, notificationSendMode::network, player->getClientID());
     350            }
     351        }
     352    }
     353
     354    /**
     355    @brief
     356        Helper method. Sends changedReadyToSpawn notifiers over the network.
     357    @param player
     358        The player that has changed its ready to spawn status.
     359    @param ready
     360        The new ready to spawn status.
     361    */
     362    void GametypeInfo::setReadyToSpawnHelper(PlayerInfo* player, bool ready)
     363    {
     364        if(GameMode::isMaster())
     365        {
     366            if(player->getClientID() == CLIENTID_SERVER)
     367                this->changedReadyToSpawn(ready);
     368            else
     369                callMemberNetworkFunction(GametypeInfo, changedReadyToSpawn, this->getObjectID(), player->getClientID(), ready);
     370        }
     371    }
     372
     373    /**
     374    @brief
     375        Helper method. Sends changedSpawned notifiers over the network.
     376    @param player
     377        The player that has changed its spawned status.
     378    @param ready
     379        The new spawned status.
     380    */
     381    void GametypeInfo::setSpawnedHelper(PlayerInfo* player, bool spawned)
     382    {
     383        if(GameMode::isMaster())
     384        {
     385            if(player->getClientID() == CLIENTID_SERVER)
     386                    this->changedSpawned(spawned);
     387            else
     388                callMemberNetworkFunction(GametypeInfo, changedSpawned, this->getObjectID(), player->getClientID(), spawned);
     389        }
     390    }
     391
     392    // Announce messages.
     393    // TODO: Replace with notifications.
    71394
    72395    void GametypeInfo::sendAnnounceMessage(const std::string& message)
  • code/trunk/src/orxonox/infos/GametypeInfo.h

    r7163 r8706  
    2323 *      Fabian 'x3n' Landau
    2424 *   Co-authors:
    25  *      ...
     25 *      Damian 'Mozork' Frick
    2626 *
    2727 */
     28
     29/**
     30    @file GametypeInfo.h
     31    @brief Definition of the GametypeInfo class
     32*/
    2833
    2934#ifndef _GametypeInfo_H__
     
    3338
    3439#include <string>
     40
    3541#include "Info.h"
    3642
    3743namespace orxonox
    3844{
     45
     46    /**
     47    @brief
     48        The GametypeInfo class keeps track of the state of the game and provides facilities to inform the player about it.
     49
     50    @author
     51        Fabian 'x3n' Landau
     52    @author
     53        Damian 'Mozork' Frick
     54    */
    3955    class _OrxonoxExport GametypeInfo : public Info
    4056    {
     
    4561            virtual ~GametypeInfo();
    4662
     63            /**
     64            @brief Get whether the game has started yet.
     65            @return Returns true if the game has started, false if not.
     66            */
    4767            inline bool hasStarted() const
    4868                { return this->bStarted_; }
     69            void changedStarted(void); // Is called when the game has changed to started.
     70           
     71            /**
     72            @brief Get whether the game has ended yet.
     73            @return Returns true if the game has ended, false if not.
     74            */
    4975            inline bool hasEnded() const
    5076                { return this->bEnded_; }
     77            void changedEnded(void); // Is called when the game has changed to ended.
    5178
     79            /**
     80            @brief Get whether the start countdown is currently running.
     81            @return Returns true if the countdown is running, false if not.
     82            */
    5283            inline bool isStartCountdownRunning() const
    5384                { return this->bStartCountdownRunning_; }
     85            void changedStartCountdownRunning(void); // Is called when the start countdown has been either started or stopped.
     86
     87            /**
     88            @brief Get the current value of the start countdown.
     89            @return Returns the current value of the start countdown.
     90            */
    5491            inline float getStartCountdown() const
    5592                { return this->startCountdown_; }
     93
     94            /**
     95            @brief Get the current start countdown counter.
     96                   The start countdown counter only has integer values that correspond to the actually displayed countdown.
     97            @return Returns the current integer countdown counter.
     98            */
     99            inline unsigned int getStartCountdownCounter() const
     100                { return this->counter_; }
     101            void changedCountdownCounter(void); // Is called when the start countdown counter has changed.
     102
     103            /**
     104            @brief Get whether the local player is ready to spawn.
     105            @return Returns true if the player is ready to spawn, false if not.
     106            */
     107            inline bool isReadyToSpawn() const
     108                { return this->readyToSpawn_; }
     109            void changedReadyToSpawn(bool ready); // Inform the GametypeInfo that the local player has changed its spawned status.
     110           
     111            /**
     112            @brief Get whether the local player is spawned.
     113            @return Returns true if the local player is currently spawned, false if not.
     114            */
     115            inline bool isSpawned() const
     116                { return this->spawned_; }
     117            void changedSpawned(bool spawned); // Inform the GametypeInfo that the local player has changed its spawned status.
    56118
    57119            inline const std::string& getHUDTemplate() const
     
    70132            void dispatchStaticMessage(const std::string& message,const ColourValue& colour);
    71133            void dispatchFadingMessage(const std::string& message);
     134           
     135        protected:
     136            void start(void); // Inform the GametypeInfo that the game has started.
     137            void end(void); // Inform the GametypeInfo that the game has ended.
     138            void setStartCountdown(float countdown); // Set the start countdown to the input value.
     139            void countdownStartCountdown(float countDown); // Count down the start countdown by the specified value.
     140            void countDown(); // Count down the start countdown counter.
     141            void startStartCountdown(void); // Inform the GametypeInfo about the start of the start countdown.
     142            void stopStartCountdown(void); // Inform the GametypeInfo about the stop of the start countdown.
     143            void playerReadyToSpawn(PlayerInfo* player); // Inform the GametypeInfo about a player that is ready to spawn.
     144            void pawnKilled(PlayerInfo* player); // Inform the GametypeInfo about a player whose Pawn has been killed.
     145            void playerSpawned(PlayerInfo* player); // Inform the GametypeInfo about a player that has spawned.
     146            void playerEntered(PlayerInfo* player); // Inform the GametypeInfo about a player that has entered,
     147
     148            inline void setHUDTemplate(const std::string& templateName)
     149                { this->hudtemplate_ = templateName; };
    72150
    73151        private:
    74152            void registerVariables();
     153            void setSpawnedHelper(PlayerInfo* player, bool spawned); // Helper method. Sends changedReadyToSpawn notifiers over the network.
     154            void setReadyToSpawnHelper(PlayerInfo* player, bool ready); // Helper method. Sends changedSpawned notifiers over the network.
    75155
    76             bool bStarted_;
    77             bool bEnded_;
    78             bool bStartCountdownRunning_;
    79             float startCountdown_;
     156            static const std::string NOTIFICATION_SENDER; //!< The name of the sender for the sending of notifications.
     157
     158            bool bStarted_; //!< Whether the game has started,
     159            bool bEnded_; //!< Whether the game has ended.
     160            bool bStartCountdownRunning_; //!< Whether the start countdown is running.
     161            float startCountdown_; //!< The current value of the start countdown.
     162            unsigned int counter_; //!< The current integer value of the start countdown, the start countdown counter.
    80163            std::string hudtemplate_;
     164           
     165            std::set<PlayerInfo*> spawnedPlayers_; //!< A set of players that are currently spawned.
     166            bool spawned_; //!< Whether the local Player is currently spawned.
     167            bool readyToSpawn_; //!< Whether the local Player is ready to spawn.
    81168    };
    82169}
  • code/trunk/src/orxonox/infos/PlayerInfo.cc

    r8327 r8706  
    5151        this->controllableEntity_ = 0;
    5252        this->controllableEntityID_ = OBJECTID_UNKNOWN;
    53         this->oldControllableEntity_ = 0;
    5453
    5554        this->gtinfo_ = 0;
     
    151150            return;
    152151
    153         if (this->oldControllableEntity_)
     152        while (this->previousControllableEntity_.size() > 0)
    154153            this->stopTemporaryControl();
     154       
    155155        if (this->controllableEntity_)
    156156            this->stopControl();
     
    177177            return;
    178178
    179         assert( this->oldControllableEntity_==0 );
    180 
    181         this->oldControllableEntity_ = this->controllableEntity_;
     179        this->controllableEntity_->destroyHud(); // HACK-ish
     180        this->previousControllableEntity_.push_back(WeakPtr<ControllableEntity>(this->controllableEntity_));
    182181        this->controllableEntity_ = entity;
    183182        this->controllableEntityID_ = entity->getObjectID();
     
    194193    void PlayerInfo::stopControl()
    195194    {
    196         if ( this->oldControllableEntity_ )
     195        while ( this->previousControllableEntity_.size() > 0)
    197196            this->stopTemporaryControl();
    198197
     
    215214    }
    216215
     216    void PlayerInfo::pauseControl()
     217    {
     218        ControllableEntity* entity = this->controllableEntity_;
     219
     220        if (!entity)
     221            return;
     222
     223        this->controllableEntity_->getController()->setActive(false);
     224        //this->controllableEntity_->getController()->setControllableEntity(NULL);
     225        this->controllableEntity_->setController(0);
     226    }
     227
    217228    void PlayerInfo::stopTemporaryControl()
    218229    {
    219230        ControllableEntity* entity = this->controllableEntity_;
    220231
    221         assert( this->controllableEntity_ && this->oldControllableEntity_ );
    222         if( !entity || !this->oldControllableEntity_ )
     232        assert(this->controllableEntity_ != NULL);
     233        if( !entity || this->previousControllableEntity_.size() == 0 )
    223234            return;
    224235
    225236        this->controllableEntity_->setController(0);
     237        this->controllableEntity_->destroyHud(); // HACK-ish
    226238       
    227         this->controllableEntity_ = this->oldControllableEntity_;
     239//        this->controllableEntity_ = this->previousControllableEntity_.back();
     240        do {
     241            this->controllableEntity_ = this->previousControllableEntity_.back();
     242        } while(this->controllableEntity_ == NULL && this->previousControllableEntity_.size() > 0);
    228243        this->controllableEntityID_ = this->controllableEntity_->getObjectID();
    229         this->oldControllableEntity_ = 0;
    230 
    231         if ( this->controllableEntity_ && this->controller_)
     244        this->previousControllableEntity_.pop_back();
     245
     246        if ( this->controllableEntity_ != NULL && this->controller_ != NULL)
    232247            this->controller_->setControllableEntity(this->controllableEntity_);
     248
     249         // HACK-ish
     250        if(this->controllableEntity_ != NULL)
     251            this->controllableEntity_->createHud();
    233252
    234253        if ( GameMode::isMaster() )
  • code/trunk/src/orxonox/infos/PlayerInfo.h

    r7163 r8706  
    6868            void startControl(ControllableEntity* entity);
    6969            void stopControl();
     70            void pauseControl();
    7071            void startTemporaryControl(ControllableEntity* entity);
    7172            void stopTemporaryControl();
     
    9899            Controller* controller_;
    99100            ControllableEntity* controllableEntity_;
    100             ControllableEntity* oldControllableEntity_;
     101            std::vector< WeakPtr<ControllableEntity> > previousControllableEntity_; //!< List of the previous ControllableEntities if repeatedly startTemporary control was called. The ControllableEntity at the back is the most recent.
    101102            unsigned int controllableEntityID_;
    102103
  • code/trunk/src/orxonox/interfaces/CMakeLists.txt

    r7504 r8706  
    11ADD_SOURCE_FILES(ORXONOX_SRC_FILES
    22  InterfaceCompilation.cc
     3  NotificationListener.cc
    34  Pickupable.cc
    45  PickupCarrier.cc
  • code/trunk/src/orxonox/interfaces/InterfaceCompilation.cc

    r7606 r8706  
    4242#include "core/CoreIncludes.h"
    4343
     44#include "infos/PlayerInfo.h"
     45#include "worldentities/pawns/Pawn.h"
     46
    4447namespace orxonox
    4548{
     
    5962        RegisterRootObject(PlayerTrigger);
    6063
    61         this->player_ = NULL;
    6264        this->isForPlayer_ = false;
     65    }
     66
     67    void PlayerTrigger::setTriggeringPawn(Pawn* pawn)
     68    {
     69        assert(pawn);
     70        this->pawn_ = WeakPtr<Pawn>(pawn);
     71        if (pawn)
     72            this->player_ = WeakPtr<PlayerInfo>(pawn->getPlayer());
    6373    }
    6474
     
    8696        RegisterRootObject(Rewardable);
    8797    }
    88 
    89     //----------------------------
    90     // NotificationListener
    91     //----------------------------
    92     NotificationListener::NotificationListener()
    93     {
    94         RegisterRootObject(NotificationListener);
    95     }
    9698}
  • code/trunk/src/orxonox/interfaces/NotificationListener.h

    r7552 r8706  
    2121 *
    2222 *   Author:
    23  *      Fabian 'x3n' Landau
     23 *      Damian 'Mozork' Frick
    2424 *   Co-authors:
    2525 *      ...
     
    4848namespace orxonox
    4949{
    50     class Notification;
     50    // TODO: Document.
     51    namespace notificationMessageType
     52    {
     53        enum Value {
     54            info,
     55            important
     56        };
     57    }
     58   
     59    namespace notificationSendMode
     60    {
     61        enum Value {
     62            local,
     63            network,
     64            broadcast
     65        };
     66    }
     67   
     68    namespace notificationCommand
     69    {
     70        enum Value {
     71            none,
     72            clear
     73        };
     74    }
    5175
     76    // TODO: Update doc.
    5277    /**
    5378    @brief
    5479        NotificationListener interface.
    5580
    56         The NotificationListener interface presents a means to being informed when @ref orxonox::Notification "Notifications" in the target set of this NotificationListener change. (e.g. @ref orxonox::Notification "Notifications" were added or removed)
    57         When inheriting from a NotificationListener it is important to register (in the constructor) and unregister (in the destructor) it to and from the @ref orxonox::NotificationManager "NotificationManager".
     81        The NotificationListener interface (or more precisely abstract class) presents a means of being informed when a new @ref orxonox::Notification "Notification" is sent.
     82        The NotificationListener can be used to send a new notification message (with NotificationListener::sendNotification() ) or a new notification command (with NotificationListener::sendCommand() ). Each NotificationListener is then informed about the new @ref orxonox::Notification "Notification" and can take appropriate action. Currently the only NotificationListener ist the @ref orxonox::NotificationManager "NotificationManager" singleton.
     83
     84        When inheriting from a NotificationListener it is important to provide an appropriate implementation of registerNotification() and executeCommand().
    5885
    5986    @author
    60         Fabian 'x3n' Landau
    61 
     87        Damian 'Mozork' Frick
     88       
    6289    @ingroup Notifications
     90    @todo Consistent terminology between message, notification and command.
    6391    */
    6492    class _OrxonoxExport NotificationListener : virtual public OrxonoxClass
     
    6997
    7098            /**
    71             @brief Get the senders that are targets of this NotificationListener.
    72             @return Returns the set of senders that are targets of this NotificationListener.
     99            @brief Sends a Notification with the specified message to the specified client from the specified sender.
     100            @param message The message that should be sent.
     101            @param sender The sender that sent the notification. Default is 'none'.
     102            @param messageType The type of the message, can be either 'info' or 'important'. Default is 'info'.
     103            @param sendMode The mode in which the notification is sent, can be 'local' to send the notification to the client where this function is executed, 'network' if the notification is to be sent to the client with the specified clientID, or 'broadcast' if the notification should be sent to all hosts. Default is notificationSendMode::local.
     104            @param clientId The id of the client the notification should be sent to. Default is 0.
    73105            */
    74             virtual const std::set<std::string> & getTargetsSet(void) = 0;
     106            static void sendNotification(const std::string& message, const std::string& sender = NotificationListener::NONE, notificationMessageType::Value messageType = notificationMessageType::info, notificationSendMode::Value sendMode = notificationSendMode::local, unsigned int clientId = 0)
     107                { NotificationListener::sendNetworkHelper(message, sender, sendMode, clientId, false, messageType); }
     108            /**
     109            @brief Sends a specified command to the specified client from the specified sender.
     110            @param command The command that should be sent (and later executed).
     111            @param sender The sender that sent the notification. Default is 'none'.
     112            @param sendMode The mode in which the command is sent, can be 'local' to send the command to the client where this function is executed, 'network' if the command is to be sent to the client with the specified clientID, or 'broadcast' if the command should be sent to all hosts. Default is notificationSendMode::local.
     113            @param clientId The id of the client the command should be sent to. Default is 0.
     114            */
     115            static void sendCommand(const std::string& command, const std::string& sender = NotificationListener::NONE, notificationSendMode::Value sendMode = notificationSendMode::local, unsigned int clientId = 0)
     116                { NotificationListener::sendNetworkHelper(command, sender, sendMode, clientId, true); }
    75117
     118            static void sendHelper(const std::string& message, const std::string& sender, bool isCommand = false, unsigned int messageMode = 0); // Helper method to register a notification/execute a command with all NotificationListeners after it has been sent over the network.
     119
     120            //TODO: Make protected?
     121           
    76122            /**
    77             @brief Updates the whole NotificationListener.
    78                    This is called by the @ref orxonox::NotificationManager "NotificationManager" when the @ref orxonox::Notification "Notifications" have changed so much, that the NotificationListener may have to re-initialize his operations.
     123            @brief Registers a notification with the NotificationListener.
     124                   This needs to be overloaded by each class inheriting from NotificationListener.
     125            @param message The notification's message.
     126            @param sender The sender of the notification.
     127            @param type The type of the notification.
     128            @return Returns true if the notification was successfully registered, false if not.
    79129            */
    80             virtual void update(void) = 0;
     130            virtual bool registerNotification(const std::string& message, const std::string& sender, notificationMessageType::Value type)
     131                { return false; }
    81132            /**
    82             @brief Updates the NotificationListener, when a new Notification has come in at the specified time.
    83             @param notification A pointer to the @ref orxonox::Notification "Notification".
    84             @param time The time the @ref orxonox::Notification "Notification" has come in.
     133            @brief Executes a command with the NotificationListener
     134                   This needs to be overloaded by each class inheriting from NotificationListener.
     135            @param command The command to be executed.
     136            @param sender The sender of the command.
     137            @return Returns true if the command was successfully executed, false if not.
    85138            */
    86             virtual void update(Notification* notification, const std::time_t & time) = 0;
     139            virtual bool executeCommand(notificationCommand::Value command, const std::string& sender) { return false; }
     140
     141        public:
     142           
     143            static const std::string ALL; //!< Static string to indicate a sender that sends to all NotificationQueues.
     144            static const std::string NONE; //!< Static string to indicate a sender that sends to no specific NotificationQueues.
     145           
     146            //! Commands
     147            static const std::string COMMAND_CLEAR;
     148            static const std::string COMMAND_NONE;
     149           
     150        protected:
     151            static void sendNetworkHelper(const std::string& message, const std::string& sender, notificationSendMode::Value sendMode, unsigned int clientId, bool isCommand = false, notificationMessageType::Value messageType = notificationMessageType::info); // Helper method to send both notifications and commands over the network.
     152
     153            static notificationCommand::Value str2Command(const std::string& string); // Helper method. Converts a string into the enum for a command.
     154            static const std::string& command2Str(notificationCommand::Value command); // Helper method. Converts a command enum into its corresponding string.
    87155    };
    88156}
  • code/trunk/src/orxonox/interfaces/PlayerTrigger.h

    r7601 r8706  
    3939
    4040#include "core/OrxonoxClass.h"
     41#include "core/WeakPtr.h"
    4142
    4243namespace orxonox
     
    4445    /**
    4546    @brief
    46         PlayerTrigger is an interface if implemented by a specific trigger can be used to recover the Player (or more precisely the @ref orxonox::Pawn "Pawn") that triggered it.
     47        PlayerTrigger is an interface if implemented by a specific trigger can be used to recover the Player (or the @ref orxonox::Pawn "Pawn") that triggered it.
    4748
    4849    @author
     
    5859
    5960        /**
    60         @brief Returns the player that triggered the PlayerTrigger.
     61        @brief Returns the Pawn that triggered the PlayerTrigger.
    6162        @return Returns a pointer to the Pawn that triggered the PlayerTrigger.
    6263        */
    63         inline Pawn* getTriggeringPlayer(void) const
     64        inline Pawn* getTriggeringPawn(void) const
     65            { return this->pawn_.get(); }
     66
     67        /**
     68        @brief Returns the player that triggered the PlayerTrigger.
     69        @return Returns a pointer to the PlayerInfo that triggered the PlayerTrigger.
     70        */
     71        inline PlayerInfo* getTriggeringPlayer(void) const
    6472            { return this->player_; }
    6573
    6674        /**
    67         @brief Checks whether the PlayerTrigger normally returns a Pawn.
    68         @return Returns true if the PlayerTrigger normally returns a Pawn.
     75        @brief Checks whether the PlayerTrigger normally returns a Pawn/PlayerInfo.
     76        @return Returns true if the PlayerTrigger normally returns a Pawn/PlayerInfo.
    6977        */
    7078        inline bool isForPlayer(void) const
     
    7684        @param player A pointer to the Pawn that triggered the PlayerTrigger.
    7785        */
    78         inline void setTriggeringPlayer(Pawn* player)
    79            { this->player_ = player; }
     86        void setTriggeringPawn(Pawn* pawn);
    8087
    8188        /**
     
    8794
    8895    private:
    89         Pawn* player_; //!< The player that triggered the PlayerTrigger.
     96        WeakPtr<PlayerInfo> player_; //!< The player that triggered the PlayerTrigger.
     97        WeakPtr<Pawn> pawn_; //!< The Pawn that triggered the PlayerTrigger.
    9098        bool isForPlayer_; //!< Is true when the PlayerTrigger should be set to normally be triggered by Pawns.
    9199
  • code/trunk/src/orxonox/items/Engine.cc

    r8079 r8706  
    3535#include "Scene.h"
    3636#include "worldentities/pawns/SpaceShip.h"
    37 #include "tools/Shader.h"
     37#include "core/Template.h"
    3838
    3939namespace orxonox
     
    4747        this->ship_ = 0;
    4848        this->shipID_ = OBJECTID_UNKNOWN;
     49        this->relativePosition_ = Vector3(0,0,0);
    4950
    5051        this->boostFactor_ = 1.5;
     
    6263        this->accelerationUpDown_ = 0.0;
    6364
    64         this->boostBlur_ = 0;
    65 
    6665        this->speedAdd_ = 0.0;
    6766        this->speedMultiply_ = 1.0;
     
    7372    Engine::~Engine()
    7473    {
    75         if (this->isInitialized() && this->ship_)
    76         {
    77             this->ship_->setEngine(0);
    78 
    79             if (this->boostBlur_)
    80                 this->boostBlur_->destroy();
     74        if (this->isInitialized())
     75        {
     76            if (this->ship_ && this->ship_->hasEngine(this))
     77                this->ship_->removeEngine(this);
    8178        }
    8279    }
     
    9895        XMLPortParam(Engine, "accelerationleftright", setAccelerationLeftRight, setAccelerationLeftRight, xmlelement, mode);
    9996        XMLPortParam(Engine, "accelerationupdown",    setAccelerationUpDown,    setAccelerationUpDown,    xmlelement, mode);
     97
     98        XMLPortParam(Engine, "position", setRelativePosition, getRelativePosition, xmlelement, mode);
     99        XMLPortParam(Engine, "template", setEngineTemplate, getEngineTemplate, xmlelement, mode);
    100100    }
    101101
    102102    void Engine::setConfigValues()
    103103    {
    104         SetConfigValueExternal(bEnableMotionBlur_, "GraphicsSettings", "enableMotionBlur", true)
    105             .description("Enable or disable the motion blur effect when moving very fast")
    106             .callback(this, &Engine::changedEnableMotionBlur);
    107         SetConfigValueExternal(blurStrength_, "GraphicsSettings", "blurStrength", 3.0f)
    108             .description("Defines the strength of the motion blur effect");
    109104    }
    110105
     
    163158        SUPER(Engine, tick, dt);
    164159
    165         const Vector3& direction = this->getDirection();
     160        Vector3 direction = this->getDirection();
     161        float directionLength = direction.length();
     162        if (directionLength > 1.0f)
     163            direction /= directionLength; // normalize
     164       
    166165        Vector3 velocity = this->ship_->getLocalVelocity();
    167166        Vector3 acceleration = Vector3::ZERO;
     
    202201        }
    203202
    204         this->ship_->setAcceleration(this->ship_->getOrientation() * (acceleration*this->getSpeedMultiply()+Vector3(0,0,-this->getSpeedAdd())));
    205 
    206         if (!this->ship_->getPermanentBoost())
    207             this->ship_->setBoost(false);
    208         this->ship_->setSteeringDirection(Vector3::ZERO);
    209 
    210         if (this->bEnableMotionBlur_ && !this->boostBlur_ && this->ship_->hasLocalController() && this->ship_->hasHumanController())
    211         {
    212             this->boostBlur_ = new Shader(this->ship_->getScene()->getSceneManager());
    213             this->boostBlur_->setCompositorName("Radial Blur");
    214         }
    215 
    216         if (this->boostBlur_ && this->maxSpeedFront_ != 0 && this->boostFactor_ != 1)
    217         {
    218             float blur = this->blurStrength_ * clamp((-velocity.z - this->maxSpeedFront_) / ((this->boostFactor_ - 1) * this->maxSpeedFront_), 0.0f, 1.0f);
    219 
    220             this->boostBlur_->setVisible(blur > 0);
    221             this->boostBlur_->setParameter(0, 0, "sampleStrength", blur);
     203        // NOTE: Bullet always uses global coordinates.
     204        this->ship_->addAcceleration(this->ship_->getOrientation() * (acceleration*this->getSpeedMultiply()+Vector3(0,0,-this->getSpeedAdd())), this->ship_->getOrientation() * this->relativePosition_);
     205
     206        // Hack to reset a temporary variable "direction"
     207        this->ship_->oneEngineTickDone();
     208        if(!this->ship_->hasEngineTicksRemaining())
     209        {
     210            this->ship_->setSteeringDirection(Vector3::ZERO);
     211            this->ship_->resetEngineTicks();
    222212        }
    223213    }
     
    226216    {
    227217        SUPER(Engine, changedActivity);
    228 
    229         if (this->boostBlur_)
    230             this->boostBlur_->setVisible(this->isVisible());
    231218    }
    232219
     
    238225        {
    239226            this->shipID_ = ship->getObjectID();
    240             if (ship->getEngine() != this)
    241                 ship->setEngine(this);
    242 
    243             if (this->boostBlur_)
    244             {
    245                 this->boostBlur_->destroy();
    246                 this->boostBlur_ = 0;
    247             }
     227            if (!ship->hasEngine(this))
     228                ship->addEngine(this);
    248229        }
    249230    }
     
    267248    }
    268249
    269     void Engine::changedEnableMotionBlur()
    270     {
    271         if (!this->bEnableMotionBlur_)
    272         {
    273             this->boostBlur_->destroy();
    274             this->boostBlur_ = 0;
     250    void Engine::loadEngineTemplate()
     251    {
     252        if(!this->engineTemplate_.empty())
     253        {
     254            COUT(4)<<"Loading an engine template: "<<this->engineTemplate_<<"\n";
     255            Template *temp = Template::getTemplate(this->engineTemplate_);
     256            if(temp)
     257            {
     258                this->addTemplate(temp);
     259            }
    275260        }
    276261    }
  • code/trunk/src/orxonox/items/Engine.h

    r8079 r8706  
    5454            inline SpaceShip* getShip() const
    5555                { return this->ship_; }
     56
     57            inline void setRelativePosition(const Vector3 &position)
     58                { this->relativePosition_ = position; }
     59            inline Vector3& getRelativePosition()
     60                { return this->relativePosition_; }
    5661
    5762            inline void setBoostFactor(float factor)
     
    119124                { this->speedMultiply_=speedMultiply; }
    120125
     126           
     127            inline void setEngineTemplate(const std::string& temp)
     128                { this->engineTemplate_ = temp; this->loadEngineTemplate(); }
     129            inline const std::string& getEngineTemplate() const
     130                { return this->engineTemplate_; }
     131
    121132        protected:
    122133            virtual std::vector<PickupCarrier*>* getCarrierChildren(void) const
    123134                { return new std::vector<PickupCarrier*>(); }
    124135            virtual PickupCarrier* getCarrierParent(void) const;
     136           
     137            void loadEngineTemplate();
    125138
    126139        private:
    127140            void registerVariables();
    128141            void networkcallback_shipID();
    129             void changedEnableMotionBlur();
     142
     143            std::string engineTemplate_;
    130144
    131145            SpaceShip* ship_;
    132146            unsigned int shipID_;
     147            Vector3 relativePosition_;
    133148
    134149            float boostFactor_;
     
    148163            float accelerationLeftRight_;
    149164            float accelerationUpDown_;
    150 
    151             Shader* boostBlur_;
    152             float blurStrength_;
    153             bool bEnableMotionBlur_;
    154165    };
    155166}
  • code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc

    r8351 r8706  
    137137        XMLPortParam(OrxonoxOverlay, "correctaspect", setAspectCorrection,   getAspectCorrection,   xmlelement, mode);
    138138        XMLPortParam(OrxonoxOverlay, "background",    setBackgroundMaterial, getBackgroundMaterial, xmlelement, mode);
     139        XMLPortParam(OrxonoxOverlay, "backgroundtex", setBackgroundTexture,  getBackgroundTexture,  xmlelement, mode);
    139140    }
    140141
     
    163164        if (this->background_)
    164165            return this->background_->getMaterialName();
     166        else
     167            return BLANKSTRING;
     168    }
     169
     170    //! Sets the background texture name and creates a new material if necessary
     171    void OrxonoxOverlay::setBackgroundTexture(const std::string& texture)
     172    {
     173        if (this->background_ && this->background_->getMaterial().isNull() && !texture.empty())
     174        {
     175            // create new material
     176            const std::string& materialname = "generated_material" + getUniqueNumberString();
     177            Ogre::MaterialPtr material = static_cast<Ogre::MaterialPtr>(Ogre::MaterialManager::getSingleton().create(materialname, "General"));
     178            material->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
     179            Ogre::TextureUnitState* textureUnitState_ = material->getTechnique(0)->getPass(0)->createTextureUnitState();
     180            textureUnitState_->setTextureName(texture);
     181            textureUnitState_->setNumMipmaps(0);
     182            this->background_->setMaterialName(materialname);
     183        }
     184    }
     185
     186    //! Returns the the texture name of the background
     187    const std::string& OrxonoxOverlay::getBackgroundTexture() const
     188    {
     189        if (this->background_)
     190        {
     191            Ogre::TextureUnitState* tempTx = this->background_->getMaterial()->getTechnique(0)->getPass(0)->getTextureUnitState(0);
     192            return tempTx->getTextureName();
     193        }
    165194        else
    166195            return BLANKSTRING;
     
    406435    }
    407436
    408     void OrxonoxOverlay::setBackgroundAlpha(float alpha) {
     437    void OrxonoxOverlay::setBackgroundAlpha(float alpha)
     438    {
    409439        Ogre::MaterialPtr ptr = this->background_->getMaterial();
    410440        Ogre::TextureUnitState* tempTx = ptr->getTechnique(0)->getPass(0)->getTextureUnitState(0);
    411441        tempTx->setAlphaOperation(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, alpha);
    412442    }
     443
     444    void OrxonoxOverlay::setBackgroundColour(ColourValue colour)
     445    {
     446        Ogre::MaterialPtr ptr = this->background_->getMaterial();
     447        Ogre::TextureUnitState* tempTx = ptr->getTechnique(0)->getPass(0)->getTextureUnitState(0);
     448        tempTx->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, colour);
     449    }
    413450}
  • code/trunk/src/orxonox/overlays/OrxonoxOverlay.h

    r8309 r8706  
    160160        const std::string& getBackgroundMaterial() const;
    161161
     162        void setBackgroundTexture(const std::string& texture);
     163        const std::string& getBackgroundTexture() const;
     164
    162165        void setBackgroundAlpha(float alpha);
     166
     167        void setBackgroundColour(ColourValue colour);
    163168
    164169        virtual void changedVisibility();
  • code/trunk/src/orxonox/sound/AmbientSound.cc

    r8351 r8706  
    8282    {
    8383        this->ambientSource_ = source;
    84         this->moodChanged(this->getMood());
     84        this->moodChanged(MoodManager::getInstance().getMood());
    8585    }
    8686
     
    8989        if (GameMode::playsSound())
    9090        {
    91             const std::string& path = "ambient/" + MoodManager::getInstance().getMood() + '/' + this->ambientSource_;
     91            const std::string& path = "ambient/" + mood + '/' + this->ambientSource_;
    9292            shared_ptr<ResourceInfo> fileInfo = Resource::getInfo(path);
    9393            if (fileInfo != NULL)
  • code/trunk/src/orxonox/weaponsystem/Munition.cc

    r7896 r8706  
    253253    bool Munition::canAddMunition(unsigned int amount) const
    254254    {
     255        // TODO: 'amount' is not used
     256
    255257        if (!this->bAllowMunitionRefilling_)
    256258            return false;
     
    334336    bool Munition::canAddMagazines(unsigned int amount) const
    335337    {
     338        // TODO: 'amount' is not used
     339
    336340        if (this->bStackMunition_)
    337341            // If we stack munition, we can always add new magazines because they contribute directly to the munition
  • code/trunk/src/orxonox/weaponsystem/WeaponMode.cc

    r7847 r8706  
    6666
    6767        this->damage_ = 0;
     68        this->healthdamage_ = 0;
     69        this->shielddamage_ = 0;
    6870
    6971        this->muzzleOffset_ = Vector3::ZERO;
     
    106108
    107109        XMLPortParam(WeaponMode, "damage",           setDamage,           getDamage,           xmlelement, mode);
     110        XMLPortParam(WeaponMode, "healthdamage",     setHealthDamage,     getHealthDamage,     xmlelement, mode);
     111        XMLPortParam(WeaponMode, "shielddamage",     setShieldDamage,     getShieldDamage,     xmlelement, mode);
    108112        XMLPortParam(WeaponMode, "muzzleoffset",     setMuzzleOffset,     getMuzzleOffset,     xmlelement, mode);
    109113    }
  • code/trunk/src/orxonox/weaponsystem/WeaponMode.h

    r7163 r8706  
    104104            // Fire
    105105            inline void setDamage(float damage)
    106                 { this->damage_ = damage; }
     106                { this->damage_ = damage;}
    107107            inline float getDamage() const
    108108                { return this->damage_; }
     109            inline void setHealthDamage(float healthdamage)
     110                { this->healthdamage_ = healthdamage; }
     111            inline float getHealthDamage() const
     112                { return this->healthdamage_; }
     113
     114            inline void setShieldDamage(float shielddamage)
     115                { this->shielddamage_ = shielddamage;}
     116            inline float getShieldDamage() const
     117                { return this->shielddamage_; }
    109118
    110119            inline void setMuzzleOffset(const Vector3& offset)
     
    146155
    147156            float damage_;
     157            float healthdamage_;
     158            float shielddamage_;
    148159            Vector3 muzzleOffset_;
    149160
  • code/trunk/src/orxonox/weaponsystem/WeaponSlot.cc

    r5929 r8706  
    4646        this->weapon_ = 0;
    4747
    48         this->setSyncMode(0x0);
     48        this->setSyncMode(ObjectDirection::None);
    4949    }
    5050
  • code/trunk/src/orxonox/worldentities/CMakeLists.txt

    r8458 r8706  
    1212  SpawnPoint.cc
    1313  TeamSpawnPoint.cc
    14   SpaceBoundaries.cc
    1514)
    1615
  • code/trunk/src/orxonox/worldentities/CameraPosition.cc

    r5929 r8706  
    4646        this->bRenderCamera_ = false;
    4747
    48         this->setSyncMode(0x0);
     48        this->setSyncMode(ObjectDirection::None);
    4949    }
    5050
  • code/trunk/src/orxonox/worldentities/ControllableEntity.cc

    r7892 r8706  
    8484        this->client_angular_velocity_ = Vector3::ZERO;
    8585
    86 
    8786        this->setConfigValues();
    8887        this->setPriority( Priority::VeryHigh );
     
    121120
    122121        XMLPortParam(ControllableEntity, "hudtemplate", setHudTemplate, getHudTemplate, xmlelement, mode);
    123         XMLPortParam(ControllableEntity, "camerapositiontemplate", setCameraPositionTemplate, getCameraPositionTemkplate, xmlelement, mode);
     122        XMLPortParam(ControllableEntity, "camerapositiontemplate", setCameraPositionTemplate, getCameraPositionTemplate, xmlelement, mode);
    124123
    125124        XMLPortObject(ControllableEntity, CameraPosition, "camerapositions", addCameraPosition, getCameraPosition, xmlelement, mode);
     
    171170        }
    172171        return 0;
     172    }
     173
     174    unsigned int ControllableEntity::getCurrentCameraIndex() const
     175    {
     176        if (this->cameraPositions_.size() <= 0)
     177            return 0;
     178
     179        unsigned int counter = 0;
     180        for (std::list<SmartPtr<CameraPosition> >::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it)
     181        {
     182            if ((*it) == this->currentCameraPosition_)
     183                break;
     184            counter++;
     185        }
     186        if (counter >= this->cameraPositions_.size())
     187            return 0;
     188
     189        return counter;
     190    }
     191   
     192    bool ControllableEntity::setCameraPosition(unsigned int index)
     193    {
     194        if(this->camera_ != NULL && this->cameraPositions_.size() > 0)
     195        {
     196            if(index >= this->cameraPositions_.size())
     197                index = 0;
     198
     199            CameraPosition* position = this->getCameraPosition(index);
     200            position->attachCamera(this->camera_);
     201            this->currentCameraPosition_ = position;
     202            return true;
     203        }
     204
     205        return false;
    173206    }
    174207
     
    373406        }
    374407
     408        this->createHud();
     409    }
     410
     411    // HACK-ish
     412    void ControllableEntity::createHud(void)
     413    {
    375414        if (!this->hud_ && GameMode::showsGraphics())
    376415        {
     
    381420                this->hud_->setOwner(this);
    382421            }
     422        }
     423    }
     424
     425    void ControllableEntity::destroyHud(void)
     426    {
     427        if (this->hud_ != NULL)
     428        {
     429            this->hud_->destroy();
     430            this->hud_ = NULL;
    383431        }
    384432    }
  • code/trunk/src/orxonox/worldentities/ControllableEntity.h

    r7889 r8706  
    9393            virtual void reload() {}
    9494
    95             virtual void boost() {}
     95            /**
     96            @brief Tells the ControllableEntity to either start or stop boosting.
     97                   This doesn't mean, that the ControllableEntity will do so, there might be additional restrictions on boosting, but if it can, then it will.
     98            @param bBoost If true the ControllableEntity is told to start boosting, if false it is told to stop.
     99            */
     100            virtual void boost(bool bBoost) {}
     101           
    96102            virtual void greet() {}
    97103            virtual void switchCamera();
     
    110116            inline const std::list<SmartPtr<CameraPosition> >& getCameraPositions() const
    111117                { return this->cameraPositions_; }
     118            unsigned int getCurrentCameraIndex() const;
     119            bool setCameraPosition(unsigned int index);
    112120
    113121            inline void setCameraPositionTemplate(const std::string& name)
    114122                { this->cameraPositionTemplate_ = name; }
    115             inline const std::string& getCameraPositionTemkplate() const
     123            inline const std::string& getCameraPositionTemplate() const
    116124                { return this->cameraPositionTemplate_; }
    117125
     
    168176            inline void setHudTemplate(const std::string& name)
    169177                { this->hudtemplate_ = name; }
     178            // HACK-ish
     179            void createHud(void);
     180            void destroyHud(void);
    170181
    171182            Ogre::SceneNode* cameraPositionRootNode_;
  • code/trunk/src/orxonox/worldentities/MobileEntity.cc

    r7163 r8706  
    143143    {
    144144        if (this->isDynamic())
     145        {
    145146            this->physicalBody_->applyCentralForce(btVector3(acceleration.x * this->getMass(), acceleration.y * this->getMass(), acceleration.z * this->getMass()));
    146 
     147        }
     148
     149        // If not bullet-managed (deprecated? SpaceShip doesn't use this anymore for movement)
    147150        this->linearAcceleration_ = acceleration;
     151    }
     152
     153    void MobileEntity::addAcceleration(const Vector3 &acceleration, const Vector3 &relativePosition)
     154    {
     155        if(this->isDynamic())
     156        {
     157            this->physicalBody_->applyForce(this->getMass() * btVector3(acceleration.x, acceleration.y, acceleration.z), btVector3(relativePosition.x, relativePosition.y, relativePosition.z));
     158        }
    148159    }
    149160
  • code/trunk/src/orxonox/worldentities/MobileEntity.h

    r5781 r8706  
    7070                { return this->linearAcceleration_; }
    7171
     72            // Added for making N engines work with spaceships
     73            void addAcceleration(const Vector3& acceleration, const Vector3 &relativePosition);
     74            inline void addAcceleration(float x, float y, float z)
     75                { this->addAcceleration(Vector3(x, y, z), Vector3(0,0,0)); }
     76            // Getter function above
     77
    7278            void setAngularAcceleration(const Vector3& acceleration);
    7379            inline void setAngularAcceleration(float x, float y, float z)
     
    8389                { this->setAngularVelocity(this->getAngularVelocity().normalisedCopy() * rate.valueRadians()); }
    8490            inline Degree getRotationRate() const
    85                 { return Degree(this->getAngularVelocity().length()); }
     91                { return Radian(this->getAngularVelocity().length()); }
    8692
    8793            inline void setRotationAxis(const Vector3& axis)
  • code/trunk/src/orxonox/worldentities/SpawnPoint.cc

    r5929 r8706  
    5050            COUT(1) << "Error: SpawnPoint has no Gametype" << std::endl;
    5151
    52         this->setSyncMode(0x0);
     52        this->setSyncMode(ObjectDirection::None);
    5353    }
    5454
  • code/trunk/src/orxonox/worldentities/WorldEntity.cc

    r7937 r8706  
    642642    void WorldEntity::setScale3D(const Vector3& scale)
    643643    {
    644 /*
    645 HACK HACK HACK
    646         if (bScalePhysics && this->hasPhysics() && scale != Vector3::UNIT_SCALE)
    647         {
    648             CCOUT(2) << "Warning: Cannot set the scale of a physical object: Not yet implemented. Ignoring scaling." << std::endl;
    649             return;
    650         }
    651 HACK HACK HACK
    652 */
     644        // If physics is enabled scale the attached CollisionShape.
     645        /*if (this->hasPhysics() && this->collisionShape_ != NULL)
     646        {
     647            this->collisionShape_->setScale3D(scale);
     648        }*/
     649
    653650        this->node_->setScale(scale);
    654651
  • code/trunk/src/orxonox/worldentities/pawns/Pawn.cc

    r8351 r8706  
    2323 *      Fabian 'x3n' Landau
    2424 *   Co-authors:
    25  *      ...
     25 *      Simon Miescher
    2626 *
    2727 */
     
    6464        this->maxHealth_ = 0;
    6565        this->initialHealth_ = 0;
     66
    6667        this->shieldHealth_ = 0;
     68        this->initialShieldHealth_ = 0;
     69        this->maxShieldHealth_ = 100; //otherwise shield might increase to float_max
    6770        this->shieldAbsorption_ = 0.5;
     71
     72        this->reloadRate_ = 0;
     73        this->reloadWaitTime_ = 1.0f;
     74        this->reloadWaitCountdown_ = 0;
    6875
    6976        this->lastHitOriginator_ = 0;
     
    109116
    110117        XMLPortParam(Pawn, "shieldhealth", setShieldHealth, getShieldHealth, xmlelement, mode).defaultValues(0);
     118        XMLPortParam(Pawn, "initialshieldhealth", setInitialShieldHealth, getInitialShieldHealth, xmlelement, mode).defaultValues(0);
     119        XMLPortParam(Pawn, "maxshieldhealth", setMaxShieldHealth, getMaxShieldHealth, xmlelement, mode).defaultValues(100);
    111120        XMLPortParam(Pawn, "shieldabsorption", setShieldAbsorption, getShieldAbsorption, xmlelement, mode).defaultValues(0);
    112121
     
    118127        XMLPortObject(Pawn, WeaponSet, "weaponsets", addWeaponSet, getWeaponSet, xmlelement, mode);
    119128        XMLPortObject(Pawn, WeaponPack, "weapons", addWeaponPackXML, getWeaponPack, xmlelement, mode);
     129
     130        XMLPortParam(Pawn, "reloadrate", setReloadRate, getReloadRate, xmlelement, mode).defaultValues(0);
     131        XMLPortParam(Pawn, "reloadwaittime", setReloadWaitTime, getReloadWaitTime, xmlelement, mode).defaultValues(1.0f);
    120132    }
    121133
     
    124136        registerVariable(this->bAlive_,           VariableDirection::ToClient);
    125137        registerVariable(this->health_,           VariableDirection::ToClient);
    126         registerVariable(this->initialHealth_,    VariableDirection::ToClient);
     138        registerVariable(this->maxHealth_,        VariableDirection::ToClient);
    127139        registerVariable(this->shieldHealth_,     VariableDirection::ToClient);
     140        registerVariable(this->maxShieldHealth_,  VariableDirection::ToClient);
    128141        registerVariable(this->shieldAbsorption_, VariableDirection::ToClient);
    129142        registerVariable(this->bReload_,          VariableDirection::ToServer);
     
    137150        this->bReload_ = false;
    138151
     152        // TODO: use the existing timer functions instead
     153        if(this->reloadWaitCountdown_ > 0)
     154        {
     155            this->decreaseReloadCountdownTime(dt);
     156        }
     157        else
     158        {
     159            this->addShieldHealth(this->getReloadRate() * dt);
     160            this->resetReloadCountdown();
     161        }
     162
    139163        if (GameMode::isMaster())
     164        {
    140165            if (this->health_ <= 0 && bAlive_)
    141166            {
    142                 this->fireEvent(); // Event to notify anyone who want's to know about the death.
     167                this->fireEvent(); // Event to notify anyone who wants to know about the death.
    143168                this->death();
    144169            }
     170        }
    145171    }
    146172
     
    168194    }
    169195
     196
    170197    void Pawn::setHealth(float health)
    171198    {
    172         this->health_ = std::min(health, this->maxHealth_);
    173     }
    174 
    175     void Pawn::damage(float damage, Pawn* originator)
     199        this->health_ = std::min(health, this->maxHealth_); //Health can't be set to a value bigger than maxHealth, otherwise it will be reduced at first hit
     200    }
     201
     202    void Pawn::setShieldHealth(float shieldHealth)
     203    {
     204        this->shieldHealth_ = std::min(shieldHealth, this->maxShieldHealth_);
     205    }
     206
     207    void Pawn::setMaxShieldHealth(float maxshieldhealth)
     208    {
     209        this->maxShieldHealth_ = maxshieldhealth;
     210    }
     211
     212    void Pawn::setReloadRate(float reloadrate)
     213    {
     214        this->reloadRate_ = reloadrate;
     215    }
     216
     217    void Pawn::setReloadWaitTime(float reloadwaittime)
     218    {
     219        this->reloadWaitTime_ = reloadwaittime;
     220    }
     221
     222    void Pawn::decreaseReloadCountdownTime(float dt)
     223    {
     224        this->reloadWaitCountdown_ -= dt;
     225    }
     226
     227    void Pawn::damage(float damage, float healthdamage, float shielddamage, Pawn* originator)
    176228    {
    177229        if (this->getGametype() && this->getGametype()->allowPawnDamage(this, originator))
    178230        {
    179             //share the dealt damage to the shield and the Pawn.
    180             float shielddamage = damage*this->shieldAbsorption_;
    181             float healthdamage = damage*(1-this->shieldAbsorption_);
    182 
    183             // In case the shield can not take all the shield damage.
    184             if (shielddamage > this->getShieldHealth())
     231            if (shielddamage >= this->getShieldHealth())
    185232            {
    186                 healthdamage += shielddamage-this->getShieldHealth();
    187233                this->setShieldHealth(0);
     234                this->setHealth(this->health_ - (healthdamage + damage));
    188235            }
    189 
    190             this->setHealth(this->health_ - healthdamage);
    191 
    192             if (this->getShieldHealth() > 0)
     236            else
    193237            {
    194238                this->setShieldHealth(this->shieldHealth_ - shielddamage);
     239
     240                // remove remaining shieldAbsorpton-Part of damage from shield
     241                shielddamage = damage * this->shieldAbsorption_;
     242                shielddamage = std::min(this->getShieldHealth(),shielddamage);
     243                this->setShieldHealth(this->shieldHealth_ - shielddamage);
     244
     245                // set remaining damage to health
     246                this->setHealth(this->health_ - (damage - shielddamage) - healthdamage);
    195247            }
    196248
    197249            this->lastHitOriginator_ = originator;
    198 
    199             // play damage effect
    200         }
    201     }
    202 
    203     void Pawn::hit(Pawn* originator, const Vector3& force, float damage)
     250        }
     251    }
     252
     253// TODO: Still valid?
     254/* HIT-Funktionen
     255    Die hit-Funktionen muessen auch in src/orxonox/controllers/Controller.h angepasst werden! (Visuelle Effekte)
     256
     257*/
     258
     259    void Pawn::hit(Pawn* originator, const Vector3& force, float damage, float healthdamage, float shielddamage)
    204260    {
    205261        if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) )
    206262        {
    207             this->damage(damage, originator);
     263            this->damage(damage, healthdamage, shielddamage, originator);
    208264            this->setVelocity(this->getVelocity() + force);
    209 
    210             // play hit effect
    211         }
    212     }
    213 
    214     void Pawn::hit(Pawn* originator, btManifoldPoint& contactpoint, float damage)
     265        }
     266    }
     267
     268
     269    void Pawn::hit(Pawn* originator, btManifoldPoint& contactpoint, float damage, float healthdamage, float shielddamage)
    215270    {
    216271        if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) )
    217272        {
    218             this->damage(damage, originator);
     273            this->damage(damage, healthdamage, shielddamage, originator);
    219274
    220275            if ( this->getController() )
    221                 this->getController()->hit(originator, contactpoint, damage);
    222 
    223             // play hit effect
    224         }
    225     }
     276                this->getController()->hit(originator, contactpoint, damage); // changed to damage, why shielddamage?
     277        }
     278    }
     279
    226280
    227281    void Pawn::kill()
  • code/trunk/src/orxonox/worldentities/pawns/Pawn.h

    r7889 r8706  
    7272                { return this->initialHealth_; }
    7373
    74             inline void setShieldHealth(float shieldHealth)
    75             { this->shieldHealth_ = shieldHealth; }
     74            virtual void setShieldHealth(float shieldHealth);
     75
    7676            inline float getShieldHealth()
    7777            { return this->shieldHealth_; }
     78
     79            inline void addShieldHealth(float amount)
     80            { this->setShieldHealth(this->shieldHealth_ + amount); }
     81
     82            inline bool hasShield()
     83            { return (this->getShieldHealth() > 0); }
     84
     85            virtual void setMaxShieldHealth(float maxshieldhealth);
     86            inline float getMaxShieldHealth() const
     87                { return this->maxShieldHealth_; }
     88
     89            inline void setInitialShieldHealth(float initialshieldhealth)
     90                { this->initialShieldHealth_ = initialshieldhealth; this->setShieldHealth(initialshieldhealth); }
     91            inline float getInitialShieldHealth() const
     92                { return this->initialShieldHealth_; }
     93
     94            inline void restoreInitialShieldHealth()
     95                { this->setShieldHealth(this->initialShieldHealth_); }
     96            inline void restoreMaxShieldHealth()
     97                { this->setShieldHealth(this->maxShieldHealth_); }
    7898
    7999            inline void setShieldAbsorption(float shieldAbsorption)
     
    82102            { return this->shieldAbsorption_; }
    83103
     104            // TODO: Rename to shieldRechargeRate
     105            virtual void setReloadRate(float reloadrate);
     106            inline float getReloadRate() const
     107                { return this->reloadRate_; }
     108
     109            virtual void setReloadWaitTime(float reloadwaittime);
     110            inline float getReloadWaitTime() const
     111                { return this->reloadWaitTime_; }
     112
     113            inline void resetReloadCountdown()
     114            { this->reloadWaitCountdown_ = 0; }
     115
     116            inline void startReloadCountdown()
     117            { this->reloadWaitCountdown_ = this->getReloadWaitTime(); } // TODO: Implement in Projectile.cc
     118
     119            virtual void decreaseReloadCountdownTime(float dt);
     120
    84121            inline ControllableEntity* getLastHitOriginator() const
    85122                { return this->lastHitOriginator_; }
    86123
    87             virtual void hit(Pawn* originator, const Vector3& force, float damage);
    88             virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage);
     124            //virtual void hit(Pawn* originator, const Vector3& force, float damage);
     125            //virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage);
     126            virtual void hit(Pawn* originator, const Vector3& force, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f);
     127            virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f);
     128
    89129            virtual void kill();
    90130
     
    142182            virtual void spawneffect();
    143183
    144             virtual void damage(float damage, Pawn* originator = 0);
     184            //virtual void damage(float damage, Pawn* originator = 0);
     185            virtual void damage(float damage, float healthdamage = 0.0f, float shielddamage = 0.0f, Pawn* originator = NULL);
    145186
    146187            bool bAlive_;
     
    154195            float maxHealth_;
    155196            float initialHealth_;
     197           
    156198            float shieldHealth_;
     199            float maxShieldHealth_;
     200            float initialShieldHealth_;
    157201            float shieldAbsorption_; // Has to be between 0 and 1
     202            float reloadRate_;
     203            float reloadWaitTime_;
     204            float reloadWaitCountdown_;
    158205
    159206            WeakPtr<Pawn> lastHitOriginator_;
  • code/trunk/src/orxonox/worldentities/pawns/SpaceShip.cc

    r7860 r8706  
    3535#include "core/Template.h"
    3636#include "core/XMLPort.h"
     37#include "tools/Shader.h"
     38#include "util/Debug.h" // TODO: Needed?
     39#include "util/Math.h"
     40
     41#include "graphics/Camera.h"
    3742#include "items/Engine.h"
     43
     44#include "CameraManager.h"
     45#include "Scene.h"
    3846
    3947namespace orxonox
     
    4250    CreateFactory(SpaceShip);
    4351
    44     SpaceShip::SpaceShip(BaseObject* creator) : Pawn(creator)
     52    SpaceShip::SpaceShip(BaseObject* creator) : Pawn(creator), boostBlur_(NULL)
    4553    {
    4654        RegisterObject(SpaceShip);
     
    5361        this->localAngularAcceleration_.setValue(0, 0, 0);
    5462        this->bBoost_ = false;
    55         this->bPermanentBoost_ = false;
    5663        this->steering_ = Vector3::ZERO;
    57         this->engine_ = 0;
    5864
    5965        this->boostPower_ = 10.0f;
     
    6470        this->bBoostCooldown_ = false;
    6571
     72        this->lift_ = 1.0f;                         // factor of the lift, standard is 1
     73        this->stallSpeed_ = 220.0f;                 // max speed where lift is added
     74
    6675        this->bInvertYAxis_ = false;
    6776
     
    7483        this->enableCollisionCallback();
    7584
     85        this->engineTicksNotDone = 0;
    7686        this->setConfigValues();
    7787        this->registerVariables();
     88       
     89        this->cameraOriginalPosition_ = Vector3::UNIT_SCALE;
     90        this->cameraOriginalOrientation_ = Quaternion::IDENTITY;
     91
     92        this->shakeFrequency_ = 15;
     93        this->shakeAmplitude_ = 5;
     94        this->shakeDt_ = 0;
    7895    }
    7996
    8097    SpaceShip::~SpaceShip()
    8198    {
    82         if (this->isInitialized() && this->engine_)
    83             this->engine_->destroy();
     99        if (this->isInitialized())
     100        {
     101            this->removeAllEngines();
     102       
     103            if (this->boostBlur_)
     104                this->boostBlur_->destroy();
     105        }
    84106    }
    85107
     
    88110        SUPER(SpaceShip, XMLPort, xmlelement, mode);
    89111
    90         XMLPortParam(SpaceShip, "engine",            setEngineTemplate,    getEngineTemplate,    xmlelement, mode);
     112        //XMLPortParam(SpaceShip, "engine",            setEngineTemplate,    getEngineTemplate,    xmlelement, mode);
    91113        XMLPortParamVariable(SpaceShip, "primaryThrust",  primaryThrust_,  xmlelement, mode);
    92114        XMLPortParamVariable(SpaceShip, "auxilaryThrust", auxilaryThrust_, xmlelement, mode);
     
    96118        XMLPortParamVariable(SpaceShip, "boostRate", boostRate_, xmlelement, mode);
    97119        XMLPortParamVariable(SpaceShip, "boostCooldownDuration", boostCooldownDuration_, xmlelement, mode);
     120        XMLPortParamVariable(SpaceShip, "shakeFrequency", shakeFrequency_, xmlelement, mode);
     121        XMLPortParamVariable(SpaceShip, "shakeAmplitude", shakeAmplitude_, xmlelement, mode);
     122        XMLPortParamVariable(SpaceShip, "lift", lift_, xmlelement, mode);
     123        XMLPortParamVariable(SpaceShip, "stallSpeed", stallSpeed_, xmlelement, mode);
     124
     125        XMLPortObject(SpaceShip, Engine, "engines", addEngine, getEngine, xmlelement, mode);
    98126    }
    99127
     
    103131        registerVariable(this->auxilaryThrust_, VariableDirection::ToClient);
    104132        registerVariable(this->rotationThrust_, VariableDirection::ToClient);
     133        // TODO: Synchronization of boost needed?
     134        registerVariable(this->boostPower_, VariableDirection::ToClient);
     135        registerVariable(this->boostPowerRate_, VariableDirection::ToClient);
     136        registerVariable(this->boostRate_, VariableDirection::ToClient);
     137        registerVariable(this->boostCooldownDuration_, VariableDirection::ToClient);
     138        registerVariable(this->shakeFrequency_, VariableDirection::ToClient);
     139        registerVariable(this->shakeAmplitude_, VariableDirection::ToClient);
     140        registerVariable(this->lift_, VariableDirection::ToClient);
     141        registerVariable(this->stallSpeed_, VariableDirection::ToClient);
    105142    }
    106143
     
    108145    {
    109146        SetConfigValue(bInvertYAxis_, false).description("Set this to true for joystick-like mouse behaviour (mouse up = ship down).");
     147       
     148        SetConfigValueExternal(bEnableMotionBlur_, "GraphicsSettings", "enableMotionBlur", true)
     149            .description("Enable or disable the motion blur effect when moving very fast")
     150            .callback(this, &SpaceShip::changedEnableMotionBlur);
     151        SetConfigValueExternal(blurStrength_, "GraphicsSettings", "blurStrength", 3.0f)
     152            .description("Defines the strength of the motion blur effect");
    110153    }
    111154
     
    128171        if (this->hasLocalController())
    129172        {
    130 /*
    131             this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() * getMass() * this->auxilaryThrust_);
    132             this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() * getMass() * this->auxilaryThrust_);
    133             if (this->localLinearAcceleration_.z() > 0)
    134                 this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->auxilaryThrust_);
    135             else
    136                 this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->primaryThrust_);
    137             this->physicalBody_->applyCentralForce(physicalBody_->getWorldTransform().getBasis() * this->localLinearAcceleration_);
    138             this->localLinearAcceleration_.setValue(0, 0, 0);
    139 */
     173            // Handle mouse look
    140174            if (!this->isInMouseLook())
    141175            {
     
    143177                this->physicalBody_->applyTorque(physicalBody_->getWorldTransform().getBasis() * this->localAngularAcceleration_);
    144178            }
    145 
    146179            this->localAngularAcceleration_.setValue(0, 0, 0);
    147180
     181            // Charge boostPower
    148182            if(!this->bBoostCooldown_ && this->boostPower_ < this->initialBoostPower_)
    149183            {
    150184                this->boostPower_ += this->boostPowerRate_*dt;
    151185            }
     186            // Use boostPower
    152187            if(this->bBoost_)
    153188            {
     
    155190                if(this->boostPower_ <= 0.0f)
    156191                {
    157                     this->bBoost_ = false;
     192                    this->boost(false);
    158193                    this->bBoostCooldown_ = true;
    159194                    this->timer_.setTimer(this->boostCooldownDuration_, false, createExecutor(createFunctor(&SpaceShip::boostCooledDown, this)));
    160195                }
    161             }
     196
     197                this->shakeCamera(dt);
     198            }
     199
     200            // Enable Blur depending on settings
     201            if (this->bEnableMotionBlur_ && !this->boostBlur_ && this->hasLocalController() && this->hasHumanController())
     202            {
     203                this->boostBlur_ = new Shader(this->getScene()->getSceneManager());
     204                this->boostBlur_->setCompositorName("Radial Blur");
     205            }
     206
     207            if (this->boostBlur_) // && this->maxSpeedFront_ != 0 && this->boostFactor_ != 1)
     208            {
     209                // TODO: this->maxSpeedFront_ gets fastest engine
     210                float blur = this->blurStrength_ * clamp((-this->getLocalVelocity().z - 0.0f /*this->maxSpeedFront_*/) / ((150.0f /*boostFactor_*/ - 1) * 1.5f /*this->maxSpeedFront_*/), 0.0f, 1.0f);
     211
     212                // Show and hide blur effect depending on state of booster
     213                if(this->bBoost_)
     214                    this->boostBlur_->setVisible(blur > 0);
     215                else
     216                    this->boostBlur_->setVisible(false);
     217
     218                this->boostBlur_->setParameter(0, 0, "sampleStrength", blur);
     219            }
     220        }
     221    }
     222
     223    void SpaceShip::moveFrontBack(const Vector2& value)
     224    {
     225        this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() - value.x);
     226        this->steering_.z -= value.x;
     227    }
     228
     229    void SpaceShip::moveRightLeft(const Vector2& value)
     230    {
     231        this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() + value.x);
     232        this->steering_.x += value.x;
     233    }
     234
     235    void SpaceShip::moveUpDown(const Vector2& value)
     236    {
     237        this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() + value.x);
     238        this->steering_.y += value.x;
     239    }
     240
     241    void SpaceShip::rotateYaw(const Vector2& value)
     242    {
     243        this->localAngularAcceleration_.setY(this->localAngularAcceleration_.y() + value.x);
     244
     245        Pawn::rotateYaw(value);
     246
     247        //This function call adds a lift to the ship when it is rotating to make it's movement more "realistic" and enhance the feeling.
     248        if (abs(this-> getLocalVelocity().z) < stallSpeed_)  {this->moveRightLeft(-lift_ / 5 * value * sqrt(abs(this-> getLocalVelocity().z)));}
     249    }
     250
     251    void SpaceShip::rotatePitch(const Vector2& value)
     252    {
     253        this->localAngularAcceleration_.setX(this->localAngularAcceleration_.x() + value.x*0.8f);
     254
     255        Pawn::rotatePitch(value);
     256
     257        //This function call adds a lift to the ship when it is pitching to make it's movement more "realistic" and enhance the feeling.
     258        if (abs(this-> getLocalVelocity().z) < stallSpeed_)  {this->moveUpDown(lift_ / 5 * value * sqrt(abs(this-> getLocalVelocity().z)));}
     259    }
     260
     261    void SpaceShip::rotateRoll(const Vector2& value)
     262    {
     263        this->localAngularAcceleration_.setZ(this->localAngularAcceleration_.z() + value.x);
     264
     265        Pawn::rotateRoll(value);
     266    }
     267
     268    void SpaceShip::fire()
     269    {
     270    }
     271
     272    /**
     273    @brief
     274        Starts or stops boosting.
     275    @param bBoost
     276        Whether to start or stop boosting.
     277    */
     278    void SpaceShip::boost(bool bBoost)
     279    {
     280        if(bBoost && !this->bBoostCooldown_)
     281        {
     282            this->bBoost_ = true;
     283            Camera* camera = CameraManager::getInstance().getActiveCamera();
     284            this->cameraOriginalPosition_ = camera->getPosition();
     285            this->cameraOriginalOrientation_ = camera->getOrientation();
     286        }
     287        if(!bBoost)
     288        {
     289            this->bBoost_ = false;
     290            this->resetCamera();
    162291        }
    163292    }
     
    167296        this->bBoostCooldown_ = false;
    168297    }
    169 
    170     void SpaceShip::moveFrontBack(const Vector2& value)
    171     {
    172         this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() - value.x);
    173         this->steering_.z = -value.x;
    174     }
    175 
    176     void SpaceShip::moveRightLeft(const Vector2& value)
    177     {
    178         this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() + value.x);
    179         this->steering_.x = value.x;
    180     }
    181 
    182     void SpaceShip::moveUpDown(const Vector2& value)
    183     {
    184         this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() + value.x);
    185         this->steering_.y = value.x;
    186     }
    187 
    188     void SpaceShip::rotateYaw(const Vector2& value)
    189     {
    190         this->localAngularAcceleration_.setY(this->localAngularAcceleration_.y() + value.x);
    191 
    192         Pawn::rotateYaw(value);
    193     }
    194 
    195     void SpaceShip::rotatePitch(const Vector2& value)
    196     {
    197         this->localAngularAcceleration_.setX(this->localAngularAcceleration_.x() + value.x);
    198 
    199         Pawn::rotatePitch(value);
    200     }
    201 
    202     void SpaceShip::rotateRoll(const Vector2& value)
    203     {
    204         this->localAngularAcceleration_.setZ(this->localAngularAcceleration_.z() + value.x);
    205 
    206         Pawn::rotateRoll(value);
    207     }
    208 
    209     // TODO: something seems to call this function every tick, could probably handled a little more efficiently!
    210     void SpaceShip::setBoost(bool bBoost)
    211     {
    212         if(bBoost == this->bBoost_)
     298   
     299    void SpaceShip::shakeCamera(float dt)
     300    {
     301        //make sure the ship is only shaking if it's moving
     302        if (this->getVelocity().squaredLength() > 80.0f)
     303        {
     304            this->shakeDt_ += dt;
     305   
     306            float frequency = this->shakeFrequency_ * (this->getVelocity().squaredLength());
     307   
     308            if (this->shakeDt_ >= 1.0f/frequency)
     309            {
     310                this->shakeDt_ -= 1.0f/frequency;
     311            }
     312   
     313            Degree angle = Degree(sin(this->shakeDt_ *2.0f* math::pi * frequency) * this->shakeAmplitude_);
     314   
     315            //COUT(0) << "Angle: " << angle << std::endl;
     316            Camera* camera = this->getCamera();
     317
     318            //Shaking Camera effect
     319            if (camera != 0)
     320            {
     321                camera->setOrientation(Vector3::UNIT_X, angle);
     322            }
     323        }
     324    }
     325
     326    void SpaceShip::resetCamera()
     327    {
     328        Camera *camera = this->getCamera();
     329
     330        if (camera == 0)
     331        {
     332            COUT(2) << "Failed to reset camera!";
    213333            return;
    214 
    215         if(bBoost)
    216             this->boost();
     334        }
     335   
     336        this->shakeDt_ = 0;
     337        camera->setPosition(this->cameraOriginalPosition_);
     338        camera->setOrientation(this->cameraOriginalOrientation_);
     339    }
     340
     341    void SpaceShip::backupCamera()
     342    {
     343        Camera* camera = CameraManager::getInstance().getActiveCamera();
     344        if(camera != NULL)
     345        {
     346            this->cameraOriginalPosition_ = camera->getPosition();
     347            this->cameraOriginalOrientation_ = camera->getOrientation();
     348        }
     349    }
     350
     351    void SpaceShip::addEngine(orxonox::Engine* engine)
     352    {
     353        //COUT(0)<<"Adding an Engine: " << engine << endl;
     354        this->engineList_.push_back(engine);
     355        engine->addToSpaceShip(this);
     356        this->resetEngineTicks();
     357    }
     358
     359    bool SpaceShip::hasEngine(Engine* engine)
     360    {
     361        for(unsigned int i=0; i<this->engineList_.size(); i++)
     362        {
     363            if(this->engineList_[i]==engine)
     364                return true;
     365        }
     366        return false;
     367    }
     368
     369    Engine* SpaceShip::getEngine(unsigned int i)
     370    {
     371        if(this->engineList_.size()>=i)
     372            return 0;
    217373        else
    218         {
    219             this->bBoost_ = false;
    220         }
    221     }
    222 
    223     void SpaceShip::fire()
    224     {
    225     }
    226 
    227     void SpaceShip::boost()
    228     {
    229         if(!this->bBoostCooldown_)
    230             this->bBoost_ = true;
    231     }
    232 
    233     void SpaceShip::loadEngineTemplate()
    234     {
    235         if (!this->enginetemplate_.empty())
    236         {
    237             Template* temp = Template::getTemplate(this->enginetemplate_);
    238 
    239             if (temp)
    240             {
    241                 Identifier* identifier = temp->getBaseclassIdentifier();
    242 
    243                 if (identifier)
    244                 {
    245                     BaseObject* object = identifier->fabricate(this);
    246                     this->engine_ = orxonox_cast<Engine*>(object);
    247 
    248                     if (this->engine_)
    249                     {
    250                         this->engine_->addTemplate(temp);
    251                         this->engine_->addToSpaceShip(this);
    252                     }
    253                     else
    254                     {
    255                         object->destroy();
    256                     }
    257                 }
    258             }
    259         }
    260     }
    261 
    262     void SpaceShip::setEngine(Engine* engine)
    263     {
    264         this->engine_ = engine;
    265         if (engine && engine->getShip() != this)
    266             engine->addToSpaceShip(this);
     374            return this->engineList_[i];
     375    }
     376
     377    void SpaceShip::removeAllEngines()
     378    {
     379        while(this->engineList_.size())
     380            this->engineList_.back()->destroy();
     381    }
     382   
     383    void SpaceShip::removeEngine(Engine* engine)
     384    {
     385        for(std::vector<Engine*>::iterator it=this->engineList_.begin(); it!=this->engineList_.end(); ++it)
     386        {
     387            if(*it==engine)
     388            {
     389                this->engineList_.erase(it);
     390                return;
     391            }
     392        }
     393    }
     394
     395    void SpaceShip::setSpeedFactor(float factor)
     396    {
     397        for(unsigned int i=0; i<this->engineList_.size(); i++)
     398            this->engineList_[i]->setSpeedFactor(factor);
     399    }
     400    float SpaceShip::getSpeedFactor() // Calculate mean SpeedFactor.
     401    {
     402        float ret = 0; unsigned int i = 0;
     403        for(; i<this->engineList_.size(); i++)
     404            ret += this->engineList_[i]->getSpeedFactor();
     405        ret /= (float)i;
     406        return ret;
     407    }
     408    float SpaceShip::getMaxSpeedFront()
     409    {
     410        float ret=0;
     411        for(unsigned int i=0; i<this->engineList_.size(); i++)
     412        {
     413            if(this->engineList_[i]->getMaxSpeedFront() > ret)
     414                ret = this->engineList_[i]->getMaxSpeedFront();
     415        }
     416        return ret;
     417    }
     418
     419    float SpaceShip::getBoostFactor()
     420    {
     421        float ret = 0; unsigned int i=0;
     422        for(; i<this->engineList_.size(); i++)
     423            ret += this->engineList_[i]->getBoostFactor();
     424        ret /= (float)i;
     425        return ret;
    267426    }
    268427
     
    270429    {
    271430        std::vector<PickupCarrier*>* list = new std::vector<PickupCarrier*>();
    272         list->push_back(this->engine_);
     431        for(unsigned int i=0; i<this->engineList_.size(); i++)
     432            list->push_back(this->engineList_[i]);
    273433        return list;
    274434    }
     435   
     436    void SpaceShip::changedEnableMotionBlur()
     437    {
     438        if (!this->bEnableMotionBlur_)
     439        {
     440            this->boostBlur_->destroy();
     441            this->boostBlur_ = 0;
     442        }
     443    }
     444
    275445}
  • code/trunk/src/orxonox/worldentities/pawns/SpaceShip.h

    r7801 r8706  
    5959
    6060            virtual void fire();
    61             virtual void boost();
     61            virtual void boost(bool bBoost); // Starts or stops boosting.
    6262
    63             void setEngine(Engine* engine);
    64             inline Engine* getEngine() const
    65                 { return this->engine_; }
     63            void addEngine(Engine* engine);
     64            bool hasEngine(Engine* engine);
     65            Engine* getEngine(unsigned int i); // This one's for XMLPort
     66            inline const std::vector<Engine*>& getEngineList()
     67                { return this->engineList_; }
     68            void removeEngine(Engine* engine);
     69            void removeAllEngines();
     70
     71            void setSpeedFactor(float factor);
     72            float getSpeedFactor(); // Gets mean speed factor
     73            float getMaxSpeedFront(); // gets largest speed forward
     74            float getBoostFactor(); // gets mean boost factor
    6675
    6776            inline void setSteeringDirection(const Vector3& direction)
     
    6978            inline const Vector3& getSteeringDirection() const
    7079                { return this->steering_; }
     80            inline void resetEngineTicks()
     81                { this->engineTicksNotDone = this->engineList_.size(); }
     82            inline void oneEngineTickDone()
     83                { this->engineTicksNotDone--; }
     84            inline bool hasEngineTicksRemaining()
     85                { return (this->engineTicksNotDone>0); }
    7186
    72             void setBoost(bool bBoost);
    7387            inline bool getBoost() const
    7488                { return this->bBoost_; }
    7589
    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_; }
     90            inline float getBoostPower() const
     91                { return this->boostPower_; }
     92            inline float getInitialBoostPower() const
     93                { return this->initialBoostPower_; }
    8094
    81             inline void setPermanentBoost(bool bPermanent)
    82                 { this->bPermanentBoost_ = bPermanent; }
    83             inline bool getPermanentBoost() const
    84                 { return this->bPermanentBoost_; }
     95            inline bool isBoostCoolingDown() const
     96                { return bBoostCooldown_; }
    8597
    8698        protected:
     
    90102            bool bBoost_;
    91103            bool bBoostCooldown_;
    92             bool bPermanentBoost_;
    93104            float boostPower_;
    94105            float initialBoostPower_;
     
    96107            float boostPowerRate_;
    97108            float boostCooldownDuration_;
     109            float lift_;
     110            float stallSpeed_;
    98111            Vector3 steering_;
    99112            float primaryThrust_;
     
    103116            btVector3 localAngularAcceleration_;
    104117
     118            float shakeFrequency_;
     119            float shakeAmplitude_;
     120
    105121        private:
    106122            void registerVariables();
    107123            virtual bool isCollisionTypeLegal(WorldEntity::CollisionType type) const;
     124           
     125            //All things booster
     126            void changedEnableMotionBlur();
     127            void boostCooledDown(void);
     128       
     129            void resetCamera();
     130            void backupCamera();
     131            void shakeCamera(float dt);
    108132
    109             void loadEngineTemplate();
    110            
    111             void boostCooledDown(void);
     133            Shader* boostBlur_;
     134            float blurStrength_;
     135            bool bEnableMotionBlur_;
    112136
    113             std::string enginetemplate_;
    114             Engine* engine_;
     137            std::vector<Engine*> engineList_;
     138            int engineTicksNotDone; // Used for knowing when to reset temporary variables.
    115139            Timer timer_;
     140            Vector3 cameraOriginalPosition_;
     141            Quaternion cameraOriginalOrientation_;
     142       
     143            float shakeDt_;
    116144    };
    117145}
Note: See TracChangeset for help on using the changeset viewer.