Changeset 8706 for code/trunk/src
- Timestamp:
- Jun 14, 2011, 8:53:28 PM (14 years ago)
- Location:
- code/trunk
- Files:
-
- 6 deleted
- 145 edited
- 46 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/libraries/core/BaseObject.cc
r7401 r8706 195 195 void BaseObject::addTemplate(Template* temp) 196 196 { 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 197 210 this->templates_.insert(temp); 198 if( temp->isLink() )199 {200 this->networkTemplateNames_.insert(temp->getLink());201 assert( !Template::getTemplate(temp->getLink())->isLink() );202 }203 else204 this->networkTemplateNames_.insert(temp->getName());205 211 temp->applyOn(this); 206 212 } -
code/trunk/src/libraries/core/ConfigValueContainer.h
r7401 r8706 109 109 */ 110 110 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&) 112 112 { 113 113 this->init(type, identifier, sectionname, varname); … … 125 125 */ 126 126 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>&) 128 128 { 129 129 this->init(type, identifier, sectionname, varname); -
code/trunk/src/libraries/core/CoreIncludes.h
r7401 r8706 171 171 */ 172 172 template <class T> 173 inline Identifier* ClassByObjectType(const T* object)173 inline Identifier* ClassByObjectType(const T*) 174 174 { 175 175 return ClassIdentifier<T>::getIdentifier(); -
code/trunk/src/libraries/core/GUIManager.cc
r8530 r8706 38 38 #include <CEGUIDefaultLogger.h> 39 39 #include <CEGUIExceptions.h> 40 #include <CEGUIFontManager.h> 40 41 #include <CEGUIInputEvent.h> 41 42 #include <CEGUIMouseCursor.h> … … 44 45 #include <CEGUIWindow.h> 45 46 #include <CEGUIWindowManager.h> 47 #include <CEGUIXMLAttributes.h> 46 48 #include <elements/CEGUIListbox.h> 47 49 #include <elements/CEGUIListboxItem.h> … … 260 262 COUT(3) << "Initialising CEGUI." << std::endl; 261 263 264 this->oldCEGUI_ = false; 265 262 266 // Note: No SceneManager specified yet 263 267 #ifdef ORXONOX_OLD_CEGUI 264 268 guiRenderer_ = new OgreCEGUIRenderer(GraphicsManager::getInstance().getRenderWindow(), Ogre::RENDER_QUEUE_OVERLAY, false, 3000); 265 269 resourceProvider_ = guiRenderer_->createResourceProvider(); 270 this->oldCEGUI_ = true; 266 271 #else 267 272 guiRenderer_ = &OgreRenderer::create(*GraphicsManager::getInstance().getRenderWindow()); … … 729 734 } 730 735 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 731 778 } -
code/trunk/src/libraries/core/GUIManager.h
r8530 r8706 128 128 129 129 // 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 133 134 134 135 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 135 142 136 143 private: … … 185 192 static const std::string defaultScheme_; 186 193 std::string guiScheme_; 187 194 bool oldCEGUI_; 195 188 196 int numScrollLines_; ///< How many lines to scroll in a list if the scroll wheel is used 189 197 -
code/trunk/src/libraries/core/Game.cc
r8423 r8706 556 556 { 557 557 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); 559 559 560 560 // If state requires graphics, load it -
code/trunk/src/libraries/core/GraphicsManager.h
r8423 r8706 109 109 // event from Ogre::LogListener 110 110 void messageLogged(const std::string& message, Ogre::LogMessageLevel lml, 111 111 bool maskDebug, const std::string& logName); 112 112 113 113 // console commands -
code/trunk/src/libraries/core/Identifier.h
r8351 r8706 119 119 120 120 /// Returns the network ID to identify a class through the network. 121 inline constuint32_t getNetworkID() const { return this->networkID_; }121 inline uint32_t getNetworkID() const { return this->networkID_; } 122 122 void setNetworkID(uint32_t id); 123 123 -
code/trunk/src/libraries/core/Super.h
r8351 r8706 100 100 } \ 101 101 \ 102 static void apply(void* temp) {} \102 static void apply(void*) {} \ 103 103 \ 104 static void apply(baseclass* temp) \104 static void apply(baseclass*) \ 105 105 { \ 106 106 ClassIdentifier<T>* identifier = ClassIdentifier<T>::getIdentifier(); \ … … 312 312 struct SuperFunctionInitialization 313 313 { 314 static void initialize(ClassIdentifier<T>* identifier) {}314 static void initialize(ClassIdentifier<T>*) {} 315 315 }; 316 316 … … 321 321 struct SuperFunctionDestruction 322 322 { 323 static void destroy(ClassIdentifier<T>* identifier) {}323 static void destroy(ClassIdentifier<T>*) {} 324 324 }; 325 325 -
code/trunk/src/libraries/core/ThreadWin.cc
- Property svn:eol-style set to native
-
code/trunk/src/libraries/core/command/Functor.h
r7871 r8706 411 411 // Helper class, used to call a function-pointer with a given object and parameters and to return its return-value (if available) 412 412 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)(); } }; 418 418 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; } }; 424 424 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)(); } }; 430 430 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; } }; 436 436 437 437 // 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 265 265 return; 266 266 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_); 268 268 if (previous_offset < this->commandHistory_.size() && command == this->commandHistory_[previous_offset]) 269 269 return; -
code/trunk/src/libraries/network/LANDiscovery.cc
r8351 r8706 38 38 namespace orxonox 39 39 { 40 ManageScopedSingleton(LANDiscovery, ScopeID:: Root, true);40 ManageScopedSingleton(LANDiscovery, ScopeID::Graphics, true); 41 41 42 42 LANDiscovery::LANDiscovery() … … 49 49 LANDiscovery::~LANDiscovery() 50 50 { 51 enet_host_destroy(this->host_); 51 if (this->host_ != NULL) 52 enet_host_destroy(this->host_); 52 53 } 53 54 -
code/trunk/src/libraries/network/Server.cc
r8351 r8706 413 413 414 414 COUT(4) << "sending welcome" << std::endl; 415 packet::Welcome *w = new packet::Welcome(clientID , OBJECTID_UNKNOWN);415 packet::Welcome *w = new packet::Welcome(clientID); 416 416 w->setPeerID(clientID); 417 417 b = w->send( static_cast<Host*>(this) ); -
code/trunk/src/libraries/network/packet/Welcome.cc
r7801 r8706 44 44 #define _ENDIANTEST _CLIENTID + sizeof(uint32_t) 45 45 46 Welcome::Welcome( uint32_t clientID , uint32_t shipID)46 Welcome::Welcome( uint32_t clientID ) 47 47 : Packet() 48 48 { -
code/trunk/src/libraries/network/packet/Welcome.h
r7801 r8706 41 41 { 42 42 public: 43 Welcome( uint32_t clientID , uint32_t shipID);43 Welcome( uint32_t clientID ); 44 44 Welcome( uint8_t* data, uint32_t clientID ); 45 45 virtual ~Welcome(); -
code/trunk/src/libraries/network/synchronisable/Serialise.h
r7284 r8706 84 84 85 85 /** @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>& ) 87 87 { 88 88 return sizeof(uint32_t); -
code/trunk/src/libraries/network/synchronisable/Synchronisable.cc
r8329 r8706 383 383 /** 384 384 * This function determines, wheter the object should be saved to the bytestream (according to its syncmode/direction) 385 * @param id gamestate id386 385 * @param mode Synchronisation mode (toclient, toserver or bidirectional) 387 386 * @return true/false … … 397 396 /** 398 397 * This function determines, wheter the object should accept data from the bytestream (according to its syncmode/direction) 399 * @param id gamestate id400 398 * @param mode Synchronisation mode (toclient, toserver or bidirectional) 401 399 * @return true/false -
code/trunk/src/libraries/network/synchronisable/Synchronisable.h
r8329 r8706 50 50 namespace ObjectDirection{ 51 51 enum Value{ 52 None=0x0, 52 53 ToClient=0x1, 53 54 ToServer=0x2, -
code/trunk/src/libraries/util/Convert.h
r8351 r8706 143 143 struct ConverterFallback 144 144 { 145 ORX_FORCEINLINE static bool convert(ToType* output, const FromType& input)145 ORX_FORCEINLINE static bool convert(ToType* /*output*/, const FromType& /*input*/) 146 146 { 147 147 COUT(2) << "Could not convert value of type " << typeid(FromType).name() -
code/trunk/src/libraries/util/Exception.h
r7401 r8706 110 110 virtual const std::string& getDescription() const { return this->description_; } 111 111 //! 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_; } 113 113 //! Returns the function in which the exception occurred. 114 114 virtual const std::string& getFunctionName() const { return this->functionName_; } -
code/trunk/src/libraries/util/Math.h
r8351 r8706 174 174 return (x % max); 175 175 else 176 return ((x % max) + max); 176 { 177 T temp = x % max; 178 return (temp < 0) ? (temp + max) : temp; 179 } 177 180 } 178 181 -
code/trunk/src/libraries/util/MultiTypeValue.h
r7401 r8706 255 255 return 4*returnSize(this->value_.x); 256 256 } 257 template <> inline void MT_Value<void*>::importData( uint8_t*& mem)257 template <> inline void MT_Value<void*>::importData( uint8_t*& /*mem*/ ) 258 258 { 259 259 assert(0); 260 260 } 261 template <> inline void MT_Value<void*>::exportData( uint8_t*& mem) const261 template <> inline void MT_Value<void*>::exportData( uint8_t*& /*mem*/ ) const 262 262 { 263 263 assert(0); -
code/trunk/src/libraries/util/ScopedSingletonManager.h
r7401 r8706 247 247 248 248 //! Destroys the singleton instance - overloaded for OrxonoxClass, calls OrxonoxClass::destroy() 249 void destroy(OrxonoxClass* ptr)249 void destroy(OrxonoxClass*) 250 250 { 251 251 singletonPtr_->destroy(); 252 252 } 253 253 //! Destroys the singleton instance - overloaded for void*, calls delete 254 void destroy(void* ptr)254 void destroy(void*) 255 255 { 256 256 delete singletonPtr_; -
code/trunk/src/libraries/util/Serialise.h
r7401 r8706 87 87 // =========== bool 88 88 89 template <> inline uint32_t returnSize( const bool& variable)89 template <> inline uint32_t returnSize( const bool& ) 90 90 { 91 91 return sizeof(uint8_t); … … 111 111 // =========== char 112 112 113 template <> inline uint32_t returnSize( const char& variable)113 template <> inline uint32_t returnSize( const char& ) 114 114 { 115 115 return sizeof(uint8_t); … … 135 135 // =========== unsigned char 136 136 137 template <> inline uint32_t returnSize( const unsigned char& variable)137 template <> inline uint32_t returnSize( const unsigned char& ) 138 138 { 139 139 return sizeof(uint8_t); … … 159 159 // =========== short 160 160 161 template <> inline uint32_t returnSize( const short& variable)161 template <> inline uint32_t returnSize( const short& ) 162 162 { 163 163 return sizeof(int16_t); … … 183 183 // =========== unsigned short 184 184 185 template <> inline uint32_t returnSize( const unsigned short& variable)185 template <> inline uint32_t returnSize( const unsigned short& ) 186 186 { 187 187 return sizeof(uint16_t); … … 207 207 // =========== int 208 208 209 template <> inline uint32_t returnSize( const int& variable)209 template <> inline uint32_t returnSize( const int& ) 210 210 { 211 211 return sizeof(int32_t); … … 231 231 // =========== unsigned int 232 232 233 template <> inline uint32_t returnSize( const unsigned int& variable)233 template <> inline uint32_t returnSize( const unsigned int& ) 234 234 { 235 235 return sizeof(uint32_t); … … 255 255 // =========== long 256 256 257 template <> inline uint32_t returnSize( const long& variable)257 template <> inline uint32_t returnSize( const long& ) 258 258 { 259 259 return sizeof(int32_t); … … 279 279 // =========== unsigned long 280 280 281 template <> inline uint32_t returnSize( const unsigned long& variable)281 template <> inline uint32_t returnSize( const unsigned long& ) 282 282 { 283 283 return sizeof(uint32_t); … … 303 303 // =========== long long 304 304 305 template <> inline uint32_t returnSize( const long long& variable)305 template <> inline uint32_t returnSize( const long long& ) 306 306 { 307 307 return sizeof(int64_t); … … 327 327 // =========== unsigned long long 328 328 329 template <> inline uint32_t returnSize( const unsigned long long& variable)329 template <> inline uint32_t returnSize( const unsigned long long& ) 330 330 { 331 331 return sizeof(uint64_t); … … 351 351 // =========== float 352 352 353 template <> inline uint32_t returnSize( const float& variable)353 template <> inline uint32_t returnSize( const float& ) 354 354 { 355 355 return sizeof(uint32_t); … … 375 375 // =========== double 376 376 377 template <> inline uint32_t returnSize( const double& variable)377 template <> inline uint32_t returnSize( const double& ) 378 378 { 379 379 return sizeof(uint64_t); … … 399 399 // =========== long double 400 400 401 template <> inline uint32_t returnSize( const long double& variable)401 template <> inline uint32_t returnSize( const long double& ) 402 402 { 403 403 return sizeof(uint64_t); … … 452 452 // =========== Degree 453 453 454 template <> inline uint32_t returnSize( const Degree& variable)454 template <> inline uint32_t returnSize( const Degree& ) 455 455 { 456 456 return sizeof(Ogre::Real); … … 479 479 // =========== Radian 480 480 481 template <> inline uint32_t returnSize( const Radian& variable)481 template <> inline uint32_t returnSize( const Radian& ) 482 482 { 483 483 return sizeof(Ogre::Real); -
code/trunk/src/libraries/util/SubString.h
r7401 r8706 110 110 SL_COMMENT, //!< In Comment mode. 111 111 SL_PARENTHESES, //!< Between parentheses (usually '{' and '}') 112 SL_PARENTHESESESCAPE, //!< Between parentheses with the internal escape character, that escapes even the closing par anthesis character.112 SL_PARENTHESESESCAPE, //!< Between parentheses with the internal escape character, that escapes even the closing parenthesis character. 113 113 }; 114 114 … … 169 169 /// Returns the number of tokens stored in this SubString 170 170 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 doken171 /// Returns the i'th token from the subset of strings @param index The index of the requested token 172 172 inline const std::string& operator[](unsigned int index) const { return this->tokens_[index]; } 173 173 /// Returns the i'th token from the subset of strings @param index The index of the requested token … … 209 209 SPLIT_LINE_STATE start_state = SL_NORMAL); 210 210 211 std::vector<std::string> tokens_; ///< The tokens after split ing the input line211 std::vector<std::string> tokens_; ///< The tokens after splitting the input line 212 212 std::vector<bool> bTokenInSafemode_; ///< Saves for each token if it was in safe mode (between quotation marks or parenthesis) 213 213 }; -
code/trunk/src/modules/CMakeLists.txt
r8457 r8706 27 27 28 28 ADD_SUBDIRECTORY(designtools) 29 ADD_SUBDIRECTORY(gametypes) 29 30 ADD_SUBDIRECTORY(notifications) 30 31 ADD_SUBDIRECTORY(objects) … … 34 35 ADD_SUBDIRECTORY(portals) 35 36 ADD_SUBDIRECTORY(questsystem) 37 ADD_SUBDIRECTORY(tetris) 36 38 ADD_SUBDIRECTORY(weapons) 39 ADD_SUBDIRECTORY(docking) -
code/trunk/src/modules/notifications/CMakeLists.txt
r7403 r8706 1 1 SET_SOURCE_FILES(NOTIFICATIONS_SRC_FILES 2 Notification.cc3 2 NotificationDispatcher.cc 4 3 NotificationManager.cc 5 4 NotificationQueue.cc 5 NotificationQueueCEGUI.cc 6 6 ) 7 7 … … 13 13 TOLUA_FILES 14 14 NotificationManager.h 15 NotificationQueue .h15 NotificationQueueCEGUI.h 16 16 PCH_FILE 17 17 NotificationsPrecompiledHeaders.h -
code/trunk/src/modules/notifications/NotificationDispatcher.cc
r7552 r8706 41 41 42 42 #include "infos/PlayerInfo.h" 43 #include "interfaces/NotificationListener.h" 43 44 #include "interfaces/PlayerTrigger.h" 44 45 #include "worldentities/pawns/Pawn.h" 45 46 #include "NotificationManager.h"47 46 48 47 namespace orxonox … … 61 60 RegisterObject(NotificationDispatcher); 62 61 63 this->sender_ = Notification Manager::NONE;62 this->sender_ = NotificationListener::NONE; 64 63 this->registerVariables(); 65 64 } … … 114 113 { 115 114 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); 117 117 } 118 118 else if(GameMode::isServer()) … … 140 140 141 141 PlayerTrigger* pTrigger = orxonox_cast<PlayerTrigger*>(trigger); 142 P awn* pawn= NULL;142 PlayerInfo* player = NULL; 143 143 144 144 // If the trigger is a PlayerTrigger. … … 148 148 return false; 149 149 else 150 p awn= pTrigger->getTriggeringPlayer();150 player = pTrigger->getTriggeringPlayer(); 151 151 } 152 152 else 153 153 return false; 154 154 155 if(p awn== NULL)155 if(player == NULL) 156 156 { 157 157 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;167 158 return false; 168 159 } -
code/trunk/src/modules/notifications/NotificationManager.cc
r8079 r8706 36 36 #include "core/command/ConsoleCommand.h" 37 37 #include "core/CoreIncludes.h" 38 #include "core/GUIManager.h"39 38 #include "core/LuaState.h" 40 #include "network/Host.h"41 #include "network/NetworkFunction.h"42 39 #include "util/ScopedSingletonManager.h" 43 40 44 41 #include "interfaces/NotificationListener.h" 45 42 46 #include "Notification.h"47 43 #include "NotificationQueue.h" 48 49 #include "ToluaBindNotifications.h" 44 #include "NotificationQueueCEGUI.h" 50 45 51 46 namespace orxonox 52 47 { 53 48 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 60 49 ManageScopedSingleton(NotificationManager, ScopeID::Root, false); 61 50 62 // Setting console command to enter the edit mode.63 SetConsoleCommand("enterEditMode", &NotificationManager::enterEditMode);64 65 registerStaticNetworkFunction(NotificationManager::sendNotification);66 67 51 /** 68 52 @brief … … 73 57 RegisterRootObject(NotificationManager); 74 58 75 this->highestIndex_ = 0;76 77 ModifyConsoleCommand("enterEditMode").setObject(this);78 79 59 COUT(3) << "NotificatioManager created." << std::endl; 80 60 } … … 86 66 NotificationManager::~NotificationManager() 87 67 { 88 ModifyConsoleCommand("enterEditMode").setObject(NULL);89 90 68 // Destroys all Notifications. 91 69 for(std::multimap<std::time_t, Notification*>::iterator it = this->allNotificationsList_.begin(); it!= this->allNotificationsList_.end(); it++) … … 106 84 while(it != this->queues_.end()) 107 85 { 108 it->second->destroy( true);86 it->second->destroy(); 109 87 it = this->queues_.begin(); 110 88 } … … 115 93 /** 116 94 @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. 118 97 @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. 122 99 @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. 146 166 @param notification 147 167 The Notification to be registered. … … 158 178 this->allNotificationsList_.insert(std::pair<std::time_t, Notification*>(time, notification)); 159 179 160 if(notification->getSender() == Notification Manager::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. 161 181 return true; 162 182 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. 173 192 if(all || bAll || set.find(notification->getSender()) != set.end()) 174 193 { 175 194 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. 178 197 } 179 198 } … … 186 205 /** 187 206 @brief 188 Unregisters a Notification within the NotificationManager for a given Notification Listener.207 Unregisters a Notification within the NotificationManager for a given NotificationQueue. 189 208 @param notification 190 209 A pointer to the Notification to be unregistered. 191 @param listener192 A pointer to the Notification Listenerthe Notification is unregistered for.193 */ 194 void NotificationManager::unregisterNotification(Notification* notification, Notification Listener* listener)210 @param queue 211 A pointer to the NotificationQueue the Notification is unregistered for. 212 */ 213 void NotificationManager::unregisterNotification(Notification* notification, NotificationQueue* queue) 195 214 { 196 215 assert(notification); 197 assert( listener);198 199 // Remove the Notification from the list of Notifications of the input Notification Listener.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; 203 222 } 204 223 … … 230 249 /** 231 250 @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. 317 254 @param map 318 255 A pointer to a multimap, in which the notifications are stored. The map needs to have been allocated. … … 324 261 Returns true if successful. 325 262 */ 326 void NotificationManager::getNotifications(Notification Listener* 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); 329 266 assert(map); 330 267 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. 332 269 333 270 std::multimap<std::time_t,Notification*>::iterator it, itLowest, itHighest; … … 342 279 /** 343 280 @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 } 353 308 } 354 309 } … … 357 312 @brief 358 313 Registers a NotificationQueue. 359 This makes sure that the NotificationQueue can be a ttained 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. 360 315 @param queue 361 316 A pointer to the NotificationQueue to be registered. … … 365 320 bool NotificationManager::registerQueue(NotificationQueue* queue) 366 321 { 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 367 353 COUT(4) << "NotificationQueue '" << queue->getName() << "' registered with the NotificationManager." << std::endl; 368 return t his->queues_.insert(std::pair<const std::string, NotificationQueue*>(queue->getName(), queue)).second;354 return true; 369 355 } 370 356 … … 377 363 void NotificationManager::unregisterQueue(NotificationQueue* queue) 378 364 { 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 379 386 COUT(4) << "NotificationQueue '" << queue->getName() << "' unregistered with the NotificationManager." << std::endl; 380 this->queues_.erase(queue->getName());381 }382 383 /**384 @brief385 Loads all the NotificationQueues that should exist.386 */387 void NotificationManager::loadQueues(void)388 {389 new NotificationQueue("all");390 }391 392 /**393 @brief394 Creates a new NotificationQueue.395 This is used in lua.396 @param name397 The name of the new NotificationQueue.398 */399 void NotificationManager::createQueue(const std::string& name)400 {401 new NotificationQueue(name);402 387 } 403 388 … … 420 405 } 421 406 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 422 464 } -
code/trunk/src/modules/notifications/NotificationManager.h
r7552 r8706 42 42 #include <string> 43 43 44 #include "core/OrxonoxClass.h" 44 45 #include "util/Singleton.h" 45 #include " core/OrxonoxClass.h"46 #include "interfaces/NotificationListener.h" 46 47 47 48 namespace orxonox // tolua_export … … 50 51 /** 51 52 @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. 55 109 56 110 @author … … 60 114 */ 61 115 class _NotificationsExport NotificationManager // tolua_export 62 : public Singleton<NotificationManager>, public OrxonoxClass116 : public Singleton<NotificationManager>, public NotificationListener 63 117 { // tolua_export 64 118 friend class Singleton<NotificationManager>; … … 67 121 virtual ~NotificationManager(); 68 122 69 virtual void preDestroy(void); // !<Is called before the object is destroyed.123 virtual void preDestroy(void); // Is called before the object is destroyed. 70 124 71 125 /** … … 75 129 static NotificationManager& getInstance() { return Singleton<NotificationManager>::getInstance(); } // tolua_export 76 130 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); 79 133 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. 82 136 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. 89 138 90 139 /** 91 @brief Fetches the Notifications for a specific Notification Listener in a timeframe from now-timeDelayto now and stores them in the input map.92 @param listener The NotificationListenerthe 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. 93 142 @param map A pointer to a multimap, in which the notifications are stored. The map needs to have been allocated. 94 143 @param timeDelay The timespan. 95 144 @return Returns true if successful. 96 145 */ 97 void getNotifications(Notification Listener* 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)); } 99 148 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. 101 150 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. 104 153 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. 110 157 111 158 private: 112 159 static NotificationManager* singletonPtr_s; 113 160 114 unsigned int highestIndex_; //!< This variable holds the highest index (resp. key) in notificationLists_s, to secure that no key appears twice.115 116 161 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. 119 163 120 164 std::map<const std::string, NotificationQueue*> queues_; //!< The list of NotificationQueues created by the NotificationManager. 121 165 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. 123 170 124 171 }; // tolua_export -
code/trunk/src/modules/notifications/NotificationQueue.cc
r8079 r8706 38 38 39 39 #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" 44 41 #include "util/SubString.h" 45 46 #include "Notification.h"47 42 48 43 namespace orxonox 49 44 { 50 45 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 54 74 @param name 55 75 The name of the new NotificationQueue. It needs to be unique … … 62 82 The time during which a Notification is (at most) displayed. 63 83 */ 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 { 80 127 // Register the NotificationQueue with the NotificationManager. 81 128 bool queueRegistered = NotificationManager::getInstance().registerQueue(this); … … 88 135 } 89 136 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 105 137 COUT(3) << "NotificationQueue '" << this->getName() << "' created." << std::endl; 106 }107 108 /**109 @brief110 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 @brief128 Destroys the NotificationQueue.129 Used in lua and NotificationManager.130 @param noGraphics131 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 @brief146 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()) + ")");152 138 } 153 139 … … 161 147 { 162 148 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 containi g 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. 166 152 167 153 std::multiset<NotificationContainer*, NotificationContainerCompare>::iterator it = this->ordering_.begin(); … … 177 163 } 178 164 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 179 188 /** 180 189 @brief 181 190 Updates the NotificationQueue. 182 191 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. 183 193 */ 184 194 void NotificationQueue::update(void) … … 188 198 std::multimap<std::time_t, Notification*>* notifications = new std::multimap<std::time_t, Notification*>; 189 199 // 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_); 191 204 192 205 if(!notifications->empty()) 193 206 { 194 // Add all Notifications .207 // Add all Notifications that have been created after this NotificationQueue was created. 195 208 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 } 197 213 } 198 214 … … 222 238 @brief 223 239 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. 225 241 @param notification 226 242 The Notification to be pushed. … … 246 262 this->notifications_.insert(this->notifications_.begin(), container); 247 263 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); 251 266 252 267 COUT(5) << "Notification \"" << notification->getMessage() << "\" pushed to NotificationQueue '" << this->getName() << "'" << endl; 268 COUT(3) << "NotificationQueue \"" << this->getName() << "\": " << notification->getMessage() << endl; 253 269 } 254 270 … … 279 295 delete container; 280 296 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(); 284 299 } 285 300 … … 305 320 delete *containerIterator; 306 321 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); 310 325 } 311 326 … … 314 329 Clears the NotificationQueue by removing all NotificationContainers. 315 330 @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. 317 332 */ 318 333 void NotificationQueue::clear(bool noGraphics) … … 326 341 this->notifications_.clear(); 327 342 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() + "\")");332 343 } 333 344 … … 354 365 return; 355 366 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 356 373 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()) 359 384 this->update(); 360 385 } … … 364 389 Sets the maximum number of seconds a Notification is displayed. 365 390 @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) 371 394 { 372 395 if(this->displayTime_ == time) 373 396 return; 374 397 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 375 403 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()) 378 414 this->update(); 379 415 } … … 381 417 /** 382 418 @brief 383 Produces all targets of the NotificationQueue concat inated as string, with commas (',') as seperators.419 Produces all targets of the NotificationQueue concatenated as string, with commas (',') as separators. 384 420 @return 385 421 Returns the targets as a string. … … 407 443 The targets are the senders whose Notifications are displayed in this queue. 408 444 @param targets 409 Accepts a string of targets, each sep erated by commas (','), spaces are ignored.445 Accepts a string of targets, each separated by commas (','), spaces are ignored. 410 446 */ 411 447 void NotificationQueue::setTargets(const std::string & targets) … … 417 453 this->targets_.insert(string[i]); 418 454 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; 424 483 } 425 484 -
code/trunk/src/modules/notifications/NotificationQueue.h
r7552 r8706 45 45 #include "NotificationManager.h" 46 46 47 #include "core/BaseObject.h" 47 48 #include "tools/interfaces/Tickable.h" 48 #include " interfaces/NotificationListener.h"49 50 namespace orxonox // tolua_export51 { // tolua_export49 #include "network/synchronisable/Synchronisable.h" 50 51 namespace orxonox 52 { 52 53 53 54 /** … … 78 79 Displays @ref orxonox::Notification "Notifications" from specific senders. 79 80 80 There are quite some parameters that influence the behavio ur of the NotificationQueue:81 There are quite some parameters that influence the behavior of the NotificationQueue: 81 82 - @b name The name of the NotificationQueue. It needs to be unique. 82 83 - @b senders The senders that are targets of this NotificationQueue, i.e. the names of senders whose Notifications this NotificationQueue displays. … … 89 90 @ingroup Notifications 90 91 */ 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 { 94 94 95 95 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); 97 97 virtual ~NotificationQueue(); 98 98 99 //! Destroys the NotificationQueue.100 v oid destroy(bool noGraphics = false); // tolua_export101 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. 106 106 107 107 // tolua_begin … … 110 110 @return Returns the name. 111 111 */ 112 inline const std::string& getName( ) const113 { 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. 116 116 /** 117 117 @brief Returns the maximum number of Notifications displayed. 118 118 @return Returns maximum size. 119 119 */ 120 inline unsigned int getMaxSize( ) const120 inline unsigned int getMaxSize(void) const 121 121 { return this->maxSize_; } 122 122 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. 124 124 /** 125 125 @brief Returns the time interval the Notification is displayed. 126 126 @return Returns the display time. 127 127 */ 128 inline unsigned int getDisplayTime() const128 inline int getDisplayTime(void) const 129 129 { return this->displayTime_; } 130 130 // tolua_end 131 void maxSizeChanged(void); // Is called when the maximum number of displayed Notifications has changed. 132 void displayTimeChanged(void); 131 133 132 134 /** … … 134 136 @return Returns the size of the NotificationQueue. 135 137 */ 136 inline unsigned int getSize( ) const138 inline unsigned int getSize(void) const 137 139 { return this->size_; } 138 140 … … 141 143 @return Returns a set of strings holding the different targets. 142 144 */ 143 inline const std::set<std::string> & getTargetsSet( )145 inline const std::set<std::string> & getTargetsSet(void) 144 146 { return this->targets_; } 145 147 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: 152 182 static const unsigned int DEFAULT_SIZE = 5; //!< The default maximum number of Notifications displayed. 153 183 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 157 191 unsigned int maxSize_; //!< The maximal number of Notifications displayed. 158 192 unsigned int size_; //!< The number of Notifications displayed. 159 unsignedint displayTime_; //!< The time a Notification is displayed.193 int displayTime_; //!< The time a Notification is displayed. 160 194 161 195 bool registered_; //!< Helper variable to remember whether the NotificationQueue is registered already. … … 169 203 NotificationContainer timeLimit_; //!< Helper object to check against to determine whether Notifications have expired. 170 204 171 void create(void); //!< Creates the NotificationQueue in lua.172 173 205 void setName(const std::string& name); //!< Sets the name of the NotificationQueue. 174 206 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 51 51 this->setSender("simpleNotification"); 52 52 53 this->setSyncMode( 0x0);53 this->setSyncMode(ObjectDirection::None); 54 54 } 55 55 -
code/trunk/src/modules/objects/CMakeLists.txt
r7163 r8706 4 4 Planet.cc 5 5 Script.cc 6 SpaceBoundaries.cc 6 7 ) 7 8 -
code/trunk/src/modules/objects/ObjectsPrereqs.h
r8351 r8706 72 72 class Planet; 73 73 class Script; 74 class SpaceBoundaries; 74 75 75 76 // collisionshapes -
code/trunk/src/modules/objects/Script.cc
r7493 r8706 140 140 141 141 PlayerTrigger* pTrigger = orxonox_cast<PlayerTrigger*>(trigger); 142 P awn* pawn= NULL;142 PlayerInfo* player = NULL; 143 143 144 144 // If the trigger is a PlayerTrigger. … … 148 148 return false; 149 149 else 150 p awn= pTrigger->getTriggeringPlayer();150 player = pTrigger->getTriggeringPlayer(); 151 151 } 152 152 else 153 153 return false; 154 154 155 if(p awn== 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. 156 156 { 157 157 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;167 158 return false; 168 159 } -
code/trunk/src/modules/objects/collisionshapes/BoxCollisionShape.cc
r6417 r8706 27 27 */ 28 28 29 /** 30 @file BoxCollisionShape.cc 31 @brief Implementation of the BoxCollisionShape class. 32 */ 33 29 34 #include "BoxCollisionShape.h" 30 35 … … 39 44 CreateFactory(BoxCollisionShape); 40 45 46 /** 47 @brief 48 Constructor. Registers and initializes the object. 49 */ 41 50 BoxCollisionShape::BoxCollisionShape(BaseObject* creator) : CollisionShape(creator) 42 51 { … … 44 53 45 54 this->halfExtents_ = Vector3(1, 1, 1); 46 updateShape();55 this->updateShape(); 47 56 48 57 this->registerVariables(); … … 51 60 BoxCollisionShape::~BoxCollisionShape() 52 61 { 62 // TODO: Move to CollisionShape? 53 63 if (this->isInitialized()) 54 64 delete this->collisionShape_; … … 70 80 } 71 81 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 */ 72 108 btCollisionShape* BoxCollisionShape::createNewShape() const 73 109 { -
code/trunk/src/modules/objects/collisionshapes/BoxCollisionShape.h
r7601 r8706 43 43 namespace orxonox 44 44 { 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 */ 45 56 class _ObjectsExport BoxCollisionShape : public CollisionShape 46 57 { … … 51 62 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 52 63 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 */ 55 77 inline const Vector3& getHalfExtents() const 56 78 { return halfExtents_;} 57 79 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 */ 60 92 inline float getWidth() const 61 { return this->halfExtents_.z * 2 ; }93 { return this->halfExtents_.z * 2.0f; } 62 94 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 */ 65 107 inline float getHeight() const 66 { return this->halfExtents_.y * 2 ; }108 { return this->halfExtents_.y * 2.0f; } 67 109 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 */ 70 122 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. 72 126 73 127 private: 74 128 void registerVariables(); 75 129 76 btCollisionShape* createNewShape() const; 130 btCollisionShape* createNewShape() const; // Creates a new internal collision shape for the BoxCollisionShape. 77 131 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. 79 133 }; 80 134 } -
code/trunk/src/modules/objects/collisionshapes/ConeCollisionShape.cc
r6417 r8706 27 27 */ 28 28 29 /** 30 @file ConeCollisionShape.cc 31 @brief Implementation of the ConeCollisionShape class. 32 */ 33 29 34 #include "ConeCollisionShape.h" 30 35 … … 33 38 #include "core/CoreIncludes.h" 34 39 #include "core/XMLPort.h" 40 #include "tools/BulletConversions.h" 35 41 36 42 namespace orxonox … … 38 44 CreateFactory(ConeCollisionShape); 39 45 46 /** 47 @brief 48 Constructor. Registers and initializes the object. 49 */ 40 50 ConeCollisionShape::ConeCollisionShape(BaseObject* creator) : CollisionShape(creator) 41 51 { … … 69 79 } 70 80 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 */ 71 109 btCollisionShape* ConeCollisionShape::createNewShape() const 72 110 { -
code/trunk/src/modules/objects/collisionshapes/ConeCollisionShape.h
r7601 r8706 41 41 namespace orxonox 42 42 { 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 */ 43 54 class _ObjectsExport ConeCollisionShape : public CollisionShape 44 55 { … … 49 60 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 50 61 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 */ 53 74 inline float getRadius() const 54 75 { return radius_; } 55 76 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 */ 58 89 inline float getHeight() const 59 90 { return this->height_; } 91 92 virtual void changedScale(); // Is called when the scale of the ConeCollisionShape has changed. 60 93 61 94 private: 62 95 void registerVariables(); 63 96 64 btCollisionShape* createNewShape() const; 97 btCollisionShape* createNewShape() const; // Creates a new internal collision shape for the ConeCollisionShape. 65 98 66 float radius_; 67 float height_; 99 float radius_; //!< The radius of the ConeCollisionShape. 100 float height_; //!< The height of the ConeCollisionShape. 68 101 }; 69 102 } -
code/trunk/src/modules/objects/collisionshapes/PlaneCollisionShape.cc
r6417 r8706 27 27 */ 28 28 29 /** 30 @file PlaneCollisionShape.cc 31 @brief Implementation of the PlaneCollisionShape class. 32 */ 33 29 34 #include "PlaneCollisionShape.h" 30 35 … … 39 44 CreateFactory(PlaneCollisionShape); 40 45 46 /** 47 @brief 48 Constructor. Registers and initializes the object. 49 */ 41 50 PlaneCollisionShape::PlaneCollisionShape(BaseObject* creator) : CollisionShape(creator) 42 51 { … … 70 79 } 71 80 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 */ 72 107 btCollisionShape* PlaneCollisionShape::createNewShape() const 73 108 { -
code/trunk/src/modules/objects/collisionshapes/PlaneCollisionShape.h
r7601 r8706 43 43 namespace orxonox 44 44 { 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 */ 45 56 class _ObjectsExport PlaneCollisionShape : public CollisionShape 46 57 { … … 51 62 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 52 63 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 56 77 { return normal_;} 57 78 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 61 92 { return this->offset_;} 93 94 virtual void changedScale(); // Is called when the scale of the PlaneCollisionShape has changed. 62 95 63 96 private: 64 97 void registerVariables(); 65 98 66 btCollisionShape* createNewShape() const;99 btCollisionShape* createNewShape() const; // Creates a new internal collision shape for the PlaneCollisionShape. 67 100 68 Vector3 normal_; 69 float offset_; 101 Vector3 normal_; //!< The normal vector of the PlaneCollisionShape. 102 float offset_; //!< The offset of the PlaneCollisionShape. 70 103 }; 71 104 } -
code/trunk/src/modules/objects/collisionshapes/SphereCollisionShape.cc
r5781 r8706 27 27 */ 28 28 29 /** 30 @file SphereCollisionShape.cc 31 @brief Implementation of the SphereCollisionShape class. 32 */ 33 29 34 #include "SphereCollisionShape.h" 30 35 … … 33 38 #include "core/CoreIncludes.h" 34 39 #include "core/XMLPort.h" 40 #include "tools/BulletConversions.h" 35 41 36 42 namespace orxonox … … 38 44 CreateFactory(SphereCollisionShape); 39 45 46 /** 47 @brief 48 Constructor. registers and initializes the object. 49 */ 40 50 SphereCollisionShape::SphereCollisionShape(BaseObject* creator) : CollisionShape(creator) 41 51 { … … 66 76 } 67 77 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 */ 68 104 btCollisionShape* SphereCollisionShape::createNewShape() const 69 105 { -
code/trunk/src/modules/objects/collisionshapes/SphereCollisionShape.h
r7601 r8706 41 41 namespace orxonox 42 42 { 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 */ 43 54 class _ObjectsExport SphereCollisionShape : public CollisionShape 44 55 { … … 49 60 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 50 61 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 */ 53 74 inline float getRadius() const 54 75 { return this->radius_; } 76 77 virtual void changedScale(); // Is called when the scale of the SphereCollisionShape has changed. 55 78 56 79 private: … … 59 82 btCollisionShape* createNewShape() const; 60 83 61 float radius_; 84 float radius_; //!< The radius of the SphereCollisionShape. 62 85 }; 63 86 } -
code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.cc
r8213 r8706 53 53 Default Constructor. Registers the object and initializes default values. 54 54 */ 55 DistanceMultiTrigger::DistanceMultiTrigger(BaseObject* creator) : MultiTrigger(creator) , beaconMask_(NULL)55 DistanceMultiTrigger::DistanceMultiTrigger(BaseObject* creator) : MultiTrigger(creator) 56 56 { 57 57 RegisterObject(DistanceMultiTrigger); … … 60 60 this->setBeaconModeDirect(distanceMultiTriggerBeaconMode::off); 61 61 this->targetName_ = ""; 62 this->beaconMask_.exclude(Class(BaseObject)); 63 this->beaconMask_.include(Class(DistanceTriggerBeacon)); 62 64 } 63 65 … … 68 70 DistanceMultiTrigger::~DistanceMultiTrigger() 69 71 { 70 if(this->beaconMask_ != NULL) 71 delete this->beaconMask_; 72 72 73 } 73 74 … … 135 136 // If we are in identify-mode another target mask has to be applies to find the DistanceTriggerBeacons. 136 137 if(this->beaconMode_ == distanceMultiTriggerBeaconMode::identify) 137 targetMask = *this->beaconMask_;138 targetMask = this->beaconMask_; 138 139 139 140 // Iterate through all objects that are targets of the DistanceMultiTrigger. … … 207 208 { 208 209 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 }215 210 } 216 211 -
code/trunk/src/modules/objects/triggers/DistanceMultiTrigger.h
r8213 r8706 152 152 distanceMultiTriggerBeaconMode::Value beaconMode_; //!< The beacon mode, the DistanceMultiTrigger is in. 153 153 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. 155 155 156 156 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 57 57 The creator of this trigger. 58 58 */ 59 DistanceTrigger::DistanceTrigger(BaseObject* creator) : Trigger(creator) , beaconMask_(NULL)59 DistanceTrigger::DistanceTrigger(BaseObject* creator) : Trigger(creator) 60 60 { 61 61 RegisterObject(DistanceTrigger); … … 64 64 this->targetMask_.exclude(Class(BaseObject)); 65 65 this->targetName_ = ""; 66 this->beaconMask_.exclude(Class(BaseObject)); 67 this->beaconMask_.include(Class(DistanceTriggerBeacon)); 66 68 } 67 69 … … 72 74 DistanceTrigger::~DistanceTrigger() 73 75 { 74 // Delete the beacon mask if it exists. 75 if(this->beaconMask_ != NULL) 76 delete this->beaconMask_; 76 77 77 } 78 78 … … 159 159 // If we are in identify-mode another target mask has to be applies to find the DistanceTriggerBeacons. 160 160 if(this->beaconMode_ == distanceTriggerBeaconMode::identify) 161 targetMask = *this->beaconMask_;161 targetMask = this->beaconMask_; 162 162 163 163 // Iterate through all objects that are targets of the DistanceTrigger. … … 205 205 entity = entity->getParent(); 206 206 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; 209 212 } 210 213 … … 228 231 { 229 232 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 }236 233 } 237 234 … … 280 277 Check whether the DistanceTrigger is triggered. 281 278 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 283 282 Returns true if it is triggered ,false if not. 284 283 */ -
code/trunk/src/modules/objects/triggers/DistanceTrigger.h
r8213 r8706 71 71 - @b target Which specifies the class of objects that can trigger the DistanceTrigger. Default is <code>"Pawn"</code>. 72 72 - @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 or oxnox::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>). 74 74 75 75 A simple DistanceTrigger could look like this: … … 162 162 distanceTriggerBeaconMode::Value beaconMode_; //!< The beacon mode. 163 163 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. 165 165 166 166 WeakPtr<WorldEntity> cache_; //!< Caches the entity that triggered the DistanceTrigger last. -
code/trunk/src/modules/objects/triggers/EventTrigger.h
r8213 r8706 60 60 61 61 @see Trigger 62 For more information on @ref or oxnox::Trigger "Triggers".62 For more information on @ref orxonox::Trigger "Triggers". 63 63 64 64 @author -
code/trunk/src/modules/objects/triggers/MultiTrigger.cc
r8213 r8706 63 63 this->bMultiTrigger_ = true; 64 64 65 this->setSyncMode( 0x0);65 this->setSyncMode(ObjectDirection::None); 66 66 } 67 67 … … 198 198 if(bActive ^ this->isActive(state->originator)) 199 199 { 200 201 200 bool bFire = true; 202 201 … … 312 311 313 312 // We only want WorldEntities 314 //TODO: Really?315 313 ClassTreeMask WEMask; 316 314 WEMask.include(Class(WorldEntity)); -
code/trunk/src/modules/objects/triggers/MultiTriggerContainer.cc
r7601 r8706 73 73 { 74 74 this->setForPlayer(true); 75 this->setTriggeringP layer(pawn);75 this->setTriggeringPawn(pawn); 76 76 } 77 77 } -
code/trunk/src/modules/objects/triggers/Trigger.cc
r8213 r8706 76 76 } 77 77 78 this->setSyncMode( 0x0);78 this->setSyncMode(ObjectDirection::None); 79 79 } 80 80 -
code/trunk/src/modules/objects/triggers/TriggerBase.cc
r7652 r8706 71 71 this->bMultiTrigger_ = false; 72 72 73 this->setSyncMode( 0x0);73 this->setSyncMode(ObjectDirection::None); 74 74 } 75 75 -
code/trunk/src/modules/objects/triggers/TriggerBase.h
r8213 r8706 133 133 inline int getActivations(void) const 134 134 { 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; } 135 141 136 142 /** -
code/trunk/src/modules/overlays/OverlaysPrereqs.h
r8351 r8706 89 89 class HUDRadar; 90 90 class HUDSpeedBar; 91 class HUDBoostBar; 91 92 class HUDTimer; 92 93 class KillMessage; -
code/trunk/src/modules/overlays/hud/CMakeLists.txt
r8178 r8706 4 4 HUDRadar.cc 5 5 HUDSpeedBar.cc 6 HUDBoostBar.cc 6 7 HUDHealthBar.cc 7 8 HUDTimer.cc 8 9 ChatOverlay.cc 9 GametypeStatus.cc10 10 AnnounceMessage.cc 11 11 KillMessage.cc -
code/trunk/src/modules/overlays/hud/HUDBar.cc
r7801 r8706 26 26 * Fabian 'x3n' Landau 27 27 * Reto Grieder 28 * Benjamin Knecht 28 29 * 29 30 */ -
code/trunk/src/modules/overlays/hud/HUDBar.h
r7401 r8706 26 26 * Fabian 'x3n' Landau 27 27 * Reto Grieder 28 * Benjamin Knecht 28 29 * 29 30 */ -
code/trunk/src/modules/overlays/hud/HUDNavigation.cc
r7801 r8706 342 342 text->hide(); 343 343 344 ObjectInfo tempStruct = {panel, text, false };344 ObjectInfo tempStruct = {panel, text, false /*, TODO: initialize wasOutOfView_ */}; 345 345 activeObjectList_[object] = tempStruct; 346 346 -
code/trunk/src/modules/overlays/hud/HUDSpeedBar.cc
r5781 r8706 54 54 SUPER(HUDSpeedBar, tick, dt); 55 55 56 if (this->owner_ && this->owner_->getEngine())56 if (this->owner_) 57 57 { 58 float value = this->owner_->getVelocity().length() / (this->owner_->get Engine()->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()); 59 59 this->setValue(value); 60 60 } -
code/trunk/src/modules/pickup/PickupManager.h
r7547 r8706 148 148 @return Returns true if the input Pickupable is still valid, false if not. 149 149 */ 150 constbool isValidPickup(uint32_t pickup) const150 bool isValidPickup(uint32_t pickup) const 151 151 { return this->pickups_.find(pickup) != this->pickups_.end(); } 152 152 // tolua_end -
code/trunk/src/modules/pickup/PickupPrereqs.h
r8351 r8706 85 85 class SpeedPickup; 86 86 class ShieldPickup; 87 class ShrinkPickup; 87 88 88 89 } -
code/trunk/src/modules/pickup/PickupRepresentation.cc
r8079 r8706 57 57 58 58 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. 60 60 } 61 61 -
code/trunk/src/modules/pickup/items/CMakeLists.txt
r7163 r8706 6 6 SpeedPickup.cc 7 7 ShieldPickup.cc 8 ShrinkPickup.cc 8 9 ) -
code/trunk/src/modules/pong/PongBat.h
r8108 r8706 100 100 { this->length_ = length; } 101 101 /** 102 @brief get the length of the bat.102 @brief Get the length of the bat. 103 103 @return Returns the length of the bat (in z-direction) as percentage of the height of the playing field. 104 104 */ -
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 1 29 #include "PortalEndPoint.h" 2 30 #include "core/XMLPort.h" … … 4 32 #include "portals/PortalLink.h" 5 33 #include "worldentities/MobileEntity.h" 6 34 #include <ctime> 7 35 8 36 namespace orxonox … … 14 42 std::map<unsigned int, PortalEndPoint *> PortalEndPoint::idMap_s; 15 43 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) 17 45 { 18 46 RegisterObject(PortalEndPoint); 47 19 48 this->trigger_ = new DistanceMultiTrigger(this); 20 49 this->trigger_->setName("portal"); 21 50 this->attach(trigger_); 51 52 this->setRadarObjectColour(ColourValue::White); 53 this->setRadarObjectShape(RadarViewable::Dot); 54 this->setRadarVisibility(true); 22 55 } 23 56 24 57 PortalEndPoint::~PortalEndPoint() 25 58 { 26 delete this->trigger_; 59 if(this->isInitialized() && this->trigger_ != NULL) 60 delete this->trigger_; 27 61 } 28 62 … … 33 67 XMLPortParam(PortalEndPoint, "id", setID, getID, xmlelement, mode); 34 68 XMLPortParam(PortalEndPoint, "design", setTemplate, getTemplate, xmlelement, mode); 69 XMLPortParam(PortalEndPoint, "reenterDelay", setReenterDelay, getReenterDelay, xmlelement, mode); 35 70 XMLPortParamExtern(PortalEndPoint, DistanceMultiTrigger, this->trigger_, "distance", setDistance, getDistance, xmlelement, mode); 36 71 XMLPortParamLoadOnly(PortalEndPoint, "target", setTarget, xmlelement, mode).defaultValues("Pawn"); … … 64 99 if(originatingTrigger == 0) 65 100 { 66 COUT(1) << "originator no DistanceMultiTrigger\n" << std::endl;67 101 return true; 68 102 } … … 74 108 if(bTriggered) 75 109 { 76 if(this-> recentlyJumpedOut_.find(entity) == this->recentlyJumpedOut_.end()) // only enter the portal if not just jumped out of it110 if(this->letsEnter(entity)) // only enter the portal if not just (this very moment) jumped out of it, or if the reenterDelay expired 77 111 { 78 112 PortalLink::use(entity, this); … … 87 121 } 88 122 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 89 145 void PortalEndPoint::jumpOut(MobileEntity* entity) 90 146 { 147 this->jumpOutTimes_[entity] = std::time(0); 91 148 this->recentlyJumpedOut_.insert(entity); 92 149 150 // adjust 93 151 entity->setPosition(this->getWorldPosition()); 94 152 entity->rotate(this->getWorldOrientation()); 95 153 entity->setVelocity(this->getWorldOrientation() * entity->getVelocity()); 96 entity->setVelocity(entity->getVelocity() * 1.5);97 154 } 98 155 -
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 1 35 #ifndef _PortalEndPoint_H__ 2 36 #define _PortalEndPoint_H__ … … 9 43 10 44 #include "worldentities/StaticEntity.h" 45 #include "interfaces/RadarViewable.h" 11 46 #include "graphics/Billboard.h" 12 47 #include "objects/triggers/DistanceMultiTrigger.h" 13 48 #include "core/EventIncludes.h" 49 #include <ctime> 14 50 15 51 namespace orxonox 16 52 { 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 18 61 { 19 62 public: 20 63 PortalEndPoint(BaseObject* creator); 21 64 virtual ~PortalEndPoint(); 65 22 66 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 67 virtual void changedActivity(void); 68 23 69 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); } 27 71 28 72 void XMLEventPort(Element& xmlelement, XMLPort::Mode mode); 29 73 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_; } 30 78 inline void setID(unsigned int id) 31 { 32 this->id_ = id; 33 } 79 { this->id_ = id; } 34 80 35 81 inline unsigned int getID() const 36 { 37 return this->id_; 38 } 82 { return this->id_; } 39 83 40 84 /// \brief Set templateName_ (the name of the design Template) and add that Template to this Object 41 85 inline void setTemplate(const std::string & name) 42 { 43 this->templateName_ = name; 44 this->addTemplate(name); 45 } 86 { this->templateName_ = name; this->addTemplate(name); } 46 87 47 88 /// \brief Get the name of the attached design template 48 89 inline const std::string & getTemplate() 49 { 50 return this->templateName_; 51 } 90 { return this->templateName_; } 52 91 53 92 /*! \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 */ 59 96 bool execute(bool bTriggered, BaseObject* trigger); 60 97 … … 62 99 * \param entity The Entity which should jump out of this portal */ 63 100 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); 64 106 protected: 65 107 … … 71 113 std::string templateName_; //!< The name of the design template used for this endpoint 72 114 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. 74 118 }; 75 119 -
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 1 29 #include "PortalLink.h" 2 30 #include "core/XMLPort.h" … … 17 45 PortalLink::~PortalLink() 18 46 { 47 19 48 } 20 49 … … 37 66 if(entrance == 0) 38 67 { 39 // TODO COUT40 68 return; 41 69 } 42 70 43 std::map<PortalEndPoint *, PortalEndPoint *>::iterator endpoint = PortalLink::links_s.find(entrance);71 std::map<PortalEndPoint *, PortalEndPoint *>::iterator endpoints = PortalLink::links_s.find(entrance); 44 72 45 if(endpoint == PortalLink::links_s.end()) // entrance has no corresponding exit73 if(endpoints == PortalLink::links_s.end()) // entrance has no corresponding exit 46 74 return; 47 48 endpoint ->second->jumpOut(entity);75 76 endpoints->second->jumpOut(entity); 49 77 } 50 51 52 78 } -
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 1 35 #ifndef _PortalLink_H__ 2 36 #define _PortalLink_H__ … … 12 46 namespace orxonox 13 47 { 48 /** 49 @brief 50 A PortalLink represents the connection between two @ref orxonox::PortalEndPoint "PortalEndPoints" 51 @ingroup Portals 52 */ 14 53 class _PortalsExport PortalLink : public BaseObject 15 54 { … … 34 73 return this->toID_; 35 74 } 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 37 80 protected: 38 81 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 46 87 }; 47 48 88 } 49 89 -
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 40 40 #include "infos/PlayerInfo.h" 41 41 42 #include " notifications/NotificationManager.h"42 #include "interfaces/NotificationListener.h" 43 43 44 44 namespace orxonox … … 119 119 } 120 120 121 Notification Manager::sendNotification(message, player->getClientID(), QuestDescription::SENDER);121 NotificationListener::sendNotification(message, QuestDescription::SENDER, notificationMessageType::info, notificationSendMode::network, player->getClientID()); 122 122 return true; 123 123 } -
code/trunk/src/modules/questsystem/QuestEffectBeacon.cc
r8351 r8706 113 113 114 114 PlayerTrigger* pTrigger = orxonox_cast<PlayerTrigger*>(trigger); 115 P awn* pawn= NULL;115 PlayerInfo* player = NULL; 116 116 117 117 // If the trigger is a PlayerTrigger. … … 121 121 return false; 122 122 else 123 p awn= pTrigger->getTriggeringPlayer();123 player = pTrigger->getTriggeringPlayer(); 124 124 } 125 125 else 126 126 return false; 127 127 128 if(p awn== NULL)128 if(player == NULL) 129 129 { 130 130 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;140 131 return false; 141 132 } -
code/trunk/src/modules/questsystem/QuestManager.cc
r8079 r8706 274 274 int QuestManager::getNumSubQuests(Quest* quest, PlayerInfo* player) 275 275 { 276 if(quest == NULL) 277 return this->getNumRootQuests(player); 278 276 279 std::list<Quest*> quests = quest->getSubQuestList(); 277 280 int numQuests = 0; … … 296 299 Quest* QuestManager::getSubQuest(Quest* quest, PlayerInfo* player, int index) 297 300 { 301 if(quest == NULL) 302 return this->getRootQuest(player, index); 303 298 304 std::list<Quest*> quests = quest->getSubQuestList(); 299 305 for(std::list<Quest*>::iterator it = quests.begin(); it != quests.end(); it++) … … 312 318 @param player 313 319 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. 315 322 */ 316 323 int QuestManager::getNumHints(Quest* quest, PlayerInfo* player) … … 335 342 @param index 336 343 The index of the QuestHint. 344 @return 345 Returns a pointer to the index-th QuestHint of the input Quest for the input player. 337 346 */ 338 347 QuestHint* QuestManager::getHints(Quest* quest, PlayerInfo* player, int index) … … 345 354 } 346 355 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(); 347 369 } 348 370 … … 375 397 /** 376 398 @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 377 425 Retrieve the player for a certain GUI. 378 426 @param guiName -
code/trunk/src/modules/questsystem/QuestManager.h
r7552 r8706 81 81 QuestHint* getHints(Quest* quest, orxonox::PlayerInfo* player, int index); //!< Get the index-th QuestHint of the input Quest for the input player. 82 82 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. 85 90 // tolua_end 86 91 -
code/trunk/src/modules/weapons/projectiles/CMakeLists.txt
r7163 r8706 6 6 Rocket.cc 7 7 SimpleRocket.cc 8 BasicProjectile.cc 8 9 ) -
code/trunk/src/modules/weapons/projectiles/Projectile.cc
r7284 r8706 23 23 * Fabian 'x3n' Landau 24 24 * Co-authors: 25 * ...25 * simonmie 26 26 * 27 27 */ … … 41 41 CreateFactory(Projectile); 42 42 43 Projectile::Projectile(BaseObject* creator) : MovableEntity(creator) 43 Projectile::Projectile(BaseObject* creator) : MovableEntity(creator), BasicProjectile() 44 44 { 45 45 RegisterObject(Projectile); 46 46 47 47 this->setConfigValues(); 48 this->bDestroy_ = false;49 48 this->owner_ = 0; 50 this->damage_ = 15;51 49 52 50 // Get notification about collisions 53 54 51 if (GameMode::isMaster()) 55 52 { … … 84 81 return; 85 82 86 if (this-> bDestroy_)83 if (this->getBDestroy()) 87 84 this->destroy(); // TODO: use a scheduler instead of deleting the object right here in tick() 88 85 } … … 94 91 } 95 92 93 /* Calls the collidesAgainst function of BasicProjectile 94 */ 96 95 bool Projectile::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint) 97 96 { 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); 130 98 } 131 99 -
code/trunk/src/modules/weapons/projectiles/Projectile.h
r5929 r8706 23 23 * Fabian 'x3n' Landau 24 24 * Co-authors: 25 * ...25 * simonmie 26 26 * 27 27 */ … … 35 35 #include "worldentities/MovableEntity.h" 36 36 37 #include "BasicProjectile.h" 38 37 39 namespace orxonox 38 40 { 39 class _WeaponsExport Projectile : public MovableEntity 41 class _WeaponsExport Projectile : public MovableEntity, public BasicProjectile 40 42 { 41 43 public: … … 49 51 virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint); 50 52 51 inline void setDamage(float damage)52 { this->damage_ = damage; }53 inline float getDamage() const54 { return this->damage_; }55 56 53 void setOwner(Pawn* owner); 57 54 inline Pawn* getOwner() const 58 55 { return this->owner_; } 59 56 57 60 58 private: 61 59 WeakPtr<Pawn> owner_; 62 60 float lifetime_; 63 float damage_;64 bool bDestroy_;65 61 Timer destroyTimer_; 66 62 }; -
code/trunk/src/modules/weapons/projectiles/Rocket.cc
r7848 r8706 23 23 * Oliver Scheuss 24 24 * Co-authors: 25 * ...25 * simonmie 26 26 * 27 27 */ … … 52 52 Constructor. Registers the object and initializes some default values. 53 53 */ 54 Rocket::Rocket(BaseObject* creator) : ControllableEntity(creator) 54 Rocket::Rocket(BaseObject* creator) : ControllableEntity(creator), BasicProjectile() 55 55 { 56 56 RegisterObject(Rocket);// - register the Rocket class to the core 57 57 58 58 this->localAngularVelocity_ = 0; 59 this->bDestroy_ = false;60 59 this->lifetime_ = 100; 61 60 … … 146 145 { 147 146 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); 150 149 151 150 if( GameMode::isMaster() ) … … 175 174 if( GameMode::isMaster() ) 176 175 { 177 if( this-> bDestroy_)176 if( this->getBDestroy() ) 178 177 this->destroy(); 179 178 … … 181 180 } 182 181 182 /* Calls the collidesAgainst function of BasicProjectile 183 */ 183 184 bool Rocket::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint) 184 185 { 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); 219 187 } 220 188 … … 233 201 void Rocket::fired(unsigned int firemode) 234 202 { 235 // if (this->owner_) 236 // { 237 this->destroy(); 238 // } 203 this->destroy(); 239 204 } 240 205 … … 242 207 { 243 208 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()); 248 213 } 249 214 else -
code/trunk/src/modules/weapons/projectiles/Rocket.h
r7163 r8706 23 23 * Oliver Scheuss 24 24 * Co-authors: 25 * ...25 * simonmie 26 26 * 27 27 */ … … 34 34 #include "tools/Timer.h" 35 35 #include "worldentities/ControllableEntity.h" 36 37 #include "BasicProjectile.h" 36 38 37 39 namespace orxonox … … 46 48 Oli Scheuss 47 49 */ 48 class _WeaponsExport Rocket : public ControllableEntity 50 class _WeaponsExport Rocket : public ControllableEntity, public BasicProjectile 49 51 { 50 52 public: … … 109 111 { return this->owner_; } 110 112 111 inline void setDamage(float damage)112 { this->damage_ = damage; }113 inline float getDamage() const114 { return this->damage_; }115 113 virtual void fired(unsigned int firemode); 116 114 … … 118 116 WeakPtr<Pawn> owner_; 119 117 Vector3 localAngularVelocity_; 120 float damage_;121 bool bDestroy_;122 118 123 119 WeakPtr<PlayerInfo> player_; -
code/trunk/src/modules/weapons/projectiles/SimpleRocket.cc
r7163 r8706 23 23 * Oliver Scheuss 24 24 * Co-authors: 25 * ...25 * simonmie 26 26 * 27 27 */ … … 48 48 CreateFactory(SimpleRocket); 49 49 50 SimpleRocket::SimpleRocket(BaseObject* creator) : ControllableEntity(creator) 50 SimpleRocket::SimpleRocket(BaseObject* creator) : ControllableEntity(creator), BasicProjectile() 51 51 { 52 52 RegisterObject(SimpleRocket);// - register the SimpleRocket class to the core 53 53 54 54 this->localAngularVelocity_ = 0; 55 this->bDestroy_ = false;56 55 this->lifetime_ = 120; 57 56 58 57 this->setMass(15); 59 COUT(4) << "simplerocket constructed\n";58 // COUT(4) << "simplerocket constructed\n"; 60 59 61 60 if (GameMode::isMaster()) … … 115 114 this->disableFire(); 116 115 117 if( this-> bDestroy_)116 if( this->getBDestroy() ) 118 117 this->destroy(); 119 118 } … … 159 158 { 160 159 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 */ 167 166 bool SimpleRocket::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint) 168 167 { 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); 206 169 } 207 170 -
code/trunk/src/modules/weapons/projectiles/SimpleRocket.h
r7163 r8706 23 23 * Oliver Scheuss 24 24 * Co-authors: 25 * ...25 * simonmie 26 26 * 27 27 */ … … 36 36 #include "graphics/ParticleSpawner.h" 37 37 38 #include "BasicProjectile.h" 39 38 40 namespace orxonox 39 41 { … … 46 48 Gabriel Nadler (Original file: Oli Scheuss) 47 49 */ 48 class _WeaponsExport SimpleRocket : public ControllableEntity 50 class _WeaponsExport SimpleRocket : public ControllableEntity, public BasicProjectile 49 51 { 50 52 public: … … 111 113 inline Pawn* getOwner() const 112 114 { return this->owner_; } 115 113 116 inline bool hasFuel() const 114 117 { return this->fuel_; } 115 116 inline void setDamage(float damage)117 { this->damage_ = damage; }118 inline float getDamage() const119 { return this->damage_; }120 118 121 119 … … 123 121 WeakPtr<Pawn> owner_; 124 122 Vector3 localAngularVelocity_; 125 float damage_;126 bool bDestroy_;127 123 bool fuel_; //!< Bool is true while the rocket "has fuel" 128 124 -
code/trunk/src/modules/weapons/weaponmodes/EnergyDrink.cc
r7284 r8706 23 23 * Hagen Seifert 24 24 * Co-authors: 25 * ...25 * simonmie 26 26 * 27 27 */ … … 50 50 51 51 this->reloadTime_ = 0.25; 52 this->damage_ = 15;52 this->damage_ = 0; //default 15 53 53 this->speed_ = 2500; 54 54 this->delay_ = 0; … … 97 97 } 98 98 99 /* Creates the projectile object, sets its properties to the EnergyDrink properties, calls muendungsfeuer() 100 */ 99 101 void EnergyDrink::shot() 100 102 { … … 112 114 projectile->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()); 113 115 projectile->setDamage(this->getDamage()); 116 projectile->setShieldDamage(this->getShieldDamage()); 117 projectile->setHealthDamage(this->getHealthDamage()); 114 118 115 119 EnergyDrink::muendungsfeuer(); -
code/trunk/src/modules/weapons/weaponmodes/FusionFire.cc
r6732 r8706 23 23 * Martin Polak 24 24 * Co-authors: 25 * ...25 * simonmie 26 26 * 27 27 */ … … 48 48 this->reloadTime_ = 1.0; 49 49 this->bParallelReload_ = false; 50 this->damage_ = 40;50 this->damage_ = 0; //default 40 51 51 this->speed_ = 1250; 52 52 … … 54 54 } 55 55 56 /* Creates the projectile (BillboardProjectile) object, sets its properties to the FusionFire properties 57 */ 56 58 void FusionFire::fire() 57 59 { … … 65 67 projectile->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()); 66 68 projectile->setDamage(this->getDamage()); 69 projectile->setShieldDamage(this->getShieldDamage()); 70 projectile->setHealthDamage(this->getHealthDamage()); 71 67 72 projectile->setColour(ColourValue(1.0f, 0.7f, 0.3f, 1.0f)); 68 73 } -
code/trunk/src/modules/weapons/weaponmodes/HsW01.cc
r7284 r8706 23 23 * Hagen Seifert 24 24 * Co-authors: 25 * ...25 * simonmie 26 26 * 27 27 */ … … 51 51 52 52 this->reloadTime_ = 0.25; 53 this->damage_ = 15;53 this->damage_ = 0; //default 15 54 54 this->speed_ = 2500; 55 55 this->delay_ = 0; … … 109 109 } 110 110 111 /* Creates the projectile object, sets its properties to the HsW01 properties, calls muendungsfeuer() 112 */ 111 113 void HsW01::shot() 112 114 { … … 126 128 projectile->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()); 127 129 projectile->setDamage(this->getDamage()); 130 projectile->setShieldDamage(this->getShieldDamage()); 131 projectile->setHealthDamage(this->getHealthDamage()); 128 132 129 133 HsW01::muendungsfeuer(); -
code/trunk/src/modules/weapons/weaponmodes/LaserFire.cc
r6732 r8706 23 23 * Martin Polak 24 24 * Co-authors: 25 * ...25 * simonmie 26 26 * 27 27 */ … … 45 45 46 46 this->reloadTime_ = 0.25; 47 this->damage_ = 15;47 this->damage_ = 0; //default 15 48 48 this->speed_ = 1250; 49 49 … … 51 51 } 52 52 53 /* Creates the projectile object, sets its properties to the LaserFire properties 54 */ 53 55 void LaserFire::fire() 54 56 { … … 61 63 projectile->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()); 62 64 projectile->setDamage(this->getDamage()); 65 projectile->setShieldDamage(this->getShieldDamage()); 66 projectile->setHealthDamage(this->getHealthDamage()); 63 67 } 64 68 } -
code/trunk/src/modules/weapons/weaponmodes/LightningGun.cc
r6732 r8706 23 23 * Joel Smely 24 24 * Co-authors: 25 * ...25 * simonmie 26 26 * 27 27 */ … … 45 45 46 46 this->reloadTime_ = 1; 47 this->damage_ = 100;47 this->damage_ = 0; //default 100 48 48 this->speed_ = 150; 49 49 … … 56 56 } 57 57 58 /* Creates the projectile (LightningGunProjectile) object, sets its properties to the LightningGun properties 59 */ 58 60 void LightningGun::fire() 59 61 { … … 69 71 projectile->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()); 70 72 projectile->setDamage(this->getDamage()); 73 projectile->setShieldDamage(this->getShieldDamage()); 74 projectile->setHealthDamage(this->getHealthDamage()); 71 75 } 72 76 } -
code/trunk/src/modules/weapons/weaponmodes/RocketFire.cc
r7846 r8706 23 23 * Oliver Scheuss 24 24 * Co-authors: 25 * ...25 * simonmie 26 26 * 27 27 */ … … 48 48 this->reloadTime_ = 0.20f; 49 49 this->bParallelReload_ = false; 50 this->damage_ = 100;50 this->damage_ = 0; 51 51 this->speed_ = 500; 52 52 … … 59 59 } 60 60 61 /* Creates the Rocket object, sets its properties to the RocketFire properties 62 */ 61 63 void RocketFire::fire() 62 64 { … … 71 73 rocket->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()); 72 74 rocket->setDamage(this->getDamage()); 75 rocket->setShieldDamage(this->getShieldDamage()); 76 rocket->setHealthDamage(this->getHealthDamage()); 73 77 } 74 78 } -
code/trunk/src/modules/weapons/weaponmodes/SimpleRocketFire.cc
r7846 r8706 23 23 * Oliver Scheuss 24 24 * Co-authors: 25 * ...25 * simonmie 26 26 * 27 27 */ … … 50 50 this->reloadTime_ = 1; 51 51 this->bParallelReload_ = false; 52 this->damage_ = 100;52 this->damage_ = 0; 53 53 this->speed_ = 500; 54 54 … … 62 62 } 63 63 64 /* Creates the Rocket (RocketController) object, sets its properties to the SimpleRocketFire properties, sets target 65 */ 64 66 void SimpleRocketFire::fire() 65 67 { … … 71 73 rocket->setVelocity(this->getMuzzleDirection()*this->speed_); 72 74 rocket->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()); 75 73 76 rocket->setDamage(this->damage_); 77 rocket->setShieldDamage(this->getShieldDamage()); 78 rocket->setHealthDamage(this->getHealthDamage()); 79 74 80 WorldEntity* pawnn=static_cast<ControllableEntity*>(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn())->getTarget(); 75 81 if (pawnn) con->setTarget(pawnn); -
code/trunk/src/orxonox/LevelManager.cc
r8079 r8706 222 222 this->nextLevel_ = this->availableLevels_.begin(); 223 223 } 224 224 225 while(this->nextIndex_ != index) 225 226 { -
code/trunk/src/orxonox/MoodManager.cc
r8351 r8706 93 93 94 94 95 std::string MoodListener::mood_s;96 97 95 MoodListener::MoodListener() 98 96 { … … 102 100 /*static*/ void MoodListener::changedMood(const std::string& mood) 103 101 { 104 mood_s = mood;105 102 for (ObjectList<MoodListener>::iterator it = ObjectList<MoodListener>::begin(); it; ++it) 106 it->moodChanged(mood _s);103 it->moodChanged(mood); 107 104 } 108 105 } -
code/trunk/src/orxonox/MoodManager.h
r7163 r8706 50 50 virtual ~MoodListener() {} 51 51 52 const std::string& getMood() const { return mood_s; }53 54 52 private: 55 53 virtual void moodChanged(const std::string& mood) = 0; 56 54 57 55 static void changedMood(const std::string& mood); 58 static std::string mood_s;59 56 }; 60 57 -
code/trunk/src/orxonox/collisionshapes/CollisionShape.cc
r7401 r8706 26 26 * 27 27 */ 28 29 /** 30 @file CollisionShape.cc 31 @brief Implementation of the CollisionShape class. 32 */ 28 33 29 34 #include "CollisionShape.h" … … 39 44 namespace orxonox 40 45 { 46 47 /** 48 @brief 49 Constructor. Registers and initializes the object. 50 */ 41 51 CollisionShape::CollisionShape(BaseObject* creator) 42 52 : BaseObject(creator) … … 51 61 this->orientation_ = Quaternion::IDENTITY; 52 62 this->scale_ = Vector3::UNIT_SCALE; 63 this->uniformScale_ = true; 53 64 54 65 this->registerVariables(); 55 66 } 56 67 68 /** 69 @brief 70 Destructor. Detaches the CollisionShape from its parent. 71 */ 57 72 CollisionShape::~CollisionShape() 58 73 { 59 // Detach from parent 74 // Detach from parent CompoundCollisionShape. 60 75 if (this->isInitialized() && this->parent_) 61 76 this->parent_->detach(this); … … 75 90 } 76 91 92 /** 93 @brief 94 Register variables that need synchronizing over the network. 95 */ 77 96 void CollisionShape::registerVariables() 78 97 { 98 // Keep the shape's parent (can be either a CompoundCollisionShape or a WorldEntity) consistent over the network. 79 99 registerVariable(this->parentID_, VariableDirection::ToClient, new NetworkCallback<CollisionShape>(this, &CollisionShape::parentChanged)); 80 100 } 81 101 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 */ 82 155 void CollisionShape::parentChanged() 83 156 { 157 // Get the parent object from the network. 84 158 Synchronisable* parent = Synchronisable::getSynchronisable(this->parentID_); 159 85 160 // Parent can either be a WorldEntity or a CompoundCollisionShape. The reason is that the 86 161 // internal collision shape (which is compound) of a WE doesn't get synchronised. 87 162 CompoundCollisionShape* parentCCS = orxonox_cast<CompoundCollisionShape*>(parent); 163 164 // If the parent is a CompoundCollisionShape, attach the CollisionShape to it. 88 165 if (parentCCS) 89 166 parentCCS->attach(this); 90 167 else 91 168 { 169 // If the parent is a WorldEntity, attach the CollisionShape to its collision shapes. 92 170 WorldEntity* parentWE = orxonox_cast<WorldEntity*>(parent); 93 171 if (parentWE) … … 96 174 } 97 175 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 */ 126 182 bool CollisionShape::hasTransform() const 127 183 { … … 130 186 } 131 187 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 */ 132 197 void CollisionShape::setScale3D(const Vector3& scale) 133 198 { 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 */ 137 222 void CollisionShape::setScale(float scale) 138 223 { 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 */ 142 248 void CollisionShape::updateShape() 143 249 { 144 250 btCollisionShape* oldShape = this->collisionShape_; 145 251 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(); 146 255 // When we recreate the shape, we have to inform the parent about this to update the shape 147 256 this->updateParent(); … … 150 259 } 151 260 261 /** 262 @brief 263 Calculates the local inertia of the collision shape. 264 @todo 265 Document. 266 */ 152 267 void CollisionShape::calculateLocalInertia(float mass, btVector3& inertia) const 153 268 { -
code/trunk/src/orxonox/collisionshapes/CollisionShape.h
r7163 r8706 27 27 */ 28 28 29 /** 30 @file CollisionShape.h 31 @brief Definition of the CollisionShape class. 32 @ingroup Collisionshapes 33 */ 34 29 35 #ifndef _CollisionShape_H__ 30 36 #define _CollisionShape_H__ … … 38 44 namespace orxonox 39 45 { 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 */ 40 57 class _OrxonoxExport CollisionShape : public BaseObject, public Synchronisable 41 58 { … … 46 63 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 47 64 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 */ 48 70 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 */ 50 76 inline const Vector3& getPosition() const 51 77 { return this->position_; } 52 78 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 */ 53 84 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 */ 55 90 inline const Quaternion& getOrientation() const 56 91 { return this->orientation_; } 57 92 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)); } 61 114 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 */ 64 129 inline const Vector3& getScale3D() const 65 130 { return this->scale_; } 66 131 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; } 68 147 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. 70 155 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 */ 71 164 inline btCollisionShape* getCollisionShape() const 72 165 { return this->collisionShape_; } 73 166 74 bool hasTransform() const; 167 bool hasTransform() const; // Check whether the CollisionShape has been either moved or rotated or both. 75 168 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. 78 171 79 172 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 */ 82 180 virtual btCollisionShape* createNewShape() const = 0; 83 181 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. 87 185 88 186 private: 89 187 void registerVariables(); 90 188 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. 94 193 }; 95 194 } -
code/trunk/src/orxonox/collisionshapes/CompoundCollisionShape.cc
r5929 r8706 27 27 */ 28 28 29 /** 30 @file CompoundCollisionShape.cc 31 @brief Implementation of the CompoundCollisionShape class. 32 */ 33 29 34 #include "CompoundCollisionShape.h" 30 35 … … 39 44 CreateFactory(CompoundCollisionShape); 40 45 46 /** 47 @brief 48 Constructor. Registers and initializes the object. 49 */ 41 50 CompoundCollisionShape::CompoundCollisionShape(BaseObject* creator) : CollisionShape(creator) 42 51 { … … 46 55 } 47 56 57 /** 58 @brief 59 Destructor. 60 Deletes all its children. 61 */ 48 62 CompoundCollisionShape::~CompoundCollisionShape() 49 63 { … … 70 84 } 71 85 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 */ 72 92 void CompoundCollisionShape::attach(CollisionShape* shape) 73 93 { 94 // If either the input shape is NULL or we try to attach the CollisionShape to itself. 74 95 if (!shape || static_cast<CollisionShape*>(this) == shape) 75 96 return; 97 76 98 if (this->attachedShapes_.find(shape) != this->attachedShapes_.end()) 77 99 { … … 80 102 } 81 103 104 // Notify the CollisionShape that it is being attached to the CompoundCollisionShape. 82 105 if (!shape->notifyBeingAttached(this)) 83 106 return; 84 107 108 // Attach it. 85 109 this->attachedShapes_[shape] = shape->getCollisionShape(); 86 110 111 // Only actually attach if we didn't pick a CompoundCollisionShape with no content. 87 112 if (shape->getCollisionShape()) 88 113 { 89 // Only actually attach if we didn't pick a CompoundCollisionShape with no content90 114 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. 91 116 this->compoundShape_->addChildShape(transf, shape->getCollisionShape()); 92 117 … … 95 120 } 96 121 122 /** 123 @brief 124 Detach the input CollisionShape form the CompoundCollisionShape. 125 @param shape 126 A pointer to the CollisionShape to be detached. 127 */ 97 128 void CompoundCollisionShape::detach(CollisionShape* shape) 98 129 { 130 // If the input CollisionShape is actually attached. 99 131 if (this->attachedShapes_.find(shape) != this->attachedShapes_.end()) 100 132 { 101 133 this->attachedShapes_.erase(shape); 102 134 if (shape->getCollisionShape()) 103 this->compoundShape_->removeChildShape(shape->getCollisionShape()); 135 this->compoundShape_->removeChildShape(shape->getCollisionShape()); // TODO: Apparently this is broken? 104 136 shape->notifyDetached(); 105 137 … … 110 142 } 111 143 144 /** 145 @brief 146 Detach all attached CollisionShapes. 147 */ 112 148 void CompoundCollisionShape::detachAll() 113 149 { … … 116 152 } 117 153 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 */ 118 161 void CompoundCollisionShape::updateAttachedShape(CollisionShape* shape) 119 162 { 120 163 if (!shape) 121 164 return; 165 122 166 std::map<CollisionShape*, btCollisionShape*>::iterator it = this->attachedShapes_.find(shape); 167 // Check whether the input shape belongs to this CompoundCollisionShape. 123 168 if (it == this->attachedShapes_.end()) 124 169 { … … 129 174 // Remove old btCollisionShape, stored in the children map 130 175 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 132 179 if (shape->getCollisionShape()) 133 180 { 134 // Only actually attach if we didn't pick a CompoundCollisionShape with no content135 181 btTransform transf(multi_cast<btQuaternion>(shape->getOrientation()), multi_cast<btVector3>(shape->getPosition())); 136 182 this->compoundShape_->addChildShape(transf, shape->getCollisionShape()); … … 141 187 } 142 188 189 /** 190 @brief 191 Updates the public shape, the collision shape this CompoundCollisionShape has to the outside. 192 */ 143 193 void CompoundCollisionShape::updatePublicShape() 144 194 { 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. 148 199 for (std::map<CollisionShape*, btCollisionShape*>::const_iterator it = this->attachedShapes_.begin(); it != this->attachedShapes_.end(); ++it) 149 200 { 201 // TODO: Make sure this is correct. 150 202 if (it->second) 151 203 { 152 204 bEmpty = false; 153 if (!it->first->hasTransform() && !bPrimitive)205 if (!it->first->hasTransform() && bPrimitive) 154 206 primitive = it->second; 155 207 else 208 { 156 209 bPrimitive = false; 210 break; 211 } 157 212 } 158 213 } 214 215 // If there is no non-empty CollisionShape. 159 216 if (bEmpty) 160 217 { 218 // If there was none all along, nothing needs to be changed. 161 219 if (this->collisionShape_ == 0) 162 {163 this->collisionShape_ = 0;164 220 return; 165 }166 221 this->collisionShape_ = 0; 167 222 } 223 // If the CompoundCollisionShape is just a primitive. 224 // Only one shape to be added, no transform; return it directly. 168 225 else if (bPrimitive) 169 {170 // --> Only one shape to be added, no transform; return it directly171 226 this->collisionShape_ = primitive; 172 }227 // Make sure we use the compound shape when returning a btCollisionShape. 173 228 else 174 {175 // Make sure we use the compound shape when returning a btCollisionShape176 229 this->collisionShape_ = this->compoundShape_; 177 } 230 178 231 this->updateParent(); 179 232 } 180 233 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 */ 181 242 CollisionShape* CompoundCollisionShape::getAttachedShape(unsigned int index) const 182 243 { … … 190 251 return 0; 191 252 } 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 } 192 299 } -
code/trunk/src/orxonox/collisionshapes/CompoundCollisionShape.h
r5781 r8706 27 27 */ 28 28 29 /** 30 @file CompoundCollisionShape.h 31 @brief Definition of the CompoundCollisionShape class. 32 @ingroup Collisionshapes 33 */ 34 29 35 #ifndef _CompoundCollisionShape_H__ 30 36 #define _CompoundCollisionShape_H__ … … 38 44 namespace orxonox 39 45 { 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 */ 40 57 class _OrxonoxExport CompoundCollisionShape : public CollisionShape 41 58 { … … 53 70 void updateAttachedShape(CollisionShape* shape); 54 71 72 virtual void changedScale(); 73 55 74 private: 56 75 void updatePublicShape(); -
code/trunk/src/orxonox/collisionshapes/WorldEntityCollisionShape.cc
r5929 r8706 43 43 this->worldEntityOwner_ = creator; 44 44 // suppress synchronisation 45 this->setSyncMode( 0x0);45 this->setSyncMode(ObjectDirection::None); 46 46 } 47 47 -
code/trunk/src/orxonox/controllers/ArtificialController.cc
r8351 r8706 381 381 } 382 382 } 383 384 if (distance < 10) 385 { 386 this->positionReached(); 387 } 383 388 } 384 389 … … 387 392 this->moveToPosition(this->targetPosition_); 388 393 } 389 390 394 391 395 /** -
code/trunk/src/orxonox/controllers/ArtificialController.h
r7163 r8706 97 97 void moveToTargetPosition(); 98 98 99 virtual void positionReached() {} 100 99 101 void removeFromFormation(); 100 102 void unregisterSlave(); -
code/trunk/src/orxonox/controllers/Controller.h
r6417 r8706 50 50 { return this->player_; } 51 51 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 */ 53 59 54 60 void setGodMode( bool mode ){ this->bGodMode_ = mode; } -
code/trunk/src/orxonox/controllers/HumanController.cc
r8079 r8706 42 42 extern const std::string __CC_fire_name = "fire"; 43 43 extern const std::string __CC_suicide_name = "suicide"; 44 const std::string __CC_boost_name = "boost"; 44 45 45 46 SetConsoleCommand("HumanController", "moveFrontBack", &HumanController::moveFrontBack ).addShortcut().setAsInputCommand(); … … 51 52 SetConsoleCommand("HumanController", __CC_fire_name, &HumanController::fire ).addShortcut().keybindMode(KeybindMode::OnHold); 52 53 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); 54 55 SetConsoleCommand("HumanController", "greet", &HumanController::greet ).addShortcut(); 55 56 SetConsoleCommand("HumanController", "switchCamera", &HumanController::switchCamera ).addShortcut(); … … 66 67 67 68 HumanController* HumanController::localController_s = 0; 69 /*static*/ const float HumanController::BOOSTING_TIME = 0.1f; 68 70 69 71 HumanController::HumanController(BaseObject* creator) : Controller(creator) … … 71 73 RegisterObject(HumanController); 72 74 73 controlPaused_ = false; 75 this->controlPaused_ = false; 76 this->boosting_ = false; 77 this->boosting_ = false; 74 78 75 79 HumanController::localController_s = this; 80 this->boostingTimeout_.setTimer(HumanController::BOOSTING_TIME, false, createExecutor(createFunctor(&HumanController::terminateBoosting, this))); 81 this->boostingTimeout_.stopTimer(); 76 82 } 77 83 … … 163 169 } 164 170 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; 169 214 } 170 215 -
code/trunk/src/orxonox/controllers/HumanController.h
r8079 r8706 32 32 #include "OrxonoxPrereqs.h" 33 33 34 #include "tools/Timer.h" 34 35 #include "tools/interfaces/Tickable.h" 35 36 #include "Controller.h" … … 64 65 static void reload(); 65 66 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 67 77 static void greet(); 68 78 static void switchCamera(); … … 92 102 static HumanController* localController_s; 93 103 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 94 110 }; // tolua_export 95 111 } // tolua_export -
code/trunk/src/orxonox/gamestates/GSRoot.cc
r8327 r8706 45 45 46 46 static const std::string __CC_setTimeFactor_name = "setTimeFactor"; 47 static const std::string __CC_getTimeFactor_name = "getTimeFactor"; 47 48 static const std::string __CC_setPause_name = "setPause"; 48 49 static const std::string __CC_pause_name = "pause"; … … 52 53 SetConsoleCommand("printObjects", &GSRoot::printObjects).hide(); 53 54 SetConsoleCommand(__CC_setTimeFactor_name, &GSRoot::setTimeFactor).accessLevel(AccessLevel::Master).defaultValues(1.0); 55 SetConsoleCommand(__CC_getTimeFactor_name, &GSRoot::getTimeFactor).accessLevel(AccessLevel::Master); 54 56 SetConsoleCommand(__CC_setPause_name, &GSRoot::setPause ).accessLevel(AccessLevel::Master).hide(); 55 57 SetConsoleCommand(__CC_pause_name, &GSRoot::pause ).accessLevel(AccessLevel::Master); … … 89 91 90 92 ModifyConsoleCommand(__CC_setTimeFactor_name).setObject(this); 93 ModifyConsoleCommand(__CC_getTimeFactor_name).setObject(this); 91 94 ModifyConsoleCommand(__CC_setPause_name).setObject(this); 92 95 ModifyConsoleCommand(__CC_pause_name).setObject(this); … … 96 99 { 97 100 ModifyConsoleCommand(__CC_setTimeFactor_name).setObject(0); 101 ModifyConsoleCommand(__CC_getTimeFactor_name).setObject(0); 98 102 ModifyConsoleCommand(__CC_setPause_name).setObject(0); 99 103 ModifyConsoleCommand(__CC_pause_name).setObject(0); … … 151 155 this->timeFactorPauseBackup_ = factor; 152 156 } 157 } 158 159 float GSRoot::getTimeFactor() 160 { 161 return TimeFactorListener::getTimeFactor(); 153 162 } 154 163 -
code/trunk/src/orxonox/gamestates/GSRoot.h
r8079 r8706 54 54 void pause(); 55 55 56 float getTimeFactor(); 57 56 58 static void delayedStartMainMenu(void); 57 59 -
code/trunk/src/orxonox/gametypes/Dynamicmatch.cc
r8327 r8706 151 151 //Give new pig boost 152 152 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); 161 154 } 162 155 … … 252 245 //Give new pig boost 253 246 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); 263 248 } 264 249 // killer vs piggy … … 321 306 } 322 307 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 323 321 void Dynamicmatch::playerStartsControllingPawn(PlayerInfo* player, Pawn* pawn) //set party + colouring 324 322 { … … 597 595 } 598 596 599 void Dynamicmatch::resetSpeedFactor(WeakPtr< Engine>* ptr)// helper function597 void Dynamicmatch::resetSpeedFactor(WeakPtr<SpaceShip>* ptr)// helper function 600 598 { 601 599 if (*ptr) -
code/trunk/src/orxonox/gametypes/Dynamicmatch.h
r7163 r8706 73 73 virtual void furtherInstructions();*/ 74 74 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); 76 77 void tick (float dt);// used to end the game 77 78 SpawnPoint* getBestSpawnPoint(PlayerInfo* player) const; -
code/trunk/src/orxonox/gametypes/Gametype.cc
r8327 r8706 121 121 } 122 122 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 127 135 this->checkStart(); 128 else if (!this->gtinfo_->bEnded_) 136 } 137 else if (!this->gtinfo_->hasEnded()) 129 138 this->spawnDeadPlayersIfRequested(); 130 139 … … 136 145 this->addBots(this->numberOfBots_); 137 146 138 this->gtinfo_-> bStarted_ = true;147 this->gtinfo_->start(); 139 148 140 149 this->spawnPlayersIfRequested(); … … 143 152 void Gametype::end() 144 153 { 145 this->gtinfo_-> bEnded_ = true;154 this->gtinfo_->end(); 146 155 147 156 for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) … … 173 182 { 174 183 this->players_[player].state_ = PlayerState::Joined; 184 this->gtinfo_->playerEntered(player); 175 185 } 176 186 … … 270 280 } 271 281 282 if(victim->getPlayer()->isHumanPlayer()) 283 this->gtinfo_->pawnKilled(victim->getPlayer()); 284 272 285 ControllableEntity* entity = this->defaultControllableEntity_.fabricate(victim->getCreator()); 273 286 if (victim->getCamera()) … … 306 319 SpawnPoint* Gametype::getBestSpawnPoint(PlayerInfo* player) const 307 320 { 321 // If there is at least one SpawnPoint. 308 322 if (this->spawnpoints_.size() > 0) 309 323 { 324 // Fallback spawn point if there is no active one, choose a random one. 310 325 SpawnPoint* fallbackSpawnPoint = NULL; 311 326 unsigned int randomspawn = static_cast<unsigned int>(rnd(static_cast<float>(this->spawnpoints_.size()))); 312 327 unsigned int index = 0; 313 std:: set<SpawnPoint*> activeSpawnPoints = this->spawnpoints_;328 std::vector<SpawnPoint*> activeSpawnPoints; 314 329 for (std::set<SpawnPoint*>::const_iterator it = this->spawnpoints_.begin(); it != this->spawnpoints_.end(); ++it) 315 330 { … … 317 332 fallbackSpawnPoint = (*it); 318 333 319 if ( !(*it)->isActive())320 activeSpawnPoints. erase(*it);334 if (*it != NULL && (*it)->isActive()) 335 activeSpawnPoints.push_back(*it); 321 336 322 337 ++index; 323 338 } 324 339 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; 335 347 return fallbackSpawnPoint; 336 348 } … … 346 358 it->second.state_ = PlayerState::Dead; 347 359 348 if (!it->first->isReadyToSpawn() || !this->gtinfo_-> bStarted_)360 if (!it->first->isReadyToSpawn() || !this->gtinfo_->hasStarted()) 349 361 { 350 362 this->spawnPlayerAsDefaultPawn(it->first); … … 357 369 void Gametype::checkStart() 358 370 { 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_->s tartCountdown_ = 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);; 367 379 this->start(); 368 380 } … … 389 401 // If in developer's mode, there is no start countdown. 390 402 if(Core::getInstance().inDevMode()) 391 this-> gtinfo_->startCountdown_ = 0;403 this->start(); 392 404 else 393 this->gtinfo_->s tartCountdown_ = this->initialStartCountdown_;394 this->gtinfo_-> bStartCountdownRunning_ = true;405 this->gtinfo_->setStartCountdown(this->initialStartCountdown_); 406 this->gtinfo_->startStartCountdown(); 395 407 } 396 408 } … … 402 414 { 403 415 for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) 416 { 404 417 if (it->first->isReadyToSpawn() || this->bForceSpawn_) 405 418 this->spawnPlayer(it->first); 419 } 406 420 } 407 421 … … 422 436 player->startControl(spawnpoint->spawn()); 423 437 this->players_[player].state_ = PlayerState::Alive; 438 439 if(player->isHumanPlayer()) 440 this->gtinfo_->playerSpawned(player); 441 424 442 this->playerPostSpawn(player); 425 443 } -
code/trunk/src/orxonox/gametypes/Gametype.h
r8178 r8706 78 78 79 79 inline bool hasStarted() const 80 { return this->gtinfo_-> bStarted_; }80 { return this->gtinfo_->hasStarted(); } 81 81 inline bool hasEnded() const 82 { return this->gtinfo_-> bEnded_; }82 { return this->gtinfo_->hasEnded(); } 83 83 84 84 virtual void start(); … … 114 114 115 115 inline bool isStartCountdownRunning() const 116 { return this->gtinfo_-> bStartCountdownRunning_; }116 { return this->gtinfo_->isStartCountdownRunning(); } 117 117 inline float getStartCountdown() const 118 { return this->gtinfo_-> startCountdown_; }118 { return this->gtinfo_->getStartCountdown(); } 119 119 120 120 inline void setHUDTemplate(const std::string& name) 121 { this->gtinfo_-> hudtemplate_ = name; }121 { this->gtinfo_->setHUDTemplate(name); } 122 122 inline const std::string& getHUDTemplate() const 123 { return this->gtinfo_-> hudtemplate_; }123 { return this->gtinfo_->getHUDTemplate(); } 124 124 125 125 void addBots(unsigned int amount); -
code/trunk/src/orxonox/gametypes/LastTeamStanding.cc
r8351 r8706 55 55 this->setHUDTemplate("lastTeamStandingHUD"); 56 56 } 57 57 58 58 LastTeamStanding::~LastTeamStanding() 59 59 { 60 } 60 } 61 61 62 62 void LastTeamStanding::playerEntered(PlayerInfo* player) … … 69 69 else 70 70 playerLives_[player]=getMinLives();//new players only get minimum of lives */ 71 71 72 72 this->timeToAct_[player] = timeRemaining; 73 73 this->playerDelayTime_[player] = respawnDelay; 74 74 this->inGame_[player] = true; 75 75 unsigned int team = getTeam(player); 76 if( team < 0|| team > teams_) // make sure getTeam returns a regular value76 if(team >= eachTeamsPlayers.size()) // make sure getTeam returns a regular value 77 77 return; 78 78 if(this->eachTeamsPlayers[team]==0) //if a player is the first in his group, a new team is alive … … 91 91 this->inGame_.erase(player); 92 92 unsigned int team = getTeam(player); 93 if( team < 0|| team > teams_) // make sure getTeam returns a regular value93 if(team >= eachTeamsPlayers.size()) // make sure getTeam returns a regular value 94 94 return valid_player; 95 95 this->eachTeamsPlayers[team]--; // a player left the team … … 107 107 bool allow = TeamDeathmatch::allowPawnDeath(victim, originator); 108 108 if(!allow) {return allow;} 109 109 110 110 playerLives_[victim->getPlayer()] = playerLives_[victim->getPlayer()] - 1; //player lost a live 111 111 this->inGame_[victim->getPlayer()] = false; //if player dies, he isn't allowed to respawn immediately … … 113 113 { 114 114 unsigned int team = getTeam(victim->getPlayer()); 115 if(team < 0|| team > teams_) // make sure getTeam returns a regular value115 if(team >= eachTeamsPlayers.size()) // make sure getTeam returns a regular value 116 116 return allow; 117 117 this->eachTeamsPlayers[team]--; … … 140 140 const std::string& message = ""; // resets Camper-Warning-message 141 141 this->gtinfo_->sendFadingMessage(message,it->first->getClientID()); 142 } 142 } 143 143 } 144 144 return allow; … … 163 163 return; 164 164 TeamDeathmatch::playerStartsControllingPawn(player,pawn); 165 165 166 166 this->timeToAct_[player] = timeRemaining + 3.0f + respawnDelay;//reset timer 167 167 this->playerDelayTime_[player] = respawnDelay; 168 168 169 169 std::map<PlayerInfo*, Player>::iterator it = this->players_.find(player); 170 170 if (it != this->players_.end()) … … 174 174 const std::string& message = ""; // resets Camper-Warning-message 175 175 this->gtinfo_->sendFadingMessage(message,it->first->getClientID()); 176 } 176 } 177 177 } 178 178 … … 187 187 } 188 188 for (std::map<PlayerInfo*, float>::iterator it = this->timeToAct_.begin(); it != this->timeToAct_.end(); ++it) 189 { 189 { 190 190 if (playerGetLives(it->first) <= 0)//Players without lives shouldn't be affected by time. 191 continue; 191 continue; 192 192 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. 194 194 { 195 195 playerDelayTime_[it->first] -= dt; … … 309 309 return 0; 310 310 } 311 311 312 312 void LastTeamStanding::setConfigValues() 313 313 { -
code/trunk/src/orxonox/graphics/Billboard.cc
r7492 r8706 23 23 * Fabian 'x3n' Landau 24 24 * Co-authors: 25 * ...25 * Maurus Kaufmann 26 26 * 27 27 */ … … 30 30 31 31 #include "OgreBillboard.h" 32 #include "OgreBillboardSet.h"33 32 34 33 #include "core/CoreIncludes.h" … … 46 45 47 46 this->colour_ = ColourValue::White; 48 //this->rotation_ = 0;47 this->rotation_ = 0; 49 48 50 49 this->registerVariables(); … … 66 65 XMLPortParam(Billboard, "material", setMaterial, getMaterial, xmlelement, mode); 67 66 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); 69 68 } 70 69 … … 73 72 registerVariable(this->material_, VariableDirection::ToClient, new NetworkCallback<Billboard>(this, &Billboard::changedMaterial)); 74 73 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)); 76 75 } 77 76 … … 89 88 this->attachOgreObject(this->billboard_.getBillboardSet()); 90 89 this->billboard_.setVisible(this->isVisible()); 91 //this->changedRotation();90 this->changedRotation(); 92 91 } 93 92 } … … 114 113 } 115 114 116 /* 115 117 116 void Billboard::changedRotation() 118 117 { … … 128 127 } 129 128 } 130 */ 129 131 130 132 131 void Billboard::changedVisibility() … … 136 135 this->billboard_.setVisible(this->isVisible()); 137 136 } 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 } 138 173 } -
code/trunk/src/orxonox/graphics/Billboard.h
r7492 r8706 23 23 * Fabian 'x3n' Landau 24 24 * Co-authors: 25 * ...25 * Maurus Kaufmann 26 26 * 27 27 */ … … 31 31 32 32 #include "OrxonoxPrereqs.h" 33 34 #include "OgreBillboardSet.h" 33 35 34 36 #include "util/Math.h" … … 62 64 { return this->colour_; } 63 65 64 /* 66 65 67 inline void setRotation(const Radian& rotation) 66 68 { this->rotation_ = rotation; this->changedRotation(); } 67 69 inline const Radian& getRotation() const 68 70 { return this->rotation_; } 69 */ 71 70 72 71 73 virtual void setTeamColour(const ColourValue& colour) 72 74 { 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 73 84 74 85 protected: … … 81 92 void registerVariables(); 82 93 void changedMaterial(); 83 //void changedRotation();94 void changedRotation(); 84 95 85 96 BillboardSet billboard_; 86 97 std::string material_; 87 98 ColourValue colour_; 88 //Radian rotation_;99 Radian rotation_; 89 100 }; 90 101 } -
code/trunk/src/orxonox/graphics/Camera.cc
r8079 r8706 71 71 this->lastDtLagged_ = false; 72 72 73 this->setSyncMode( 0x0);73 this->setSyncMode(ObjectDirection::None); 74 74 75 75 this->setConfigValues(); -
code/trunk/src/orxonox/graphics/Camera.h
r8079 r8706 40 40 namespace orxonox 41 41 { 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 43 44 { 44 45 friend class CameraManager; -
code/trunk/src/orxonox/infos/GametypeInfo.cc
r8327 r8706 23 23 * Fabian 'x3n' Landau 24 24 * Co-authors: 25 * ...25 * Damian 'Mozork' Frick 26 26 * 27 27 */ 28 29 /** 30 @file GametypeInfo.cc 31 @brief Implementation of the GametypeInfo class 32 */ 28 33 29 34 #include "GametypeInfo.h" … … 31 36 #include "core/CoreIncludes.h" 32 37 #include "core/GameMode.h" 38 #include "network/Host.h" 33 39 #include "network/NetworkFunction.h" 34 #include "network/Host.h" 40 #include "util/Convert.h" 41 42 #include "controllers/HumanController.h" 35 43 #include "interfaces/GametypeMessageListener.h" 44 #include "interfaces/NotificationListener.h" 45 46 #include "PlayerInfo.h" 36 47 37 48 namespace orxonox … … 45 56 registerMemberNetworkFunction(GametypeInfo, dispatchFadingMessage); 46 57 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 */ 47 67 GametypeInfo::GametypeInfo(BaseObject* creator) : Info(creator) 48 68 { 49 69 RegisterObject(GametypeInfo); 50 70 51 71 this->bStarted_ = false; 52 72 this->bEnded_ = false; 53 this->startCountdown_ = 0 ;73 this->startCountdown_ = 0.0f; 54 74 this->bStartCountdownRunning_ = false; 75 this->counter_ = 0; 76 this->spawned_ = false; 77 this->readyToSpawn_ = false; 55 78 56 79 this->registerVariables(); … … 63 86 void GametypeInfo::registerVariables() 64 87 { 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)); 67 91 registerVariable(this->startCountdown_, VariableDirection::ToClient); 68 registerVariable(this-> bStartCountdownRunning_, VariableDirection::ToClient);92 registerVariable(this->counter_, VariableDirection::ToClient, new NetworkCallback<GametypeInfo>(this, &GametypeInfo::changedCountdownCounter)); 69 93 registerVariable(this->hudtemplate_, VariableDirection::ToClient); 70 94 } 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. 71 394 72 395 void GametypeInfo::sendAnnounceMessage(const std::string& message) -
code/trunk/src/orxonox/infos/GametypeInfo.h
r7163 r8706 23 23 * Fabian 'x3n' Landau 24 24 * Co-authors: 25 * ...25 * Damian 'Mozork' Frick 26 26 * 27 27 */ 28 29 /** 30 @file GametypeInfo.h 31 @brief Definition of the GametypeInfo class 32 */ 28 33 29 34 #ifndef _GametypeInfo_H__ … … 33 38 34 39 #include <string> 40 35 41 #include "Info.h" 36 42 37 43 namespace orxonox 38 44 { 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 */ 39 55 class _OrxonoxExport GametypeInfo : public Info 40 56 { … … 45 61 virtual ~GametypeInfo(); 46 62 63 /** 64 @brief Get whether the game has started yet. 65 @return Returns true if the game has started, false if not. 66 */ 47 67 inline bool hasStarted() const 48 68 { 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 */ 49 75 inline bool hasEnded() const 50 76 { return this->bEnded_; } 77 void changedEnded(void); // Is called when the game has changed to ended. 51 78 79 /** 80 @brief Get whether the start countdown is currently running. 81 @return Returns true if the countdown is running, false if not. 82 */ 52 83 inline bool isStartCountdownRunning() const 53 84 { 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 */ 54 91 inline float getStartCountdown() const 55 92 { 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. 56 118 57 119 inline const std::string& getHUDTemplate() const … … 70 132 void dispatchStaticMessage(const std::string& message,const ColourValue& colour); 71 133 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; }; 72 150 73 151 private: 74 152 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. 75 155 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. 80 163 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. 81 168 }; 82 169 } -
code/trunk/src/orxonox/infos/PlayerInfo.cc
r8327 r8706 51 51 this->controllableEntity_ = 0; 52 52 this->controllableEntityID_ = OBJECTID_UNKNOWN; 53 this->oldControllableEntity_ = 0;54 53 55 54 this->gtinfo_ = 0; … … 151 150 return; 152 151 153 if (this->oldControllableEntity_)152 while (this->previousControllableEntity_.size() > 0) 154 153 this->stopTemporaryControl(); 154 155 155 if (this->controllableEntity_) 156 156 this->stopControl(); … … 177 177 return; 178 178 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_)); 182 181 this->controllableEntity_ = entity; 183 182 this->controllableEntityID_ = entity->getObjectID(); … … 194 193 void PlayerInfo::stopControl() 195 194 { 196 if ( this->oldControllableEntity_)195 while ( this->previousControllableEntity_.size() > 0) 197 196 this->stopTemporaryControl(); 198 197 … … 215 214 } 216 215 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 217 228 void PlayerInfo::stopTemporaryControl() 218 229 { 219 230 ControllableEntity* entity = this->controllableEntity_; 220 231 221 assert( this->controllableEntity_ && this->oldControllableEntity_);222 if( !entity || !this->oldControllableEntity_)232 assert(this->controllableEntity_ != NULL); 233 if( !entity || this->previousControllableEntity_.size() == 0 ) 223 234 return; 224 235 225 236 this->controllableEntity_->setController(0); 237 this->controllableEntity_->destroyHud(); // HACK-ish 226 238 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); 228 243 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) 232 247 this->controller_->setControllableEntity(this->controllableEntity_); 248 249 // HACK-ish 250 if(this->controllableEntity_ != NULL) 251 this->controllableEntity_->createHud(); 233 252 234 253 if ( GameMode::isMaster() ) -
code/trunk/src/orxonox/infos/PlayerInfo.h
r7163 r8706 68 68 void startControl(ControllableEntity* entity); 69 69 void stopControl(); 70 void pauseControl(); 70 71 void startTemporaryControl(ControllableEntity* entity); 71 72 void stopTemporaryControl(); … … 98 99 Controller* controller_; 99 100 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. 101 102 unsigned int controllableEntityID_; 102 103 -
code/trunk/src/orxonox/interfaces/CMakeLists.txt
r7504 r8706 1 1 ADD_SOURCE_FILES(ORXONOX_SRC_FILES 2 2 InterfaceCompilation.cc 3 NotificationListener.cc 3 4 Pickupable.cc 4 5 PickupCarrier.cc -
code/trunk/src/orxonox/interfaces/InterfaceCompilation.cc
r7606 r8706 42 42 #include "core/CoreIncludes.h" 43 43 44 #include "infos/PlayerInfo.h" 45 #include "worldentities/pawns/Pawn.h" 46 44 47 namespace orxonox 45 48 { … … 59 62 RegisterRootObject(PlayerTrigger); 60 63 61 this->player_ = NULL;62 64 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()); 63 73 } 64 74 … … 86 96 RegisterRootObject(Rewardable); 87 97 } 88 89 //----------------------------90 // NotificationListener91 //----------------------------92 NotificationListener::NotificationListener()93 {94 RegisterRootObject(NotificationListener);95 }96 98 } -
code/trunk/src/orxonox/interfaces/NotificationListener.h
r7552 r8706 21 21 * 22 22 * Author: 23 * Fabian 'x3n' Landau23 * Damian 'Mozork' Frick 24 24 * Co-authors: 25 25 * ... … … 48 48 namespace orxonox 49 49 { 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 } 51 75 76 // TODO: Update doc. 52 77 /** 53 78 @brief 54 79 NotificationListener interface. 55 80 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(). 58 85 59 86 @author 60 Fabian 'x3n' Landau61 87 Damian 'Mozork' Frick 88 62 89 @ingroup Notifications 90 @todo Consistent terminology between message, notification and command. 63 91 */ 64 92 class _OrxonoxExport NotificationListener : virtual public OrxonoxClass … … 69 97 70 98 /** 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. 73 105 */ 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); } 75 117 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 76 122 /** 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. 79 129 */ 80 virtual void update(void) = 0; 130 virtual bool registerNotification(const std::string& message, const std::string& sender, notificationMessageType::Value type) 131 { return false; } 81 132 /** 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. 85 138 */ 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. 87 155 }; 88 156 } -
code/trunk/src/orxonox/interfaces/PlayerTrigger.h
r7601 r8706 39 39 40 40 #include "core/OrxonoxClass.h" 41 #include "core/WeakPtr.h" 41 42 42 43 namespace orxonox … … 44 45 /** 45 46 @brief 46 PlayerTrigger is an interface if implemented by a specific trigger can be used to recover the Player (or more preciselythe @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. 47 48 48 49 @author … … 58 59 59 60 /** 60 @brief Returns the playerthat triggered the PlayerTrigger.61 @brief Returns the Pawn that triggered the PlayerTrigger. 61 62 @return Returns a pointer to the Pawn that triggered the PlayerTrigger. 62 63 */ 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 64 72 { return this->player_; } 65 73 66 74 /** 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. 69 77 */ 70 78 inline bool isForPlayer(void) const … … 76 84 @param player A pointer to the Pawn that triggered the PlayerTrigger. 77 85 */ 78 inline void setTriggeringPlayer(Pawn* player) 79 { this->player_ = player; } 86 void setTriggeringPawn(Pawn* pawn); 80 87 81 88 /** … … 87 94 88 95 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. 90 98 bool isForPlayer_; //!< Is true when the PlayerTrigger should be set to normally be triggered by Pawns. 91 99 -
code/trunk/src/orxonox/items/Engine.cc
r8079 r8706 35 35 #include "Scene.h" 36 36 #include "worldentities/pawns/SpaceShip.h" 37 #include " tools/Shader.h"37 #include "core/Template.h" 38 38 39 39 namespace orxonox … … 47 47 this->ship_ = 0; 48 48 this->shipID_ = OBJECTID_UNKNOWN; 49 this->relativePosition_ = Vector3(0,0,0); 49 50 50 51 this->boostFactor_ = 1.5; … … 62 63 this->accelerationUpDown_ = 0.0; 63 64 64 this->boostBlur_ = 0;65 66 65 this->speedAdd_ = 0.0; 67 66 this->speedMultiply_ = 1.0; … … 73 72 Engine::~Engine() 74 73 { 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); 81 78 } 82 79 } … … 98 95 XMLPortParam(Engine, "accelerationleftright", setAccelerationLeftRight, setAccelerationLeftRight, xmlelement, mode); 99 96 XMLPortParam(Engine, "accelerationupdown", setAccelerationUpDown, setAccelerationUpDown, xmlelement, mode); 97 98 XMLPortParam(Engine, "position", setRelativePosition, getRelativePosition, xmlelement, mode); 99 XMLPortParam(Engine, "template", setEngineTemplate, getEngineTemplate, xmlelement, mode); 100 100 } 101 101 102 102 void Engine::setConfigValues() 103 103 { 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");109 104 } 110 105 … … 163 158 SUPER(Engine, tick, dt); 164 159 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 166 165 Vector3 velocity = this->ship_->getLocalVelocity(); 167 166 Vector3 acceleration = Vector3::ZERO; … … 202 201 } 203 202 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(); 222 212 } 223 213 } … … 226 216 { 227 217 SUPER(Engine, changedActivity); 228 229 if (this->boostBlur_)230 this->boostBlur_->setVisible(this->isVisible());231 218 } 232 219 … … 238 225 { 239 226 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); 248 229 } 249 230 } … … 267 248 } 268 249 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 } 275 260 } 276 261 } -
code/trunk/src/orxonox/items/Engine.h
r8079 r8706 54 54 inline SpaceShip* getShip() const 55 55 { return this->ship_; } 56 57 inline void setRelativePosition(const Vector3 &position) 58 { this->relativePosition_ = position; } 59 inline Vector3& getRelativePosition() 60 { return this->relativePosition_; } 56 61 57 62 inline void setBoostFactor(float factor) … … 119 124 { this->speedMultiply_=speedMultiply; } 120 125 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 121 132 protected: 122 133 virtual std::vector<PickupCarrier*>* getCarrierChildren(void) const 123 134 { return new std::vector<PickupCarrier*>(); } 124 135 virtual PickupCarrier* getCarrierParent(void) const; 136 137 void loadEngineTemplate(); 125 138 126 139 private: 127 140 void registerVariables(); 128 141 void networkcallback_shipID(); 129 void changedEnableMotionBlur(); 142 143 std::string engineTemplate_; 130 144 131 145 SpaceShip* ship_; 132 146 unsigned int shipID_; 147 Vector3 relativePosition_; 133 148 134 149 float boostFactor_; … … 148 163 float accelerationLeftRight_; 149 164 float accelerationUpDown_; 150 151 Shader* boostBlur_;152 float blurStrength_;153 bool bEnableMotionBlur_;154 165 }; 155 166 } -
code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc
r8351 r8706 137 137 XMLPortParam(OrxonoxOverlay, "correctaspect", setAspectCorrection, getAspectCorrection, xmlelement, mode); 138 138 XMLPortParam(OrxonoxOverlay, "background", setBackgroundMaterial, getBackgroundMaterial, xmlelement, mode); 139 XMLPortParam(OrxonoxOverlay, "backgroundtex", setBackgroundTexture, getBackgroundTexture, xmlelement, mode); 139 140 } 140 141 … … 163 164 if (this->background_) 164 165 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 } 165 194 else 166 195 return BLANKSTRING; … … 406 435 } 407 436 408 void OrxonoxOverlay::setBackgroundAlpha(float alpha) { 437 void OrxonoxOverlay::setBackgroundAlpha(float alpha) 438 { 409 439 Ogre::MaterialPtr ptr = this->background_->getMaterial(); 410 440 Ogre::TextureUnitState* tempTx = ptr->getTechnique(0)->getPass(0)->getTextureUnitState(0); 411 441 tempTx->setAlphaOperation(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, alpha); 412 442 } 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 } 413 450 } -
code/trunk/src/orxonox/overlays/OrxonoxOverlay.h
r8309 r8706 160 160 const std::string& getBackgroundMaterial() const; 161 161 162 void setBackgroundTexture(const std::string& texture); 163 const std::string& getBackgroundTexture() const; 164 162 165 void setBackgroundAlpha(float alpha); 166 167 void setBackgroundColour(ColourValue colour); 163 168 164 169 virtual void changedVisibility(); -
code/trunk/src/orxonox/sound/AmbientSound.cc
r8351 r8706 82 82 { 83 83 this->ambientSource_ = source; 84 this->moodChanged( this->getMood());84 this->moodChanged(MoodManager::getInstance().getMood()); 85 85 } 86 86 … … 89 89 if (GameMode::playsSound()) 90 90 { 91 const std::string& path = "ambient/" + MoodManager::getInstance().getMood()+ '/' + this->ambientSource_;91 const std::string& path = "ambient/" + mood + '/' + this->ambientSource_; 92 92 shared_ptr<ResourceInfo> fileInfo = Resource::getInfo(path); 93 93 if (fileInfo != NULL) -
code/trunk/src/orxonox/weaponsystem/Munition.cc
r7896 r8706 253 253 bool Munition::canAddMunition(unsigned int amount) const 254 254 { 255 // TODO: 'amount' is not used 256 255 257 if (!this->bAllowMunitionRefilling_) 256 258 return false; … … 334 336 bool Munition::canAddMagazines(unsigned int amount) const 335 337 { 338 // TODO: 'amount' is not used 339 336 340 if (this->bStackMunition_) 337 341 // 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 66 66 67 67 this->damage_ = 0; 68 this->healthdamage_ = 0; 69 this->shielddamage_ = 0; 68 70 69 71 this->muzzleOffset_ = Vector3::ZERO; … … 106 108 107 109 XMLPortParam(WeaponMode, "damage", setDamage, getDamage, xmlelement, mode); 110 XMLPortParam(WeaponMode, "healthdamage", setHealthDamage, getHealthDamage, xmlelement, mode); 111 XMLPortParam(WeaponMode, "shielddamage", setShieldDamage, getShieldDamage, xmlelement, mode); 108 112 XMLPortParam(WeaponMode, "muzzleoffset", setMuzzleOffset, getMuzzleOffset, xmlelement, mode); 109 113 } -
code/trunk/src/orxonox/weaponsystem/WeaponMode.h
r7163 r8706 104 104 // Fire 105 105 inline void setDamage(float damage) 106 { this->damage_ = damage; 106 { this->damage_ = damage;} 107 107 inline float getDamage() const 108 108 { 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_; } 109 118 110 119 inline void setMuzzleOffset(const Vector3& offset) … … 146 155 147 156 float damage_; 157 float healthdamage_; 158 float shielddamage_; 148 159 Vector3 muzzleOffset_; 149 160 -
code/trunk/src/orxonox/weaponsystem/WeaponSlot.cc
r5929 r8706 46 46 this->weapon_ = 0; 47 47 48 this->setSyncMode( 0x0);48 this->setSyncMode(ObjectDirection::None); 49 49 } 50 50 -
code/trunk/src/orxonox/worldentities/CMakeLists.txt
r8458 r8706 12 12 SpawnPoint.cc 13 13 TeamSpawnPoint.cc 14 SpaceBoundaries.cc15 14 ) 16 15 -
code/trunk/src/orxonox/worldentities/CameraPosition.cc
r5929 r8706 46 46 this->bRenderCamera_ = false; 47 47 48 this->setSyncMode( 0x0);48 this->setSyncMode(ObjectDirection::None); 49 49 } 50 50 -
code/trunk/src/orxonox/worldentities/ControllableEntity.cc
r7892 r8706 84 84 this->client_angular_velocity_ = Vector3::ZERO; 85 85 86 87 86 this->setConfigValues(); 88 87 this->setPriority( Priority::VeryHigh ); … … 121 120 122 121 XMLPortParam(ControllableEntity, "hudtemplate", setHudTemplate, getHudTemplate, xmlelement, mode); 123 XMLPortParam(ControllableEntity, "camerapositiontemplate", setCameraPositionTemplate, getCameraPositionTem kplate, xmlelement, mode);122 XMLPortParam(ControllableEntity, "camerapositiontemplate", setCameraPositionTemplate, getCameraPositionTemplate, xmlelement, mode); 124 123 125 124 XMLPortObject(ControllableEntity, CameraPosition, "camerapositions", addCameraPosition, getCameraPosition, xmlelement, mode); … … 171 170 } 172 171 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; 173 206 } 174 207 … … 373 406 } 374 407 408 this->createHud(); 409 } 410 411 // HACK-ish 412 void ControllableEntity::createHud(void) 413 { 375 414 if (!this->hud_ && GameMode::showsGraphics()) 376 415 { … … 381 420 this->hud_->setOwner(this); 382 421 } 422 } 423 } 424 425 void ControllableEntity::destroyHud(void) 426 { 427 if (this->hud_ != NULL) 428 { 429 this->hud_->destroy(); 430 this->hud_ = NULL; 383 431 } 384 432 } -
code/trunk/src/orxonox/worldentities/ControllableEntity.h
r7889 r8706 93 93 virtual void reload() {} 94 94 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 96 102 virtual void greet() {} 97 103 virtual void switchCamera(); … … 110 116 inline const std::list<SmartPtr<CameraPosition> >& getCameraPositions() const 111 117 { return this->cameraPositions_; } 118 unsigned int getCurrentCameraIndex() const; 119 bool setCameraPosition(unsigned int index); 112 120 113 121 inline void setCameraPositionTemplate(const std::string& name) 114 122 { this->cameraPositionTemplate_ = name; } 115 inline const std::string& getCameraPositionTem kplate() const123 inline const std::string& getCameraPositionTemplate() const 116 124 { return this->cameraPositionTemplate_; } 117 125 … … 168 176 inline void setHudTemplate(const std::string& name) 169 177 { this->hudtemplate_ = name; } 178 // HACK-ish 179 void createHud(void); 180 void destroyHud(void); 170 181 171 182 Ogre::SceneNode* cameraPositionRootNode_; -
code/trunk/src/orxonox/worldentities/MobileEntity.cc
r7163 r8706 143 143 { 144 144 if (this->isDynamic()) 145 { 145 146 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) 147 150 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 } 148 159 } 149 160 -
code/trunk/src/orxonox/worldentities/MobileEntity.h
r5781 r8706 70 70 { return this->linearAcceleration_; } 71 71 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 72 78 void setAngularAcceleration(const Vector3& acceleration); 73 79 inline void setAngularAcceleration(float x, float y, float z) … … 83 89 { this->setAngularVelocity(this->getAngularVelocity().normalisedCopy() * rate.valueRadians()); } 84 90 inline Degree getRotationRate() const 85 { return Degree(this->getAngularVelocity().length()); }91 { return Radian(this->getAngularVelocity().length()); } 86 92 87 93 inline void setRotationAxis(const Vector3& axis) -
code/trunk/src/orxonox/worldentities/SpawnPoint.cc
r5929 r8706 50 50 COUT(1) << "Error: SpawnPoint has no Gametype" << std::endl; 51 51 52 this->setSyncMode( 0x0);52 this->setSyncMode(ObjectDirection::None); 53 53 } 54 54 -
code/trunk/src/orxonox/worldentities/WorldEntity.cc
r7937 r8706 642 642 void WorldEntity::setScale3D(const Vector3& scale) 643 643 { 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 653 650 this->node_->setScale(scale); 654 651 -
code/trunk/src/orxonox/worldentities/pawns/Pawn.cc
r8351 r8706 23 23 * Fabian 'x3n' Landau 24 24 * Co-authors: 25 * ...25 * Simon Miescher 26 26 * 27 27 */ … … 64 64 this->maxHealth_ = 0; 65 65 this->initialHealth_ = 0; 66 66 67 this->shieldHealth_ = 0; 68 this->initialShieldHealth_ = 0; 69 this->maxShieldHealth_ = 100; //otherwise shield might increase to float_max 67 70 this->shieldAbsorption_ = 0.5; 71 72 this->reloadRate_ = 0; 73 this->reloadWaitTime_ = 1.0f; 74 this->reloadWaitCountdown_ = 0; 68 75 69 76 this->lastHitOriginator_ = 0; … … 109 116 110 117 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); 111 120 XMLPortParam(Pawn, "shieldabsorption", setShieldAbsorption, getShieldAbsorption, xmlelement, mode).defaultValues(0); 112 121 … … 118 127 XMLPortObject(Pawn, WeaponSet, "weaponsets", addWeaponSet, getWeaponSet, xmlelement, mode); 119 128 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); 120 132 } 121 133 … … 124 136 registerVariable(this->bAlive_, VariableDirection::ToClient); 125 137 registerVariable(this->health_, VariableDirection::ToClient); 126 registerVariable(this-> initialHealth_,VariableDirection::ToClient);138 registerVariable(this->maxHealth_, VariableDirection::ToClient); 127 139 registerVariable(this->shieldHealth_, VariableDirection::ToClient); 140 registerVariable(this->maxShieldHealth_, VariableDirection::ToClient); 128 141 registerVariable(this->shieldAbsorption_, VariableDirection::ToClient); 129 142 registerVariable(this->bReload_, VariableDirection::ToServer); … … 137 150 this->bReload_ = false; 138 151 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 139 163 if (GameMode::isMaster()) 164 { 140 165 if (this->health_ <= 0 && bAlive_) 141 166 { 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. 143 168 this->death(); 144 169 } 170 } 145 171 } 146 172 … … 168 194 } 169 195 196 170 197 void Pawn::setHealth(float health) 171 198 { 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) 176 228 { 177 229 if (this->getGametype() && this->getGametype()->allowPawnDamage(this, originator)) 178 230 { 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()) 185 232 { 186 healthdamage += shielddamage-this->getShieldHealth();187 233 this->setShieldHealth(0); 234 this->setHealth(this->health_ - (healthdamage + damage)); 188 235 } 189 190 this->setHealth(this->health_ - healthdamage); 191 192 if (this->getShieldHealth() > 0) 236 else 193 237 { 194 238 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); 195 247 } 196 248 197 249 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) 204 260 { 205 261 if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) ) 206 262 { 207 this->damage(damage, originator);263 this->damage(damage, healthdamage, shielddamage, originator); 208 264 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) 215 270 { 216 271 if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) ) 217 272 { 218 this->damage(damage, originator);273 this->damage(damage, healthdamage, shielddamage, originator); 219 274 220 275 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 226 280 227 281 void Pawn::kill() -
code/trunk/src/orxonox/worldentities/pawns/Pawn.h
r7889 r8706 72 72 { return this->initialHealth_; } 73 73 74 inline void setShieldHealth(float shieldHealth)75 { this->shieldHealth_ = shieldHealth; } 74 virtual void setShieldHealth(float shieldHealth); 75 76 76 inline float getShieldHealth() 77 77 { 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_); } 78 98 79 99 inline void setShieldAbsorption(float shieldAbsorption) … … 82 102 { return this->shieldAbsorption_; } 83 103 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 84 121 inline ControllableEntity* getLastHitOriginator() const 85 122 { return this->lastHitOriginator_; } 86 123 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 89 129 virtual void kill(); 90 130 … … 142 182 virtual void spawneffect(); 143 183 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); 145 186 146 187 bool bAlive_; … … 154 195 float maxHealth_; 155 196 float initialHealth_; 197 156 198 float shieldHealth_; 199 float maxShieldHealth_; 200 float initialShieldHealth_; 157 201 float shieldAbsorption_; // Has to be between 0 and 1 202 float reloadRate_; 203 float reloadWaitTime_; 204 float reloadWaitCountdown_; 158 205 159 206 WeakPtr<Pawn> lastHitOriginator_; -
code/trunk/src/orxonox/worldentities/pawns/SpaceShip.cc
r7860 r8706 35 35 #include "core/Template.h" 36 36 #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" 37 42 #include "items/Engine.h" 43 44 #include "CameraManager.h" 45 #include "Scene.h" 38 46 39 47 namespace orxonox … … 42 50 CreateFactory(SpaceShip); 43 51 44 SpaceShip::SpaceShip(BaseObject* creator) : Pawn(creator) 52 SpaceShip::SpaceShip(BaseObject* creator) : Pawn(creator), boostBlur_(NULL) 45 53 { 46 54 RegisterObject(SpaceShip); … … 53 61 this->localAngularAcceleration_.setValue(0, 0, 0); 54 62 this->bBoost_ = false; 55 this->bPermanentBoost_ = false;56 63 this->steering_ = Vector3::ZERO; 57 this->engine_ = 0;58 64 59 65 this->boostPower_ = 10.0f; … … 64 70 this->bBoostCooldown_ = false; 65 71 72 this->lift_ = 1.0f; // factor of the lift, standard is 1 73 this->stallSpeed_ = 220.0f; // max speed where lift is added 74 66 75 this->bInvertYAxis_ = false; 67 76 … … 74 83 this->enableCollisionCallback(); 75 84 85 this->engineTicksNotDone = 0; 76 86 this->setConfigValues(); 77 87 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; 78 95 } 79 96 80 97 SpaceShip::~SpaceShip() 81 98 { 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 } 84 106 } 85 107 … … 88 110 SUPER(SpaceShip, XMLPort, xmlelement, mode); 89 111 90 XMLPortParam(SpaceShip, "engine", setEngineTemplate, getEngineTemplate, xmlelement, mode);112 //XMLPortParam(SpaceShip, "engine", setEngineTemplate, getEngineTemplate, xmlelement, mode); 91 113 XMLPortParamVariable(SpaceShip, "primaryThrust", primaryThrust_, xmlelement, mode); 92 114 XMLPortParamVariable(SpaceShip, "auxilaryThrust", auxilaryThrust_, xmlelement, mode); … … 96 118 XMLPortParamVariable(SpaceShip, "boostRate", boostRate_, xmlelement, mode); 97 119 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); 98 126 } 99 127 … … 103 131 registerVariable(this->auxilaryThrust_, VariableDirection::ToClient); 104 132 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); 105 142 } 106 143 … … 108 145 { 109 146 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"); 110 153 } 111 154 … … 128 171 if (this->hasLocalController()) 129 172 { 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 140 174 if (!this->isInMouseLook()) 141 175 { … … 143 177 this->physicalBody_->applyTorque(physicalBody_->getWorldTransform().getBasis() * this->localAngularAcceleration_); 144 178 } 145 146 179 this->localAngularAcceleration_.setValue(0, 0, 0); 147 180 181 // Charge boostPower 148 182 if(!this->bBoostCooldown_ && this->boostPower_ < this->initialBoostPower_) 149 183 { 150 184 this->boostPower_ += this->boostPowerRate_*dt; 151 185 } 186 // Use boostPower 152 187 if(this->bBoost_) 153 188 { … … 155 190 if(this->boostPower_ <= 0.0f) 156 191 { 157 this->b Boost_ = false;192 this->boost(false); 158 193 this->bBoostCooldown_ = true; 159 194 this->timer_.setTimer(this->boostCooldownDuration_, false, createExecutor(createFunctor(&SpaceShip::boostCooledDown, this))); 160 195 } 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(); 162 291 } 163 292 } … … 167 296 this->bBoostCooldown_ = false; 168 297 } 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!"; 213 333 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; 217 373 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; 267 426 } 268 427 … … 270 429 { 271 430 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]); 273 433 return list; 274 434 } 435 436 void SpaceShip::changedEnableMotionBlur() 437 { 438 if (!this->bEnableMotionBlur_) 439 { 440 this->boostBlur_->destroy(); 441 this->boostBlur_ = 0; 442 } 443 } 444 275 445 } -
code/trunk/src/orxonox/worldentities/pawns/SpaceShip.h
r7801 r8706 59 59 60 60 virtual void fire(); 61 virtual void boost( );61 virtual void boost(bool bBoost); // Starts or stops boosting. 62 62 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 66 75 67 76 inline void setSteeringDirection(const Vector3& direction) … … 69 78 inline const Vector3& getSteeringDirection() const 70 79 { 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); } 71 86 72 void setBoost(bool bBoost);73 87 inline bool getBoost() const 74 88 { return this->bBoost_; } 75 89 76 inline void setEngineTemplate(const std::string& temp)77 { this->enginetemplate_ = temp; this->loadEngineTemplate(); }78 inline const std::string& getEngineTemplate() const79 { return this-> enginetemplate_; }90 inline float getBoostPower() const 91 { return this->boostPower_; } 92 inline float getInitialBoostPower() const 93 { return this->initialBoostPower_; } 80 94 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_; } 85 97 86 98 protected: … … 90 102 bool bBoost_; 91 103 bool bBoostCooldown_; 92 bool bPermanentBoost_;93 104 float boostPower_; 94 105 float initialBoostPower_; … … 96 107 float boostPowerRate_; 97 108 float boostCooldownDuration_; 109 float lift_; 110 float stallSpeed_; 98 111 Vector3 steering_; 99 112 float primaryThrust_; … … 103 116 btVector3 localAngularAcceleration_; 104 117 118 float shakeFrequency_; 119 float shakeAmplitude_; 120 105 121 private: 106 122 void registerVariables(); 107 123 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); 108 132 109 void loadEngineTemplate();110 111 void boostCooledDown(void);133 Shader* boostBlur_; 134 float blurStrength_; 135 bool bEnableMotionBlur_; 112 136 113 std:: string enginetemplate_;114 Engine* engine_;137 std::vector<Engine*> engineList_; 138 int engineTicksNotDone; // Used for knowing when to reset temporary variables. 115 139 Timer timer_; 140 Vector3 cameraOriginalPosition_; 141 Quaternion cameraOriginalOrientation_; 142 143 float shakeDt_; 116 144 }; 117 145 }
Note: See TracChangeset
for help on using the changeset viewer.