Changeset 2662
- Timestamp:
- Feb 14, 2009, 10:17:35 PM (16 years ago)
- Location:
- code/trunk
- Files:
-
- 6 deleted
- 281 edited
- 400 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/TODO
r2171 r2662 3 3 test network functionality with paketloss/delay: http://www.linuxfoundation.org/en/Net:Netem#Packet_loss 4 4 5 bidirectional6 7 5 minimize synchronisableHeader 8 6 9 7 10 !!! check that enet does not cause a packet traffic jam when a reliable packet gets missed !!!11 8 !!! ensure that objects get synched, when newly created, even if not their tick 12 9 -
code/trunk/bin/Plugins.cfg
r1763 r2662 10 10 Plugin=Plugin_BSPSceneManager 11 11 Plugin=Plugin_OctreeSceneManager 12 #Plugin=Plugin_CgProgramManager12 Plugin=Plugin_CgProgramManager 13 13 -
code/trunk/bin/def_keybindings.ini
r2103 r2662 32 32 KeyF14= 33 33 KeyF15= 34 KeyF2= 34 KeyF2="OverlayGroup toggleVisibility Stats" 35 35 KeyF3= 36 36 KeyF4= … … 50 50 KeyKana= 51 51 KeyKanji= 52 KeyL= 52 KeyL=dropItems 53 53 KeyLeft= 54 54 KeyLeftAlt= 55 55 KeyLeftBracket= 56 KeyLeftControl= 56 KeyLeftControl=mouseLook 57 57 KeyLeftShift= 58 58 KeyLeftWindows= … … 100 100 KeyPageDown= 101 101 KeyPageUp= 102 KeyPause= 102 KeyPause=pause 103 103 KeyPeriod= 104 104 KeyPlayPause= … … 119 119 KeySlash= 120 120 KeySleep= 121 KeySpace= 121 KeySpace=boost 122 122 KeyStop= 123 123 KeySystemRequest= … … 145 145 KeyYen= 146 146 KeyZ= 147 Key_084=148 Key_085=149 Key_089=150 Key_090=151 Key_091=152 Key_092=153 Key_093=154 Key_094=155 Key_095=156 Key_096=157 Key_097=158 Key_098=159 Key_099=160 Key_103=161 Key_104=162 Key_105=163 Key_106=164 Key_107=165 Key_108=166 Key_109=167 Key_110=168 Key_111=169 Key_112=170 Key_114=171 Key_115=172 Key_117=173 Key_118=174 Key_119=175 Key_120=176 Key_121=177 Key_123=178 Key_125=179 Key_128=180 Key_129=181 Key_130=182 Key_131=183 Key_132=184 Key_133=185 Key_134=186 Key_135=187 Key_136=188 Key_137=189 Key_138=190 Key_139=191 Key_140=192 Key_141=193 Key_143=194 Key_144=195 Key_154=196 Key_155=197 Key_158=198 Key_159=199 Key_163=200 Key_165=201 Key_166=202 Key_167=203 Key_168=204 Key_169=205 Key_170=206 Key_171=207 Key_172=208 Key_173=209 Key_175=210 Key_177=211 Key_180=212 Key_182=213 Key_185=214 Key_186=215 Key_187=216 Key_188=217 Key_189=218 Key_190=219 Key_191=220 Key_192=221 Key_193=222 Key_194=223 Key_195=224 Key_196=225 Key_198=226 Key_202=227 Key_204=228 Key_206=229 Key_212=230 Key_213=231 Key_214=232 Key_215=233 Key_216=234 Key_217=235 Key_218=236 Key_224=237 Key_225=238 Key_226=239 Key_228=240 147 241 148 [MouseButtons] … … 247 154 MouseLeft="fire" 248 155 MouseMiddle= 249 MouseRight= 156 MouseRight="altfire" 250 157 MouseWheel1Down= 251 158 MouseWheel1Up= … … 256 163 MouseXNeg="scale -1 rotateYaw" 257 164 MouseXPos="scale 1 rotateYaw" 258 MouseYNeg="scale 1 rotatePitch"259 MouseYPos="scale -1 rotatePitch"165 MouseYNeg="scale -1 rotatePitch" 166 MouseYPos="scale 1 rotatePitch" 260 167 -
code/trunk/bin/telnet_server.tcl
r1505 r2662 81 81 return 82 82 } 83 if {[string equal $line " quit"] || [string equal $line "exit"]} {83 if {[string equal $line "logout"] || [string equal $line "quit"]} { 84 84 disconnect $client 85 return 86 } 87 if {[string equal $line "exit"]} { 88 set ::termination 1 85 89 return 86 90 } -
code/trunk/src/CMakeLists.txt
r2129 r2662 2 2 INCLUDE_DIRECTORIES(..) 3 3 INCLUDE_DIRECTORIES(orxonox) 4 INCLUDE_DIRECTORIES(bullet) 4 5 5 6 ADD_SUBDIRECTORY(cpptcl) 6 7 ADD_SUBDIRECTORY(ois) 7 8 ADD_SUBDIRECTORY(tinyxml) 9 ADD_SUBDIRECTORY(bullet) 8 10 ADD_SUBDIRECTORY(lua) 9 11 ADD_SUBDIRECTORY(tolua) -
code/trunk/src/core/BaseObject.cc
r2171 r2662 36 36 #include "CoreIncludes.h" 37 37 #include "EventIncludes.h" 38 #include "Functor.h" 38 39 #include "XMLPort.h" 39 40 #include "XMLFile.h" … … 60 61 this->oldGametype_ = 0; 61 62 63 this->lastLoadedXMLElement_ = 0; 64 65 this->functorSetMainState_ = 0; 66 this->functorGetMainState_ = 0; 67 62 68 this->setCreator(creator); 63 69 if (this->creator_) … … 82 88 BaseObject::~BaseObject() 83 89 { 84 for (std::list<BaseObject*>::const_iterator it = this->events_.begin(); it != this->events_.end(); ++it) 85 (*it)->unregisterEventListener(this); 86 87 for (std::map<BaseObject*, std::string>::const_iterator it = this->eventListeners_.begin(); it != this->eventListeners_.end(); ++it) 88 it->first->removeEvent(this); 90 if (this->isInitialized()) 91 { 92 for (std::list<BaseObject*>::const_iterator it = this->events_.begin(); it != this->events_.end(); ++it) 93 (*it)->unregisterEventListener(this); 94 95 for (std::map<BaseObject*, std::string>::const_iterator it = this->eventListeners_.begin(); it != this->eventListeners_.end(); ++it) 96 it->first->removeEvent(this); 97 98 if (this->functorSetMainState_) 99 delete this->functorSetMainState_; 100 if (this->functorGetMainState_) 101 delete this->functorGetMainState_; 102 } 89 103 } 90 104 … … 100 114 XMLPortParam(BaseObject, "visible", setVisible, isVisible, xmlelement, mode); 101 115 XMLPortParam(BaseObject, "active", setActive, isActive, xmlelement, mode); 116 XMLPortParam(BaseObject, "mainstate", setMainStateName, getMainStateName, xmlelement, mode); 102 117 103 118 XMLPortObjectTemplate(BaseObject, Template, "templates", addTemplate, getTemplate, xmlelement, mode, Template*); … … 109 124 std::list<std::string> eventnames; 110 125 111 if (mode == XMLPort::LoadObject )126 if (mode == XMLPort::LoadObject || mode == XMLPort::ExpandObject) 112 127 { 113 128 for (ticpp::Iterator<ticpp::Element> child = events->FirstChildElement(false); child != child.end(); child++) … … 279 294 SetEvent(BaseObject, "visibility", setVisible, event); 280 295 } 296 297 void BaseObject::setMainStateName(const std::string& name) 298 { 299 if (this->mainStateName_ != name) 300 { 301 this->mainStateName_ = name; 302 if (this->functorSetMainState_) 303 delete this->functorSetMainState_; 304 if (this->functorGetMainState_) 305 delete this->functorGetMainState_; 306 this->changedMainState(); 307 if (!this->functorSetMainState_) 308 COUT(2) << "Warning: \"" << name << "\" is not a valid MainState." << std::endl; 309 } 310 } 311 312 void BaseObject::setMainState(bool state) 313 { 314 if (this->functorSetMainState_) 315 (*this->functorSetMainState_)(state); 316 else 317 COUT(2) << "Warning: No MainState defined in object \"" << this->getName() << "\" (" << this->getIdentifier()->getName() << ")" << std::endl; 318 } 319 320 bool BaseObject::getMainState() const 321 { 322 if (this->functorGetMainState_) 323 { 324 (*this->functorGetMainState_)(); 325 return this->functorGetMainState_->getReturnvalue(); 326 } 327 else 328 { 329 COUT(2) << "Warning: No MainState defined in object \"" << this->getName() << "\" (" << this->getIdentifier()->getName() << ")" << std::endl; 330 return false; 331 } 332 } 333 334 void BaseObject::changedMainState() 335 { 336 SetMainState(BaseObject, "activity", setActive, isActive); 337 SetMainState(BaseObject, "visibility", setVisible, isVisible); 338 } 281 339 } -
code/trunk/src/core/BaseObject.h
r2171 r2662 36 36 #ifndef _BaseObject_H__ 37 37 #define _BaseObject_H__ 38 39 #define SetMainState(classname, statename, setfunction, getfunction) \ 40 if (this->getMainStateName() == statename) \ 41 { \ 42 this->functorSetMainState_ = createFunctor(&classname::setfunction)->setObject(this); \ 43 this->functorGetMainState_ = createFunctor(&classname::getfunction)->setObject(this); \ 44 } 38 45 39 46 #include <map> … … 55 62 class _CoreExport BaseObject : virtual public OrxonoxClass 56 63 { 64 template <class T> friend class XMLPortClassParamContainer; 65 57 66 public: 58 67 BaseObject(BaseObject* creator); … … 100 109 virtual void changedVisibility() {} 101 110 111 void setMainState(bool state); 112 bool getMainState() const; 113 114 void setMainStateName(const std::string& name); 115 inline const std::string& getMainStateName() const { return this->mainStateName_; } 116 virtual void changedMainState(); 117 102 118 /** @brief Sets a pointer to the xml file that loaded this object. @param file The pointer to the XMLFile */ 103 119 inline void setFile(const XMLFile* file) { this->file_ = file; } … … 121 137 inline Scene* getScene() const { return this->scene_; } 122 138 123 inline void setGametype(Gametype* gametype) { this->oldGametype_ = this->gametype_; this->gametype_ = gametype; this->changedGametype(); } 139 inline void setGametype(Gametype* gametype) 140 { 141 if (gametype != this->gametype_) 142 { 143 this->oldGametype_ = this->gametype_; 144 this->gametype_ = gametype; 145 this->changedGametype(); 146 } 147 } 124 148 inline Gametype* getGametype() const { return this->gametype_; } 125 149 inline Gametype* getOldGametype() const { return this->oldGametype_; } 126 virtual inlinevoid changedGametype() {}150 virtual void changedGametype() {} 127 151 128 152 void fireEvent(); … … 151 175 152 176 protected: 153 std::string name_; //!< The name of the object 154 std::string oldName_; //!< The old name of the object 155 mbool bActive_; //!< True = the object is active 156 mbool bVisible_; //!< True = the object is visible 177 std::string name_; //!< The name of the object 178 std::string oldName_; //!< The old name of the object 179 mbool bActive_; //!< True = the object is active 180 mbool bVisible_; //!< True = the object is visible 181 std::string mainStateName_; 182 Functor* functorSetMainState_; 183 Functor* functorGetMainState_; 157 184 158 185 private: … … 160 187 Template* getTemplate(unsigned int index) const; 161 188 162 bool bInitialized_; //!< True if the object was initialized (passed the object registration) 163 const XMLFile* file_; //!< The XMLFile that loaded this object 164 std::string loaderIndentation_; //!< Indentation of the debug output in the Loader 165 Namespace* namespace_; 166 BaseObject* creator_; 167 Scene* scene_; 168 Gametype* gametype_; 169 Gametype* oldGametype_; 170 std::set<Template*> templates_; 171 std::map<BaseObject*, std::string> eventListeners_; 189 bool bInitialized_; //!< True if the object was initialized (passed the object registration) 190 const XMLFile* file_; //!< The XMLFile that loaded this object 191 Element* lastLoadedXMLElement_; //!< Non 0 if the TinyXML attributes have already been copied to our own lowercase map 192 std::map<std::string, std::string> xmlAttributes_; //!< Lowercase XML attributes 193 std::string loaderIndentation_; //!< Indentation of the debug output in the Loader 194 Namespace* namespace_; 195 BaseObject* creator_; 196 Scene* scene_; 197 Gametype* gametype_; 198 Gametype* oldGametype_; 199 std::set<Template*> templates_; 200 std::map<BaseObject*, std::string> eventListeners_; 172 201 std::list<BaseObject*> events_; 173 202 std::map<std::string, EventContainer*> eventContainers_; … … 178 207 SUPER_FUNCTION(3, BaseObject, changedVisibility, false); 179 208 SUPER_FUNCTION(4, BaseObject, processEvent, false); 209 SUPER_FUNCTION(6, BaseObject, changedMainState, false); 210 SUPER_FUNCTION(9, BaseObject, changedName, false); 211 SUPER_FUNCTION(10, BaseObject, changedGametype, false); 180 212 } 181 213 -
code/trunk/src/core/CommandExecutor.cc
r1784 r2662 53 53 } 54 54 55 ConsoleCommand& CommandExecutor::addConsoleCommandShortcut(ConsoleCommand* command )55 ConsoleCommand& CommandExecutor::addConsoleCommandShortcut(ConsoleCommand* command, bool bDeleteAtExit) 56 56 { 57 57 std::map<std::string, ConsoleCommand*>::const_iterator it = CommandExecutor::getInstance().consoleCommandShortcuts_.find(command->getName()); … … 61 61 } 62 62 63 // Make sure we can also delete the external ConsoleCommands that don't belong to an Identifier 64 if (command && bDeleteAtExit) 65 { 66 CommandExecutor::getInstance().consoleCommandExternals_.insert(command); 67 } 63 68 64 69 CommandExecutor::getInstance().consoleCommandShortcuts_[command->getName()] = command; … … 647 652 } 648 653 } 654 655 void CommandExecutor::destroyExternalCommands() 656 { 657 for (std::set<ConsoleCommand*>::const_iterator it = CommandExecutor::getInstance().consoleCommandExternals_.begin(); 658 it != CommandExecutor::getInstance().consoleCommandExternals_.end(); ++it) 659 delete *it; 660 } 649 661 } -
code/trunk/src/core/CommandExecutor.h
r1771 r2662 51 51 static const CommandEvaluation& getLastEvaluation(); 52 52 53 static ConsoleCommand& addConsoleCommandShortcut(ConsoleCommand* command );53 static ConsoleCommand& addConsoleCommandShortcut(ConsoleCommand* command, bool bDeleteAtExit = false); 54 54 static ConsoleCommand* getConsoleCommandShortcut(const std::string& name); 55 55 static ConsoleCommand* getLowercaseConsoleCommandShortcut(const std::string& name); … … 68 68 /** @brief Returns a const_iterator to the end of the map that stores all console commands with their names in lowercase. @return The const_iterator */ 69 69 static inline std::map<std::string, ConsoleCommand*>::const_iterator getLowercaseConsoleCommandShortcutMapEnd() { return CommandExecutor::getInstance().consoleCommandShortcuts_LC_.end(); } 70 71 static void destroyExternalCommands(); 70 72 71 73 private: … … 101 103 std::map<std::string, ConsoleCommand*> consoleCommandShortcuts_; 102 104 std::map<std::string, ConsoleCommand*> consoleCommandShortcuts_LC_; 105 std::set<ConsoleCommand*> consoleCommandExternals_; 103 106 }; // tolua_export 104 107 } // tolua_export -
code/trunk/src/core/CommandLine.cc
r2105 r2662 83 83 CommandLine::~CommandLine() 84 84 { 85 for (std::map<std::string, CommandLineArgument*>::const_iterator it = cmdLineArgs_.begin(); 86 it != cmdLineArgs_.end(); ++it) 87 { 88 delete it->second; 89 } 85 CommandLine::destroyAllArguments(); 90 86 } 91 87 … … 98 94 static CommandLine instance; 99 95 return instance; 96 } 97 98 /** 99 @brief 100 Destroys all command line arguments. This should be called at the end 101 of main. Do not use before that. 102 */ 103 void CommandLine::destroyAllArguments() 104 { 105 for (std::map<std::string, CommandLineArgument*>::const_iterator it = _getInstance().cmdLineArgs_.begin(); 106 it != _getInstance().cmdLineArgs_.end(); ++it) 107 delete it->second; 108 _getInstance().cmdLineArgs_.clear(); 100 109 } 101 110 -
code/trunk/src/core/CommandLine.h
r2103 r2662 155 155 } 156 156 157 static void destroyAllArguments(); 157 158 158 159 private: … … 179 180 //! Holds all pointers to the arguments and serves as a search map by name. 180 181 std::map<std::string, CommandLineArgument*> cmdLineArgs_; 181 //! Search map by chortcut for the arguments.182 //! Search map by shortcut for the arguments. 182 183 std::map<std::string, CommandLineArgument*> cmdLineArgsShortcut_; 183 184 }; -
code/trunk/src/core/ConfigFileManager.cc
r2103 r2662 160 160 if ((*it)->getIndex() > size) 161 161 size = (*it)->getIndex(); 162 return (size + 1); 162 if (size == 0) 163 return 0; 164 else 165 return (size + 1); 163 166 } 164 167 -
code/trunk/src/core/ConfigFileManager.h
r2103 r2662 38 38 39 39 #include "util/Math.h" 40 #include "util/OrxEnum.h" 40 41 41 42 namespace orxonox 42 43 { 43 // Use unsigned int as config file type to have an arbitrary number of files 44 class ConfigFileType 45 { 46 public: 47 ConfigFileType() { } 48 ConfigFileType(unsigned int type) { type_ = type; } 49 ConfigFileType(const ConfigFileType& instance) { type_ = instance.type_; } 50 51 operator unsigned int() { return type_; } 52 ConfigFileType& operator =(unsigned int type) { type_ = type; return *this; } 53 bool operator <(const ConfigFileType& right) const { return (type_ < right.type_); } 54 55 /* *** Put the different config file types here *** */ 56 static const unsigned int NoType = 0; 57 static const unsigned int Settings = 1; 58 static const unsigned int JoyStickCalibration = 2; 59 60 static const unsigned int numberOfReservedTypes = 1024; 61 62 private: 63 unsigned int type_; 44 // Use int as config file type to have an arbitrary number of files 45 struct ConfigFileType : OrxEnum<ConfigFileType> 46 { 47 OrxEnumConstructors(ConfigFileType); 48 49 static const int NoType = 0; 50 static const int Settings = 1; 51 static const int JoyStickCalibration = 2; 52 53 static const int numberOfReservedTypes = 1024; 64 54 }; 65 55 -
code/trunk/src/core/ConfigValueContainer.cc
r2171 r2662 273 273 { 274 274 this->valueVector_.clear(); 275 for (unsigned int i = 0; i < ConfigFileManager::getInstance().getVectorSize(this->type_, this->sectionname_, this->varname_); i++) 275 unsigned int vectorSize = ConfigFileManager::getInstance().getVectorSize(this->type_, this->sectionname_, this->varname_); 276 for (unsigned int i = 0; i < vectorSize; i++) 276 277 { 277 278 if (i < this->defvalueStringVector_.size()) -
code/trunk/src/core/ConfigValueContainer.h
r2171 r2662 109 109 { 110 110 this->init(type, identifier, sectionname, varname); 111 this->initValue( (V)defvalue);111 this->initValue(static_cast<V>(defvalue)); 112 112 } 113 113 … … 217 217 inline const std::string& getName() const 218 218 { return this->varname_; } 219 /** @brief Retuns the name of the section this config value is in. */ 220 inline const std::string& getSectionName() const 221 { return this->sectionname_; } 219 222 /** @brief Returns true if this config-value is a vector */ 220 223 inline bool isVector() const -
code/trunk/src/core/ConsoleCommand.h
r2087 r2662 64 64 65 65 #define SetConsoleCommandShortcutGeneric(fakevariable, command) \ 66 orxonox::ConsoleCommand& fakevariable = orxonox::CommandExecutor::addConsoleCommandShortcut(command )66 orxonox::ConsoleCommand& fakevariable = orxonox::CommandExecutor::addConsoleCommandShortcut(command, true) 67 67 68 68 -
code/trunk/src/core/Core.cc
r2171 r2662 46 46 bool Core::bIsMaster_s = false; 47 47 48 Core* Core::singletonRef_s = 0; 49 48 50 /** 49 51 @brief Constructor: Registers the object and sets the config-values. … … 53 55 { 54 56 RegisterRootObject(Core); 57 58 assert(Core::singletonRef_s == 0); 59 Core::singletonRef_s = this; 60 this->bInitializeRandomNumberGenerator_ = false; 61 55 62 this->setConfigValues(); 56 isCreatingCoreSettings() = false;57 63 } 58 64 … … 62 68 Core::~Core() 63 69 { 64 isCreatingCoreSettings() = true; 65 } 66 67 /** 68 @brief Returns true if the Core instance is not yet ready and the static functions have to return a default value. 69 */ 70 bool& Core::isCreatingCoreSettings() 71 { 72 static bool bCreatingCoreSettings = true; 73 return bCreatingCoreSettings; 74 } 75 76 /** 77 @brief Returns a unique instance of Core. 78 @return The instance 79 */ 80 Core& Core::getInstance() 81 { 82 // If bCreatingSoftDebugLevelObject is true, we're just about to create an instance of the DebugLevel class 83 //if (Core::isCreatingCoreSettings()) 84 //{ 85 // isCreatingCoreSettings() = false; 86 // //instance.setConfigValues(); 87 //} 88 89 static bool firstTime = true; 90 if (firstTime) 91 isCreatingCoreSettings() = true; 92 93 static Core instance; 94 return instance; 70 assert(Core::singletonRef_s); 71 Core::singletonRef_s = 0; 95 72 } 96 73 … … 104 81 SetConfigValue(softDebugLevelShell_, 1).description("The maximal level of debug output shown in the ingame shell").callback(this, &Core::debugLevelChanged); 105 82 SetConfigValue(language_, Language::getLanguage().defaultLanguage_).description("The language of the ingame text").callback(this, &Core::languageChanged); 83 SetConfigValue(bInitializeRandomNumberGenerator_, true).description("If true, all random actions are different each time you start the game").callback(this, &Core::initializeRandomNumberGenerator); 106 84 } 107 85 … … 140 118 int Core::getSoftDebugLevel(OutputHandler::OutputDevice device) 141 119 { 142 if (!Core::isCreatingCoreSettings())120 switch (device) 143 121 { 144 switch (device) 145 { 146 case OutputHandler::LD_All: 147 return Core::getInstance().softDebugLevel_; 148 case OutputHandler::LD_Console: 149 return Core::getInstance().softDebugLevelConsole_; 150 case OutputHandler::LD_Logfile: 151 return Core::getInstance().softDebugLevelLogfile_; 152 case OutputHandler::LD_Shell: 153 return Core::getInstance().softDebugLevelShell_; 154 default: 155 assert(0); 156 } 122 case OutputHandler::LD_All: 123 return Core::getInstance().softDebugLevel_; 124 case OutputHandler::LD_Console: 125 return Core::getInstance().softDebugLevelConsole_; 126 case OutputHandler::LD_Logfile: 127 return Core::getInstance().softDebugLevelLogfile_; 128 case OutputHandler::LD_Shell: 129 return Core::getInstance().softDebugLevelShell_; 130 default: 131 assert(0); 132 return 2; 157 133 } 158 159 // Return a constant value while we're creating the object160 return 2;161 134 } 162 135 … … 168 141 void Core::setSoftDebugLevel(OutputHandler::OutputDevice device, int level) 169 142 { 170 if (!Core::isCreatingCoreSettings()) 171 { 172 if (device == OutputHandler::LD_All) 173 Core::getInstance().softDebugLevel_ = level; 174 else if (device == OutputHandler::LD_Console) 175 Core::getInstance().softDebugLevelConsole_ = level; 176 else if (device == OutputHandler::LD_Logfile) 177 Core::getInstance().softDebugLevelLogfile_ = level; 178 else if (device == OutputHandler::LD_Shell) 179 Core::getInstance().softDebugLevelShell_ = level; 143 if (device == OutputHandler::LD_All) 144 Core::getInstance().softDebugLevel_ = level; 145 else if (device == OutputHandler::LD_Console) 146 Core::getInstance().softDebugLevelConsole_ = level; 147 else if (device == OutputHandler::LD_Logfile) 148 Core::getInstance().softDebugLevelLogfile_ = level; 149 else if (device == OutputHandler::LD_Shell) 150 Core::getInstance().softDebugLevelShell_ = level; 180 151 181 OutputHandler::setSoftDebugLevel(device, level); 182 } 152 OutputHandler::setSoftDebugLevel(device, level); 183 153 } 184 154 … … 188 158 const std::string& Core::getLanguage() 189 159 { 190 if (!Core::isCreatingCoreSettings()) 191 return Core::getInstance().language_; 192 193 return Language::getLanguage().defaultLanguage_; 160 return Core::getInstance().language_; 194 161 } 195 162 … … 209 176 ResetConfigValue(language_); 210 177 } 178 179 void Core::initializeRandomNumberGenerator() 180 { 181 static bool bInitialized = false; 182 if (!bInitialized && this->bInitializeRandomNumberGenerator_) 183 { 184 srand(time(0)); 185 rand(); 186 bInitialized = true; 187 } 188 } 211 189 } -
code/trunk/src/core/Core.h
r2171 r2662 40 40 #include "CorePrereqs.h" 41 41 42 #include <cassert> 42 43 #include "OrxonoxClass.h" 43 44 #include "util/OutputHandler.h" … … 49 50 { 50 51 public: 51 static Core& getInstance();52 static bool& isCreatingCoreSettings();52 Core(); 53 ~Core(); 53 54 void setConfigValues(); 54 55 void debugLevelChanged(); 55 56 void languageChanged(); 56 57 57 static int getSoftDebugLevel(OutputHandler::OutputDevice device = OutputHandler::LD_All); 58 static void setSoftDebugLevel(OutputHandler::OutputDevice device, int level); 58 static Core& getInstance() { assert(Core::singletonRef_s); return *Core::singletonRef_s; } 59 60 static int getSoftDebugLevel(OutputHandler::OutputDevice device = OutputHandler::LD_All); 61 static void setSoftDebugLevel(OutputHandler::OutputDevice device, int level); 59 62 static const std::string& getLanguage(); 60 static void resetLanguage();63 static void resetLanguage(); 61 64 62 65 // fast access global variables. … … 73 76 74 77 private: 78 Core(const Core&); 75 79 void resetLanguageIntern(); 76 77 Core(); 78 Core(const Core& other); 79 virtual ~Core(); 80 void initializeRandomNumberGenerator(); 80 81 81 82 int softDebugLevel_; //!< The debug level … … 84 85 int softDebugLevelShell_; //!< The debug level for the ingame shell 85 86 std::string language_; //!< The language 87 bool bInitializeRandomNumberGenerator_; //!< If true, srand(time(0)) is called 86 88 87 89 static bool bShowsGraphics_s; //!< global variable that tells whether to show graphics … … 90 92 static bool bIsStandalone_s; 91 93 static bool bIsMaster_s; 94 95 static Core* singletonRef_s; 92 96 }; 93 97 } -
code/trunk/src/core/CorePrereqs.h
r2087 r2662 69 69 { 70 70 LoadObject, 71 SaveObject 71 SaveObject, 72 ExpandObject 72 73 }; 73 74 } … … 132 133 class LanguageEntry; 133 134 class Loader; 135 class LuaBind; 134 136 class MetaObjectList; 135 137 class MetaObjectListElement; -
code/trunk/src/core/Factory.cc
r2171 r2662 58 58 @return The Identifier 59 59 */ 60 Identifier* Factory::getIdentifier(const u nsigned int id)60 Identifier* Factory::getIdentifier(const uint32_t id) 61 61 { 62 std::map<u nsigned int, Identifier*>::const_iterator it = getFactoryPointer()->identifierNetworkIDMap_.find(id);62 std::map<uint32_t, Identifier*>::const_iterator it = getFactoryPointer()->identifierNetworkIDMap_.find(id); 63 63 if (it != getFactoryPointer()->identifierNetworkIDMap_.end()) 64 64 return it->second; … … 85 85 @param newID The new networkID 86 86 */ 87 void Factory::changeNetworkID(Identifier* identifier, const u nsigned int oldID, const unsigned int newID)87 void Factory::changeNetworkID(Identifier* identifier, const uint32_t oldID, const uint32_t newID) 88 88 { 89 89 getFactoryPointer()->identifierNetworkIDMap_.erase(oldID); -
code/trunk/src/core/Factory.h
r2171 r2662 49 49 #include <map> 50 50 #include <string> 51 #include "util/Integers.h" 51 52 52 53 namespace orxonox … … 60 61 public: 61 62 static Identifier* getIdentifier(const std::string& name); 62 static Identifier* getIdentifier(const u nsigned int id);63 static Identifier* getIdentifier(const uint32_t id); 63 64 static void add(const std::string& name, Identifier* identifier); 64 static void changeNetworkID(Identifier* identifier, const u nsigned int oldID, const unsigned int newID);65 static void changeNetworkID(Identifier* identifier, const uint32_t oldID, const uint32_t newID); 65 66 static void createClassHierarchy(); 66 67 … … 83 84 84 85 std::map<std::string, Identifier*> identifierStringMap_; //!< The map, mapping the name with the Identifier 85 std::map<u nsigned int, Identifier*> identifierNetworkIDMap_; //!< The map, mapping the network ID with the Identifier86 std::map<uint32_t, Identifier*> identifierNetworkIDMap_; //!< The map, mapping the network ID with the Identifier 86 87 }; 87 88 -
code/trunk/src/core/Functor.h
r2087 r2662 167 167 } 168 168 169 FunctorMember * setObject(T* object)169 FunctorMember<T>* setObject(T* object) 170 170 { 171 171 this->bConstObject_ = false; … … 174 174 } 175 175 176 FunctorMember * setObject(const T* object)176 FunctorMember<T>* setObject(const T* object) 177 177 { 178 178 this->bConstObject_ = true; -
code/trunk/src/core/Identifier.cc
r2171 r2662 93 93 for (std::map<std::string, XMLPortObjectContainer*>::iterator it = this->xmlportObjectContainers_.begin(); it != this->xmlportObjectContainers_.end(); ++it) 94 94 delete (it->second); 95 for (std::vector<Functor*>::iterator it = this->constructionCallbacks_.begin(); it != this->constructionCallbacks_.end(); ++it) 96 delete *it; 97 } 98 99 /** 100 @brief Returns the identifier map with the names as received by typeid(). This is only used internally. 101 */ 102 std::map<std::string, Identifier*>& Identifier::getTypeIDIdentifierMap() 103 { 104 static std::map<std::string, Identifier*> identifiers; //!< The map to store all Identifiers. 105 return identifiers; 95 106 } 96 107 … … 103 114 Identifier* Identifier::getIdentifierSingleton(const std::string& name, Identifier* proposal) 104 115 { 105 static std::map<std::string, Identifier*> identifiers; //!< The map to store all Identifiers. 106 std::map<std::string, Identifier*>::const_iterator it = identifiers.find(name); 107 108 if (it != identifiers.end()) 116 std::map<std::string, Identifier*>::const_iterator it = getTypeIDIdentifierMap().find(name); 117 118 if (it != getTypeIDIdentifierMap().end()) 109 119 { 110 120 // There is already an entry: return it and delete the proposal … … 115 125 { 116 126 // There is no entry: put the proposal into the map and return it 117 identifiers[name] = proposal;127 getTypeIDIdentifierMap()[name] = proposal; 118 128 return proposal; 119 129 } … … 192 202 void Identifier::destroyAllIdentifiers() 193 203 { 194 for (std::map<std::string, Identifier*>::iterator it = Identifier::get IdentifierMapIntern().begin(); it != Identifier::getIdentifierMapIntern().end(); ++it)204 for (std::map<std::string, Identifier*>::iterator it = Identifier::getTypeIDIdentifierMap().begin(); it != Identifier::getTypeIDIdentifierMap().end(); ++it) 195 205 delete (it->second); 196 206 } … … 235 245 @param id The new network ID 236 246 */ 237 void Identifier::setNetworkID(u nsigned int id)247 void Identifier::setNetworkID(uint32_t id) 238 248 { 239 249 Factory::changeNetworkID(this, this->classID_, id); -
code/trunk/src/core/Identifier.h
r2171 r2662 68 68 #include "Super.h" 69 69 #include "Functor.h" 70 #include "util/Integers.h" 70 71 #include "util/Debug.h" 71 72 #include "util/String.h" … … 230 231 231 232 /** @brief Returns the network ID to identify a class through the network. @return the network ID */ 232 inline const u nsigned int getNetworkID() const { return this->classID_; }233 inline const uint32_t getNetworkID() const { return this->classID_; } 233 234 234 235 /** @brief Sets the network ID to a new value. @param id The new value */ 235 void setNetworkID(u nsigned int id);236 void setNetworkID(uint32_t id); 236 237 237 238 void addConfigValueContainer(const std::string& varname, ConfigValueContainer* container); … … 256 257 257 258 void initializeClassHierarchy(std::set<const Identifier*>* parents, bool bRootClass); 259 260 static void destroyAllIdentifiers(); 258 261 259 262 protected: … … 299 302 } 300 303 304 static std::map<std::string, Identifier*>& getTypeIDIdentifierMap(); 305 301 306 void initialize(std::set<const Identifier*>* parents); 302 303 static void destroyAllIdentifiers();304 307 305 308 std::set<const Identifier*> parents_; //!< The parents of the class the Identifier belongs to … … 315 318 BaseFactory* factory_; //!< The Factory, able to create new objects of the given class (if available) 316 319 static int hierarchyCreatingCounter_s; //!< Bigger than zero if at least one Identifier stores its parents (its an int instead of a bool to avoid conflicts with multithreading) 317 u nsigned int classID_;//!< The network ID to identify a class through the network320 uint32_t classID_; //!< The network ID to identify a class through the network 318 321 319 322 bool bHasConfigValues_; //!< True if this class has at least one assigned config value -
code/trunk/src/core/Iterator.h
r2171 r2662 96 96 inline Iterator(ObjectListElement<O>* element) 97 97 { 98 this->element_ = (element) ? (ObjectListBaseElement*)element: 0;98 this->element_ = (element) ? static_cast<ObjectListBaseElement*>(element) : 0; 99 99 this->list_ = ClassIdentifier<O>::getIdentifier()->getObjects(); 100 100 this->iterator_ = this->list_->registerIterator(this); … … 108 108 inline Iterator(const ObjectListIterator<O>& other) 109 109 { 110 this->element_ = (other.element_) ? (ObjectListBaseElement*)other.element_: 0;110 this->element_ = (other.element_) ? static_cast<ObjectListBaseElement*>(other.element_) : 0; 111 111 this->list_ = ClassIdentifier<O>::getIdentifier()->getObjects(); 112 112 this->iterator_ = this->list_->registerIterator(this); … … 163 163 this->list_->unregisterIterator(this->iterator_); 164 164 165 this->element_ = (element) ? (ObjectListBaseElement*)element: 0;165 this->element_ = (element) ? static_cast<ObjectListBaseElement*>(element) : 0; 166 166 this->list_ = ClassIdentifier<O>::getIdentifier()->getObjects(); 167 167 this->iterator_ = this->list_->registerIterator(this); -
code/trunk/src/core/Language.cc
r2171 r2662 87 87 // ### Language ### 88 88 // ############################### 89 90 Language* Language::singletonRef_s = 0; 91 89 92 /** 90 93 @brief Constructor: Reads the default language file and sets some values. … … 92 95 Language::Language() 93 96 { 97 assert(singletonRef_s == 0); 98 singletonRef_s = this; 99 94 100 this->defaultLanguage_ = "default"; 95 101 this->defaultLocalisation_ = "ERROR: LANGUAGE ENTRY DOESN'T EXIST!"; … … 106 112 for (std::map<std::string, LanguageEntry*>::iterator it = this->languageEntries_.begin(); it != this->languageEntries_.end(); ++it) 107 113 delete (it->second); 108 } 109 110 /** 111 @brief Returns a reference to the only existing instance of the Language class and calls the setConfigValues() function. 112 @return The reference to the only existing instance 113 */ 114 Language& Language::getLanguage() 115 { 116 static Language instance = Language(); 117 return instance; 114 115 assert(singletonRef_s); 116 singletonRef_s = 0; 118 117 } 119 118 … … 233 232 if ((lineString != "") && (lineString.size() > 0)) 234 233 { 235 unsigned int pos = lineString.find('=');234 size_t pos = lineString.find('='); 236 235 237 236 // Check if the length is at least 3 and if there's an entry before and behind the = … … 279 278 if ((lineString != "") && (lineString.size() > 0)) 280 279 { 281 unsigned int pos = lineString.find('=');280 size_t pos = lineString.find('='); 282 281 283 282 // Check if the length is at least 3 and if there's an entry before and behind the = -
code/trunk/src/core/Language.h
r2171 r2662 50 50 #include <map> 51 51 #include <string> 52 #include <cassert> 52 53 53 54 #define AddLanguageEntry(label, fallbackstring) \ … … 116 117 117 118 public: 118 static Language& getLanguage(); 119 Language(); 120 ~Language(); 121 122 static Language& getLanguage() { assert(singletonRef_s); return *singletonRef_s; } 119 123 void addEntry(const LanguageEntryLabel& label, const std::string& entry); 120 124 const std::string& getLocalisation(const LanguageEntryLabel& label) const; 121 125 122 126 private: 123 Language(); 124 Language(const Language& language); // don't copy 125 virtual ~Language(); 127 Language(const Language&); 126 128 127 129 void readDefaultLanguageFile(); … … 134 136 std::string defaultLocalisation_; //!< The returned string, if an entry unavailable entry is requested 135 137 std::map<std::string, LanguageEntry*> languageEntries_; //!< A map to store all LanguageEntry objects and their labels 138 139 static Language* singletonRef_s; 136 140 }; 137 141 } -
code/trunk/src/core/Loader.cc
r2171 r2662 120 120 121 121 // let Lua work this out: 122 LuaBind *lua = LuaBind::getInstance();123 lua ->clearLuaOutput();124 lua ->loadFile(file->getFilename(), true);125 lua ->run();122 LuaBind& lua = LuaBind::getInstance(); 123 lua.clearLuaOutput(); 124 lua.loadFile(file->getFilename(), true); 125 lua.run(); 126 126 127 127 try … … 135 135 ticpp::Document xmlfile; 136 136 //xmlfile.ToDocument(); 137 xmlfile.Parse(lua ->getLuaOutput(), true);137 xmlfile.Parse(lua.getLuaOutput(), true); 138 138 139 139 ticpp::Element rootElement; -
code/trunk/src/core/LuaBind.cc
r2508 r2662 40 40 namespace orxonox 41 41 { 42 LuaBind* LuaBind::singletonRef = NULL;42 LuaBind* LuaBind::singletonRef_s = NULL; 43 43 44 44 LuaBind::LuaBind() 45 45 { 46 assert(LuaBind::singletonRef_s == 0); 47 LuaBind::singletonRef_s = this; 48 46 49 luaState_ = lua_open(); 47 50 luaSource_ = ""; -
code/trunk/src/core/LuaBind.h
r2087 r2662 42 42 } 43 43 44 #include <cassert> 44 45 #include <list> 45 46 #include <string> … … 58 59 59 60 public: 60 inline static LuaBind* getInstance() { if (!LuaBind::singletonRef) LuaBind::singletonRef = new LuaBind(); return LuaBind::singletonRef; } // tolua_export 61 inline ~LuaBind() { LuaBind::singletonRef = NULL; }; 61 LuaBind(); 62 inline ~LuaBind() { assert(singletonRef_s); LuaBind::singletonRef_s = NULL; }; 63 64 inline static LuaBind& getInstance() { assert(singletonRef_s); return *LuaBind::singletonRef_s; } // tolua_export 62 65 63 66 void loadFile(std::string filename, bool luaTags); … … 83 86 84 87 private: 85 LuaBind(); 86 static LuaBind* singletonRef; 88 static LuaBind* singletonRef_s; 87 89 88 90 std::string luaSource_; -
code/trunk/src/core/ObjectListIterator.h
r1747 r2662 123 123 { 124 124 if (this->element_) 125 this->element_ = (ObjectListElement<T>*)this->element_->next_;125 this->element_ = static_cast<ObjectListElement<T>*>(this->element_->next_); 126 126 return *this; 127 127 } … … 135 135 ObjectListIterator<T> copy = *this; 136 136 if (this->element_) 137 this->element_ = (ObjectListElement<T>*)this->element_->next_;137 this->element_ = static_cast<ObjectListElement<T>*>(this->element_->next_); 138 138 return copy; 139 139 } … … 146 146 { 147 147 if (this->element_) 148 this->element_ = (ObjectListElement<T>*)this->element_->prev_;148 this->element_ = static_cast<ObjectListElement<T>*>(this->element_->prev_); 149 149 return *this; 150 150 } … … 158 158 ObjectListIterator<T> copy = *this; 159 159 if (this->element_) 160 this->element_ = (ObjectListElement<T>*)this->element_->prev_;160 this->element_ = static_cast<ObjectListElement<T>*>(this->element_->prev_); 161 161 return copy; 162 162 } -
code/trunk/src/core/RootGameState.cc
r2103 r2662 31 31 #include "util/Debug.h" 32 32 #include "util/Exception.h" 33 #include "Core.h"34 33 #include "Clock.h" 35 34 #include "CommandLine.h" … … 123 122 /** 124 123 @brief 124 Main loop of the orxonox game. 125 125 Starts the game. The little 'while' denotes the main loop. 126 126 Whenever the root state is selected, the game ends. 127 127 @param name 128 128 State to start with (usually main menu or specified by command line) 129 @note 130 We use the Ogre::Timer to measure time since it uses the most precise 131 method an a platform (however the windows timer lacks time when under 132 heavy kernel load!). 129 133 */ 130 134 void RootGameState::start() 131 135 { 132 #ifdef NDEBUG 136 // Don't catch errors when having a debugger in msvc 137 #if ORXONOX_COMPILER != ORXONOX_COMPILER_MSVC || defined(NDEBUG) 133 138 try 134 139 { … … 136 141 // start global orxonox time 137 142 Clock clock; 138 139 // create the Core settings to configure the output level140 Core::getInstance();141 143 142 144 this->activate(); … … 156 158 157 159 this->deactivate(); 158 #if def NDEBUG160 #if ORXONOX_COMPILER != ORXONOX_COMPILER_MSVC || defined(NDEBUG) 159 161 } 160 162 // Note: These are all unhandled exceptions that should not have made its way here! … … 162 164 catch (std::exception& ex) 163 165 { 164 COUT(1) << ex.what() << std::endl; 165 COUT(1) << "Program aborted." << std::endl; 166 COUT(0) << ex.what() << std::endl; 167 COUT(0) << "Program aborted." << std::endl; 168 abort(); 166 169 } 167 170 // anything that doesn't inherit from std::exception 168 171 catch (...) 169 172 { 170 COUT(1) << "An unidentifiable exception has occured. Program aborted." << std::endl; 173 COUT(0) << "An unidentifiable exception has occured. Program aborted." << std::endl; 174 abort(); 171 175 } 172 176 #endif -
code/trunk/src/core/RootGameState.h
r2103 r2662 48 48 void gotoState(const std::string& name); 49 49 50 std::string 50 std::string stateRequest_; 51 51 }; 52 52 } -
code/trunk/src/core/Shell.cc
r1792 r2662 75 75 76 76 this->outputBuffer_.registerListener(this); 77 OutputHandler::getOutStream().setOutputBuffer( this->outputBuffer_);77 OutputHandler::getOutStream().setOutputBuffer(&this->outputBuffer_); 78 78 79 79 this->setConfigValues(); … … 84 84 Shell::~Shell() 85 85 { 86 OutputHandler::getOutStream().setOutputBuffer(0); 86 87 if (this->inputBuffer_) 87 88 delete this->inputBuffer_; -
code/trunk/src/core/Super.h
r2171 r2662 99 99 \ 100 100 static void apply(void* temp) {} \ 101 \ 101 102 static void apply(baseclass* temp) \ 102 103 { \ … … 104 105 for (std::set<const Identifier*>::iterator it = identifier->getDirectChildrenIntern().begin(); it != identifier->getDirectChildrenIntern().end(); ++it) \ 105 106 { \ 107 if (((ClassIdentifier<T>*)(*it))->bSuperFunctionCaller_##functionname##_isFallback_ && ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_) \ 108 { \ 109 delete ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_; \ 110 ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_ = 0; \ 111 ((ClassIdentifier<T>*)(*it))->bSuperFunctionCaller_##functionname##_isFallback_ = false; \ 112 } \ 113 \ 106 114 if (!((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_) \ 107 115 { \ … … 163 171 for (std::set<const Identifier*>::iterator it = identifier->getDirectChildrenIntern().begin(); it != identifier->getDirectChildrenIntern().end(); ++it) 164 172 { 173 // Check if the caller is a fallback-caller 174 if (((ClassIdentifier<T>*)(*it))->bSuperFunctionCaller_##functionname##_isFallback_ && ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_) 175 { 176 // Delete the fallback caller an prepare to get a real caller 177 delete ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_; 178 ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_ = 0; 179 ((ClassIdentifier<T>*)(*it))->bSuperFunctionCaller_##functionname##_isFallback_ = false; 180 } 181 165 182 // Check if there's not already a caller 166 183 if (!((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_) … … 183 200 struct SuperFunctionCondition<functionnumber, baseclass, 0, templatehack2> \ 184 201 { \ 185 // The check function just behaves like the fallback - it advances to the check for the next super-function (functionnumber + 1)202 // The check function acts like the fallback - it advances to the check for the next super-function (functionnumber + 1) 186 203 static void check() \ 187 204 { \ … … 233 250 #define SUPER_processEvent(classname, functionname, ...) \ 234 251 SUPER_ARGS(classname, functionname, __VA_ARGS__) 252 253 #define SUPER_changedScale(classname, functionname, ...) \ 254 SUPER_NOARGS(classname, functionname) 255 256 #define SUPER_changedMainState(classname, functionname, ...) \ 257 SUPER_NOARGS(classname, functionname) 258 259 #define SUPER_changedOwner(classname, functionname, ...) \ 260 SUPER_NOARGS(classname, functionname) 261 262 #define SUPER_changedOverlayGroup(classname, functionname, ...) \ 263 SUPER_NOARGS(classname, functionname) 264 265 #define SUPER_changedName(classname, functionname, ...) \ 266 SUPER_NOARGS(classname, functionname) 267 268 #define SUPER_changedGametype(classname, functionname, ...) \ 269 SUPER_NOARGS(classname, functionname) 235 270 // (1/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- 236 271 … … 292 327 }; \ 293 328 \ 329 class _CoreExport SuperFunctionCaller_##functionname \ 330 { \ 331 public: \ 332 virtual void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) ) = 0; \ 333 virtual ~SuperFunctionCaller_##functionname () {} \ 334 }; \ 335 \ 336 template <class T> \ 337 class SuperFunctionClassCaller_purevirtualfallback_##functionname : public SuperFunctionCaller_##functionname \ 338 { \ 339 public: \ 340 inline void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) ) \ 341 { \ 342 } \ 343 }; \ 344 \ 294 345 template <class T> \ 295 346 struct SuperFunctionInitialization<functionnumber, T> \ … … 297 348 static void initialize(ClassIdentifier<T>* identifier) \ 298 349 { \ 299 identifier->superFunctionCaller_##functionname##_ = 0; \ 350 identifier->superFunctionCaller_##functionname##_ = new SuperFunctionClassCaller_purevirtualfallback_##functionname <T>; \ 351 identifier->bSuperFunctionCaller_##functionname##_isFallback_ = true; \ 300 352 SuperFunctionInitialization<functionnumber + 1, T>::initialize(identifier); \ 301 353 } \ … … 313 365 }; \ 314 366 \ 315 class _CoreExport SuperFunctionCaller_##functionname \316 { \317 public: \318 virtual void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) ) = 0; \319 virtual ~SuperFunctionCaller_##functionname () {} \320 }; \321 \322 367 template <class T> \ 323 368 class SuperFunctionClassCaller_##functionname : public SuperFunctionCaller_##functionname \ … … 366 411 }; 367 412 368 // Initializes the SuperFunctionCaller-pointer with zero. 413 // Baseclass of the super-function caller. The real call will be done by a 414 // templatized subclass through the virtual () operator. 415 class _CoreExport SuperFunctionCaller_##functionname 416 { 417 public: 418 virtual void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) ) = 0; 419 virtual ~SuperFunctionCaller_##functionname () {} 420 }; 421 422 // Fallback if the base is pure virtual 423 template <class T> 424 class SuperFunctionClassCaller_purevirtualfallback_##functionname : public SuperFunctionCaller_##functionname 425 { 426 public: 427 // Fallback does nothing 428 inline void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) ) 429 { 430 } 431 }; 432 433 // Initializes the SuperFunctionCaller-pointer with a fallback caller in case the base function is pure virtual 369 434 template <class T> 370 435 struct SuperFunctionInitialization<functionnumber, T> … … 372 437 static void initialize(ClassIdentifier<T>* identifier) 373 438 { 374 identifier->superFunctionCaller_##functionname##_ = 0; 439 identifier->superFunctionCaller_##functionname##_ = new SuperFunctionClassCaller_purevirtualfallback_##functionname <T>; 440 identifier->bSuperFunctionCaller_##functionname##_isFallback_ = true; 375 441 376 442 // Calls the initialization of the next super-function (functionnumber + 1) … … 391 457 SuperFunctionDestruction<functionnumber + 1, T>::destroy(identifier); 392 458 } 393 };394 395 // Baseclass of the super-function caller. The real call will be done by a396 // templatized subclass through the virtual () operator.397 class _CoreExport SuperFunctionCaller_##functionname398 {399 public:400 virtual void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) ) = 0;401 virtual ~SuperFunctionCaller_##functionname () {}402 459 }; 403 460 … … 441 498 (event) 442 499 SUPER_FUNCTION_GLOBAL_DECLARATION_PART2; 500 501 SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(5, changedScale, false) 502 () 503 SUPER_FUNCTION_GLOBAL_DECLARATION_PART2; 504 505 SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(6, changedMainState, false) 506 () 507 SUPER_FUNCTION_GLOBAL_DECLARATION_PART2; 508 509 SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(7, changedOwner, false) 510 () 511 SUPER_FUNCTION_GLOBAL_DECLARATION_PART2; 512 513 SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(8, changedOverlayGroup, false) 514 () 515 SUPER_FUNCTION_GLOBAL_DECLARATION_PART2; 516 517 SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(9, changedName, false) 518 () 519 SUPER_FUNCTION_GLOBAL_DECLARATION_PART2; 520 521 SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(10, changedGametype, false) 522 () 523 SUPER_FUNCTION_GLOBAL_DECLARATION_PART2; 443 524 // (2/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- 444 525 … … 476 557 #ifndef SUPER_INTRUSIVE_DECLARATION 477 558 #define SUPER_INTRUSIVE_DECLARATION(functionname) \ 478 SuperFunctionCaller_##functionname * superFunctionCaller_##functionname##_ 559 SuperFunctionCaller_##functionname * superFunctionCaller_##functionname##_; \ 560 bool bSuperFunctionCaller_##functionname##_isFallback_ 479 561 #endif 480 562 … … 488 570 SUPER_INTRUSIVE_DECLARATION(changedVisibility); 489 571 SUPER_INTRUSIVE_DECLARATION(processEvent); 572 SUPER_INTRUSIVE_DECLARATION(changedScale); 573 SUPER_INTRUSIVE_DECLARATION(changedMainState); 574 SUPER_INTRUSIVE_DECLARATION(changedOwner); 575 SUPER_INTRUSIVE_DECLARATION(changedOverlayGroup); 576 SUPER_INTRUSIVE_DECLARATION(changedName); 577 SUPER_INTRUSIVE_DECLARATION(changedGametype); 490 578 // (3/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- 491 579 -
code/trunk/src/core/Template.cc
- Property svn:mergeinfo changed
/code/branches/network/src/core/Template.cc (added) merged: 2356 /code/branches/objecthierarchy2/src/core/Template.cc (added) merged: 2173,2369 /code/branches/physics_merge/src/core/Template.cc (added) merged: 2442 /code/branches/presentation/src/core/Template.cc (added) merged: 2371,2420,2459,2485,2492-2493,2500
r2261 r2662 43 43 44 44 this->bIsLink_ = false; 45 this->bLoadDefaults_ = true; 45 46 this->bIsReturningXMLElement_ = false; 46 47 this->baseclassIdentifier_ = 0; … … 56 57 SUPER(Template, XMLPort, xmlelement, mode); 57 58 58 XMLPortParam(Template, "link", setLink, getLink, xmlelement, mode); 59 XMLPortParam(Template, "baseclass", setBaseclass, getBaseclass, xmlelement, mode); 59 XMLPortParam(Template, "link", setLink, getLink, xmlelement, mode); 60 XMLPortParam(Template, "baseclass", setBaseclass, getBaseclass, xmlelement, mode); 61 XMLPortParam(Template, "defaults", setLoadDefaults, getLoadDefaults, xmlelement, mode).defaultValues(true); 60 62 61 63 Element* element = xmlelement.FirstChildElement(false); … … 70 72 void Template::changedName() 71 73 { 74 SUPER(Template, changedName); 75 72 76 if (this->getName() != "") 73 77 { … … 134 138 135 139 Element temp = ((TiXmlElement*)&this->getXMLElement()); 136 object->XMLPort(temp, XMLPort::LoadObject); 140 141 if (this->bLoadDefaults_) 142 object->XMLPort(temp, XMLPort::LoadObject); 143 else 144 object->XMLPort(temp, XMLPort::ExpandObject); 137 145 } 138 146 - Property svn:mergeinfo changed
-
code/trunk/src/core/Template.h
- Property svn:mergeinfo changed
/code/branches/network/src/core/Template.h (added) merged: 2356 /code/branches/objecthierarchy2/src/core/Template.h (added) merged: 2173 /code/branches/physics_merge/src/core/Template.h (added) merged: 2442 /code/branches/presentation/src/core/Template.h (added) merged: 2371,2420,2459,2485,2492-2493,2500
r2261 r2662 53 53 { return this->link_; } 54 54 55 inline void setLoadDefaults(bool bLoadDefaults) 56 { this->bLoadDefaults_ = bLoadDefaults; } 57 inline bool getLoadDefaults() const 58 { return this->bLoadDefaults_; } 59 55 60 inline void setXMLElement(const TiXmlElement& xmlelement) 56 61 { this->xmlelement_ = xmlelement; } … … 75 80 Identifier* baseclassIdentifier_; 76 81 bool bIsLink_; 82 bool bLoadDefaults_; 77 83 mutable bool bIsReturningXMLElement_; 78 84 }; - Property svn:mergeinfo changed
-
code/trunk/src/core/XMLFile.h
- Property svn:mergeinfo changed
/code/branches/network/src/core/XMLFile.h (added) merged: 2356 /code/branches/physics_merge/src/core/XMLFile.h (added) merged: 2442 /code/branches/presentation/src/core/XMLFile.h (added) merged: 2371,2420,2459,2485,2492-2493,2500 /code/trunk/src/core/XMLFile.h (added) merged: 2-2085
- Property svn:mergeinfo changed
-
code/trunk/src/core/XMLIncludes.h
- Property svn:mergeinfo changed
/code/branches/network/src/core/XMLIncludes.h (added) merged: 2356 /code/branches/physics/src/core/XMLIncludes.h (added) merged: 2192 /code/branches/physics_merge/src/core/XMLIncludes.h (added) merged: 2442 /code/branches/pickups2/src/core/XMLIncludes.h (added) merged: 2136 /code/branches/presentation/src/core/XMLIncludes.h (added) merged: 2371,2420,2459,2485,2492-2493,2500,2539
r2261 r2662 64 64 namespace orxonox 65 65 { 66 typedef ticpp::DocumentDocument;67 typedef ticpp::ElementElement;68 typedef ticpp::DeclarationDeclaration;69 typedef ticpp::StylesheetReferenceStylesheetReference;70 typedef ticpp::TextText;71 typedef ticpp::CommentComment;72 typedef ticpp::AttributeAttribute;66 using ticpp::Document; 67 using ticpp::Element; 68 using ticpp::Declaration; 69 using ticpp::StylesheetReference; 70 using ticpp::Text; 71 using ticpp::Comment; 72 using ticpp::Attribute; 73 73 } - Property svn:mergeinfo changed
-
code/trunk/src/core/XMLPort.h
r2171 r2662 43 43 #include "CorePrereqs.h" 44 44 45 #include <cassert> 45 46 #include "util/Debug.h" 46 47 #include "util/Exception.h" … … 74 75 static ExecutorMember<classname>* xmlcontainer##loadfunction##savefunction##saveexecutor = orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction); \ 75 76 XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, classname, this, paramname, xmlcontainer##loadfunction##savefunction##loadexecutor, xmlcontainer##loadfunction##savefunction##saveexecutor, xmlelement, mode) 77 78 /** 79 @brief Declares an XML attribute with a name, which will be set through a variable. 80 @param classname The name of the class owning this param 81 @param paramname The name of the attribute 82 @param variable Name of the variable used to save and load the value 83 @param xmlelement The XMLElement, you get this from the XMLPort function 84 @param mode The mode (load or save), you get this from the XMLPort function 85 86 In the XML file, a param or attribute will be set like this: 87 <classname paramname="value" /> 88 89 The macro will then store "value" in the variable or read it when saving. 90 */ 91 #define XMLPortParamVariable(classname, paramname, variable, xmlelement, mode) \ 92 XMLPortVariableHelperClass xmlcontainer##variable##dummy((void*)&variable); \ 93 static ExecutorMember<orxonox::XMLPortVariableHelperClass>* xmlcontainer##variable##loadexecutor = static_cast<ExecutorMember<orxonox::XMLPortVariableHelperClass>*>(orxonox::createExecutor(orxonox::createFunctor(orxonox::XMLPortVariableHelperClass::getLoader(variable)), std::string( #classname ) + "::" + #variable + "loader")); \ 94 static ExecutorMember<orxonox::XMLPortVariableHelperClass>* xmlcontainer##variable##saveexecutor = static_cast<ExecutorMember<orxonox::XMLPortVariableHelperClass>*>(orxonox::createExecutor(orxonox::createFunctor(orxonox::XMLPortVariableHelperClass::getSaver (variable)), std::string( #classname ) + "::" + #variable + "saver" )); \ 95 XMLPortParamGeneric(xmlcontainer##variable, classname, orxonox::XMLPortVariableHelperClass, &xmlcontainer##variable##dummy, paramname, xmlcontainer##variable##loadexecutor, xmlcontainer##variable##saveexecutor, xmlelement, mode) 96 76 97 /** 77 98 @brief This is the same as XMLPortParam, but you can set the template arguments needed to store the loadfunction. … … 161 182 ClassIdentifier<classname>::getIdentifier()->addXMLPortParamContainer(paramname, containername); \ 162 183 } \ 163 containername->port( (BaseObject*)this, object, xmlelement, mode)184 containername->port(static_cast<BaseObject*>(this), object, xmlelement, mode) 164 185 165 186 // -------------------- … … 175 196 @param xmlelement The XMLElement (recieved through the XMLPort function) 176 197 @param mode The mode (load/save) (received through the XMLPort function) 177 @param bApplyLoaderMask If this is true, an added sub-object only gets loadedif it's class is included in the Loaders ClassTreeMask (this is usually false)178 @param bLoadBefore If this is true, the sub- cobject gets loaded (through XMLPort) BEFORE it gets added to the main class (this is usually true)198 @param bApplyLoaderMask If this is true, an added sub-object gets loaded only if it's class is included in the Loaders ClassTreeMask (this is usually false) 199 @param bLoadBefore If this is true, the sub-object gets loaded (through XMLPort) BEFORE it gets added to the main class (this is usually true) 179 200 180 201 bApplyLoaderMask is usually false for the following reason: … … 183 204 Of course, if there are "standalone" weapons in the level, they wont be loaded. 184 205 185 If bLoadBefore , an added object already has all attributes set (like it's name). This is most206 If bLoadBefore is true, an added object already has all attributes set (like it's name). This is most 186 207 likely the best option, so this is usually true. 187 208 … … 222 243 Note that "weapons" is the subsection. This allows you to add more types of sub-objects. In our example, 223 244 you could add pilots, blinking lights or other stuff. If you don't want a subsection, just use "" (an 224 empty string). The you can add sub-objects directly into the mainclass.245 empty string). Then you can add sub-objects directly into the mainclass. 225 246 */ 226 247 #define XMLPortObjectExtended(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, mode, bApplyLoaderMask, bLoadBefore) \ … … 329 350 } 330 351 352 ~XMLPortClassParamContainer() 353 { 354 assert(this->loadexecutor_); 355 delete this->loadexecutor_; 356 if (this->saveexecutor_) 357 delete this->saveexecutor_; 358 } 359 331 360 XMLPortParamContainer& port(BaseObject* owner, T* object, Element& xmlelement, XMLPort::Mode mode) 332 361 { 362 OrxAssert(owner, "XMLPortParamContainer must have a BaseObject as owner."); 333 363 this->owner_ = owner; 334 364 this->parseParams_.object = object; … … 336 366 this->parseParams_.mode = mode; 337 367 338 if ( mode == XMLPort::LoadObject)368 if ((mode == XMLPort::LoadObject) || (mode == XMLPort::ExpandObject)) 339 369 { 340 370 try 341 371 { 342 std::string attribute = xmlelement.GetAttribute(this->paramname_); 343 if ((attribute.size() > 0) || (this->loadexecutor_->allDefaultValuesSet())) 372 if (this->owner_->lastLoadedXMLElement_ != &xmlelement) 373 { 374 this->owner_->xmlAttributes_.clear(); 375 // Iterate through the attributes manually in order to make them case insensitive 376 Attribute* attribute = xmlelement.FirstAttribute(false); 377 while (attribute != 0) 378 { 379 this->owner_->xmlAttributes_[getLowercase(attribute->Name())] = attribute->Value(); 380 attribute = attribute->Next(false); 381 } 382 this->owner_->lastLoadedXMLElement_ = &xmlelement; 383 } 384 std::map<std::string, std::string>::const_iterator it = this->owner_->xmlAttributes_.find(getLowercase(this->paramname_)); 385 std::string attributeValue(""); 386 if (it != this->owner_->xmlAttributes_.end()) 387 attributeValue = it->second; 388 389 // TODO: Checking the iterator would be better since then we can have strings with value "" as well. 390 // Unfortunately this does not seem to work with the Executor parser yet. 391 if ((!attributeValue.empty()) || ((mode != XMLPort::ExpandObject) && this->loadexecutor_->allDefaultValuesSet())) 344 392 { 345 393 COUT(5) << this->owner_->getLoaderIndentation() << "Loading parameter " << this->paramname_ << " in " << this->identifier_->getName() << " (objectname " << this->owner_->getName() << ")." << std::endl << this->owner_->getLoaderIndentation(); 346 if (this->loadexecutor_->parse(object, attribute , ","))394 if (this->loadexecutor_->parse(object, attributeValue, ",") || (mode == XMLPort::ExpandObject)) 347 395 this->parseResult_ = PR_finished; 348 396 else 349 397 this->parseResult_ = PR_waiting_for_default_values; 350 398 } 399 else if (mode == XMLPort::ExpandObject) 400 this->parseResult_ = PR_finished; 351 401 else 352 402 this->parseResult_ = PR_waiting_for_default_values; … … 471 521 } 472 522 523 ~XMLPortClassObjectContainer() 524 { 525 assert(this->loadexecutor_); 526 delete this->loadexecutor_; 527 if (this->saveexecutor_) 528 delete this->saveexecutor_; 529 } 530 473 531 XMLPortObjectContainer& port(T* object, Element& xmlelement, XMLPort::Mode mode) 474 532 { 475 if ( mode == XMLPort::LoadObject)533 if ((mode == XMLPort::LoadObject) || (mode == XMLPort::ExpandObject)) 476 534 { 477 535 try … … 588 646 ExecutorMember<T>* saveexecutor_; 589 647 }; 648 649 650 // #################################### 651 // ### XMLPortVariableHelperClass ### 652 // #################################### 653 /** 654 @brief 655 Helper class to load and save simple variables with XMLPort. 656 657 getLoader and getSaver were necessary to get the type T with 658 the help of template function type deduction (const T& is unused). 659 These functions return the adress of save<T> or load<T>. 660 */ 661 class XMLPortVariableHelperClass 662 { 663 public: 664 XMLPortVariableHelperClass(void* var) 665 : variable_(var) 666 { } 667 668 template <class T> 669 void load(const T& value) 670 { *((T*)this->variable_) = value; } 671 672 template <class T> 673 const T& save() 674 { return *((T*)this->variable_); } 675 676 template <class T> 677 static void (XMLPortVariableHelperClass::*getLoader(const T& var))(const T& value) 678 { return &XMLPortVariableHelperClass::load<T>; } 679 680 template <class T> 681 static const T& (XMLPortVariableHelperClass::*getSaver(const T& var))() 682 { return &XMLPortVariableHelperClass::save<T>; } 683 684 private: 685 void* variable_; 686 }; 590 687 } 591 688 -
code/trunk/src/core/input/Button.cc
r2103 r2662 59 59 nCommands_[1]=0; 60 60 nCommands_[2]=0; 61 this->configContainer_ = 0; 61 62 clear(); 63 } 64 65 Button::~Button() 66 { 67 this->clear(); 68 69 if (this->configContainer_) 70 delete this->configContainer_; 62 71 } 63 72 -
code/trunk/src/core/input/Button.h
r2103 r2662 49 49 public: 50 50 Button(); 51 virtual ~Button() { clear(); }51 virtual ~Button(); 52 52 virtual void clear(); 53 53 virtual bool addParamCommand(ParamCommand* command) { return false; } -
code/trunk/src/core/input/InputBuffer.cc
r1755 r2662 73 73 } 74 74 75 InputBuffer::~InputBuffer() 76 { 77 for (std::list<BaseInputBufferListenerTuple*>::const_iterator it = this->listeners_.begin(); 78 it != this->listeners_.end(); ++it) 79 delete *it; 80 } 81 75 82 void InputBuffer::setConfigValues() 76 83 { -
code/trunk/src/core/input/InputBuffer.h
r1887 r2662 79 79 public: 80 80 InputBuffer(); 81 ~InputBuffer(); 81 82 InputBuffer(const std::string allowedChars); 82 83 -
code/trunk/src/core/input/InputInterfaces.h
r1887 r2662 378 378 const char* const ByString[] = 379 379 { 380 "Button0 ", "Button1", "Button2", "Button3",381 "Button 4", "Button5", "Button6", "Button7",382 "Button 8", "Button9","Button10", "Button11",380 "Button00", "Button01", "Button02", "Button03", 381 "Button04", "Button05", "Button06", "Button07", 382 "Button08", "Button09", "Button10", "Button11", 383 383 "Button12", "Button13", "Button14", "Button15", 384 384 "Button16", "Button17", "Button18", "Button19", … … 416 416 "Slider0", "Slider1", "Slider2", "Slider3", 417 417 "Slider4", "Slider5", "Slider6", "Slider7", 418 "Axis0 ", "Axis1", "Axis2", "Axis3",419 "Axis 4", "Axis5", "Axis6", "Axis7",420 "Axis 8", "Axis9","Axis10", "Axis11",418 "Axis00", "Axis01", "Axis02", "Axis03", 419 "Axis04", "Axis05", "Axis06", "Axis07", 420 "Axis08", "Axis09", "Axis10", "Axis11", 421 421 "Axis12", "Axis13", "Axis14", "Axis15" 422 422 }; -
code/trunk/src/core/input/InputManager.cc
r2103 r2662 65 65 SetCommandLineSwitch(keyboard_no_grab); 66 66 67 std::string InputManager::bindingCommmandString_s = "";68 67 EmptyHandler InputManager::EMPTY_HANDLER; 69 68 InputManager* InputManager::singletonRef_s = 0; … … 112 111 , keyDetector_(0) 113 112 , calibratorCallbackBuffer_(0) 114 , bCalibrating_(false)115 113 , keyboardModifiers_(0) 116 114 { … … 119 117 assert(singletonRef_s == 0); 120 118 singletonRef_s = this; 119 120 setConfigValues(); 121 } 122 123 /** 124 @brief 125 Sets the configurable values. 126 */ 127 void InputManager::setConfigValues() 128 { 129 SetConfigValue(calibrationFilename_, "joystick_calibration.ini") 130 .description("Ini filename for the the joy stick calibration data.") 131 .callback(this, &InputManager::_calibrationFileCallback); 132 } 133 134 /** 135 @brief 136 Callback for the joy stick calibration config file. @see setConfigValues. 137 */ 138 void InputManager::_calibrationFileCallback() 139 { 140 ConfigFileManager::getInstance().setFilename(ConfigFileType::JoyStickCalibration, calibrationFilename_); 121 141 } 122 142 … … 174 194 if (joyStickSupport) 175 195 _initialiseJoySticks(); 176 // Do this anyway to also inform every one ifa joystick was detached.177 _configure NumberOfJoySticks();196 // Do this anyway to also inform everything when a joystick was detached. 197 _configureJoySticks(); 178 198 179 199 // Set mouse/joystick region … … 183 203 // clear all buffers 184 204 _clearBuffers(); 185 186 // load joy stick calibration187 setConfigValues();188 205 189 206 internalState_ |= OISReady; … … 335 352 /** 336 353 @brief 354 Helper function that loads the config value vector of one coefficient 355 */ 356 void loadCalibration(std::vector<int>& list, const std::string& sectionName, const std::string& valueName, size_t size, int defaultValue) 357 { 358 list.resize(size); 359 unsigned int configValueVectorSize = ConfigFileManager::getInstance().getVectorSize(ConfigFileType::JoyStickCalibration, sectionName, valueName); 360 if (configValueVectorSize > size) 361 configValueVectorSize = size; 362 363 for (unsigned int i = 0; i < configValueVectorSize; ++i) 364 { 365 list[i] = omni_cast<int>(ConfigFileManager::getInstance().getValue( 366 ConfigFileType::JoyStickCalibration, sectionName, valueName, i, omni_cast<std::string>(defaultValue), false)); 367 } 368 369 // fill the rest with default values 370 for (unsigned int i = configValueVectorSize; i < size; ++i) 371 { 372 list[i] = defaultValue; 373 } 374 } 375 376 /** 377 @brief 337 378 Sets the size of all the different lists that are dependent on the number 338 of joy stick devices created .379 of joy stick devices created and loads the joy stick calibration. 339 380 @remarks 340 381 No matter whether there are a mouse and/or keyboard, they will always 341 382 occupy 2 places in the device number dependent lists. 342 383 */ 343 void InputManager::_configure NumberOfJoySticks()384 void InputManager::_configureJoySticks() 344 385 { 345 386 joySticksSize_ = joySticks_.size(); 346 devicesNum_ = 2 + joySticksSize_; 387 devicesNum_ = 2 + joySticksSize_; 388 joyStickIDs_ .resize(joySticksSize_); 347 389 joyStickButtonsDown_ .resize(joySticksSize_); 348 390 povStates_ .resize(joySticksSize_); 349 391 sliderStates_ .resize(joySticksSize_); 350 joySticksCalibration_.resize(joySticksSize_); 392 joyStickMinValues_ .resize(joySticksSize_); 393 joyStickMaxValues_ .resize(joySticksSize_); 394 joyStickMiddleValues_.resize(joySticksSize_); 395 joyStickCalibrations_.resize(joySticksSize_); 351 396 352 397 for (unsigned int iJoyStick = 0; iJoyStick < joySticksSize_; iJoyStick++) 353 398 { 354 // reset the calibration with default values 355 for (unsigned int i = 0; i < 24; i++) 356 { 357 joySticksCalibration_[iJoyStick].negativeCoeff[i] = 1.0f/32767.0f; 358 joySticksCalibration_[iJoyStick].positiveCoeff[i] = 1.0f/32768.0f; 359 joySticksCalibration_[iJoyStick].zeroStates[i] = 0; 360 } 361 } 399 // Generate some sort of execution unique id per joy stick 400 std::string id = "JoyStick_"; 401 id += omni_cast<std::string>(joySticks_[iJoyStick]->getNumberOfComponents(OIS::OIS_Button)) + "_"; 402 id += omni_cast<std::string>(joySticks_[iJoyStick]->getNumberOfComponents(OIS::OIS_Axis)) + "_"; 403 id += omni_cast<std::string>(joySticks_[iJoyStick]->getNumberOfComponents(OIS::OIS_Slider)) + "_"; 404 id += omni_cast<std::string>(joySticks_[iJoyStick]->getNumberOfComponents(OIS::OIS_POV)) + "_"; 405 id += omni_cast<std::string>(joySticks_[iJoyStick]->getNumberOfComponents(OIS::OIS_Vector3)) + "_"; 406 id += joySticks_[iJoyStick]->vendor(); 407 for (unsigned int i = 0; i < iJoyStick; ++i) 408 { 409 if (id == joyStickIDs_[i]) 410 { 411 // Two joysticks are probably equal --> add the index as well 412 id += "_" + omni_cast<std::string>(iJoyStick); 413 } 414 } 415 joyStickIDs_[iJoyStick] = id; 416 417 size_t axes = sliderAxes + (size_t)this->joySticks_[iJoyStick]->getNumberOfComponents(OIS::OIS_Axis); 418 loadCalibration(joyStickMinValues_[iJoyStick], id, "MinValue", axes, -32768); 419 loadCalibration(joyStickMaxValues_[iJoyStick], id, "MaxValue", axes, 32768); 420 loadCalibration(joyStickMiddleValues_[iJoyStick], id, "MiddleValue", axes, 0); 421 } 422 423 _evaluateCalibration(); 362 424 363 425 // state management … … 380 442 } 381 443 382 /** 383 @brief 384 Sets the configurable values. 385 This mainly concerns joy stick calibrations. 386 */ 387 void InputManager::setConfigValues() 388 { 389 if (joySticksSize_ > 0) 390 { 391 std::vector<double> coeffPos; 392 std::vector<double> coeffNeg; 393 std::vector<int> zero; 394 coeffPos.resize(24); 395 coeffNeg.resize(24); 396 zero.resize(24); 397 for (unsigned int i = 0; i < 24; i++) 398 { 399 coeffPos[i] = 1.0f/32767.0f; 400 coeffNeg[i] = 1.0f/32768.0f; 401 zero[i] = 0; 402 } 403 404 ConfigValueContainer* cont = getIdentifier()->getConfigValueContainer("CoeffPos"); 405 if (!cont) 406 { 407 cont = new ConfigValueContainer(ConfigFileType::Settings, getIdentifier(), getIdentifier()->getName(), "CoeffPos", coeffPos); 408 getIdentifier()->addConfigValueContainer("CoeffPos", cont); 409 } 410 cont->getValue(&coeffPos, this); 411 412 cont = getIdentifier()->getConfigValueContainer("CoeffNeg"); 413 if (!cont) 414 { 415 cont = new ConfigValueContainer(ConfigFileType::Settings, getIdentifier(), getIdentifier()->getName(), "CoeffNeg", coeffNeg); 416 getIdentifier()->addConfigValueContainer("CoeffNeg", cont); 417 } 418 cont->getValue(&coeffNeg, this); 419 420 cont = getIdentifier()->getConfigValueContainer("Zero"); 421 if (!cont) 422 { 423 cont = new ConfigValueContainer(ConfigFileType::Settings, getIdentifier(), getIdentifier()->getName(), "Zero", zero); 424 getIdentifier()->addConfigValueContainer("Zero", cont); 425 } 426 cont->getValue(&zero, this); 427 428 // copy values to our own variables 429 for (unsigned int i = 0; i < 24; i++) 430 { 431 joySticksCalibration_[0].positiveCoeff[i] = coeffPos[i]; 432 joySticksCalibration_[0].negativeCoeff[i] = coeffNeg[i]; 433 joySticksCalibration_[0].zeroStates[i] = zero[i]; 434 } 435 } 436 } 437 444 void InputManager::_evaluateCalibration() 445 { 446 for (unsigned int iJoyStick = 0; iJoyStick < this->joySticksSize_; ++iJoyStick) 447 { 448 for (unsigned int i = 0; i < this->joyStickMinValues_[iJoyStick].size(); i++) 449 { 450 this->joyStickCalibrations_[iJoyStick].middleValue[i] = this->joyStickMiddleValues_[iJoyStick][i]; 451 this->joyStickCalibrations_[iJoyStick].negativeCoeff[i] = - 1.0f / (this->joyStickMinValues_[iJoyStick][i] - this->joyStickMiddleValues_[iJoyStick][i]); 452 this->joyStickCalibrations_[iJoyStick].positiveCoeff[i] = 1.0f / (this->joyStickMaxValues_[iJoyStick][i] - this->joyStickMiddleValues_[iJoyStick][i]); 453 } 454 } 455 } 456 457 void InputManager::_startCalibration() 458 { 459 for (unsigned int iJoyStick = 0; iJoyStick < this->joySticksSize_; ++iJoyStick) 460 { 461 // Set initial values 462 for (unsigned int i = 0; i < this->joyStickMinValues_[iJoyStick].size(); ++i) 463 this->joyStickMinValues_[iJoyStick][i] = INT_MAX; 464 for (unsigned int i = 0; i < this->joyStickMaxValues_[iJoyStick].size(); ++i) 465 this->joyStickMaxValues_[iJoyStick][i] = INT_MIN; 466 for (unsigned int i = 0; i < this->joyStickMiddleValues_[iJoyStick].size(); ++i) 467 this->joyStickMiddleValues_[iJoyStick][i] = 0; 468 } 469 470 getInstance().internalState_ |= Calibrating; 471 getInstance().requestEnterState("calibrator"); 472 } 473 474 void InputManager::_completeCalibration() 475 { 476 for (unsigned int iJoyStick = 0; iJoyStick < this->joySticksSize_; ++iJoyStick) 477 { 478 // Get the middle positions now 479 unsigned int iAxis = 0; 480 for (unsigned int i = 0; i < sliderAxes/2; ++i) 481 { 482 this->joyStickMiddleValues_[iJoyStick][iAxis++] = this->joySticks_[iJoyStick]->getJoyStickState().mSliders[i].abX; 483 this->joyStickMiddleValues_[iJoyStick][iAxis++] = this->joySticks_[iJoyStick]->getJoyStickState().mSliders[i].abY; 484 } 485 // Note: joyStickMiddleValues_[iJoyStick] was already correctly resized in _configureJoySticks() 486 assert(joySticks_[iJoyStick]->getJoyStickState().mAxes.size() == joyStickMiddleValues_[iJoyStick].size() - sliderAxes); 487 for (unsigned int i = 0; i < joyStickMiddleValues_[iJoyStick].size() - sliderAxes; ++i) 488 { 489 this->joyStickMiddleValues_[iJoyStick][iAxis++] = this->joySticks_[iJoyStick]->getJoyStickState().mAxes[i].abs; 490 } 491 492 for (unsigned int i = 0; i < joyStickMinValues_[iJoyStick].size(); ++i) 493 { 494 // Minimum values 495 if (joyStickMinValues_[iJoyStick][i] == INT_MAX) 496 joyStickMinValues_[iJoyStick][i] = -32768; 497 ConfigFileManager::getInstance().setValue(ConfigFileType::JoyStickCalibration, 498 this->joyStickIDs_[iJoyStick], "MinValue", i, omni_cast<std::string>(joyStickMinValues_[iJoyStick][i]), false); 499 500 // Maximum values 501 if (joyStickMaxValues_[iJoyStick][i] == INT_MIN) 502 joyStickMaxValues_[iJoyStick][i] = 32767; 503 ConfigFileManager::getInstance().setValue(ConfigFileType::JoyStickCalibration, 504 this->joyStickIDs_[iJoyStick], "MaxValue", i, omni_cast<std::string>(joyStickMaxValues_[iJoyStick][i]), false); 505 506 // Middle values 507 ConfigFileManager::getInstance().setValue(ConfigFileType::JoyStickCalibration, 508 this->joyStickIDs_[iJoyStick], "MiddleValue", i, omni_cast<std::string>(joyStickMiddleValues_[iJoyStick][i]), false); 509 } 510 } 511 512 _evaluateCalibration(); 513 514 // restore old input state 515 requestLeaveState("calibrator"); 516 internalState_ &= ~Calibrating; 517 } 438 518 439 519 // ############################################################ … … 492 572 } 493 573 } 494 singletonRef_s = 0; 574 575 singletonRef_s = 0; 495 576 } 496 577 … … 660 741 /** 661 742 @brief 662 Updates the InputManager. Tick is called by the Core class.743 Updates the states and the InputState situation. 663 744 @param dt 664 745 Delta time … … 676 757 677 758 // check for states to leave 678 for (std::set<InputState*>::reverse_iterator rit = stateLeaveRequests_.rbegin(); 679 rit != stateLeaveRequests_.rend(); ++rit) 680 { 681 (*rit)->onLeave(); 682 // just to be sure that the state actually is registered 683 assert(inputStatesByName_.find((*rit)->getName()) != inputStatesByName_.end()); 684 685 activeStates_.erase((*rit)->getPriority()); 686 _updateActiveStates(); 687 } 688 stateLeaveRequests_.clear(); 759 if (!stateLeaveRequests_.empty()) 760 { 761 for (std::set<InputState*>::reverse_iterator rit = stateLeaveRequests_.rbegin(); 762 rit != stateLeaveRequests_.rend(); ++rit) 763 { 764 (*rit)->onLeave(); 765 // just to be sure that the state actually is registered 766 assert(inputStatesByName_.find((*rit)->getName()) != inputStatesByName_.end()); 767 768 activeStates_.erase((*rit)->getPriority()); 769 _updateActiveStates(); 770 } 771 stateLeaveRequests_.clear(); 772 } 689 773 690 774 // check for states to enter 691 for (std::set<InputState*>::reverse_iterator rit = stateEnterRequests_.rbegin(); 692 rit != stateEnterRequests_.rend(); ++rit) 693 { 694 // just to be sure that the state actually is registered 695 assert(inputStatesByName_.find((*rit)->getName()) != inputStatesByName_.end()); 696 697 activeStates_[(*rit)->getPriority()] = (*rit); 698 _updateActiveStates(); 699 (*rit)->onEnter(); 700 } 701 stateEnterRequests_.clear(); 775 if (!stateEnterRequests_.empty()) 776 { 777 for (std::set<InputState*>::reverse_iterator rit = stateEnterRequests_.rbegin(); 778 rit != stateEnterRequests_.rend(); ++rit) 779 { 780 // just to be sure that the state actually is registered 781 assert(inputStatesByName_.find((*rit)->getName()) != inputStatesByName_.end()); 782 783 activeStates_[(*rit)->getPriority()] = (*rit); 784 _updateActiveStates(); 785 (*rit)->onEnter(); 786 } 787 stateEnterRequests_.clear(); 788 } 702 789 703 790 // check for states to destroy 704 for (std::set<InputState*>::reverse_iterator rit = stateDestroyRequests_.rbegin(); 705 rit != stateDestroyRequests_.rend(); ++rit) 706 { 707 _destroyState((*rit)); 708 } 709 stateDestroyRequests_.clear(); 791 if (!stateDestroyRequests_.empty()) 792 { 793 for (std::set<InputState*>::reverse_iterator rit = stateDestroyRequests_.rbegin(); 794 rit != stateDestroyRequests_.rend(); ++rit) 795 { 796 _destroyState((*rit)); 797 } 798 stateDestroyRequests_.clear(); 799 } 710 800 711 801 // check whether a state has changed its EMPTY_HANDLER situation … … 733 823 joySticks_[i]->capture(); 734 824 735 if (! bCalibrating_)825 if (!(internalState_ & Calibrating)) 736 826 { 737 827 // call all the handlers for the held key events … … 804 894 /** 805 895 @brief 806 Processes the accumultated data for the joy stick calibration. 807 */ 808 void InputManager::_completeCalibration() 809 { 810 for (unsigned int i = 0; i < 24; i++) 811 { 812 // positive coefficient 813 if (marginalsMax_[i] == INT_MIN) 814 marginalsMax_[i] = 32767; 815 // coefficients 816 if (marginalsMax_[i] - joySticksCalibration_[0].zeroStates[i]) 817 { 818 joySticksCalibration_[0].positiveCoeff[i] 819 = 1.0f/(marginalsMax_[i] - joySticksCalibration_[0].zeroStates[i]); 820 } 821 else 822 joySticksCalibration_[0].positiveCoeff[i] = 1.0f; 823 824 // config value 825 ConfigValueContainer* cont = getIdentifier()->getConfigValueContainer("CoeffPos"); 826 assert(cont); 827 cont->set(i, joySticksCalibration_[0].positiveCoeff[i]); 828 829 // negative coefficient 830 if (marginalsMin_[i] == INT_MAX) 831 marginalsMin_[i] = -32768; 832 // coefficients 833 if (marginalsMin_[i] - joySticksCalibration_[0].zeroStates[i]) 834 { 835 joySticksCalibration_[0].negativeCoeff[i] = -1.0f 836 / (marginalsMin_[i] - joySticksCalibration_[0].zeroStates[i]); 837 } 838 else 839 joySticksCalibration_[0].negativeCoeff[i] = 1.0f; 840 // config value 841 cont = getIdentifier()->getConfigValueContainer("CoeffNeg"); 842 assert(cont); 843 cont->set(i, joySticksCalibration_[0].negativeCoeff[i]); 844 845 // zero states 846 if (i < 8) 847 { 848 if (!(i & 1)) 849 joySticksCalibration_[0].zeroStates[i] = joySticks_[0]->getJoyStickState().mSliders[i/2].abX; 850 else 851 joySticksCalibration_[0].zeroStates[i] = joySticks_[0]->getJoyStickState().mSliders[i/2].abY; 852 } 853 else 854 { 855 if (i - 8 < joySticks_[0]->getJoyStickState().mAxes.size()) 856 joySticksCalibration_[0].zeroStates[i] = joySticks_[0]->getJoyStickState().mAxes[i - 8].abs; 857 else 858 joySticksCalibration_[0].zeroStates[i] = 0; 859 } 860 // config value 861 cont = getIdentifier()->getConfigValueContainer("Zero"); 862 assert(cont); 863 cont->set(i, joySticksCalibration_[0].zeroStates[i]); 864 } 865 866 // restore old input state 867 requestLeaveState("calibrator"); 868 bCalibrating_ = false; 869 } 870 896 Clears all buffers that store what keys/buttons are being pressed at the moment. 897 */ 871 898 void InputManager::clearBuffers() 872 899 { … … 1099 1126 void InputManager::_fireAxis(unsigned int iJoyStick, int axis, int value) 1100 1127 { 1101 if ( bCalibrating_)1102 { 1103 if (value > marginalsMax_[axis])1104 marginalsMax_[axis] = value;1105 if (value < marginalsMin_[axis])1106 marginalsMin_[axis] = value;1128 if (internalState_ & Calibrating) 1129 { 1130 if (value < joyStickMinValues_[iJoyStick][axis]) 1131 joyStickMinValues_[iJoyStick][axis] = value; 1132 if (value > joyStickMaxValues_[iJoyStick][axis]) 1133 joyStickMaxValues_[iJoyStick][axis] = value; 1107 1134 } 1108 1135 else 1109 1136 { 1110 float fValue = value - joyStick sCalibration_[iJoyStick].zeroStates[axis];1137 float fValue = value - joyStickCalibrations_[iJoyStick].middleValue[axis]; 1111 1138 if (fValue > 0.0f) 1112 fValue *= joyStick sCalibration_[iJoyStick].positiveCoeff[axis];1139 fValue *= joyStickCalibrations_[iJoyStick].positiveCoeff[axis]; 1113 1140 else 1114 fValue *= joyStick sCalibration_[iJoyStick].negativeCoeff[axis];1141 fValue *= joyStickCalibrations_[iJoyStick].negativeCoeff[axis]; 1115 1142 1116 1143 activeStatesTop_[2 + iJoyStick]->joyStickAxisMoved(iJoyStick, axis, fValue); … … 1124 1151 1125 1152 // keep in mind that the first 8 axes are reserved for the sliders 1126 _fireAxis(iJoyStick, axis + 8, arg.state.mAxes[axis].abs);1153 _fireAxis(iJoyStick, axis + sliderAxes, arg.state.mAxes[axis].abs); 1127 1154 1128 1155 return true; … … 1390 1417 void InputManager::calibrate() 1391 1418 { 1392 getInstance().bCalibrating_ = true; 1393 getInstance().requestEnterState("calibrator"); 1419 COUT(0) << "Move all joy stick axes fully in all directions." << std::endl 1420 << "When done, put the axex in the middle position and press enter." << std::endl; 1421 1422 getInstance()._startCalibration(); 1394 1423 } 1395 1424 -
code/trunk/src/core/input/InputManager.h
r2102 r2662 71 71 struct JoyStickCalibration 72 72 { 73 int zeroStates[24];73 int middleValue[24]; 74 74 float positiveCoeff[24]; 75 75 float negativeCoeff[24]; … … 136 136 public: // variables 137 137 static EmptyHandler EMPTY_HANDLER; 138 static const unsigned int sliderAxes = 8; 138 139 139 140 private: // functions … … 145 146 void _initialiseMouse(); 146 147 void _initialiseJoySticks(); 147 void _configureNumberOfJoySticks(); 148 void _configureJoySticks(); 149 150 void _loadCalibration(); 151 void _startCalibration(); 152 void _completeCalibration(); 153 void _evaluateCalibration(); 148 154 149 155 void _destroyKeyboard(); … … 154 160 155 161 void _reload(bool joyStickSupport); 156 157 void _completeCalibration();158 162 159 163 void _fireAxis(unsigned int iJoyStick, int axis, int value); … … 178 182 179 183 void setConfigValues(); 184 void _calibrationFileCallback(); 180 185 181 186 private: // variables … … 185 190 std::vector<OIS::JoyStick*> joySticks_; //!< OIS joy sticks 186 191 unsigned int joySticksSize_; 192 std::vector<std::string> joyStickIDs_; //!< Execution unique identification strings for the joy sticks 187 193 unsigned int devicesNum_; 188 194 size_t windowHnd_; //!< Render window handle … … 192 198 SimpleInputState* stateEmpty_; 193 199 ExtendedInputState* stateMaster_; //!< Always active master input state 194 KeyDetector* keyDetector_; //!< KeyDetector instance200 KeyDetector* keyDetector_; //!< KeyDetector instance 195 201 InputBuffer* calibratorCallbackBuffer_; 196 202 … … 207 213 208 214 // joystick calibration 209 //std::vector<int> marginalsMaxConfig_; 210 //std::vector<int> marginalsMinConfig_; 211 int marginalsMax_[24]; 212 int marginalsMin_[24]; 213 bool bCalibrated_; 214 bool bCalibrating_; 215 std::vector<std::vector<int> > joyStickMinValues_; 216 std::vector<std::vector<int> > joyStickMaxValues_; 217 std::vector<std::vector<int> > joyStickMiddleValues_; 218 std::vector<ConfigValueContainer*> calibrationConfigValueContainers_; 219 std::vector<JoyStickCalibration> joyStickCalibrations_; 215 220 216 221 unsigned int keyboardModifiers_; //!< Bit mask representing keyboard modifiers. 217 222 std::vector<POVStates> povStates_; //!< Keeps track of the joy stick POV states. 218 223 std::vector<SliderStates> sliderStates_; //!< Keeps track of the possibly two slider axes. 219 std::vector<JoyStickCalibration> joySticksCalibration_;220 224 221 225 std::vector<Key> keysDown_; … … 223 227 std::vector<std::vector<JoyStickButtonCode::ByEnum> > joyStickButtonsDown_; 224 228 225 static std::string bindingCommmandString_s; 229 // ConfigValues 230 std::string calibrationFilename_; //!< Joy stick calibration ini filename 231 226 232 static InputManager* singletonRef_s; 227 233 }; -
code/trunk/src/core/input/KeyBinder.cc
r2103 r2662 33 33 34 34 #include "KeyBinder.h" 35 35 36 #include <fstream> 36 37 #include <string> 38 37 39 #include "util/Convert.h" 38 40 #include "util/Debug.h" … … 66 68 std::string keyname = KeyCode::ByString[i]; 67 69 if (!keyname.empty()) 68 {69 70 keys_[i].name_ = std::string("Key") + keyname; 70 }71 71 else 72 { 73 // some keys have name "" because the code is not occupied by OIS 74 // Use "Key_" plus the number as name to put it at the end of the config file section 75 std::string number = convertToString(i); 76 if (i < 100) 77 number.insert(0, "0"); 78 keys_[i].name_ = std::string("Key_") + number; 79 } 72 keys_[i].name_ = ""; 80 73 keys_[i].paramCommandBuffer_ = ¶mCommandBuffer_; 81 74 keys_[i].groupName_ = "Keys"; … … 97 90 for (unsigned int i = 0; i < MouseAxisCode::numberOfAxes * 2; i++) 98 91 { 99 mouseAxes_[i].name_ = std::string("Mouse") + MouseAxisCode::ByString[i >> 1];92 mouseAxes_[i].name_ = std::string("Mouse") + MouseAxisCode::ByString[i / 2]; 100 93 if (i & 1) 101 94 mouseAxes_[i].name_ += "Pos"; … … 224 217 allHalfAxes_.clear(); 225 218 219 // Note: Don't include the dummy keys which don't actually exist in OIS but have a number 226 220 for (unsigned int i = 0; i < KeyCode::numberOfKeys; i++) 227 allButtons_[keys_[i].name_] = keys_ + i; 221 if (!keys_[i].name_.empty()) 222 allButtons_[keys_[i].name_] = keys_ + i; 228 223 for (unsigned int i = 0; i < numberOfMouseButtons_; i++) 229 224 allButtons_[mouseButtons_[i].name_] = mouseButtons_ + i; … … 327 322 if (bDeriveMouseInput_) 328 323 { 329 // only update when deriv edt has passed324 // only update when derivation dt has passed 330 325 if (deriveTime_ > derivePeriod_) 331 326 { 332 327 for (int i = 0; i < 2; i++) 333 328 { 334 if (mouseRelative_[i] >0)329 if (mouseRelative_[i] < 0) 335 330 { 336 331 mouseAxes_[2*i + 0].absVal_ 337 = 332 = -mouseRelative_[i] / deriveTime_ * 0.0005 * mouseSensitivityDerived_; 338 333 mouseAxes_[2*i + 1].absVal_ = 0.0f; 339 334 } 340 else if (mouseRelative_[i] <0)335 else if (mouseRelative_[i] > 0) 341 336 { 342 337 mouseAxes_[2*i + 0].absVal_ = 0.0f; 343 338 mouseAxes_[2*i + 1].absVal_ 344 = -mouseRelative_[i] / deriveTime_ * 0.0005 * mouseSensitivityDerived_;339 = mouseRelative_[i] / deriveTime_ * 0.0005 * mouseSensitivityDerived_; 345 340 } 346 341 else … … 363 358 // Why dividing relative value by dt? The reason lies in the simple fact, that when you 364 359 // press a button that has relative movement, that value has to be multiplied by dt to be 365 // frame rate independ ant. This can easily (and only) be done in tickInput(float).360 // frame rate independent. This can easily (and only) be done in tickInput(float). 366 361 // Hence we need to divide by dt here for the mouse to compensate, because the relative 367 362 // move movements have nothing to do with dt. … … 441 436 for (int i = 0; i < 2; i++) 442 437 { 443 if (rel[i]) // performance opt. ifrel[i] == 0438 if (rel[i]) // performance opt. for the case that rel[i] == 0 444 439 { 445 440 // write absolute values … … 454 449 mousePosition_[i] = -mouseClippingSize_; 455 450 456 if (mousePosition_[i] >=0)451 if (mousePosition_[i] < 0) 457 452 { 458 mouseAxes_[2*i + 0].absVal_ = 453 mouseAxes_[2*i + 0].absVal_ = -mousePosition_[i]/(float)mouseClippingSize_ * mouseSensitivity_; 459 454 mouseAxes_[2*i + 1].absVal_ = 0.0f; 460 455 } … … 462 457 { 463 458 mouseAxes_[2*i + 0].absVal_ = 0.0f; 464 mouseAxes_[2*i + 1].absVal_ = -mousePosition_[i]/(float)mouseClippingSize_ * mouseSensitivity_;459 mouseAxes_[2*i + 1].absVal_ = mousePosition_[i]/(float)mouseClippingSize_ * mouseSensitivity_; 465 460 } 466 461 } … … 471 466 for (int i = 0; i < 2; i++) 472 467 { 473 if (rel[i] >0)474 mouseAxes_[0 + 2*i].relVal_ = 468 if (rel[i] < 0) 469 mouseAxes_[0 + 2*i].relVal_ = -((float)rel[i])/(float)mouseClippingSize_ * mouseSensitivity_; 475 470 else 476 mouseAxes_[1 + 2*i].relVal_ = -((float)rel[i])/(float)mouseClippingSize_ * mouseSensitivity_;471 mouseAxes_[1 + 2*i].relVal_ = ((float)rel[i])/(float)mouseClippingSize_ * mouseSensitivity_; 477 472 } 478 473 } … … 484 479 void KeyBinder::mouseScrolled(int abs, int rel) 485 480 { 486 if (rel >0)487 for (int i = 0; i < rel/mouseWheelStepSize_; i++)481 if (rel < 0) 482 for (int i = 0; i < -rel/mouseWheelStepSize_; i++) 488 483 mouseButtons_[8].execute(KeybindMode::OnPress, ((float)abs)/mouseWheelStepSize_); 489 484 else 490 for (int i = 0; i < -rel/mouseWheelStepSize_; i++)485 for (int i = 0; i < rel/mouseWheelStepSize_; i++) 491 486 mouseButtons_[9].execute(KeybindMode::OnPress, ((float)abs)/mouseWheelStepSize_); 492 487 } … … 495 490 { 496 491 int i = axis * 2; 497 if (value >=0)498 { 499 joyStickAxes_[joyStickID][i].absVal_ = value;500 joyStickAxes_[joyStickID][i].relVal_ = value;492 if (value < 0) 493 { 494 joyStickAxes_[joyStickID][i].absVal_ = -value; 495 joyStickAxes_[joyStickID][i].relVal_ = -value; 501 496 joyStickAxes_[joyStickID][i].hasChanged_ = true; 502 497 if (joyStickAxes_[joyStickID][i + 1].absVal_ > 0.0f) … … 509 504 else 510 505 { 511 joyStickAxes_[joyStickID][i + 1].absVal_ = -value;512 joyStickAxes_[joyStickID][i + 1].relVal_ = -value;506 joyStickAxes_[joyStickID][i + 1].absVal_ = value; 507 joyStickAxes_[joyStickID][i + 1].relVal_ = value; 513 508 joyStickAxes_[joyStickID][i + 1].hasChanged_ = true; 514 509 if (joyStickAxes_[joyStickID][i].absVal_ > 0.0f) -
code/trunk/src/core/input/KeyBinder.h
r2103 r2662 39 39 40 40 #include <vector> 41 #include <cassert> 42 41 43 #include "InputInterfaces.h" 42 44 #include "Button.h" … … 44 46 #include "InputCommands.h" 45 47 #include "JoyStickDeviceNumberListener.h" 46 #include "core/ConfigFileManager.h"47 48 48 49 namespace orxonox … … 171 172 172 173 inline void KeyBinder::keyPressed (const KeyEvent& evt) 173 { keys_[evt.key].execute(KeybindMode::OnPress); }174 { assert(!keys_[evt.key].name_.empty()); keys_[evt.key].execute(KeybindMode::OnPress); } 174 175 175 176 inline void KeyBinder::keyReleased(const KeyEvent& evt) 176 { keys_[evt.key].execute(KeybindMode::OnRelease); }177 { assert(!keys_[evt.key].name_.empty()); keys_[evt.key].execute(KeybindMode::OnRelease); } 177 178 178 179 inline void KeyBinder::keyHeld (const KeyEvent& evt) 179 { keys_[evt.key].execute(KeybindMode::OnHold); }180 { assert(!keys_[evt.key].name_.empty()); keys_[evt.key].execute(KeybindMode::OnHold); } 180 181 181 182 -
code/trunk/src/network/CMakeLists.txt
r2131 r2662 11 11 PacketBuffer.cc 12 12 Server.cc 13 Synchronisable.cc13 TrafficControl.cc 14 14 Host.cc 15 15 ) 16 16 17 17 ADD_SOURCE_DIRECTORY(NETWORK_SRC_FILES packet) 18 ADD_SOURCE_DIRECTORY(NETWORK_SRC_FILES synchronisable) 19 18 20 19 21 IF(WIN32) -
code/trunk/src/network/Client.cc
r2171 r2662 43 43 #include "Client.h" 44 44 #include "Host.h" 45 #include " Synchronisable.h"45 #include "synchronisable/Synchronisable.h" 46 46 #include "core/CoreIncludes.h" 47 47 #include "packet/Packet.h" -
code/trunk/src/network/ClientConnection.cc
r2171 r2662 172 172 break; 173 173 case ENET_EVENT_TYPE_RECEIVE: 174 COUT(5) << "Cl.Con: receiver-Thread while loop: got new packet" << std::endl;174 //COUT(5) << "Cl.Con: receiver-Thread while loop: got new packet" << std::endl; 175 175 if ( !processData(event) ) COUT(2) << "Current packet was not pushed to packetBuffer -> ev ongoing SegFault" << std::endl; 176 COUT(5) << "Cl.Con: processed Data in receiver-thread while loop" << std::endl;176 //COUT(5) << "Cl.Con: processed Data in receiver-thread while loop" << std::endl; 177 177 event = new ENetEvent; 178 178 break; -
code/trunk/src/network/ClientInformation.cc
r2171 r2662 45 45 namespace orxonox 46 46 { 47 47 48 48 49 ClientInformation *ClientInformation::head_=0; -
code/trunk/src/network/ClientInformation.h
r2171 r2662 46 46 #include <boost/thread/recursive_mutex.hpp> 47 47 48 48 49 // WATCH OUT: THE CLIENTINFORMATION LIST IS NOT THREADSAFE ANYMORE 49 50 50 51 namespace orxonox 51 52 { 52 static const unsigned int GAMESTATEID_INITIAL = (unsigned int)-1;53 static const unsigned int CLIENTID_UNKNOWN = (unsigned int)-2;54 53 55 54 /** -
code/trunk/src/network/ConnectionManager.cc
r2171 r2662 52 52 #include "util/Sleep.h" 53 53 #include "ClientInformation.h" 54 #include " Synchronisable.h"54 #include "synchronisable/Synchronisable.h" 55 55 #include "packet/ClassID.h" 56 56 … … 206 206 // log handling ================ 207 207 case ENET_EVENT_TYPE_CONNECT: 208 COUT(3) << "adding event_type_connect to queue" << std::endl;208 //COUT(3) << "adding event_type_connect to queue" << std::endl; 209 209 case ENET_EVENT_TYPE_DISCONNECT: 210 210 //addClient(event); … … 214 214 case ENET_EVENT_TYPE_RECEIVE: 215 215 //std::cout << "received data" << std::endl; 216 COUT(5) << "Con.Man: receive event has occured" << std::endl;216 //COUT(5) << "Con.Man: receive event has occured" << std::endl; 217 217 // only add, if client has connected yet and not been disconnected 218 218 //if(head_->findClient(&event->peer->address)) -
code/trunk/src/network/GamestateClient.cc
r2171 r2662 35 35 #include "core/BaseObject.h" 36 36 #include "core/Iterator.h" 37 #include "Synchronisable.h" 37 #include "synchronisable/Synchronisable.h" 38 #include "synchronisable/NetworkCallbackManager.h" 38 39 #include "packet/Acknowledgement.h" 39 40 … … 74 75 if(tempGamestate_==NULL) 75 76 return false; 77 bool isDiffed = tempGamestate_->isDiffed(); 76 78 int id = GAMESTATEID_INITIAL; 77 79 packet::Gamestate *processed = processGamestate(tempGamestate_); 78 // assert(processed); 79 if (!processed) 80 return false; 80 assert(processed); 81 82 //now call the queued callbacks 83 NetworkCallbackManager::callCallbacks(); 84 85 if (!processed){ 86 sendAck(0); 87 return false; 88 } 81 89 //successfully loaded data from gamestate. now save gamestate for diff and delete the old gs 82 90 tempGamestate_=NULL; 83 91 gamestateMap_[processed->getID()]=processed; 84 last_diff_ = processed->getID(); 92 if(isDiffed) 93 last_diff_ = processed->getBaseID(); 85 94 id = processed->getID(); 86 95 sendAck(id); … … 153 162 packet::Gamestate *base = gamestateMap_[gs->getBaseID()]; 154 163 if(!base){ 164 COUT(3) << "could not find base gamestate id: " << gs->getBaseID() << endl; 155 165 delete gs; 156 166 return 0; … … 165 175 return gs; 166 176 else 177 { 178 COUT(3) << "could not spread gamestate" << endl; 167 179 return NULL; 180 } 168 181 } 169 182 -
code/trunk/src/network/GamestateManager.cc
r2171 r2662 49 49 #include "core/BaseObject.h" 50 50 #include "ClientInformation.h" 51 #include "Synchronisable.h" 51 #include "synchronisable/Synchronisable.h" 52 #include "synchronisable/NetworkCallbackManager.h" 53 #include "packet/Acknowledgement.h" 52 54 53 55 namespace orxonox 54 56 { 55 GamestateManager::GamestateManager() { 56 id_=0; 57 } 58 59 GamestateManager::~GamestateManager() { 57 GamestateManager::GamestateManager() : 58 reference(0), id_(0) 59 { 60 trafficControl_ = new TrafficControl(); 61 } 62 63 GamestateManager::~GamestateManager() 64 { 65 delete trafficControl_; 60 66 } 61 67 … … 86 92 // now clear the queue 87 93 gamestateQueue.clear(); 94 //and call all queued callbacks 95 NetworkCallbackManager::callCallbacks(); 88 96 return true; 89 97 } … … 91 99 92 100 bool GamestateManager::getSnapshot(){ 101 if ( reference != 0 ) 102 delete reference; 93 103 reference = new packet::Gamestate(); 94 104 if(!reference->collectData(++id_)){ //we have no data to send … … 99 109 } 100 110 101 /**102 * this function is used to keep the memory usage low103 * it tries to delete all the unused gamestates104 *105 *106 */107 /* void GamestateManager::cleanup(){108 std::map<int,int>::iterator it = gamestateUsed.begin();109 while(it!=gamestateUsed.end()){110 if((id_-(*it).first)<KEEP_GAMESTATES)111 break;112 if( (*it).second <= 0 ){113 COUT(5) << "GameStateManager: deleting gamestate with id: " << (*it).first << ", uses: " << (*it).second << std::endl;114 std::map<int, packet::Gamestate *>::iterator tempit = gamestateMap.find((*it).first);115 if( tempit != gamestateMap.end() ){116 packet::Gamestate *temp = tempit->second;117 if(temp){118 delete gamestateMap[(*it).first];119 gamestateMap.erase((*it).first);120 }121 }122 gamestateUsed.erase(it++);123 continue;124 }125 it++;126 }127 }*/128 111 129 112 packet::Gamestate *GamestateManager::popGameState(unsigned int clientID) { … … 134 117 if(!reference) 135 118 return 0; 136 gs = reference->doSelection(clientID); 137 // gs = new packet::Gamestate(*reference); 119 gs = reference->doSelection(clientID, 10000); 138 120 // gs = new packet::Gamestate(*reference); 139 121 // save the (undiffed) gamestate in the clients gamestate map 140 gamestateMap_[clientID] .insert(std::pair<int, packet::Gamestate*>(gs->getID(), gs));122 gamestateMap_[clientID][gs->getID()]=gs; 141 123 //chose wheather the next gamestate is the first or not 142 packet::Gamestate *client= NULL;124 packet::Gamestate *client=0; 143 125 if(gID != GAMESTATEID_INITIAL){ 144 std::map<unsigned int, std::map<unsigned int, packet::Gamestate*> >::iterator clientMap = gamestateMap_.find(clientID);145 if(clientMap!=gamestateMap_.end()){146 std::map<unsigned int, packet::Gamestate*>::iterator it = clientMap->second.find(gID);147 if(it!=clientMap->second.end())148 126 assert(gamestateMap_.find(clientID)!=gamestateMap_.end()); 127 std::map<unsigned int, packet::Gamestate*>::iterator it = gamestateMap_[clientID].find(gID); 128 if(it!=gamestateMap_[clientID].end()) 129 { 130 client = it->second; 149 131 } 150 132 } … … 152 134 // COUT(3) << "diffing" << std::endl; 153 135 gs = gs->diff(client); 136 // gs = new packet::Gamestate(*gs); 154 137 } 155 138 else{ … … 159 142 bool b = gs->compressData(); 160 143 assert(b); 144 COUT(4) << "sending gamestate with id " << gs->getID(); 145 if(gs->isDiffed()) 146 COUT(4) << " and baseid " << gs->getBaseID() << endl; 147 else 148 COUT(4) << endl; 161 149 return gs; 162 150 } … … 168 156 unsigned int curid = temp->getGamestateID(); 169 157 170 if(gamestateID == 0){158 if(gamestateID == ACKID_NACK){ 171 159 temp->setGamestateID(GAMESTATEID_INITIAL); 160 // now delete all saved gamestates for this client 161 std::map<unsigned int, packet::Gamestate*>::iterator it; 162 for(it = gamestateMap_[clientID].begin(); it!=gamestateMap_[clientID].end(); ){ 163 delete it->second; 164 gamestateMap_[clientID].erase(it++); 165 } 172 166 return true; 173 167 } … … 175 169 assert(curid==(unsigned int)GAMESTATEID_INITIAL || curid<gamestateID); 176 170 COUT(4) << "acking gamestate " << gamestateID << " for clientid: " << clientID << " curid: " << curid << std::endl; 177 std::map<unsigned int, packet::Gamestate*>::iterator it, tempit; 178 for(it = gamestateMap_[clientID].begin(); it!=gamestateMap_[clientID].end() && it->first<gamestateID; it++){ 179 delete it->second; 180 tempit=it++; 181 gamestateMap_[clientID].erase(tempit); 171 std::map<unsigned int, packet::Gamestate*>::iterator it; 172 for(it = gamestateMap_[clientID].begin(); it!=gamestateMap_[clientID].end() && it->first<gamestateID; ){ 173 delete it->second; 174 gamestateMap_[clientID].erase(it++); 182 175 } 183 176 temp->setGamestateID(gamestateID); 177 TrafficControl::processAck(clientID, gamestateID); 184 178 return true; 185 179 } -
code/trunk/src/network/GamestateManager.h
r2171 r2662 43 43 #include "NetworkPrereqs.h" 44 44 #include "GamestateHandler.h" 45 #include "TrafficControl.h" 45 46 #include <map> 46 47 … … 81 82 void removeClient(ClientInformation *client); 82 83 private: 83 // void cleanup(); // "garbage handler"84 84 bool processGamestate(packet::Gamestate *gs); 85 85 … … 89 89 std::map<unsigned int, packet::Gamestate*> gamestateQueue; 90 90 packet::Gamestate *reference; 91 TrafficControl *trafficControl_; 91 92 unsigned int id_; 92 93 }; -
code/trunk/src/network/NetworkPrereqs.h
r2171 r2662 57 57 58 58 //----------------------------------------------------------------------- 59 // Includes 60 //----------------------------------------------------------------------- 61 #include "util/Integers.h" 62 63 //----------------------------------------------------------------------- 64 // Library global contants 65 //----------------------------------------------------------------------- 66 namespace orxonox 67 { 68 static const unsigned int GAMESTATEID_INITIAL = (unsigned int)-1; 69 static const unsigned int CLIENTID_UNKNOWN = (unsigned int)-2; 70 static const uint32_t OBJECTID_UNKNOWN = (uint32_t)(-1); 71 } 72 73 //----------------------------------------------------------------------- 59 74 // Forward declarations 60 75 //----------------------------------------------------------------------- … … 70 85 class GamestateManager; 71 86 class GamestateHandler; 87 class NetworkCallbackBase; 88 template <class T> class NetworkCallback; 89 class NetworkCallbackManager; 72 90 class PacketBuffer; 73 91 class Server; 74 92 class ServerFrameListener; 75 93 class Synchronisable; 94 class SynchronisableVariableBase; 95 template <class T> class SynchronisableVariable; 96 template <class T> class SynchronisableVariableBidirectional; 76 97 struct ClientList; 77 98 struct PacketEnvelope; 78 99 struct QueueItem; 79 100 struct syncData; 80 struct synchronisableVariable; 81 namespace packet{ 101 class obj; 102 class objInfo; 103 104 namespace packet 105 { 82 106 class Gamestate; 83 107 class Packet; -
code/trunk/src/network/Server.cc
r2171 r2662 63 63 { 64 64 const unsigned int MAX_FAILURES = 20; 65 const unsigned int NETWORK_FREQUENCY = 25;66 const float NETWORK_PERIOD = (float)1/NETWORK_FREQUENCY;67 65 68 66 /** … … 218 216 */ 219 217 void Server::updateGamestate() { 218 // if( ClientInformation::getBegin()==NULL ) 219 //no client connected 220 // return; 220 221 gamestates_->update(); 221 222 COUT(5) << "Server: one gamestate update complete, goig to sendGameState" << std::endl; … … 276 277 bool Server::sendObjectDeletes(){ 277 278 ClientInformation *temp = ClientInformation::getBegin(); 279 if( temp == NULL ) 280 //no client connected 281 return true; 278 282 packet::DeleteObjects *del = new packet::DeleteObjects(); 279 283 if(!del->fetchIDs()) -
code/trunk/src/network/Server.h
r2171 r2662 52 52 { 53 53 const int CLIENTID_SERVER = 0; 54 const unsigned int NETWORK_FREQUENCY = 25; 55 const float NETWORK_PERIOD = 1./NETWORK_FREQUENCY; 54 56 55 57 /** -
code/trunk/src/network/packet/Acknowledgement.cc
r2171 r2662 64 64 65 65 bool Acknowledgement::process(){ 66 COUT(0) << "processing ACK with ID: " << getAckID() << endl; 66 67 bool b = GamestateHandler::ackGamestate(getAckID(), clientID_); 67 68 delete this; -
code/trunk/src/network/packet/Acknowledgement.h
r2171 r2662 32 32 #include "Packet.h" 33 33 34 const unsigned int ACKID_NACK = 0; 34 35 35 36 namespace orxonox { -
code/trunk/src/network/packet/DeleteObjects.cc
r2171 r2662 30 30 #include "DeleteObjects.h" 31 31 #include <enet/enet.h> 32 #include "network/ Synchronisable.h"32 #include "network/synchronisable/Synchronisable.h" 33 33 #include "core/CoreIncludes.h" 34 34 #include <assert.h> … … 61 61 if(number==0) 62 62 return false; 63 COUT( 3) << "sending DeleteObjects: ";63 COUT(4) << "sending DeleteObjects: "; 64 64 unsigned int size = sizeof(ENUM::Type) + sizeof(uint32_t)*(number+1); 65 65 data_ = new uint8_t[size]; 66 66 uint8_t *tdata = data_; 67 * (ENUM::Type *)(tdata) = ENUM::DeleteObjects;67 *reinterpret_cast<ENUM::Type*>(tdata) = ENUM::DeleteObjects; 68 68 tdata += sizeof(ENUM::Type); 69 69 *(uint32_t *)tdata = number; … … 72 72 unsigned int temp = Synchronisable::popDeletedObject(); 73 73 // assert(temp<10000); //ugly hack 74 * (uint32_t *)(tdata) = temp;75 COUT( 3) << temp << " ";74 *reinterpret_cast<uint32_t*>(tdata) = temp; 75 COUT(4) << temp << " "; 76 76 tdata += sizeof(uint32_t); 77 77 } 78 COUT( 3) << std::endl;78 COUT(4) << std::endl; 79 79 return true; 80 80 } … … 87 87 bool DeleteObjects::process(){ 88 88 for(unsigned int i=0; i<*(unsigned int *)(data_+_QUANTITY); i++){ 89 COUT( 3) << "deleting object with id: " << *(uint32_t*)(data_+_OBJECTIDS+i*sizeof(uint32_t)) << std::endl;89 COUT(4) << "deleting object with id: " << *(uint32_t*)(data_+_OBJECTIDS+i*sizeof(uint32_t)) << std::endl; 90 90 Synchronisable::deleteObject( *(uint32_t*)(data_+_OBJECTIDS+i*sizeof(uint32_t)) ); 91 91 } -
code/trunk/src/network/packet/Gamestate.cc
r2171 r2662 28 28 29 29 #include "Gamestate.h" 30 #include "network/ClientInformation.h" 31 #include "network/GamestateHandler.h" 30 #include "../GamestateHandler.h" 31 #include "../synchronisable/Synchronisable.h" 32 #include "../TrafficControl.h" 33 #include "core/Core.h" 32 34 #include "core/CoreIncludes.h" 33 35 #include "core/Iterator.h" 34 36 35 37 #include <zlib.h> 36 #include < assert.h>38 #include <cassert> 37 39 38 40 … … 42 44 namespace packet { 43 45 44 #define GAMESTATE_START(data) (data + sizeof(GamestateHeader)) 45 #define GAMESTATE_HEADER(data) ((GamestateHeader *)data) 46 #define HEADER GAMESTATE_HEADER(data_) 47 46 #define GAMESTATE_START(data) (data + GamestateHeader::getSize()) 48 47 49 48 #define PACKET_FLAG_GAMESTATE ENET_PACKET_FLAG_RELIABLE 50 49 50 // Gamestate::Gamestate() 51 // { 52 // flags_ = flags_ | PACKET_FLAG_GAMESTATE; 53 // } 54 51 55 Gamestate::Gamestate() 52 56 { 53 57 flags_ = flags_ | PACKET_FLAG_GAMESTATE; 58 header_ = 0; 54 59 } 55 60 … … 58 63 { 59 64 flags_ = flags_ | PACKET_FLAG_GAMESTATE; 65 header_ = new GamestateHeader(data_); 60 66 } 61 67 … … 64 70 flags_ = flags_ | PACKET_FLAG_GAMESTATE; 65 71 data_=data; 72 header_ = new GamestateHeader(data_); 73 } 74 75 Gamestate::Gamestate(const Gamestate& g) : 76 Packet( *(Packet*)&g ) 77 { 78 flags_ = flags_ | PACKET_FLAG_GAMESTATE; 79 header_ = new GamestateHeader(data_); 66 80 } 67 81 … … 73 87 bool Gamestate::collectData(int id, uint8_t mode) 74 88 { 75 unsigned int tempsize=0, currentsize=0; 89 assert(this->header_==0); // make sure the header didn't exist before 90 uint32_t tempsize=0, currentsize=0; 76 91 assert(data_==0); 77 u nsigned int size = calcGamestateSize(id, mode);92 uint32_t size = calcGamestateSize(id, mode); 78 93 79 94 COUT(4) << "G.ST.Man: producing gamestate with id: " << id << std::endl; 80 95 if(size==0) 81 96 return false; 82 data_ = new u nsigned char[size + sizeof(GamestateHeader)];97 data_ = new uint8_t[size + GamestateHeader::getSize()]; 83 98 if(!data_){ 84 99 COUT(2) << "GameStateManager: could not allocate memory" << std::endl; 85 100 return false; 86 101 } 102 103 // create the header object 104 header_ = new GamestateHeader(data_); 87 105 88 106 //start collect data synchronisable by synchronisable 89 107 uint8_t *mem=data_; 90 mem +=sizeof(GamestateHeader);108 mem += GamestateHeader::getSize(); 91 109 ObjectList<Synchronisable>::iterator it; 92 110 for(it = ObjectList<Synchronisable>::begin(); it; ++it){ 111 112 #ifndef NDEBUG 93 113 tempsize=it->getSize(id, mode); 94 95 114 if(currentsize+tempsize > size){ 96 115 assert(0); // if we don't use multithreading this part shouldn't be neccessary … … 98 117 COUT(3) << "G.St.Man: need additional memory" << std::endl; 99 118 ObjectList<Synchronisable>::iterator temp = it; 100 int addsize=tempsize;119 uint32_t addsize=tempsize; 101 120 while(++temp) 102 121 addsize+=temp->getSize(id, mode); 103 data_ = (uint8_t *)realloc(data_, sizeof(GamestateHeader) + currentsize + addsize);122 data_ = (uint8_t *)realloc(data_, GamestateHeader::getSize() + currentsize + addsize); 104 123 if(!data_) 105 124 return false; 106 125 size = currentsize+addsize; 107 126 }// stop allocate additional memory 108 127 #endif 109 128 110 129 //if(it->doSelection(id)) 111 dataMap_[mem-data_]=(*it); // save the mem location of the synchronisable data 130 if ( it->doSync( id, mode ) ) 131 dataMap_.push_back( obj(it->getObjectID(), it->getCreatorID(), tempsize, mem-data_) ); 132 // dataMap_[mem-data_]=(*it); // save the mem location of the synchronisable data 112 133 if(!it->getData(mem, id, mode)) 113 134 return false; // mem pointer gets automatically increased because of call by reference … … 118 139 119 140 //start write gamestate header 120 HEADER->packetType = ENUM::Gamestate; 121 HEADER->datasize = currentsize; 122 HEADER->id = id; 123 HEADER->diffed = false; 124 HEADER->complete = true; 125 HEADER->compressed = false; 141 header_->setDataSize( currentsize ); 142 header_->setID( id ); 143 header_->setDiffed( false ); 144 header_->setComplete( true ); 145 header_->setCompressed( false ); 126 146 //stop write gamestate header 127 147 … … 133 153 bool Gamestate::spreadData(uint8_t mode) 134 154 { 135 assert(data_); 136 assert(!HEADER->compressed); 137 assert(!HEADER->diffed); 138 uint8_t *mem=data_+sizeof(GamestateHeader); 155 COUT(4) << "processing gamestate with id " << header_->getID() << endl; 156 assert(data_); 157 assert(!header_->isCompressed()); 158 assert(!header_->isDiffed()); 159 uint8_t *mem=data_+GamestateHeader::getSize(); 139 160 // get the start of the Synchronisable list 140 161 //ObjectList<Synchronisable>::iterator it=ObjectList<Synchronisable>::begin(); … … 142 163 143 164 // update the data of the objects we received 144 while(mem < data_+ sizeof(GamestateHeader)+HEADER->datasize){145 synchronisableHeader *objectheader = (synchronisableHeader*)mem;146 147 s = Synchronisable::getSynchronisable( objectheader ->objectID);165 while(mem < data_+GamestateHeader::getSize()+header_->getDataSize()){ 166 SynchronisableHeader objectheader(mem); 167 168 s = Synchronisable::getSynchronisable( objectheader.getObjectID() ); 148 169 if(!s) 149 170 { 150 Synchronisable::fabricate(mem, mode); 171 if (!Core::isMaster()) 172 { 173 Synchronisable::fabricate(mem, mode); 174 } 175 else 176 { 177 mem += objectheader.getDataSize(); 178 } 179 // COUT(0) << "could not fabricate synchronisable: " << objectheader->objectID << " classid: " << objectheader->classID << " creator: " << objectheader->creatorID << endl; 180 // else 181 // COUT(0) << "fabricated: " << objectheader->objectID << " classid: " << objectheader->classID << " creator: " << objectheader->creatorID << endl; 151 182 } 152 183 else … … 157 188 } 158 189 190 // In debug mode, check first, whether there are no duplicate objectIDs 191 #ifndef NDEBUG 192 ObjectList<Synchronisable>::iterator it; 193 for (it = ObjectList<Synchronisable>::begin(); it != ObjectList<Synchronisable>::end(); ++it) { 194 if (it->getObjectID() == OBJECTID_UNKNOWN) { 195 if (it->objectMode_ != 0x0) { 196 COUT(0) << "Found object with OBJECTID_UNKNOWN on the client with objectMode != 0x0!" << std::endl; 197 COUT(0) << "Possible reason for this error: Client created a synchronized object without the Server's approval." << std::endl; 198 COUT(0) << "Objects class: " << it->getIdentifier()->getName() << std::endl; 199 assert(false); 200 } 201 } 202 else { 203 ObjectList<Synchronisable>::iterator it2; 204 for (it2 = ObjectList<Synchronisable>::begin(); it2 != ObjectList<Synchronisable>::end(); ++it2) { 205 if (it->getObjectID() == it2->getObjectID() && *it != *it2) { 206 COUT(0) << "Found duplicate objectIDs on the client!" << std::endl 207 << "Are you sure you don't create a Sychnronisable objcect with 'new' \ 208 that doesn't have objectMode = 0x0?" << std::endl; 209 assert(false); 210 } 211 } 212 } 213 } 214 #endif 215 159 216 return true; 160 217 } 161 218 162 163 164 int Gamestate::getID(){ 165 return HEADER->id; 166 } 167 168 unsigned int Gamestate::getSize() const 169 { 170 assert(data_); 171 if(HEADER->compressed) 172 return HEADER->compsize+sizeof(GamestateHeader); 219 uint32_t Gamestate::getSize() const 220 { 221 assert(data_); 222 if(header_->isCompressed()) 223 return header_->getCompSize()+GamestateHeader::getSize(); 173 224 else 174 225 { 175 return HEADER->datasize+sizeof(GamestateHeader);226 return header_->getDataSize()+GamestateHeader::getSize(); 176 227 } 177 228 } 178 229 179 230 bool Gamestate::operator==(packet::Gamestate gs){ 180 uint8_t *d1 = data_+ sizeof(GamestateHeader);181 uint8_t *d2 = gs.data_+ sizeof(GamestateHeader);231 uint8_t *d1 = data_+GamestateHeader::getSize(); 232 uint8_t *d2 = gs.data_+GamestateHeader::getSize(); 182 233 assert(!isCompressed()); 183 234 assert(!gs.isCompressed()); 184 while(d1<data_+ HEADER->datasize)235 while(d1<data_+header_->getDataSize()) 185 236 { 186 237 if(*d1!=*d2) … … 201 252 bool Gamestate::compressData() 202 253 { 203 assert( HEADER);204 assert(! HEADER->compressed);205 uLongf buffer = (uLongf)((( HEADER->datasize+ 12)*1.01)+1);254 assert(data_); 255 assert(!header_->isCompressed()); 256 uLongf buffer = (uLongf)(((header_->getDataSize() + 12)*1.01)+1); 206 257 if(buffer==0) 207 258 return false; 208 259 209 uint8_t *ndata = new uint8_t[buffer+ sizeof(GamestateHeader)];210 uint8_t *dest = GAMESTATE_START(ndata);260 uint8_t *ndata = new uint8_t[buffer+GamestateHeader::getSize()]; 261 uint8_t *dest = ndata + GamestateHeader::getSize(); 211 262 //unsigned char *dest = new unsigned char[buffer]; 212 uint8_t *source = GAMESTATE_START(data_);263 uint8_t *source = data_ + GamestateHeader::getSize(); 213 264 int retval; 214 retval = compress( dest, &buffer, source, (uLong)( HEADER->datasize) );265 retval = compress( dest, &buffer, source, (uLong)(header_->getDataSize()) ); 215 266 switch ( retval ) { 216 267 case Z_OK: COUT(5) << "G.St.Man: compress: successfully compressed" << std::endl; break; … … 219 270 case Z_DATA_ERROR: COUT(2) << "G.St.Man: compress: data corrupted in gamestate.compress" << std::endl; return false; 220 271 } 221 #ifndef NDEBUG222 //decompress and compare the start and the decompressed data223 uint8_t *rdata = new uint8_t[HEADER->datasize+sizeof(GamestateHeader)];224 uint8_t *d2 = GAMESTATE_START(rdata);225 uLongf length2 = HEADER->datasize;226 uncompress(d2, &length2, dest, buffer);227 for(unsigned int i=0; i<HEADER->datasize; i++){228 assert(*(source+i)==*(d2+i));229 }230 delete[] rdata;231 #endif232 272 233 273 //copy and modify header 234 #ifndef NDEBUG 235 HEADER->crc32 = calcCRC(data_+sizeof(GamestateHeader), HEADER->datasize); 236 #endif 237 *GAMESTATE_HEADER(ndata) = *HEADER; 274 GamestateHeader *temp = header_; 275 header_ = new GamestateHeader(ndata, temp); 276 delete temp; 238 277 //delete old data 239 278 delete[] data_; 240 279 //save new data 241 280 data_ = ndata; 242 HEADER->compsize = buffer; 243 HEADER->compressed = true; 244 assert(HEADER->compressed); 245 COUT(4) << "gamestate compress datasize: " << HEADER->datasize << " compsize: " << HEADER->compsize << std::endl; 281 header_->setCompSize( buffer ); 282 header_->setCompressed( true ); 283 COUT(5) << "gamestate compress datasize: " << header_->getDataSize() << " compsize: " << header_->getCompSize() << std::endl; 246 284 return true; 247 285 } 248 286 bool Gamestate::decompressData() 249 287 { 250 assert( HEADER);251 assert( HEADER->compressed);252 COUT(4) << "GameStateClient: uncompressing gamestate. id: " << HEADER->id << ", baseid: " << HEADER->base_id << ", datasize: " << HEADER->datasize << ", compsize: " << HEADER->compsize<< std::endl;253 u nsigned int datasize = HEADER->datasize;254 u nsigned int compsize = HEADER->compsize;255 u nsigned int bufsize;288 assert(data_); 289 assert(header_->isCompressed()); 290 COUT(4) << "GameStateClient: uncompressing gamestate. id: " << header_->getID() << ", baseid: " << header_->getBaseID() << ", datasize: " << header_->getDataSize() << ", compsize: " << header_->getCompSize() << std::endl; 291 uint32_t datasize = header_->getDataSize(); 292 uint32_t compsize = header_->getCompSize(); 293 uint32_t bufsize; 256 294 // assert(compsize<=datasize); 257 295 bufsize = datasize; 258 296 assert(bufsize!=0); 259 uint8_t *ndata = new uint8_t[bufsize + sizeof(GamestateHeader)];260 uint8_t *dest = ndata + sizeof(GamestateHeader);261 uint8_t *source = data_ + sizeof(GamestateHeader);297 uint8_t *ndata = new uint8_t[bufsize + GamestateHeader::getSize()]; 298 uint8_t *dest = ndata + GamestateHeader::getSize(); 299 uint8_t *source = data_ + GamestateHeader::getSize(); 262 300 int retval; 263 301 uLongf length=bufsize; … … 269 307 case Z_DATA_ERROR: COUT(2) << "data corrupted (zlib)" << std::endl; return false; 270 308 } 271 #ifndef NDEBUG272 assert(HEADER->crc32==calcCRC(ndata+sizeof(GamestateHeader), HEADER->datasize));273 #endif274 309 275 310 //copy over the header 276 *GAMESTATE_HEADER(ndata) = *HEADER; 311 GamestateHeader *temp = header_; 312 header_ = new GamestateHeader( data_, header_ ); 313 delete temp; 277 314 278 315 if (this->bDataENetAllocated_){ … … 289 326 //set new pointers 290 327 data_ = ndata; 291 HEADER->compressed = false;292 assert( HEADER->datasize==datasize);293 assert( HEADER->compsize==compsize);328 header_->setCompressed( false ); 329 assert(header_->getDataSize()==datasize); 330 assert(header_->getCompSize()==compsize); 294 331 return true; 295 332 } … … 297 334 Gamestate *Gamestate::diff(Gamestate *base) 298 335 { 299 assert(HEADER); 300 assert(!HEADER->compressed); 301 assert(!HEADER->diffed); 336 assert(data_); 337 assert(!header_->isCompressed()); 338 assert(!header_->isDiffed()); 339 GamestateHeader diffHeader(base->data_); 302 340 //unsigned char *basep = base->getGs()/*, *gs = getGs()*/; 303 341 uint8_t *basep = GAMESTATE_START(base->data_), *gs = GAMESTATE_START(this->data_); 304 u nsigned int of=0; // pointers offset305 u nsigned int dest_length=0;306 dest_length= HEADER->datasize;342 uint32_t of=0; // pointers offset 343 uint32_t dest_length=0; 344 dest_length=header_->getDataSize(); 307 345 if(dest_length==0) 308 346 return NULL; 309 uint8_t *ndata = new uint8_t[dest_length*sizeof(uint8_t)+ sizeof(GamestateHeader)];310 uint8_t *dest = ndata + sizeof(GamestateHeader);311 while(of < GAMESTATE_HEADER(base->data_)->datasize && of < HEADER->datasize){347 uint8_t *ndata = new uint8_t[dest_length*sizeof(uint8_t)+GamestateHeader::getSize()]; 348 uint8_t *dest = ndata + GamestateHeader::getSize(); 349 while(of < diffHeader.getDataSize() && of < header_->getDataSize()){ 312 350 *(dest+of)=*(basep+of)^*(gs+of); // do the xor 313 351 ++of; 314 352 } 315 if( GAMESTATE_HEADER(base->data_)->datasize!=HEADER->datasize){353 if(diffHeader.getDataSize()!=header_->getDataSize()){ 316 354 uint8_t n=0; 317 if( GAMESTATE_HEADER(base->data_)->datasize < HEADER->datasize){355 if(diffHeader.getDataSize() < header_->getDataSize()){ 318 356 while(of<dest_length){ 319 357 *(dest+of)=n^*(gs+of); … … 323 361 } 324 362 325 *GAMESTATE_HEADER(ndata) = *HEADER;326 GAMESTATE_HEADER(ndata)->diffed = true;327 GAMESTATE_HEADER(ndata)->base_id = base->getID();328 363 Gamestate *g = new Gamestate(ndata, getClientID()); 364 *(g->header_) = *header_; 365 g->header_->setDiffed( true ); 366 g->header_->setBaseID( base->getID() ); 329 367 g->flags_=flags_; 330 368 g->packetDirection_ = packetDirection_; … … 332 370 } 333 371 334 Gamestate* Gamestate::doSelection(unsigned int clientID ){335 assert(data_); 336 std:: map<unsigned int, Synchronisable *>::iterator it;372 Gamestate* Gamestate::doSelection(unsigned int clientID, unsigned int targetSize){ 373 assert(data_); 374 std::list<obj>::iterator it; 337 375 338 376 // allocate memory for new data 339 uint8_t *gdata = new uint8_t[ HEADER->datasize+sizeof(GamestateHeader)];377 uint8_t *gdata = new uint8_t[header_->getDataSize()+GamestateHeader::getSize()]; 340 378 // create a gamestate out of it 341 379 Gamestate *gs = new Gamestate(gdata); 342 uint8_t *newdata = gdata + sizeof(GamestateHeader);380 uint8_t *newdata = gdata + GamestateHeader::getSize(); 343 381 uint8_t *origdata = GAMESTATE_START(data_); 344 382 345 383 //copy the GamestateHeader 346 *(GamestateHeader*)gdata = *HEADER; 347 348 synchronisableHeader *oldobjectheader, *newobjectheader; 349 unsigned int objectOffset; 384 assert(gs->header_); 385 *(gs->header_) = *header_; 386 387 uint32_t objectOffset; 388 unsigned int objectsize, destsize=0; 389 // TODO: Why is this variable not used? 390 //Synchronisable *object; 391 392 //call TrafficControl 393 TrafficControl::getInstance()->processObjectList( clientID, header_->getID(), &dataMap_ ); 350 394 351 395 //copy in the zeros 352 for(it=dataMap_.begin(); it!=dataMap_.end(); it++){ 353 oldobjectheader = (synchronisableHeader*)origdata; 354 newobjectheader = (synchronisableHeader*)newdata; 355 unsigned int objectsize = oldobjectheader->size; 356 assert(it->second->objectID==oldobjectheader->objectID); 357 *newobjectheader = *oldobjectheader; 358 objectOffset=sizeof(synchronisableHeader); //skip the size and the availableData variables in the objectheader 359 if(it->second->doSelection(HEADER->id)){ 360 assert(newobjectheader->dataAvailable==true); 361 memcpy(newdata+objectOffset, origdata+objectOffset, objectsize-objectOffset); 396 for(it=dataMap_.begin(); it!=dataMap_.end();){ 397 // if((*it).objSize==0) 398 // continue; 399 // if(it->second->getSize(HEADER->id)==0) // merged from objecthierarchy2, doesn't work anymore; TODO: change this 400 // continue; // merged from objecthierarchy2, doesn't work anymore; TODO: change this 401 SynchronisableHeader oldobjectheader(origdata); 402 SynchronisableHeader newobjectheader(newdata); 403 if ( (*it).objSize == 0 ) 404 { 405 ++it; 406 continue; 407 } 408 // object = Synchronisable::getSynchronisable( (*it).objID ); 409 // assert(object->objectID == oldobjectheader->objectID); 410 objectsize = oldobjectheader.getDataSize(); 411 objectOffset=SynchronisableHeader::getSize(); //skip the size and the availableData variables in the objectheader 412 if ( (*it).objID == oldobjectheader.getObjectID() ){ 413 memcpy(newdata, origdata, objectsize); 414 assert(newobjectheader.isDataAvailable()==true); 415 ++it; 362 416 }else{ 363 newobjectheader->dataAvailable=false; 417 newobjectheader = oldobjectheader; 418 newobjectheader.setDataAvailable(false); 364 419 memset(newdata+objectOffset, 0, objectsize-objectOffset); 365 assert(objectOffset==objectsize);366 420 } 367 421 newdata += objectsize; 368 422 origdata += objectsize; 369 } 423 destsize += objectsize; 424 } 425 #ifndef NDEBUG 426 uint32_t origsize = destsize; 427 while ( origsize < header_->getDataSize() ) 428 { 429 SynchronisableHeader oldobjectheader(origdata); 430 objectsize = oldobjectheader.getDataSize(); 431 origdata += objectsize; 432 origsize += objectsize; 433 } 434 assert(origsize==header_->getDataSize()); 435 assert(destsize!=0); 436 #endif 437 gs->header_->setDataSize( destsize ); 370 438 return gs; 371 439 } 372 440 373 441 374 Gamestate* Gamestate::intelligentDiff(Gamestate *base, unsigned int clientID){375 // asserts376 assert(data_);377 assert(base->data_);378 assert(!GAMESTATE_HEADER(base->data_)->diffed);379 assert(!GAMESTATE_HEADER(base->data_)->compressed);380 assert(!HEADER->compressed);381 assert(!HEADER->diffed);382 383 //preparations384 std::map<unsigned int, Synchronisable *>::iterator it;385 uint8_t *origdata, *basedata, *destdata, *ndata;386 unsigned int objectOffset, streamOffset=0; //data offset387 unsigned int minsize = (HEADER->datasize < GAMESTATE_HEADER(base->data_)->datasize) ? HEADER->datasize : GAMESTATE_HEADER(base->data_)->datasize;388 synchronisableHeader *origheader;389 synchronisableHeader *destheader;390 391 origdata = GAMESTATE_START(this->data_);392 basedata = GAMESTATE_START(base->data_);393 ndata = new uint8_t[HEADER->datasize + sizeof(GamestateHeader)];394 destdata = ndata + sizeof(GamestateHeader);395 396 // do the diff397 for(it=dataMap_.begin(); it!=dataMap_.end(); it++){398 assert(streamOffset<HEADER->datasize);399 bool sendData = it->second->doSelection(HEADER->id);400 origheader = (synchronisableHeader *)(origdata+streamOffset);401 destheader = (synchronisableHeader *)(destdata+streamOffset);402 403 //copy and partially diff the object header404 assert(sizeof(synchronisableHeader)==3*sizeof(unsigned int)+sizeof(bool));405 *(uint32_t*)destdata = *(uint32_t*)origdata; //size (do not diff)406 *(bool*)(destdata+sizeof(uint32_t)) = sendData;407 if(sendData){408 *(uint32_t*)(destdata+sizeof(uint32_t)+sizeof(bool)) = *(uint32_t*)(basedata+sizeof(uint32_t)+sizeof(bool)) ^ *(uint32_t*)(origdata+sizeof(uint32_t)+sizeof(bool)); //objectid (diff it)409 *(uint32_t*)(destdata+2*sizeof(uint32_t)+sizeof(bool)) = *(uint32_t*)(basedata+2*sizeof(uint32_t)+sizeof(bool)) ^ *(uint32_t*)(origdata+2*sizeof(uint32_t)+sizeof(bool)); //classid (diff it)410 }else{411 *(uint32_t*)(destdata+sizeof(uint32_t)+sizeof(bool)) = 0;412 *(uint32_t*)(destdata+2*sizeof(uint32_t)+sizeof(bool)) = 0;413 }414 objectOffset=sizeof(synchronisableHeader);415 streamOffset+=sizeof(synchronisableHeader);416 417 //now handle the object data or fill with zeros418 while(objectOffset<origheader->size ){419 420 if(sendData && streamOffset<minsize)421 *(destdata+objectOffset)=*(basedata+objectOffset)^*(origdata+objectOffset); // do the xor422 else if(sendData)423 *(destdata+objectOffset)=((uint8_t)0)^*(origdata+objectOffset); // xor with 0 (basestream is too short)424 else425 *(destdata+objectOffset)=0; // set to 0 because this object should not be transfered426 427 objectOffset++;428 streamOffset++;429 }430 destdata+=objectOffset;431 origdata+=objectOffset;432 basedata+=objectOffset;433 }434 435 //copy over the gamestate header and set the diffed flag436 *(GamestateHeader *)ndata = *HEADER; //copy over the header437 Gamestate *gs = new Gamestate(ndata);438 GAMESTATE_HEADER(ndata)->diffed=true;439 return gs;440 }441 442 Gamestate* Gamestate::intelligentUnDiff(Gamestate *base){443 // asserts444 assert(data_);445 assert(base->data_);446 assert(!GAMESTATE_HEADER(base->data_)->diffed);447 assert(!GAMESTATE_HEADER(base->data_)->compressed);448 assert(!HEADER->compressed);449 assert(HEADER->diffed);450 451 //preparations452 std::map<unsigned int, Synchronisable *>::iterator it;453 uint8_t *origdata, *basedata, *destdata, *ndata;454 unsigned int objectOffset, streamOffset=0; //data offset455 unsigned int minsize = (HEADER->datasize < GAMESTATE_HEADER(base->data_)->datasize) ? HEADER->datasize : GAMESTATE_HEADER(base->data_)->datasize;456 synchronisableHeader *origheader;457 synchronisableHeader *destheader;458 459 origdata = GAMESTATE_START(this->data_);460 basedata = GAMESTATE_START(base->data_);461 ndata = new uint8_t[HEADER->datasize + sizeof(GamestateHeader)];462 destdata = ndata + sizeof(GamestateHeader);463 464 // do the undiff465 for(it=dataMap_.begin(); it!=dataMap_.end(); it++){466 assert(streamOffset<HEADER->datasize);467 origheader = (synchronisableHeader *)(origdata+streamOffset);468 destheader = (synchronisableHeader *)(destdata+streamOffset);469 bool sendData;470 471 //copy and partially diff the object header472 assert(sizeof(synchronisableHeader)==3*sizeof(unsigned int)+sizeof(bool));473 *(unsigned int*)destdata = *(unsigned int*)origdata; //size (do not diff)474 *(bool*)(destdata+sizeof(unsigned int)) = *(bool*)(origdata+sizeof(unsigned int));475 sendData = *(bool*)(origdata+sizeof(unsigned int));476 if(sendData){477 *(unsigned int*)(destdata+sizeof(unsigned int)+sizeof(bool)) = *(unsigned int*)(basedata+sizeof(unsigned int)+sizeof(bool)) ^ *(unsigned int*)(origdata+sizeof(unsigned int)+sizeof(bool)); //objectid (diff it)478 *(unsigned int*)(destdata+2*sizeof(unsigned int)+sizeof(bool)) = *(unsigned int*)(basedata+2*sizeof(unsigned int)+sizeof(bool)) ^ *(unsigned int*)(origdata+2*sizeof(unsigned int)+sizeof(bool)); //classid (diff it)479 }else{480 *(unsigned int*)(destdata+sizeof(unsigned int)+sizeof(bool)) = 0;481 *(unsigned int*)(destdata+2*sizeof(unsigned int)+sizeof(bool)) = 0;482 }483 objectOffset=sizeof(synchronisableHeader);484 streamOffset+=sizeof(synchronisableHeader);485 486 //now handle the object data or fill with zeros487 while(objectOffset<origheader->size ){488 489 if(sendData && streamOffset<minsize)490 *(destdata+objectOffset)=*(basedata+objectOffset)^*(origdata+objectOffset); // do the xor491 else if(sendData)492 *(destdata+objectOffset)=((unsigned char)0)^*(origdata+objectOffset); // xor with 0 (basestream is too short)493 else494 *(destdata+objectOffset)=0; // set to 0 because this object should not be transfered495 496 objectOffset++;497 streamOffset++;498 }499 destdata+=objectOffset;500 origdata+=objectOffset;501 basedata+=objectOffset;502 }503 504 //copy over the gamestate header and set the diffed flag505 *(GamestateHeader *)ndata = *HEADER; //copy over the header506 Gamestate *gs = new Gamestate(ndata);507 GAMESTATE_HEADER(ndata)->diffed=false;508 return gs;509 }510 511 442 Gamestate *Gamestate::undiff(Gamestate *base) 512 443 { 513 assert(this && base);assert( HEADER);514 assert( HEADER->diffed);515 assert(! HEADER->compressed && !GAMESTATE_HEADER(base->data_)->compressed);444 assert(this && base);assert(data_); 445 assert(header_->isDiffed()); 446 assert(!header_->isCompressed() && !base->header_->isCompressed()); 516 447 //unsigned char *basep = base->getGs()/*, *gs = getGs()*/; 517 448 uint8_t *basep = GAMESTATE_START(base->data_); 518 449 uint8_t *gs = GAMESTATE_START(this->data_); 519 u nsigned int of=0; // pointers offset520 u nsigned int dest_length=0;521 dest_length= HEADER->datasize;450 uint32_t of=0; // pointers offset 451 uint32_t dest_length=0; 452 dest_length=header_->getDataSize(); 522 453 if(dest_length==0) 523 454 return NULL; 524 uint8_t *ndata = new uint8_t[dest_length*sizeof(uint8_t)+ sizeof(GamestateHeader)];525 uint8_t *dest = ndata + sizeof(GamestateHeader);526 while(of < GAMESTATE_HEADER(base->data_)->datasize && of < HEADER->datasize){455 uint8_t *ndata = new uint8_t[dest_length*sizeof(uint8_t)+GamestateHeader::getSize()]; 456 uint8_t *dest = ndata + GamestateHeader::getSize(); 457 while(of < base->header_->getDataSize() && of < header_->getDataSize()){ 527 458 *(dest+of)=*(basep+of)^*(gs+of); // do the xor 528 459 ++of; 529 460 } 530 if( GAMESTATE_HEADER(base->data_)->datasize!=HEADER->datasize){461 if(base->header_->getDataSize()!=header_->getDataSize()){ 531 462 uint8_t n=0; 532 if( GAMESTATE_HEADER(base->data_)->datasize < HEADER->datasize){463 if(base->header_->getDataSize() < header_->getDataSize()){ 533 464 while(of < dest_length){ 534 465 *(dest+of)=n^*(gs+of); … … 537 468 } 538 469 } 539 *GAMESTATE_HEADER(ndata) = *HEADER;540 GAMESTATE_HEADER(ndata)->diffed = false;541 470 Gamestate *g = new Gamestate(ndata, getClientID()); 471 assert(g->header_); 472 *(g->header_) = *header_; 473 g->header_->setDiffed( false ); 542 474 g->flags_=flags_; 543 475 g->packetDirection_ = packetDirection_; … … 548 480 549 481 550 u nsigned int Gamestate::calcGamestateSize(unsigned int id, uint8_t mode)551 { 552 u nsigned int size=0;482 uint32_t Gamestate::calcGamestateSize(int32_t id, uint8_t mode) 483 { 484 uint32_t size=0; 553 485 // get the start of the Synchronisable list 554 486 ObjectList<Synchronisable>::iterator it; … … 556 488 for(it = ObjectList<Synchronisable>::begin(); it; ++it) 557 489 size+=it->getSize(id, mode); // size of the actual data of the synchronisable 558 // size+=sizeof(GamestateHeader);559 490 return size; 560 491 } 561 492 562 /** 563 * This function removes a Synchronisable out of the universe 564 * @param it iterator of the list pointing to the object 565 * @return iterator pointing to the next object in the list 566 */ 567 void Gamestate::removeObject(ObjectList<Synchronisable>::iterator &it) { 568 ObjectList<Synchronisable>::iterator temp=it; 569 ++it; 570 delete *temp; 571 } 572 573 bool Gamestate::isDiffed(){ 574 return HEADER->diffed; 575 } 576 577 bool Gamestate::isCompressed(){ 578 return HEADER->compressed; 579 } 580 581 int Gamestate::getBaseID(){ 582 return HEADER->base_id; 583 } 584 } 585 586 } 493 } //namespace packet 494 } //namespace orxonox -
code/trunk/src/network/packet/Gamestate.h
r2171 r2662 31 31 #define NETWORK_PACKETGAMESTATE_H 32 32 33 #include " ../NetworkPrereqs.h"33 #include "network/NetworkPrereqs.h" 34 34 35 35 #include "Packet.h" 36 #include "network/Synchronisable.h" 36 #include "network/TrafficControl.h" 37 #include "core/CoreIncludes.h" 37 38 #include <map> 39 #include <list> 38 40 #ifndef NDEBUG 39 41 #include "util/CRC32.h" … … 44 46 namespace packet { 45 47 46 struct _NetworkExport GamestateHeader{ 47 ENUM::Type packetType; 48 int32_t id; // id of the gamestate 49 uint32_t compsize; 50 uint32_t datasize; 51 int32_t base_id; // id of the base-gamestate diffed from 52 bool diffed:1; // wheter diffed or not 53 bool complete:1; // wheter it is a complete gamestate or only partial 54 bool compressed:1; 55 #ifndef NDEBUG 56 uint32_t crc32; 57 #endif 48 class _NetworkExport GamestateHeader{ 49 public: 50 GamestateHeader(uint8_t *data){ assert(data); data_ = data; *(uint32_t*)data_ = ENUM::Gamestate; } 51 GamestateHeader(uint8_t *data, GamestateHeader* h) 52 { assert(data); data_=data; memcpy(data_, h->data_, getSize()); } 53 static inline uint32_t getSize() 54 { return 21; } 55 56 inline int32_t getID() const 57 { assert(data_); return *(int32_t*)(data_+4); } 58 inline void setID(int32_t id) 59 { assert(data_); *(int32_t*)(data_+4) = id; } 60 61 inline int32_t getBaseID() const 62 { assert(data_); return *(int32_t*)(data_+8); } 63 inline void setBaseID(int32_t id) 64 { assert(data_); *(int32_t*)(data_+8) = id; } 65 66 inline uint32_t getDataSize() const 67 { assert(data_); return *(uint32_t*)(data_+12); } 68 inline void setDataSize(uint32_t size) 69 { assert(data_); *(uint32_t*)(data_+12) = size; } 70 71 inline uint32_t getCompSize() const 72 { assert(data_); return *(uint32_t*)(data_+16); } 73 inline void setCompSize(uint32_t size) 74 { assert(data_); *(uint32_t*)(data_+16) = size; } 75 76 inline bool isDiffed() const 77 { assert(data_); return *(int8_t*)(data_+20) & 0x1; } 78 inline void setDiffed(bool b) 79 { assert(data_); *(int8_t*)(data_+20) = (b<<0) | (*(int8_t*)(data_+20) & 0x6 ); } 80 81 inline bool isComplete() const 82 { assert(data_); return *(int8_t*)(data_+20) & 0x2; } 83 inline void setComplete(bool b) 84 { assert(data_); *(int8_t*)(data_+20) = (b<<1) | (*(int8_t*)(data_+20) & 0x5 ); } 85 86 inline bool isCompressed() const 87 { assert(data_); return *(int8_t*)(data_+20) & 0x4; } 88 inline void setCompressed(bool b) 89 { assert(data_); *(int8_t*)(data_+20) = (b<<2) | (*(int8_t*)(data_+20) & 0x3 ); } 90 91 inline void operator=(GamestateHeader& h) 92 { assert(data_); assert(h.data_); memcpy( data_, h.data_, getSize()); } 93 private: 94 uint8_t *data_; 95 //#define GAMESTATE_START(data) (data + sizeof(GamestateHeader)) 96 //#define GAMESTATE_HEADER(data) ((GamestateHeader *)data) 97 //#define HEADER GAMESTATE_HEADER(data_) 98 58 99 }; 59 100 … … 66 107 Gamestate(uint8_t *data, unsigned int clientID); 67 108 Gamestate(uint8_t *data); 109 Gamestate(const Gamestate& g); 68 110 69 111 ~Gamestate(); … … 71 113 bool collectData(int id, uint8_t mode=0x0); 72 114 bool spreadData( uint8_t mode=0x0); 73 in t getID();74 bool isDiffed();75 bool isCompressed();76 in t getBaseID();115 inline int32_t getID() const { return header_->getID(); } 116 inline bool isDiffed() const { return header_->isDiffed(); } 117 inline bool isCompressed() const { return header_->isCompressed(); } 118 inline int32_t getBaseID() const { return header_->getBaseID(); } 77 119 Gamestate *diff(Gamestate *base); 78 Gamestate* intelligentDiff(Gamestate *base, unsigned int clientID);79 120 Gamestate *undiff(Gamestate *base); 80 Gamestate* intelligentUnDiff(Gamestate *base); 81 Gamestate* doSelection(unsigned int clientID); 121 Gamestate* doSelection(unsigned int clientID, unsigned int targetSize); 82 122 bool compressData(); 83 123 bool decompressData(); … … 85 125 // Packet functions 86 126 private: 87 virtual u nsigned int getSize() const;88 virtual bool process();127 virtual uint32_t getSize() const; 128 virtual inline bool process(); 89 129 90 130 bool operator ==(packet::Gamestate gs); 91 131 private: 92 u nsigned int calcGamestateSize(unsigned int id, uint8_t mode=0x0);93 void removeObject(ObjectListIterator<Synchronisable> &it);94 std::map<unsigned int, Synchronisable*> dataMap_;132 uint32_t calcGamestateSize(int32_t id, uint8_t mode=0x0); 133 std::list<obj> dataMap_; 134 GamestateHeader* header_; 95 135 }; 96 136 -
code/trunk/src/network/packet/Packet.cc
r2171 r2662 129 129 return false; 130 130 } 131 // Assures we don't create a packet and destroy it right after in another thread132 // without having a reference in the packetMap_133 boost::recursive_mutex::scoped_lock lock(Packet::packetMap_mutex);134 131 // We deliver ENet the data address so that it doesn't memcpy everything again. 135 132 // --> We have to delete data_ ourselves! … … 138 135 // Add the packet to a global list so we can access it again once enet calls our 139 136 // deletePacket method. We can of course only give a one argument function to the ENet C library. 140 packetMap_[(size_t)(void*)enetPacket_] = this; 137 { 138 // Assures we don't create a packet and destroy it right after in another thread 139 // without having a reference in the packetMap_ 140 boost::recursive_mutex::scoped_lock lock(Packet::packetMap_mutex); 141 packetMap_[(size_t)(void*)enetPacket_] = this; 142 } 141 143 } 142 144 #ifndef NDEBUG -
code/trunk/src/network/packet/Welcome.cc
r2171 r2662 32 32 #include "Welcome.h" 33 33 #include "network/Host.h" 34 #include "network/ Synchronisable.h"34 #include "network/synchronisable/Synchronisable.h" 35 35 #include "core/CoreIncludes.h" 36 36 #include <assert.h> … … 42 42 #define _PACKETID 0 43 43 #define _CLIENTID _PACKETID + sizeof(ENUM::Type) 44 #define _ SHIPID_CLIENTID + sizeof(uint32_t)45 46 Welcome::Welcome( u nsigned int clientID, unsigned int shipID )44 #define _ENDIANTEST _CLIENTID + sizeof(uint32_t) 45 46 Welcome::Welcome( uint32_t clientID, uint32_t shipID ) 47 47 : Packet() 48 48 { … … 52 52 assert(data_); 53 53 *(packet::ENUM::Type *)(data_ + _PACKETID ) = packet::ENUM::Welcome; 54 *(uint32_t *) &data_[ _CLIENTID ] = clientID;55 *(uint32_t *) &data_[ _SHIPID ] = shipID;54 *(uint32_t *)(data_ + _CLIENTID ) = static_cast<uint32_t>(clientID); 55 *(uint32_t *)(data_ + _ENDIANTEST ) = 0xFEDC4321; 56 56 } 57 57 58 Welcome::Welcome( uint8_t* data, u nsigned int clientID )58 Welcome::Welcome( uint8_t* data, uint32_t clientID ) 59 59 : Packet(data, clientID) 60 60 { … … 74 74 75 75 bool Welcome::process(){ 76 u nsigned int shipID,clientID;77 clientID = *(uint32_t *) &data_[ _CLIENTID ];78 shipID = *(uint32_t *)&data_[ _SHIPID ];76 uint32_t clientID; 77 clientID = *(uint32_t *)(data_ + _CLIENTID ); 78 assert(*(uint32_t *)(data_ + _ENDIANTEST ) == 0xFEDC4321); 79 79 Host::setClientID(clientID); 80 Host::setShipID(shipID); 81 COUT(3) << "Welcome set clientId: " << clientID << " shipID: " << shipID << std::endl; 80 COUT(3) << "Welcome set clientId: " << clientID << endl; 82 81 Synchronisable::setClient(true); 83 82 delete this; -
code/trunk/src/network/packet/Welcome.h
r2171 r2662 42 42 { 43 43 public: 44 Welcome( u nsigned int clientID, unsigned int shipID );45 Welcome( uint8_t* data, u nsigned int clientID );44 Welcome( uint32_t clientID, uint32_t shipID ); 45 Welcome( uint8_t* data, uint32_t clientID ); 46 46 virtual ~Welcome(); 47 47 -
code/trunk/src/network/synchronisable/NetworkCallback.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/network/synchronisable/Synchronisable.cc
- Property svn:mergeinfo changed
/code/branches/presentation/src/network/synchronisable/Synchronisable.cc (added) merged: 2655
r2653 r2662 28 28 */ 29 29 30 //31 // C++ Implementation: synchronisable32 //33 // Description:34 //35 //36 // Author: Dumeni, Oliver Scheuss, (C) 200737 //38 // Copyright: See COPYING file that comes with this distribution39 //40 30 41 31 #include "Synchronisable.h" … … 155 145 Synchronisable *Synchronisable::fabricate(uint8_t*& mem, uint8_t mode) 156 146 { 157 synchronisableHeader *header = (synchronisableHeader *)mem;158 159 if(!header ->dataAvailable)160 { 161 mem += header ->size;147 SynchronisableHeader header(mem); 148 149 if(!header.isDataAvailable()) 150 { 151 mem += header.getDataSize(); 162 152 return 0; 163 153 } 164 154 165 COUT(4) << "fabricating object with id: " << header ->objectID<< std::endl;166 167 Identifier* id = ClassByID(header ->classID);155 COUT(4) << "fabricating object with id: " << header.getObjectID() << std::endl; 156 157 Identifier* id = ClassByID(header.getClassID()); 168 158 if (!id) 169 159 { … … 174 164 assert(id); 175 165 BaseObject* creator = 0; 176 if (header ->creatorID!= OBJECTID_UNKNOWN)177 { 178 Synchronisable* synchronisable_creator = Synchronisable::getSynchronisable(header ->creatorID);166 if (header.getCreatorID() != OBJECTID_UNKNOWN) 167 { 168 Synchronisable* synchronisable_creator = Synchronisable::getSynchronisable(header.getCreatorID()); 179 169 if (!synchronisable_creator) 180 170 { 181 mem += header ->size; //.TODO: this suckz.... remove size from header182 //assert(0); // TODO: uncomment this if we have a clean objecthierarchy (with destruction of children of objects) ^^171 mem += header.getDataSize(); //.TODO: this suckz.... remove size from header 172 assert(0); // TODO: uncomment this if we have a clean objecthierarchy (with destruction of children of objects) ^^ 183 173 return 0; 184 174 } … … 186 176 creator = dynamic_cast<BaseObject*>(synchronisable_creator); 187 177 } 188 assert(getSynchronisable(header ->objectID)==0); //make sure no object with this id exists178 assert(getSynchronisable(header.getObjectID())==0); //make sure no object with this id exists 189 179 BaseObject *bo = id->fabricate(creator); 190 180 assert(bo); 191 181 Synchronisable *no = dynamic_cast<Synchronisable *>(bo); 192 182 assert(no); 193 no->objectID=header ->objectID;194 no->creatorID=header ->creatorID; //TODO: remove this195 no->classID=header ->classID;183 no->objectID=header.getObjectID(); 184 no->creatorID=header.getCreatorID(); //TODO: remove this 185 no->classID=header.getClassID(); 196 186 COUT(4) << "fabricate objectID: " << no->objectID << " classID: " << no->classID << std::endl; 197 187 // update data and create object/entity... … … 329 319 330 320 // start copy header 331 synchronisableHeader *header = (synchronisableHeader *)mem;332 header ->size = size;333 header ->objectID = this->objectID;334 header ->creatorID = this->creatorID;335 header ->classID = this->classID;336 header ->dataAvailable = true;337 tempsize += sizeof(synchronisableHeader);338 mem += sizeof(synchronisableHeader);321 SynchronisableHeader header(mem); 322 header.setDataSize( size ); 323 header.setObjectID( this->objectID ); 324 header.setCreatorID( this->creatorID ); 325 header.setClassID( this->classID ); 326 header.setDataAvailable( true ); 327 tempsize += SynchronisableHeader::getSize(); 328 mem += SynchronisableHeader::getSize(); 339 329 // end copy header 340 330 … … 371 361 uint8_t* data=mem; 372 362 // start extract header 373 synchronisableHeader *syncHeader = (synchronisableHeader *)mem;374 assert(syncHeader ->objectID==this->objectID);375 assert(syncHeader ->creatorID==this->creatorID);376 assert( this->classID==syncHeader->classID); //TODO: fix this!!! maybe a problem with the identifier ?377 if(syncHeader ->dataAvailable==false){378 mem += syncHeader ->size;363 SynchronisableHeader syncHeader(mem); 364 assert(syncHeader.getObjectID()==this->objectID); 365 assert(syncHeader.getCreatorID()==this->creatorID); 366 assert(syncHeader.getClassID()==this->classID); 367 if(syncHeader.isDataAvailable()==false){ 368 mem += syncHeader.getDataSize(); 379 369 return true; 380 370 } 381 371 382 mem += sizeof(synchronisableHeader);372 mem += SynchronisableHeader::getSize(); 383 373 // stop extract header 384 374 385 COUT(5) << "Synchronisable: objectID " << syncHeader->objectID << ", classID " << syncHeader->classID << " size: " << syncHeader->size << " synchronising data" << std::endl; 386 for(i=syncList.begin(); i!=syncList.end() && mem <= data+syncHeader->size; i++) 387 { 375 //COUT(5) << "Synchronisable: objectID " << syncHeader.getObjectID() << ", classID " << syncHeader.getClassID() << " size: " << syncHeader.getDataSize() << " synchronising data" << std::endl; 376 for(i=syncList.begin(); i!=syncList.end(); i++) 377 { 378 assert( mem <= data+syncHeader.getDataSize() ); // always make sure we don't exceed the datasize in our stream 388 379 (*i)->putData( mem, mode, forceCallback ); 389 380 } 390 assert(mem == data+syncHeader ->size);381 assert(mem == data+syncHeader.getDataSize()); 391 382 return true; 392 383 } … … 399 390 */ 400 391 uint32_t Synchronisable::getSize(int32_t id, uint8_t mode){ 401 int tsize= sizeof(synchronisableHeader);392 int tsize=SynchronisableHeader::getSize(); 402 393 if(mode==0x0) 403 394 mode=state_; … … 428 419 bool Synchronisable::isMyData(uint8_t* mem) 429 420 { 430 synchronisableHeader *header = (synchronisableHeader *)mem;431 assert(header ->objectID==this->objectID);432 return header ->dataAvailable;421 SynchronisableHeader header(mem); 422 assert(header.getObjectID()==this->objectID); 423 return header.isDataAvailable(); 433 424 } 434 425 - Property svn:mergeinfo changed
-
code/trunk/src/network/synchronisable/Synchronisable.h
- Property svn:mergeinfo changed
/code/branches/presentation/src/network/synchronisable/Synchronisable.h (added) merged: 2655
r2653 r2662 72 72 } 73 73 74 struct _NetworkExport synchronisableHeader{ 75 uint32_t size:31; 76 bool dataAvailable:1; 77 uint32_t objectID; 78 uint32_t creatorID; 79 uint32_t classID; 74 /** 75 * @brief: stores information about a Synchronisable 76 * 77 * This class stores the information about a Synchronisable (objectID, classID, creatorID, dataSize) 78 * in an emulated bitset. 79 * Bit 1 to 31 store the size of the Data the synchronisable consumes in the stream 80 * Bit 32 is a bool and defines whether the data is actually stored or is just filled up with 0 81 * Byte 5 to 8: objectID 82 * Byte 9 to 12: classID 83 * Byte 13 to 16: creatorID 84 */ 85 class _NetworkExport SynchronisableHeader{ 86 private: 87 uint8_t *data_; 88 public: 89 SynchronisableHeader(uint8_t* data) 90 { data_ = data; } 91 inline static uint32_t getSize() 92 { return 16; } 93 inline uint32_t getDataSize() const 94 { return (*(uint32_t*)data_) & 0x7FFFFFFF; } //only use the first 31 bits 95 inline void setDataSize(uint32_t size) 96 { *(uint32_t*)(data_) = (size & 0x7FFFFFFF) | (*(uint32_t*)(data_) & 0x80000000 ); } 97 inline bool isDataAvailable() const 98 { return ( (*(uint32_t*)data_) & 0x80000000 ) == 0x80000000; } 99 inline void setDataAvailable( bool b) 100 { *(uint32_t*)(data_) = (b << 31) | (*(uint32_t*)(data_) & 0x7FFFFFFF ); } 101 inline uint32_t getObjectID() const 102 { return *(uint32_t*)(data_+4); } 103 inline void setObjectID(uint32_t objectID) 104 { *(uint32_t*)(data_+4) = objectID; } 105 inline uint32_t getClassID() const 106 { return *(uint32_t*)(data_+8); } 107 inline void setClassID(uint32_t classID) 108 { *(uint32_t*)(data_+8) = classID; } 109 inline uint32_t getCreatorID() const 110 { return *(uint32_t*)(data_+12); } 111 inline void setCreatorID(uint32_t creatorID) 112 { *(uint32_t*)(data_+12) = creatorID; } 113 inline void operator=(SynchronisableHeader& h) 114 { memcpy(data_, h.data_, getSize()); } 80 115 }; 81 116 … … 83 118 /** 84 119 * This class is the base class of all the Objects in the universe that need to be synchronised over the network 85 120 * Every class, that inherits from this class has to link the DATA THAT NEEDS TO BE SYNCHRONISED into the linked list. 86 121 * @author Oliver Scheuss 87 122 */ - Property svn:mergeinfo changed
-
code/trunk/src/orxonox/CMakeLists.txt
r2171 r2662 4 4 LevelManager.cc 5 5 Main.cc 6 PawnManager.cc 6 7 PlayerManager.cc 7 8 Settings.cc … … 48 49 tinyxml_orxonox 49 50 tolualib_orxonox 51 BulletDynamics 52 BulletCollision 53 LinearMath 50 54 util 51 55 core -
code/trunk/src/orxonox/CameraManager.cc
- Property svn:mergeinfo changed
r2261 r2662 29 29 #include "CameraManager.h" 30 30 31 #include <OgreSceneManager.h> 31 32 #include <OgreViewport.h> 33 #include <OgreCamera.h> 34 #include <OgreCompositorManager.h> 35 #include <OgreResource.h> 32 36 33 37 #include "core/Core.h" 38 #include "core/Iterator.h" 34 39 #include "objects/worldentities/Camera.h" 35 40 #include "objects/Scene.h" 41 #include "tools/Shader.h" 42 #include "util/String.h" 36 43 37 44 namespace orxonox … … 44 51 assert(singletonRef_s == 0); 45 52 singletonRef_s = this; 53 54 this->fallbackCamera_ = 0; 46 55 } 47 56 … … 50 59 assert(singletonRef_s != 0); 51 60 singletonRef_s = 0; 61 62 if (this->fallbackCamera_) 63 this->fallbackCamera_->getSceneManager()->destroyCamera(this->fallbackCamera_); 52 64 } 53 65 … … 68 80 if (this->cameraList_.size() > 0) 69 81 this->cameraList_.front()->removeFocus(); 82 else if (this->fallbackCamera_) 83 { 84 this->fallbackCamera_->getSceneManager()->destroyCamera(this->fallbackCamera_); 85 this->fallbackCamera_ = 0; 86 } 70 87 71 camera->setFocus(this->viewport_); 88 camera->setFocus(); 89 90 // make sure we don't add it twice 91 for (std::list<Camera*>::iterator it = this->cameraList_.begin(); it != this->cameraList_.end(); ++it) 92 if ((*it) == camera) 93 return; 72 94 73 95 // add to list 74 std::list<Camera*>::iterator it;75 for (it = this->cameraList_.begin(); it != this->cameraList_.end(); ++it)76 {77 if ((*it) == camera)78 return; // make sure we don't add it twice79 }80 96 this->cameraList_.push_front(camera); 81 97 } … … 92 108 this->cameraList_.pop_front(); 93 109 94 // set new focus if necessary 95 if (cameraList_.size() > 0) 96 cameraList_.front()->setFocus(this->viewport_); 110 // set new focus if possible 111 if (this->cameraList_.size() > 0) 112 this->cameraList_.front()->setFocus(); 113 else 114 { 115 // there are no more cameras, create a fallback 116 if (!this->fallbackCamera_) 117 this->fallbackCamera_ = camera->getScene()->getSceneManager()->createCamera(getUniqueNumberString()); 118 this->useCamera(this->fallbackCamera_); 119 } 97 120 } 98 121 else … … 101 124 } 102 125 } 126 127 void CameraManager::useCamera(Ogre::Camera* camera) 128 { 129 // This workaround is needed to avoid weird behaviour with active compositors while 130 // switching the camera (like freezing the image) 131 // 132 // Last known Ogre version needing this workaround: 133 // 1.4.8 134 135 // deactivate all compositors 136 { 137 Ogre::ResourceManager::ResourceMapIterator iterator = Ogre::CompositorManager::getSingleton().getResourceIterator(); 138 while (iterator.hasMoreElements()) 139 Ogre::CompositorManager::getSingleton().setCompositorEnabled(this->viewport_, iterator.getNext()->getName(), false); 140 } 141 142 this->viewport_->setCamera(camera); 143 144 // reactivate all visible compositors 145 { 146 for (ObjectList<Shader>::iterator it = ObjectList<Shader>::begin(); it != ObjectList<Shader>::end(); ++it) 147 it->updateVisibility(); 148 } 149 } 103 150 } -
code/trunk/src/orxonox/CameraManager.h
- Property svn:mergeinfo changed
r2261 r2662 57 57 static CameraManager& getInstance() { assert(singletonRef_s); return *singletonRef_s; } 58 58 59 void useCamera(Ogre::Camera* camera); 60 59 61 private: 60 62 CameraManager(const CameraManager&); … … 62 64 std::list<Camera*> cameraList_; 63 65 Ogre::Viewport* viewport_; 66 Ogre::Camera* fallbackCamera_; 64 67 65 68 static CameraManager* singletonRef_s; -
code/trunk/src/orxonox/GraphicsEngine.cc
r2087 r2662 77 77 singletonRef_s = this; 78 78 79 this->viewport_ = 0; 80 79 81 this->detailLevelParticle_ = 0; 80 82 -
code/trunk/src/orxonox/GraphicsEngine.h
r2087 r2662 72 72 static GraphicsEngine* getInstancePtr() { return singletonRef_s; } 73 73 74 inline void setViewport(Ogre::Viewport* viewport) 75 { this->viewport_ = viewport; } 76 inline Ogre::Viewport* getViewport() const 77 { return this->viewport_; } 78 74 79 private: 75 80 // don't mess with singletons 76 81 GraphicsEngine(GraphicsEngine&); 82 83 Ogre::Viewport* viewport_; //!< default full size viewport 77 84 78 85 // stats -
code/trunk/src/orxonox/Main.cc
r2103 r2662 43 43 #include "core/ConfigFileManager.h" 44 44 #include "core/CommandLine.h" 45 #include "core/CommandExecutor.h" 46 #include "core/Identifier.h" 47 #include "core/Core.h" 48 #include "core/Language.h" 45 49 46 50 #include "gamestates/GSRoot.h" … … 92 96 93 97 // create a signal handler (only works for linux) 94 SignalHandler::getInstance()->doCatch(argv[0], "orxonox.log"); 98 SignalHandler signalHandler; 99 signalHandler.doCatch(argv[0], "orxonox.log"); 95 100 96 101 // Parse command line arguments … … 109 114 ConfigFileManager* configFileManager = new ConfigFileManager(); 110 115 configFileManager->setFilename(ConfigFileType::Settings, CommandLine::getValue("settingsFile").getString()); 116 // create the Core settings to configure the output level 117 Language* language = new Language(); 118 Core* core = new Core(); 111 119 112 // create the gamestates 113 GSRoot root; 114 GSGraphics graphics; 115 GSStandalone standalone; 116 GSServer server; 117 GSClient client; 118 GSDedicated dedicated; 119 GSGUI gui; 120 GSIOConsole ioConsole; 120 // put GameStates in its own scope so we can destroy the identifiers at the end of main(). 121 { 122 // create the gamestates 123 GSRoot root; 124 GSGraphics graphics; 125 GSStandalone standalone; 126 GSServer server; 127 GSClient client; 128 GSDedicated dedicated; 129 GSGUI gui; 130 GSIOConsole ioConsole; 121 131 122 // make the hierarchy123 root.addChild(&graphics);124 graphics.addChild(&standalone);125 graphics.addChild(&server);126 graphics.addChild(&client);127 graphics.addChild(&gui);128 root.addChild(&ioConsole);129 root.addChild(&dedicated);132 // make the hierarchy 133 root.addChild(&graphics); 134 graphics.addChild(&standalone); 135 graphics.addChild(&server); 136 graphics.addChild(&client); 137 graphics.addChild(&gui); 138 root.addChild(&ioConsole); 139 root.addChild(&dedicated); 130 140 131 // Here happens the game 132 root.start(); 141 // Here happens the game 142 root.start(); 143 } 133 144 134 // Destroy ConfigFileManager again. 145 // destroy singletons 146 delete core; 147 delete language; 135 148 delete configFileManager; 149 150 // Clean up class hierarchy stuff (identifiers, xmlport, configvalue, consolecommand) 151 Identifier::destroyAllIdentifiers(); 152 // destroy command line arguments 153 CommandLine::destroyAllArguments(); 154 // Also delete external console command that don't belong to an Identifier 155 CommandExecutor::destroyExternalCommands(); 136 156 137 157 return 0; -
code/trunk/src/orxonox/OrxonoxPrereqs.h
r2261 r2662 73 73 } 74 74 75 //put here all existing munitionTypes 76 namespace MunitionType 77 { 78 79 80 81 enum Enum 82 { laserGunMunition }; 83 } 84 85 //put here all weapon fire modes. 86 //they have to be added to Pawn and HumanController, too. 87 namespace WeaponMode 88 { 89 enum Enum 90 { 91 fire = 0x1, 92 altFire = 0x2, 93 altFire2 = 0x4 94 }; 95 } 96 97 75 98 class GraphicsEngine; 76 99 class Settings; … … 82 105 class CameraManager; 83 106 class LevelManager; 107 class PawnManager; 84 108 class PlayerManager; 85 109 … … 102 126 class QuestHint; 103 127 class QuestItem; 128 class QuestListener; 104 129 class QuestManager; 105 130 class Rewardable; 106 131 107 132 class WorldEntity; 108 class PositionableEntity; 133 class StaticEntity; 134 class MobileEntity; 135 class ControllableEntity; 109 136 class MovableEntity; 110 class ControllableEntity;111 137 class Sublevel; 112 138 … … 114 140 class Billboard; 115 141 class BlinkingBillboard; 142 class ExplosionChunk; 143 class FadingBillboard; 144 class GlobalShader; 116 145 class Light; 117 146 class Backlight; … … 127 156 class SpaceShip; 128 157 158 class Item; 159 class Engine; 160 class MultiStateEngine; 161 class RotatingEngine; 162 129 163 class Trigger; 130 164 class DistanceTrigger; … … 135 169 class WeaponSet; 136 170 class WeaponSlot; 171 class WeaponPack; 137 172 class Weapon; 138 173 class Munition; 174 class LaserGun; 175 class LaserGunMunition; 139 176 140 177 class EventListener; … … 144 181 class Controller; 145 182 class HumanController; 183 class ArtificialController; 184 class AIController; 185 class ScriptController; 146 186 147 187 class Info; 148 188 class PlayerInfo; 149 189 class HumanPlayer; 190 class Bot; 191 class GametypeInfo; 150 192 151 193 class Gametype; 152 194 153 195 class Scores; 196 class CreateLines; 197 class Scoreboard; 198 class Stats; 199 200 // collision 201 class CollisionShape; 202 class SphereCollisionShape; 203 class CompoundCollisionShape; 204 class PlaneCollisionShape; 205 class WorldEntityCollisionShape; 154 206 155 207 // tools … … 158 210 class Mesh; 159 211 class ParticleInterface; 212 class Shader; 160 213 template <class T> 161 214 class Timer; … … 169 222 class HUDRadar; 170 223 class HUDSpeedBar; 224 class HUDHealthBar; 171 225 class InGameConsole; 226 class Notification; 227 class NotificationManager; 228 class NotificationQueue; 172 229 class OrxonoxOverlay; 173 230 class OverlayGroup; 174 231 class OverlayText; 232 class GametypeStatus; 233 class CreateLines; 234 class Scoreboard; 175 235 176 236 //gui … … 206 266 } 207 267 268 // Bullet Physics Engine 269 270 class btTransform; 271 class btVector3; 272 273 class btRigidBody; 274 class btCollisionObject; 275 class btGhostObject; 276 class btManifoldPoint; 277 278 class btCollisionShape; 279 class btSphereShape; 280 class btCompoundShape; 281 class btStaticPlaneShape; 282 283 class btDiscreteDynamicsWorld; 284 class bt32BitAxisSweep3; 285 class btDefaultCollisionConfiguration; 286 class btCollisionDispatcher; 287 class btSequentialImpulseConstraintSolver; 288 289 // lua 208 290 struct lua_State; 209 291 -
code/trunk/src/orxonox/OrxonoxStableHeaders.h
r2087 r2662 47 47 #include <Ogre.h> 48 48 #include <CEGUI.h> 49 #include "ois/OIS.h"50 49 #include <boost/thread/recursive_mutex.hpp> 51 50 //#include <boost/thread/mutex.hpp> … … 53 52 //#include <boost/thread/thread.hpp> 54 53 #include <boost/static_assert.hpp> 54 55 #include "BulletDynamics/Dynamics/btRigidBody.h" 56 #include "ois/OIS.h" 55 57 #include "tinyxml/ticpp.h" 56 58 #include "tinyxml/tinyxml.h" … … 95 97 #include "core/input/InputManager.h" 96 98 97 #include "network/ Synchronisable.h"99 #include "network/synchronisable/Synchronisable.h" 98 100 99 #include "Settings.h"101 //#include "Settings.h" 100 102 101 103 //#endif /* ifdef NDEBUG */ 102 104 103 #endif /* ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC && !defined(ORXONOX_DISABLE_PCH) */105 #endif /* defined(ORXONOX_ENABLE_PCH) */ 104 106 105 107 #endif /* _OrxonoxStableHeaders_H__ */ -
code/trunk/src/orxonox/PlayerManager.cc
r2171 r2662 38 38 namespace orxonox 39 39 { 40 PlayerManager* PlayerManager::singletonRef_s = 0; 41 40 42 PlayerManager::PlayerManager() 41 43 { 42 44 RegisterRootObject(PlayerManager); 45 46 assert(singletonRef_s == 0); 47 singletonRef_s = this; 43 48 44 49 this->getConnectedClients(); … … 47 52 PlayerManager::~PlayerManager() 48 53 { 49 } 50 51 PlayerManager& PlayerManager::getInstance() 52 { 53 static PlayerManager instance; 54 return instance; 54 assert(singletonRef_s); 55 singletonRef_s = 0; 55 56 } 56 57 -
code/trunk/src/orxonox/PlayerManager.h
r2171 r2662 32 32 #include "OrxonoxPrereqs.h" 33 33 34 #include <cassert> 34 35 #include <map> 35 36 #include "network/ClientConnectionListener.h" … … 43 44 virtual ~PlayerManager(); 44 45 45 static PlayerManager& getInstance(); 46 static PlayerManager& getInstance() 47 { assert(singletonRef_s); return *singletonRef_s; } 46 48 47 49 PlayerInfo* getClient(unsigned int clientID) const; … … 54 56 55 57 std::map<unsigned int, PlayerInfo*> clients_; 58 59 static PlayerManager* singletonRef_s; 56 60 }; 57 61 } -
code/trunk/src/orxonox/Settings.cc
r2087 r2662 83 83 } 84 84 85 LuaBind::getInstance() ->setIncludePath(this->dataPath_);85 LuaBind::getInstance().setIncludePath(this->dataPath_); 86 86 } 87 87 -
code/trunk/src/orxonox/gamestates/GSDedicated.cc
r2171 r2662 35 35 #include "network/Server.h" 36 36 #include "objects/Tickable.h" 37 #include "util/Sleep.h" 37 38 38 39 namespace orxonox … … 41 42 : GameState<GSRoot>("dedicated") 42 43 , server_(0) 44 , timeSinceLastUpdate_(0) 43 45 { 44 46 } … … 72 74 void GSDedicated::ticked(const Clock& time) 73 75 { 74 GSLevel::ticked(time); 75 server_->tick(time.getDeltaTime()); 76 this->tickChild(time); 76 // static float startTime = time.getSecondsPrecise(); 77 // static int nrOfTicks = 0; 78 timeSinceLastUpdate_ += time.getDeltaTime(); 79 if (timeSinceLastUpdate_ >= NETWORK_PERIOD) 80 { 81 // ++nrOfTicks; 82 // COUT(0) << "estimated ticks/sec: " << nrOfTicks/(time.getSecondsPrecise()-startTime) << endl; 83 timeSinceLastUpdate_ -= static_cast<unsigned int>(timeSinceLastUpdate_ / NETWORK_PERIOD) * NETWORK_PERIOD; 84 GSLevel::ticked(time); 85 server_->tick(time.getDeltaTime()); 86 this->tickChild(time); 87 } 88 else 89 { 90 usleep((int)((NETWORK_PERIOD - timeSinceLastUpdate_) * 1000 * 1000)); 91 // COUT(0) << "sleeping for " << (int)((NETWORK_PERIOD - timeSinceLastUpdate_) * 1000 * 1000) << " usec" << endl; 92 } 77 93 } 78 94 } -
code/trunk/src/orxonox/gamestates/GSDedicated.h
r2171 r2662 49 49 50 50 Server* server_; 51 float timeSinceLastUpdate_; 51 52 }; 52 53 } -
code/trunk/src/orxonox/gamestates/GSGraphics.cc
r2171 r2662 31 31 32 32 #include <fstream> 33 #include <OgreCompositorManager.h> 33 34 #include <OgreConfigFile.h> 34 35 #include <OgreFrameListener.h> … … 75 76 , graphicsEngine_(0) 76 77 , masterKeyBinder_(0) 77 , frameCount_(0)78 , statisticsRefreshCycle_(0)79 , statisticsStartTime_(0)80 , statisticsStartCount_(0)81 , tickTime_(0)82 78 , debugOverlay_(0) 83 79 { … … 106 102 SetConfigValue(ogreLogLevelCritical_, 2) 107 103 .description("Corresponding orxonox debug level for ogre Critical"); 108 SetConfigValue(statisticsRefreshCycle_, 200000)109 .description("Sets the time in microseconds interval at which average fps, etc. get updated.");110 104 SetConfigValue(defaultMasterKeybindings_, "def_masterKeybindings.ini") 111 105 .description("Filename of default master keybindings."); … … 155 149 guiManager_->initialise(this->renderWindow_); 156 150 157 // reset frame counter158 this->frameCount_ = 0;159 this->tickTime_ = 0;160 statisticsStartTime_ = 0;161 statisticsStartCount_ = 0;162 163 151 // add console commands 164 152 FunctorMember<GSGraphics>* functor1 = createFunctor(&GSGraphics::printScreen); 165 153 functor1->setObject(this); 166 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor1, "printScreen")); 154 ccPrintScreen_ = createConsoleCommand(functor1, "printScreen"); 155 CommandExecutor::addConsoleCommandShortcut(ccPrintScreen_); 167 156 } 168 157 … … 170 159 { 171 160 using namespace Ogre; 161 162 delete this->ccPrintScreen_; 172 163 173 164 // remove our WindowEventListener first to avoid bad calls after the window has been destroyed … … 184 175 Loader::unload(this->debugOverlay_); 185 176 delete this->debugOverlay_; 177 178 // unload all compositors 179 Ogre::CompositorManager::getSingleton().removeAll(); 186 180 187 181 // destroy render window … … 206 200 delete this->ogreRoot_; 207 201 208 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32202 //#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32 209 203 // delete the ogre log and the logManager (since we have created it). 210 204 this->ogreLogger_->getDefaultLog()->removeListener(this); 211 205 this->ogreLogger_->destroyLog(Ogre::LogManager::getSingleton().getDefaultLog()); 212 206 delete this->ogreLogger_; 213 #endif207 //#endif 214 208 215 209 delete graphicsEngine_; … … 219 213 220 214 /** 221 Main loop of the orxonox game. 222 We use the Ogre::Timer to measure time since it uses the most precise 223 method an a platform (however the windows timer lacks time when under 224 heavy kernel load!). 225 There is a simple mechanism to measure the average time spent in our 226 ticks as it may indicate performance issues. 215 @note 227 216 A note about the Ogre::FrameListener: Even though we don't use them, 228 217 they still get called. However, the delta times are not correct (except … … 233 222 void GSGraphics::ticked(const Clock& time) 234 223 { 235 unsigned long long timeBeforeTick = time.getRealMicroseconds(); 224 uint64_t timeBeforeTick = time.getRealMicroseconds(); 225 236 226 float dt = time.getDeltaTime(); 237 227 … … 248 238 } 249 239 250 unsigned long long timeAfterTick = time.getRealMicroseconds(); 251 252 tickTime_ += (unsigned int)(timeAfterTick - timeBeforeTick); 253 if (timeAfterTick > statisticsStartTime_ + statisticsRefreshCycle_) 254 { 255 GraphicsEngine::getInstance().setAverageTickTime( 256 (float)tickTime_ * 0.001f / (frameCount_ - statisticsStartCount_)); 257 float avgFPS = (float)(frameCount_ - statisticsStartCount_) 258 / (timeAfterTick - statisticsStartTime_) * 1000000.0; 259 GraphicsEngine::getInstance().setAverageFramesPerSecond(avgFPS); 260 261 tickTime_ = 0; 262 statisticsStartCount_ = frameCount_; 263 statisticsStartTime_ = timeAfterTick; 264 } 240 uint64_t timeAfterTick = time.getRealMicroseconds(); 241 242 // Also add our tick time to the list in GSRoot 243 this->getParent()->addTickTime(timeAfterTick - timeBeforeTick); 244 245 // Update statistics overlay. Note that the values only change periodically in GSRoot. 246 GraphicsEngine::getInstance().setAverageFramesPerSecond(this->getParent()->getAvgFPS()); 247 GraphicsEngine::getInstance().setAverageTickTime(this->getParent()->getAvgTickTime()); 265 248 266 249 // don't forget to call _fireFrameStarted in ogre to make sure … … 283 266 // again, just to be sure ogre works fine 284 267 ogreRoot_->_fireFrameEnded(evt); // note: uses the same time as _fireFrameStarted 285 286 ++frameCount_;287 268 } 288 269 … … 296 277 297 278 // TODO: LogManager doesn't work on oli platform. The why is yet unknown. 298 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32279 //#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32 299 280 // create a new logManager 300 281 ogreLogger_ = new Ogre::LogManager(); … … 311 292 myLog->setLogDetail(Ogre::LL_BOREME); 312 293 myLog->addListener(this); 313 #endif294 //#endif 314 295 315 296 // Root will detect that we've already created a Log … … 430 411 // create a full screen default viewport 431 412 this->viewport_ = this->renderWindow_->addViewport(0, 0); 413 414 if (this->graphicsEngine_) 415 this->graphicsEngine_->setViewport(this->viewport_); 432 416 } 433 417 -
code/trunk/src/orxonox/gamestates/GSGraphics.h
r2103 r2662 93 93 94 94 KeyBinder* masterKeyBinder_; 95 96 // variables for time statistics97 unsigned long frameCount_;98 unsigned int statisticsRefreshCycle_;99 unsigned long long statisticsStartTime_;100 unsigned long statisticsStartCount_;101 unsigned int tickTime_;102 95 XMLFile* debugOverlay_; 103 96 … … 110 103 int ogreLogLevelNormal_; //!< Corresponding Orxonx debug level for LL_NORMAL 111 104 int ogreLogLevelCritical_; //!< Corresponding Orxonx debug level for LL_CRITICAL 112 unsigned int detailLevelParticle_; //!< Detail level of particle effects (0: off, 1: low, 2: normal, 3: high)113 105 std::string defaultMasterKeybindings_; //!< Filename of default master keybindings. 106 107 // console commands 108 ConsoleCommand* ccPrintScreen_; 114 109 }; 115 110 } -
code/trunk/src/orxonox/gamestates/GSLevel.cc
r2103 r2662 41 41 #include "core/CoreIncludes.h" 42 42 #include "core/Core.h" 43 //#include "objects/Backlight.h"44 43 #include "objects/Tickable.h" 45 44 #include "objects/Radar.h" 46 //#include "tools/ParticleInterface.h"47 45 #include "CameraManager.h" 48 46 #include "LevelManager.h" 47 #include "PlayerManager.h" 49 48 #include "Settings.h" 50 49 51 50 namespace orxonox 52 51 { 53 SetCommandLineArgument(level, " sample2.oxw").shortcut("l");52 SetCommandLineArgument(level, "presentation.oxw").shortcut("l"); 54 53 55 54 GSLevel::GSLevel() 56 55 // : GameState<GSGraphics>(name) 57 : timeFactor_(1.0f) 58 , keyBinder_(0) 56 : keyBinder_(0) 59 57 , inputState_(0) 60 58 , radar_(0) … … 64 62 { 65 63 RegisterObject(GSLevel); 64 65 this->ccKeybind_ = 0; 66 this->ccTkeybind_ = 0; 67 66 68 setConfigValues(); 67 69 } … … 95 97 } 96 98 99 this->playerManager_ = new PlayerManager(); 100 97 101 if (Core::isMaster()) 98 102 { 99 103 // create the global LevelManager 100 104 this->levelManager_ = new LevelManager(); 101 102 // reset game speed to normal103 timeFactor_ = 1.0f;104 105 105 106 this->loadLevel(); … … 114 115 FunctorMember<GSLevel>* functor1 = createFunctor(&GSLevel::keybind); 115 116 functor1->setObject(this); 116 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor1, "keybind")); 117 ccKeybind_ = createConsoleCommand(functor1, "keybind"); 118 CommandExecutor::addConsoleCommandShortcut(ccKeybind_); 117 119 FunctorMember<GSLevel>* functor2 = createFunctor(&GSLevel::tkeybind); 118 120 functor2->setObject(this); 119 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor2, "tkeybind")); 121 ccTkeybind_ = createConsoleCommand(functor2, "tkeybind"); 122 CommandExecutor::addConsoleCommandShortcut(ccTkeybind_); 120 123 // set our console command as callback for the key detector 121 124 InputManager::getInstance().setKeyDetectorCallback(std::string("keybind ") + keyDetectorCallbackCode_); … … 124 127 InputManager::getInstance().requestEnterState("game"); 125 128 } 126 127 if (Core::isMaster())128 {129 // time factor console command130 FunctorMember<GSLevel>* functor = createFunctor(&GSLevel::setTimeFactor);131 functor->setObject(this);132 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor")).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);;133 }134 129 } 135 130 136 131 void GSLevel::leave() 137 132 { 133 // destroy console commands 134 if (this->ccKeybind_) 135 { 136 delete this->ccKeybind_; 137 this->ccKeybind_ = 0; 138 } 139 if (this->ccTkeybind_) 140 { 141 delete this->ccTkeybind_; 142 this->ccTkeybind_ = 0; 143 } 144 138 145 // this call will delete every BaseObject! 139 146 // But currently this will call methods of objects that exist no more … … 149 156 150 157 if (this->radar_) 158 { 151 159 delete this->radar_; 160 this->radar_ = 0; 161 } 152 162 153 163 if (this->cameraManager_) 164 { 154 165 delete this->cameraManager_; 166 this->cameraManager_ = 0; 167 } 155 168 156 169 if (this->levelManager_) 170 { 157 171 delete this->levelManager_; 172 this->levelManager_ = 0; 173 } 174 175 if (this->playerManager_) 176 { 177 delete this->playerManager_; 178 this->playerManager_ = 0; 179 } 158 180 159 181 if (Core::showsGraphics()) … … 162 184 InputManager::getInstance().requestDestroyState("game"); 163 185 if (this->keyBinder_) 186 { 164 187 delete this->keyBinder_; 188 this->keyBinder_ = 0; 189 } 165 190 } 166 191 } … … 172 197 //for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it) 173 198 // it->tick(time.getDeltaTime() * this->timeFactor_); 174 }175 176 /**177 @brief178 Changes the speed of Orxonox179 */180 void GSLevel::setTimeFactor(float factor)181 {182 /*183 float change = factor / this->timeFactor_;184 */185 this->timeFactor_ = factor;186 /*187 for (ObjectList<ParticleInterface>::iterator it = ObjectList<ParticleInterface>::begin(); it; ++it)188 it->setSpeedFactor(it->getSpeedFactor() * change);189 190 for (ObjectList<Backlight>::iterator it = ObjectList<Backlight>::begin(); it; ++it)191 it->setTimeFactor(timeFactor_);192 */193 199 } 194 200 -
code/trunk/src/orxonox/gamestates/GSLevel.h
r2103 r2662 32 32 #include "OrxonoxPrereqs.h" 33 33 #include <OgrePrerequisites.h> 34 #include "core/GameState.h" 35 #include "GSGraphics.h" 34 #include "core/OrxonoxClass.h" 36 35 37 36 namespace orxonox 38 37 { 39 class _OrxonoxExport GSLevel : public OrxonoxClass //,public GameState<GSGraphics>38 class _OrxonoxExport GSLevel : public OrxonoxClass 40 39 { 41 40 friend class ClassIdentifier<GSLevel>; … … 43 42 GSLevel(); 44 43 ~GSLevel(); 45 46 // this has to be public because proteced triggers a bug in msvc47 // when taking the function address.48 void setTimeFactor(float factor);49 float getTimeFactor() { return this->timeFactor_; }50 44 51 45 protected: … … 56 50 void loadLevel(); 57 51 void unloadLevel(); 58 59 float timeFactor_; //!< A factor that sets the gamespeed. 1 is normal.60 52 61 53 // console commands … … 70 62 CameraManager* cameraManager_; 71 63 LevelManager* levelManager_; 64 PlayerManager* playerManager_; 72 65 73 66 //##### ConfigValues ##### … … 75 68 //! Filename of default keybindings. 76 69 std::string defaultKeybindings_; 70 71 // console commands 72 ConsoleCommand* ccKeybind_; 73 ConsoleCommand* ccTkeybind_; 77 74 78 75 private: -
code/trunk/src/orxonox/gamestates/GSRoot.cc
r2171 r2662 32 32 #include "util/Exception.h" 33 33 #include "util/Debug.h" 34 #include "core/Core.h" 34 35 #include "core/Factory.h" 35 36 #include "core/ConfigValueIncludes.h" … … 40 41 #include "core/TclBind.h" 41 42 #include "core/TclThreadManager.h" 43 #include "core/LuaBind.h" 42 44 #include "tools/Timer.h" 43 45 #include "objects/Tickable.h" 44 46 #include "Settings.h" 45 47 46 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32 48 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32 47 49 # ifndef WIN32_LEAN_AND_MEAN 48 50 # define WIN32_LEAN_AND_MEAN … … 66 68 GSRoot::GSRoot() 67 69 : RootGameState("root") 70 , timeFactor_(1.0f) 71 , bPaused_(false) 72 , timeFactorPauseBackup_(1.0f) 68 73 , settings_(0) 69 74 , tclBind_(0) … … 73 78 RegisterRootObject(GSRoot); 74 79 setConfigValues(); 80 81 this->ccSetTimeFactor_ = 0; 82 this->ccPause_ = 0; 75 83 } 76 84 … … 81 89 void GSRoot::setConfigValues() 82 90 { 91 SetConfigValue(statisticsRefreshCycle_, 250000) 92 .description("Sets the time in microseconds interval at which average fps, etc. get updated."); 93 SetConfigValue(statisticsAvgLength_, 1000000) 94 .description("Sets the time in microseconds interval at which average fps, etc. gets calculated."); 83 95 } 84 96 … … 87 99 // creates the class hierarchy for all classes with factories 88 100 Factory::createClassHierarchy(); 101 102 // reset game speed to normal 103 timeFactor_ = 1.0f; 104 105 // reset frame counter 106 this->statisticsStartTime_ = 0; 107 this->statisticsTickTimes_.clear(); 108 this->periodTickTime_ = 0; 109 this->avgFPS_ = 0.0f; 110 this->avgTickTime_ = 0.0f; 111 112 // Create the lua interface 113 this->luaBind_ = new LuaBind(); 89 114 90 115 // instantiate Settings class … … 114 139 setThreadAffinity((unsigned int)(limitToCPU - 1)); 115 140 116 // add console commands 117 FunctorMember<GSRoot>* functor1 = createFunctor(&GSRoot::exitGame); 118 functor1->setObject(this); 119 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor1, "exit")); 120 121 // add console commands 122 FunctorMember01<GameStateBase, const std::string&>* functor2 = createFunctor(&GameStateBase::requestState); 123 functor2->setObject(this); 124 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor2, "selectGameState")); 141 { 142 // add console commands 143 FunctorMember<GSRoot>* functor = createFunctor(&GSRoot::exitGame); 144 functor->setObject(this); 145 this->ccExit_ = createConsoleCommand(functor, "exit"); 146 CommandExecutor::addConsoleCommandShortcut(this->ccExit_); 147 } 148 149 { 150 // add console commands 151 FunctorMember01<GameStateBase, const std::string&>* functor = createFunctor(&GameStateBase::requestState); 152 functor->setObject(this); 153 this->ccSelectGameState_ = createConsoleCommand(functor, "selectGameState"); 154 CommandExecutor::addConsoleCommandShortcut(this->ccSelectGameState_); 155 } 156 157 { 158 // time factor console command 159 FunctorMember<GSRoot>* functor = createFunctor(&GSRoot::setTimeFactor); 160 functor->setObject(this); 161 this->ccSetTimeFactor_ = createConsoleCommand(functor, "setTimeFactor"); 162 CommandExecutor::addConsoleCommandShortcut(this->ccSetTimeFactor_).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0); 163 } 164 165 { 166 // time factor console command 167 FunctorMember<GSRoot>* functor = createFunctor(&GSRoot::pause); 168 functor->setObject(this); 169 this->ccPause_ = createConsoleCommand(functor, "pause"); 170 CommandExecutor::addConsoleCommandShortcut(this->ccPause_).accessLevel(AccessLevel::Offline); 171 } 125 172 } 126 173 127 174 void GSRoot::leave() 128 175 { 129 // TODO: remove and destroy console commands 176 // destroy console commands 177 delete this->ccExit_; 178 delete this->ccSelectGameState_; 130 179 131 180 delete this->shell_; … … 133 182 delete this->tclBind_; 134 183 135 delete settings_; 136 184 delete this->settings_; 185 delete this->luaBind_; 186 187 if (this->ccSetTimeFactor_) 188 { 189 delete this->ccSetTimeFactor_; 190 this->ccSetTimeFactor_ = 0; 191 } 192 193 if (this->ccPause_) 194 { 195 delete this->ccPause_; 196 this->ccPause_ = 0; 197 } 137 198 } 138 199 139 200 void GSRoot::ticked(const Clock& time) 140 201 { 202 uint64_t timeBeforeTick = time.getRealMicroseconds(); 203 141 204 TclThreadManager::getInstance().tick(time.getDeltaTime()); 142 205 … … 146 209 /*** HACK *** HACK ***/ 147 210 // Call the Tickable objects 211 float leveldt = time.getDeltaTime(); 212 if (leveldt > 1.0f) 213 { 214 // just loaded 215 leveldt = 0.0f; 216 } 148 217 for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it) 149 it->tick( time.getDeltaTime());218 it->tick(leveldt * this->timeFactor_); 150 219 /*** HACK *** HACK ***/ 151 220 221 uint64_t timeAfterTick = time.getRealMicroseconds(); 222 223 // STATISTICS 224 assert(timeAfterTick - timeBeforeTick >= 0 ); 225 statisticsTickInfo tickInfo = {timeAfterTick, timeAfterTick - timeBeforeTick}; 226 statisticsTickTimes_.push_back(tickInfo); 227 assert(statisticsTickTimes_.back().tickLength==tickInfo.tickLength); 228 this->periodTickTime_ += tickInfo.tickLength; 229 230 // Ticks GSGraphics or GSDedicated 152 231 this->tickChild(time); 232 233 if (timeAfterTick > statisticsStartTime_ + statisticsRefreshCycle_) 234 { 235 std::list<statisticsTickInfo>::iterator it = this->statisticsTickTimes_.begin(); 236 assert(it != this->statisticsTickTimes_.end()); 237 int64_t lastTime = timeAfterTick - statisticsAvgLength_; 238 if ((int64_t)it->tickTime < lastTime) 239 { 240 do 241 { 242 assert(this->periodTickTime_ > it->tickLength); 243 this->periodTickTime_ -= it->tickLength; 244 ++it; 245 assert(it != this->statisticsTickTimes_.end()); 246 } while ((int64_t)it->tickTime < lastTime); 247 this->statisticsTickTimes_.erase(this->statisticsTickTimes_.begin(), it); 248 } 249 250 uint32_t framesPerPeriod = this->statisticsTickTimes_.size(); 251 this->avgFPS_ = (float)framesPerPeriod / (timeAfterTick - this->statisticsTickTimes_.front().tickTime) * 1000000.0; 252 this->avgTickTime_ = (float)this->periodTickTime_ / framesPerPeriod / 1000.0; 253 254 statisticsStartTime_ = timeAfterTick; 255 } 256 153 257 } 154 258 … … 160 264 161 265 Copyright (c) 2000-2008 Torus Knot Software Ltd 162 266 163 267 OGRE is licensed under the LGPL. For more info, see OGRE license. 164 268 */ … … 167 271 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32 168 272 // Get the current process core mask 169 170 273 DWORD procMask; 274 DWORD sysMask; 171 275 # if _MSC_VER >= 1400 && defined (_M_X64) 172 276 GetProcessAffinityMask(GetCurrentProcess(), (PDWORD_PTR)&procMask, (PDWORD_PTR)&sysMask); 173 277 # else 174 278 GetProcessAffinityMask(GetCurrentProcess(), &procMask, &sysMask); 175 279 # endif 176 280 177 178 179 180 281 // If procMask is 0, consider there is only one core available 282 // (using 0 as procMask will cause an infinite loop below) 283 if (procMask == 0) 284 procMask = 1; 181 285 182 286 // if the core specified with limitToCPU is not available, take the lowest one … … 184 288 limitToCPU = 0; 185 289 186 290 // Find the lowest core that this process uses and limitToCPU suggests 187 291 DWORD threadMask = 1; 188 189 190 191 192 292 while ((threadMask & procMask) == 0 || (threadMask < (1u << limitToCPU))) 293 threadMask <<= 1; 294 295 // Set affinity to the first core 296 SetThreadAffinityMask(GetCurrentThread(), threadMask); 193 297 #endif 194 298 } 299 300 /** 301 @brief 302 Changes the speed of Orxonox 303 */ 304 void GSRoot::setTimeFactor(float factor) 305 { 306 if (Core::isMaster()) 307 { 308 if (!this->bPaused_) 309 { 310 TimeFactorListener::timefactor_s = factor; 311 312 for (ObjectList<TimeFactorListener>::iterator it = ObjectList<TimeFactorListener>::begin(); it != ObjectList<TimeFactorListener>::end(); ++it) 313 it->changedTimeFactor(factor, this->timeFactor_); 314 315 this->timeFactor_ = factor; 316 } 317 else 318 this->timeFactorPauseBackup_ = factor; 319 } 320 } 321 322 void GSRoot::pause() 323 { 324 if (Core::isMaster()) 325 { 326 if (!this->bPaused_) 327 { 328 this->timeFactorPauseBackup_ = this->timeFactor_; 329 this->setTimeFactor(0.0f); 330 this->bPaused_ = true; 331 } 332 else 333 { 334 this->bPaused_ = false; 335 this->setTimeFactor(this->timeFactorPauseBackup_); 336 } 337 } 338 } 339 340 //////////////////////// 341 // TimeFactorListener // 342 //////////////////////// 343 float TimeFactorListener::timefactor_s = 1.0f; 344 345 TimeFactorListener::TimeFactorListener() 346 { 347 RegisterRootObject(TimeFactorListener); 348 } 195 349 } -
code/trunk/src/orxonox/gamestates/GSRoot.h
r1891 r2662 31 31 32 32 #include "OrxonoxPrereqs.h" 33 34 #include <list> 33 35 #include <OgreLog.h> 34 36 #include "core/RootGameState.h" … … 40 42 { 41 43 friend class ClassIdentifier<GSRoot>; 44 45 public: 46 struct statisticsTickInfo 47 { 48 uint64_t tickTime; 49 uint32_t tickLength; 50 }; 51 42 52 public: 43 53 GSRoot(); … … 46 56 void exitGame() 47 57 { requestState("root"); } 58 59 // this has to be public because proteced triggers a bug in msvc 60 // when taking the function address. 61 void setTimeFactor(float factor); 62 void pause(); 63 float getTimeFactor() { return this->timeFactor_; } 64 65 float getAvgTickTime() { return this->avgTickTime_; } 66 float getAvgFPS() { return this->avgFPS_; } 67 68 inline void addTickTime(uint32_t length) 69 { assert(!this->statisticsTickTimes_.empty()); this->statisticsTickTimes_.back().tickLength += length; 70 this->periodTickTime_+=length; } 48 71 49 72 private: … … 55 78 void setThreadAffinity(unsigned int limitToCPU); 56 79 80 float timeFactor_; //!< A factor that sets the gamespeed. 1 is normal. 81 bool bPaused_; 82 float timeFactorPauseBackup_; 57 83 Settings* settings_; 58 84 TclBind* tclBind_; 59 85 TclThreadManager* tclThreadManager_; 60 86 Shell* shell_; 87 LuaBind* luaBind_; 88 89 // variables for time statistics 90 uint64_t statisticsStartTime_; 91 std::list<statisticsTickInfo> 92 statisticsTickTimes_; 93 uint32_t periodTickTime_; 94 float avgFPS_; 95 float avgTickTime_; 96 97 // config values 98 unsigned int statisticsRefreshCycle_; 99 unsigned int statisticsAvgLength_; 100 101 // console commands 102 ConsoleCommand* ccExit_; 103 ConsoleCommand* ccSelectGameState_; 104 ConsoleCommand* ccSetTimeFactor_; 105 ConsoleCommand* ccPause_; 106 }; 107 108 class _OrxonoxExport TimeFactorListener : virtual public OrxonoxClass 109 { 110 friend class GSRoot; 111 112 public: 113 TimeFactorListener(); 114 virtual ~TimeFactorListener() {} 115 116 protected: 117 virtual void changedTimeFactor(float factor_new, float factor_old) {} 118 inline float getTimeFactor() const 119 { return TimeFactorListener::timefactor_s; } 120 121 private: 122 static float timefactor_s; 61 123 }; 62 124 } -
code/trunk/src/orxonox/gui/GUIManager.cc
r2087 r2662 96 96 { 97 97 // destroy our own tolua interfaces 98 //lua_pushnil(luaState_);99 //lua_setglobal(luaState_, "Orxonox");100 //lua_pushnil(luaState_);101 //lua_setglobal(luaState_, "Core");98 lua_pushnil(luaState_); 99 lua_setglobal(luaState_, "Orxonox"); 100 lua_pushnil(luaState_); 101 lua_setglobal(luaState_, "Core"); 102 102 // TODO: deleting the script module fails an assertation. 103 103 // However there is not much we can do about it since it occurs too when 104 104 // we don't open Core or Orxonox. Might be a CEGUI issue. 105 105 // The memory leak is not a problem anyway.. 106 //delete scriptModule_;106 delete scriptModule_; 107 107 } 108 108 -
code/trunk/src/orxonox/objects/CMakeLists.txt
r2171 r2662 3 3 EventDispatcher.cc 4 4 EventTarget.cc 5 GlobalShader.cc 5 6 Level.cc 6 7 Radar.cc … … 13 14 ) 14 15 16 ADD_SOURCE_DIRECTORY(SRC_FILES collisionshapes) 15 17 ADD_SOURCE_DIRECTORY(SRC_FILES controllers) 16 18 ADD_SOURCE_DIRECTORY(SRC_FILES gametypes) 17 19 ADD_SOURCE_DIRECTORY(SRC_FILES infos) 18 #ADD_SOURCE_DIRECTORY(SRC_FILES pickup) 20 ADD_SOURCE_DIRECTORY(SRC_FILES items) 21 ADD_SOURCE_DIRECTORY(SRC_FILES pickup) 19 22 ADD_SOURCE_DIRECTORY(SRC_FILES quest) 20 23 ADD_SOURCE_DIRECTORY(SRC_FILES weaponSystem) -
code/trunk/src/orxonox/objects/EventTarget.cc
r2087 r2662 48 48 void EventTarget::changedName() 49 49 { 50 SUPER(EventTarget, changedName); 51 50 52 for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ++it) 51 53 if (it->getName() == this->getName()) -
code/trunk/src/orxonox/objects/Level.cc
- Property svn:mergeinfo changed
r2261 r2662 83 83 void Level::registerVariables() 84 84 { 85 REGISTERSTRING(this->xmlfilename_, direction::toclient, new NetworkCallback<Level>(this, &Level::networkcallback_applyXMLFile));86 REGISTERSTRING(this->name_, direction::toclient, new NetworkCallback<Level>(this, &Level::changedName));87 REGISTERSTRING(this->description_, direction::toclient);85 registerVariable(this->xmlfilename_, variableDirection::toclient, new NetworkCallback<Level>(this, &Level::networkcallback_applyXMLFile)); 86 registerVariable(this->name_, variableDirection::toclient, new NetworkCallback<Level>(this, &Level::changedName)); 87 registerVariable(this->description_, variableDirection::toclient); 88 88 } 89 89 … … 141 141 void Level::playerEntered(PlayerInfo* player) 142 142 { 143 COUT(3) << "player entered level " << std::endl;143 COUT(3) << "player entered level (id: " << player->getClientID() << ", name: " << player->getName() << ")" << std::endl; 144 144 player->setGametype(this->getGametype()); 145 145 } … … 147 147 void Level::playerLeft(PlayerInfo* player) 148 148 { 149 COUT(3) << "player left level " << std::endl;149 COUT(3) << "player left level (id: " << player->getClientID() << ", name: " << player->getName() << ")" << std::endl; 150 150 player->setGametype(0); 151 151 } -
code/trunk/src/orxonox/objects/Level.h
- Property svn:mergeinfo changed
r2261 r2662 32 32 #include "OrxonoxPrereqs.h" 33 33 34 #include "network/ Synchronisable.h"34 #include "network/synchronisable/Synchronisable.h" 35 35 #include "core/BaseObject.h" 36 36 -
code/trunk/src/orxonox/objects/Radar.cc
r2087 r2662 99 99 void Radar::tick(float dt) 100 100 { 101 SUPER(Radar, tick, dt); 102 101 103 if (this->focus_ != *(this->itFocus_)) 102 104 { … … 112 114 for (ObjectList<RadarViewable>::iterator itElement = ObjectList<RadarViewable>::begin(); itElement; ++itElement) 113 115 { 114 /* 115 if ((*itElement) != SpaceShip::getLocalShip() && (*itListener)->getRadarSensitivity() > (*itElement)->getRadarObjectCamouflage()) 116 if ((*itListener)->getRadarSensitivity() > (*itElement)->getRadarObjectCamouflage()) 116 117 (*itListener)->displayObject(*itElement, *itElement == this->focus_); 117 */118 118 } 119 119 } … … 128 128 this->focus_ = 0; 129 129 } 130 else 131 { 132 Vector3 localPosition;// = SpaceShip::getLocalShip()->getPosition(); 130 /* 131 else if (this->owner_) 132 { 133 Vector3 localPosition = this->owner_->getPosition(); 133 134 Vector3 targetPosition = localPosition; 134 135 if (*(this->itFocus_)) 135 targetPosition = this->itFocus_->get WorldPosition();136 targetPosition = this->itFocus_->getRVWorldPosition(); 136 137 137 138 // find the closed object further away than targetPosition … … 143 144 for (ObjectList<RadarViewable>::iterator it = ObjectList<RadarViewable>::begin(); it; ++it) 144 145 { 145 /* 146 if (*it == SpaceShip::getLocalShip()) 146 if (*it == (RadarViewable*)this->owner_) 147 147 continue; 148 */ 149 float targetDistance = localPosition.squaredDistance((*it)->get WorldPosition());148 149 float targetDistance = localPosition.squaredDistance((*it)->getRVWorldPosition()); 150 150 if (targetDistance > currentDistance && targetDistance < nextDistance) 151 151 { … … 171 171 } 172 172 } 173 */ 173 174 } 174 175 … … 186 187 for (ObjectList<RadarViewable>::iterator it = ObjectList<RadarViewable>::begin(); it; ++it, ++i) 187 188 { 188 COUT(3) << i++ << ": " << (*it)->get WorldPosition() << std::endl;189 COUT(3) << i++ << ": " << (*it)->getRVWorldPosition() << std::endl; 189 190 } 190 191 } -
code/trunk/src/orxonox/objects/RadarViewable.cc
r2087 r2662 29 29 #include "OrxonoxStableHeaders.h" 30 30 #include "RadarViewable.h" 31 31 32 #include "util/Debug.h" 33 #include "util/Exception.h" 32 34 #include "core/CoreIncludes.h" 33 //#include "objects/WorldEntity.h"34 #include " Radar.h"35 #include "objects/worldentities/WorldEntity.h" 36 #include "objects/Radar.h" 35 37 36 38 namespace orxonox … … 40 42 */ 41 43 RadarViewable::RadarViewable() 42 : radarObject_(0) 43 , radarObjectCamouflage_(0.0f) 44 , radarObjectType_(Dot) 44 : radarObjectCamouflage_(0.0f) 45 , radarObjectShape_(Dot) 45 46 , radarObjectDescription_("staticObject") 46 47 { … … 52 53 Radar* radar = Radar::getInstancePtr(); 53 54 if (radar) 54 this->radarObject Type_ = radar->addObjectDescription(str);55 this->radarObjectShape_ = radar->addObjectDescription(str); 55 56 else 56 57 { … … 60 61 } 61 62 62 const Vector3& RadarViewable::get WorldPosition() const63 const Vector3& RadarViewable::getRVWorldPosition() const 63 64 { 64 validate(); 65 return Vector3::ZERO;//this->radarObject_->getWorldPosition(); 65 const WorldEntity* object = this->getWorldEntity(); 66 validate(object); 67 return object->getWorldPosition(); 66 68 } 67 69 68 Vector3 RadarViewable::get OrientedVelocity() const70 Vector3 RadarViewable::getRVOrientedVelocity() const 69 71 { 70 validate(); 71 return Vector3::ZERO;//this->radarObject_->getOrientation() * this->radarObject_->getVelocity(); 72 const WorldEntity* object = this->getWorldEntity(); 73 validate(object); 74 return object->getWorldOrientation() * object->getVelocity(); 72 75 } 73 76 } -
code/trunk/src/orxonox/objects/RadarViewable.h
r2087 r2662 44 44 class _OrxonoxExport RadarViewable : virtual public OrxonoxClass 45 45 { 46 class WorldEntity;47 48 46 public: 49 47 enum Shape … … 58 56 virtual ~RadarViewable() { } 59 57 60 float getRadarObjectCamouflage() const { return this->radarObjectCamouflage_; } 61 void setRadarObjectCamouflage(float camouflage) { this->radarObjectCamouflage_ = camouflage; } 58 inline void setRadarObjectCamouflage(float camouflage) 59 { this->radarObjectCamouflage_ = camouflage; } 60 inline float getRadarObjectCamouflage() const 61 { return this->radarObjectCamouflage_; } 62 62 63 const ColourValue& getRadarObjectColour() const { return this->radarObjectColour_; } 64 void setRadarObjectColour(const ColourValue& colour) { this->radarObjectColour_ = colour; } 63 inline void setRadarObjectColour(const ColourValue& colour) 64 { this->radarObjectColour_ = colour; } 65 inline const ColourValue& getRadarObjectColour() const 66 { return this->radarObjectColour_; } 65 67 66 const std::string& getRadarObjectDescription() const { return this->radarObjectDescription_; }67 68 void setRadarObjectDescription(const std::string& str); 69 inline const std::string& getRadarObjectDescription() const 70 { return this->radarObjectDescription_; } 68 71 69 const WorldEntity* getWorldEntity() const { return this->radarObject_; } 70 const Vector3& getWorldPosition() const; 71 Vector3 getOrientedVelocity() const; 72 virtual const WorldEntity* getWorldEntity() const = 0; 72 73 73 Shape getRadarObjectType() const { return this->radarObjectType_; } 74 const Vector3& getRVWorldPosition() const; 75 Vector3 getRVOrientedVelocity() const; 74 76 75 protected: 76 WorldEntity* radarObject_; 77 inline void setRadarObjectShape(Shape shape) 78 { this->radarObjectShape_ = shape; } 79 inline Shape getRadarObjectShape() const 80 { return this->radarObjectShape_; } 77 81 78 82 private: 79 void validate() const { if (!this->radarObject_) 80 { COUT(1) << "Assertation: Every RadarViewable has to be assigned a WorldEntity pointer!" << std::endl; assert(0); } } 83 void validate(const WorldEntity* object) const 84 { 85 if (!object) 86 { 87 COUT(1) << "Assertation: Every RadarViewable has to be assigned a WorldEntity pointer!" << std::endl; 88 assert(0); 89 } 90 } 81 91 82 92 float radarObjectCamouflage_; 83 Shape radarObject Type_;93 Shape radarObjectShape_; 84 94 std::string radarObjectDescription_; 85 95 ColourValue radarObjectColour_; -
code/trunk/src/orxonox/objects/Scene.cc
r2171 r2662 22 22 * Author: 23 23 * Fabian 'x3n' Landau 24 * Reto Grieder (physics) 24 25 * Co-authors: 25 26 * ... … … 33 34 #include <OgreSceneManagerEnumerator.h> 34 35 #include <OgreSceneNode.h> 35 #include <OgreLight.h> 36 37 #include "BulletCollision/BroadphaseCollision/btAxisSweep3.h" 38 #include "BulletCollision/CollisionDispatch/btDefaultCollisionConfiguration.h" 39 #include "BulletDynamics/ConstraintSolver/btSequentialImpulseConstraintSolver.h" 40 #include "BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h" 36 41 37 42 #include "core/CoreIncludes.h" 38 43 #include "core/Core.h" 39 44 #include "core/XMLPort.h" 45 #include "tools/BulletConversions.h" 46 #include "objects/worldentities/WorldEntity.h" 40 47 41 48 namespace orxonox … … 48 55 49 56 this->setScene(this); 50 this->bShadows_ = false;57 this->bShadows_ = true; 51 58 52 59 if (Core::showsGraphics()) … … 70 77 } 71 78 72 // test test test 73 if (Core::showsGraphics() && this->sceneManager_) 74 { 75 Ogre::Light* light; 76 light = this->sceneManager_->createLight("Light-1"); 77 light->setType(Ogre::Light::LT_DIRECTIONAL); 78 light->setDiffuseColour(ColourValue(1.0, 0.9, 0.6, 1.0)); 79 light->setSpecularColour(ColourValue(1.0, 0.9, 0.6, 1.0)); 80 light->setDirection(1, -0.3, 0.3); 81 } 82 // test test test 79 // No physics yet, XMLPort will do that. 80 const int defaultMaxWorldSize = 100000; 81 this->negativeWorldRange_ = Vector3::UNIT_SCALE * -defaultMaxWorldSize; 82 this->positiveWorldRange_ = Vector3::UNIT_SCALE * defaultMaxWorldSize; 83 this->gravity_ = Vector3::ZERO; 84 this->physicalWorld_ = 0; 85 this->solver_ = 0; 86 this->dispatcher_ = 0; 87 this->collisionConfig_ = 0; 88 this->broadphase_ = 0; 83 89 84 90 this->registerVariables(); … … 91 97 if (Ogre::Root::getSingletonPtr()) 92 98 { 93 // this->sceneManager_->destroySceneNode(this->rootSceneNode_->getName()); // TODO: remove getName() for newer versions of Ogre94 99 Ogre::Root::getSingleton().destroySceneManager(this->sceneManager_); 95 100 } … … 98 103 delete this->sceneManager_; 99 104 } 105 106 this->setPhysicalWorld(false); 100 107 } 101 108 } … … 109 116 XMLPortParam(Scene, "shadow", setShadow, getShadow, xmlelement, mode).defaultValues(true); 110 117 118 XMLPortParam(Scene, "gravity", setGravity, getGravity, xmlelement, mode); 119 XMLPortParam(Scene, "negativeWorldRange", setNegativeWorldRange, getNegativeWorldRange, xmlelement, mode); 120 XMLPortParam(Scene, "positiveWorldRange", setPositiveWorldRange, getPositiveWorldRange, xmlelement, mode); 121 XMLPortParam(Scene, "hasPhysics", setPhysicalWorld, hasPhysics, xmlelement, mode).defaultValues(true); 122 111 123 XMLPortObjectExtended(Scene, BaseObject, "", addObject, getObject, xmlelement, mode, true, false); 112 124 } … … 114 126 void Scene::registerVariables() 115 127 { 116 REGISTERSTRING(this->skybox_, direction::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applySkybox)); 117 REGISTERDATA(this->ambientLight_, direction::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applyAmbientLight)); 128 registerVariable(this->skybox_, variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applySkybox)); 129 registerVariable(this->ambientLight_, variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applyAmbientLight)); 130 registerVariable(this->negativeWorldRange_, variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_negativeWorldRange)); 131 registerVariable(this->positiveWorldRange_, variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_positiveWorldRange)); 132 registerVariable(this->gravity_, variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_gravity)); 133 registerVariable(this->bHasPhysics_, variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_hasPhysics)); 134 registerVariable(this->bShadows_, variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_applyShadows)); 135 } 136 137 void Scene::setNegativeWorldRange(const Vector3& range) 138 { 139 if (range.length() < 10.0f) 140 { 141 CCOUT(2) << "Warning: Setting the negative world range to a very small value: " 142 << omni_cast<std::string>(range) << std::endl; 143 } 144 if (this->hasPhysics()) 145 { 146 CCOUT(2) << "Warning: Attempting to set the physical world range at run time. " 147 << "This causes a complete physical reload which might take some time." << std::endl; 148 this->setPhysicalWorld(false); 149 this->negativeWorldRange_ = range; 150 this->setPhysicalWorld(true); 151 } 152 else 153 this->negativeWorldRange_ = range; 154 } 155 156 void Scene::setPositiveWorldRange(const Vector3& range) 157 { 158 if (range.length() < 10.0f) 159 { 160 CCOUT(2) << "Warning: Setting the positive world range to a very small value: " 161 << omni_cast<std::string>(range) << std::endl; 162 } 163 if (this->hasPhysics()) 164 { 165 CCOUT(2) << "Warning: Attempting to set the physical world range at run time. " 166 << "This causes a complete physical reload which might take some time." << std::endl; 167 this->setPhysicalWorld(false); 168 this->positiveWorldRange_ = range; 169 this->setPhysicalWorld(true); 170 } 171 else 172 this->positiveWorldRange_ = range; 173 } 174 175 void Scene::setGravity(const Vector3& gravity) 176 { 177 this->gravity_ = gravity; 178 if (this->hasPhysics()) 179 this->physicalWorld_->setGravity(omni_cast<btVector3>(this->gravity_)); 180 } 181 182 void Scene::setPhysicalWorld(bool wantPhysics) 183 { 184 this->bHasPhysics_ = wantPhysics; 185 if (wantPhysics && !hasPhysics()) 186 { 187 // Note: These are all little known default classes and values. 188 // It would require further investigation to properly dertermine the right choices. 189 this->broadphase_ = new bt32BitAxisSweep3( 190 omni_cast<btVector3>(this->negativeWorldRange_), omni_cast<btVector3>(this->positiveWorldRange_)); 191 this->collisionConfig_ = new btDefaultCollisionConfiguration(); 192 this->dispatcher_ = new btCollisionDispatcher(this->collisionConfig_); 193 this->solver_ = new btSequentialImpulseConstraintSolver(); 194 195 this->physicalWorld_ = new btDiscreteDynamicsWorld(this->dispatcher_, this->broadphase_, this->solver_, this->collisionConfig_); 196 this->physicalWorld_->setGravity(omni_cast<btVector3>(this->gravity_)); 197 198 // also set the collision callback variable. 199 // Note: This is a global variable which we assign a static function. 200 // TODO: Check whether this (or anything about Bullet) works with multiple physics engine instances. 201 gContactAddedCallback = &Scene::collisionCallback; 202 } 203 else if (!wantPhysics && hasPhysics()) 204 { 205 // Remove all WorldEntities and shove them to the queue since they would still like to be in a physical world. 206 for (std::set<WorldEntity*>::const_iterator it = this->physicalObjects_.begin(); 207 it != this->physicalObjects_.end(); ++it) 208 { 209 this->physicalWorld_->removeRigidBody((*it)->physicalBody_); 210 this->physicalObjectQueue_.insert(*it); 211 } 212 this->physicalObjects_.clear(); 213 214 delete this->physicalWorld_; 215 delete this->solver_; 216 delete this->dispatcher_; 217 delete this->collisionConfig_; 218 delete this->broadphase_; 219 this->physicalWorld_ = 0; 220 this->solver_ = 0; 221 this->dispatcher_ = 0; 222 this->collisionConfig_ = 0; 223 this->broadphase_ = 0; 224 } 225 } 226 227 void Scene::tick(float dt) 228 { 229 if (!Core::showsGraphics()) 230 { 231 // We need to update the scene nodes if we don't render 232 this->rootSceneNode_->_update(true, false); 233 } 234 if (this->hasPhysics()) 235 { 236 // TODO: This here is bad practice! It will slow down the first tick() by ages. 237 // Rather have an initialise() method as well, called by the Level after everything has been loaded. 238 if (this->physicalObjectQueue_.size() > 0) 239 { 240 // Add all scheduled WorldEntities 241 for (std::set<WorldEntity*>::const_iterator it = this->physicalObjectQueue_.begin(); 242 it != this->physicalObjectQueue_.end(); ++it) 243 { 244 this->physicalWorld_->addRigidBody((*it)->physicalBody_); 245 this->physicalObjects_.insert(*it); 246 } 247 this->physicalObjectQueue_.clear(); 248 } 249 250 // Note: 60 means that Bullet will do physics correctly down to 1 frames per seconds. 251 // Under that mark, the simulation will "loose time" and get unusable. 252 physicalWorld_->stepSimulation(dt, 60); 253 } 118 254 } 119 255 … … 165 301 } 166 302 167 void Scene::tick(float dt) 168 { 169 if (!Core::showsGraphics()) 170 { 171 // We need to update the scene nodes if we don't render 172 this->rootSceneNode_->_update(true, false); 173 } 303 void Scene::addPhysicalObject(WorldEntity* object) 304 { 305 if (object) 306 { 307 std::set<WorldEntity*>::iterator it = this->physicalObjects_.find(object); 308 if (it != this->physicalObjects_.end()) 309 return; 310 311 this->physicalObjectQueue_.insert(object); 312 } 313 } 314 315 void Scene::removePhysicalObject(WorldEntity* object) 316 { 317 // check queue first 318 std::set<WorldEntity*>::iterator it = this->physicalObjectQueue_.find(object); 319 if (it != this->physicalObjectQueue_.end()) 320 { 321 this->physicalObjectQueue_.erase(it); 322 return; 323 } 324 325 it = this->physicalObjects_.find(object); 326 if (it == this->physicalObjects_.end()) 327 return; 328 this->physicalObjects_.erase(it); 329 330 if (this->hasPhysics()) 331 this->physicalWorld_->removeRigidBody(object->physicalBody_); 332 } 333 334 /*static*/ bool Scene::collisionCallback(btManifoldPoint& cp, const btCollisionObject* colObj0, int partId0, 335 int index0, const btCollisionObject* colObj1, int partId1, int index1) 336 { 337 // get the WorldEntity pointers 338 WorldEntity* object0 = (WorldEntity*)colObj0->getUserPointer(); 339 assert(dynamic_cast<WorldEntity*>(object0)); 340 WorldEntity* object1 = (WorldEntity*)colObj1->getUserPointer(); 341 assert(dynamic_cast<WorldEntity*>(object1)); 342 343 // false means that bullet will assume we didn't modify the contact 344 bool modified = false; 345 if (object0->isCollisionCallbackActive()) 346 { 347 modified |= object0->collidesAgainst(object1, cp); 348 if (object1->isCollisionCallbackActive()) 349 modified |= object1->collidesAgainst(object0, cp); 350 } 351 else 352 modified |= object1->collidesAgainst(object0, cp); 353 354 return modified; 174 355 } 175 356 } -
code/trunk/src/orxonox/objects/Scene.h
r2171 r2662 22 22 * Author: 23 23 * Fabian 'x3n' Landau 24 * Reto Grieder (physics) 24 25 * Co-authors: 25 26 * ... … … 32 33 #include "OrxonoxPrereqs.h" 33 34 34 #include "network/ Synchronisable.h"35 #include "network/synchronisable/Synchronisable.h" 35 36 #include "core/BaseObject.h" 36 37 #include "util/Math.h" … … 75 76 void networkcallback_applyAmbientLight() 76 77 { this->setAmbientLight(this->ambientLight_); } 78 void networkcallback_applyShadows() 79 { this->setShadow(this->bShadows_); } 77 80 78 Ogre::SceneManager* sceneManager_; 79 Ogre::SceneNode* rootSceneNode_; 80 std::string skybox_; 81 ColourValue ambientLight_; 82 std::list<BaseObject*> objects_; 83 bool bShadows_; 81 Ogre::SceneManager* sceneManager_; 82 Ogre::SceneNode* rootSceneNode_; 83 84 std::string skybox_; 85 ColourValue ambientLight_; 86 std::list<BaseObject*> objects_; 87 bool bShadows_; 88 89 90 ///////////// 91 // Physics // 92 ///////////// 93 94 public: 95 inline bool hasPhysics() 96 { return this->physicalWorld_ != 0; } 97 void setPhysicalWorld(bool wantsPhysics); 98 99 void setNegativeWorldRange(const Vector3& range); 100 inline const Vector3& getNegativeWorldRange() const 101 { return this->negativeWorldRange_; } 102 103 void setPositiveWorldRange(const Vector3& range); 104 inline const Vector3& getPositiveWorldRange() const 105 { return this->positiveWorldRange_; } 106 107 void setGravity(const Vector3& gravity); 108 inline const Vector3& getGravity() const 109 { return this->gravity_; } 110 111 void addPhysicalObject(WorldEntity* object); 112 void removePhysicalObject(WorldEntity* object); 113 114 private: 115 inline void networkcallback_hasPhysics() 116 { this->setPhysicalWorld(this->bHasPhysics_); } 117 inline void networkcallback_negativeWorldRange() 118 { this->setNegativeWorldRange(this->negativeWorldRange_); } 119 inline void networkcallback_positiveWorldRange() 120 { this->setPositiveWorldRange(this->positiveWorldRange_); } 121 inline void networkcallback_gravity() 122 { this->setGravity(this->gravity_); } 123 124 // collision callback from bullet 125 static bool collisionCallback(btManifoldPoint& cp, const btCollisionObject* colObj0, int partId0, 126 int index0, const btCollisionObject* colObj1, int partId1, int index1); 127 128 // Bullet objects 129 btDiscreteDynamicsWorld* physicalWorld_; 130 bt32BitAxisSweep3* broadphase_; 131 btDefaultCollisionConfiguration* collisionConfig_; 132 btCollisionDispatcher* dispatcher_; 133 btSequentialImpulseConstraintSolver* solver_; 134 135 std::set<WorldEntity*> physicalObjectQueue_; 136 std::set<WorldEntity*> physicalObjects_; 137 bool bHasPhysics_; 138 Vector3 negativeWorldRange_; 139 Vector3 positiveWorldRange_; 140 Vector3 gravity_; 84 141 }; 85 142 } -
code/trunk/src/orxonox/objects/Script.cc
r2087 r2662 64 64 void Script::execute() 65 65 { 66 LuaBind *lua = LuaBind::getInstance();67 lua ->loadString(this->code_);68 lua ->run();66 LuaBind& lua = LuaBind::getInstance(); 67 lua.loadString(this->code_); 68 lua.run(); 69 69 } 70 70 } -
code/trunk/src/orxonox/objects/Test.cc
r2171 r2662 61 61 void Test::setConfigValues() 62 62 { 63 SetConfigValue ( v1, 1 )/*.callback ( this, &Test::checkV1 )*/; 64 SetConfigValue ( v2, 2 )/*.callback ( this, &Test::checkV2 )*/; 65 SetConfigValue ( v3, 3 )/*.callback ( this, &Test::checkV3 )*/; 66 SetConfigValue ( v4, 4 )/*.callback ( this, &Test::checkV4 )*/; 63 SetConfigValue ( u1, 1 )/*.callback ( this, &Test::checkV1 )*/; 64 SetConfigValue ( u2, 2 )/*.callback ( this, &Test::checkV2 )*/; 65 SetConfigValue ( u3, 3 )/*.callback ( this, &Test::checkV3 )*/; 66 SetConfigValue ( u4, 4 )/*.callback ( this, &Test::checkV4 )*/; 67 68 SetConfigValue ( s1, 1 )/*.callback ( this, &Test::checkV1 )*/; 69 SetConfigValue ( s2, 2 )/*.callback ( this, &Test::checkV2 )*/; 70 SetConfigValue ( s3, 3 )/*.callback ( this, &Test::checkV3 )*/; 71 SetConfigValue ( s4, 4 )/*.callback ( this, &Test::checkV4 )*/; 67 72 } 68 73 … … 70 75 void Test::registerVariables() 71 76 { 72 REGISTERDATA ( v1,direction::toclient, new NetworkCallback<Test> ( this, &Test::checkV1 ) ); 73 REGISTERDATA ( v2,direction::toserver, new NetworkCallback<Test> ( this, &Test::checkV2 ) ); 74 REGISTERDATA ( v3,direction::serverMaster, new NetworkCallback<Test> ( this, &Test::checkV3 ) ); 75 REGISTERDATA ( v4,direction::clientMaster, new NetworkCallback<Test> ( this, &Test::checkV4 ) ); 77 registerVariable ( u1, variableDirection::toclient, new NetworkCallback<Test> ( this, &Test::checkU1 )); 78 registerVariable ( u2, variableDirection::toserver, new NetworkCallback<Test> ( this, &Test::checkU2 )); 79 registerVariable ( u3, variableDirection::serverMaster, new NetworkCallback<Test> ( this, &Test::checkU3 ), true ); 80 registerVariable ( u4, variableDirection::clientMaster, new NetworkCallback<Test> ( this, &Test::checkU4 ), true ); 81 82 registerVariable ( s1, variableDirection::toclient, new NetworkCallback<Test> ( this, &Test::checkS1 )); 83 registerVariable ( s2, variableDirection::toserver, new NetworkCallback<Test> ( this, &Test::checkS2 )); 84 registerVariable ( s3, variableDirection::serverMaster, new NetworkCallback<Test> ( this, &Test::checkS3 ), true ); 85 registerVariable ( s4, variableDirection::clientMaster, new NetworkCallback<Test> ( this, &Test::checkS4 ), true ); 76 86 } 77 87 78 void Test::checkV1(){ 79 COUT(1) << "V1 changed: " << v1 << std::endl; 80 } 88 void Test::checkU1(){ COUT(1) << "U1 changed: " << u1 << std::endl; } 89 void Test::checkU2(){ COUT(1) << "U2 changed: " << u2 << std::endl; } 90 void Test::checkU3(){ COUT(1) << "U3 changed: " << u3 << std::endl; } 91 void Test::checkU4(){ COUT(1) << "U4 changed: " << u4 << std::endl; } 81 92 82 void Test::checkV2(){ 83 COUT(1) << "V2 changed: " << v2 << std::endl; 84 } 85 86 void Test::checkV3(){ 87 COUT(1) << "V3 changed: " << v3 << std::endl; 88 } 89 90 void Test::checkV4(){ 91 COUT(1) << "V4 changed: " << v4 << std::endl; 92 } 93 93 void Test::checkS1(){ COUT(1) << "S1 changed: " << s1 << std::endl; } 94 void Test::checkS2(){ COUT(1) << "S2 changed: " << s2 << std::endl; } 95 void Test::checkS3(){ COUT(1) << "S3 changed: " << s3 << std::endl; } 96 void Test::checkS4(){ COUT(1) << "S4 changed: " << s4 << std::endl; } 94 97 95 98 } -
code/trunk/src/orxonox/objects/Test.h
r2171 r2662 32 32 #include "OrxonoxPrereqs.h" 33 33 #include "core/BaseObject.h" 34 #include "network/Synchronisable.h" 34 #include "network/synchronisable/Synchronisable.h" 35 36 37 typedef int TYPE; 38 typedef unsigned int UTYPE; 39 35 40 36 41 namespace orxonox … … 45 50 void registerVariables(); 46 51 47 void setV1(unsigned int value){ v1 = value; }48 void setV2(unsigned int value){ v2 = value; }49 void setV3(unsigned int value){ v3 = value; }50 void setV4(unsigned int value){ v4 = value; }51 52 52 void checkV1(); 53 void checkV2(); 54 void checkV3(); 55 void checkV4(); 53 //unsigned functions 54 void setU1(UTYPE value){ u1 = value; } 55 void setU2(UTYPE value){ u2 = value; } 56 void setU3(UTYPE value){ u3 = value; } 57 void setU4(UTYPE value){ u4 = value; } 58 void checkU1(); 59 void checkU2(); 60 void checkU3(); 61 void checkU4(); 56 62 57 void printV1(){ instance_->checkV1(); } 58 void printV2(){ instance_->checkV2(); } 59 void printV3(){ instance_->checkV3(); } 60 void printV4(){ instance_->checkV4(); } 63 //signed functions 64 void setS1(TYPE value){ s1 = value; } 65 void setS2(TYPE value){ s2 = value; } 66 void setS3(TYPE value){ s3 = value; } 67 void setS4(TYPE value){ s4 = value; } 68 void checkS1(); 69 void checkS2(); 70 void checkS3(); 71 void checkS4(); 72 73 static void printV1(){ instance_->checkU1(); } 74 static void printV2(){ instance_->checkU2(); } 75 static void printV3(){ instance_->checkU3(); } 76 static void printV4(){ instance_->checkU4(); } 61 77 62 78 private: 63 unsigned int v1; 64 unsigned int v2; 65 unsigned int v3; 66 unsigned int v4; 79 UTYPE u1; 80 UTYPE u2; 81 UTYPE u3; 82 UTYPE u4; 83 84 TYPE s1; 85 TYPE s2; 86 TYPE s3; 87 TYPE s4; 67 88 68 89 static Test* instance_; -
code/trunk/src/orxonox/objects/collisionshapes
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/objects/controllers/CMakeLists.txt
r2131 r2662 2 2 Controller.cc 3 3 HumanController.cc 4 ArtificialController.cc 5 AIController.cc 6 ScriptController.cc 4 7 ) 5 8 -
code/trunk/src/orxonox/objects/controllers/Controller.cc
r2087 r2662 31 31 32 32 #include "core/CoreIncludes.h" 33 #include "overlays/OverlayGroup.h" 33 34 34 35 namespace orxonox … … 42 43 this->player_ = 0; 43 44 this->controllableEntity_ = 0; 45 this->hud_ = 0; 46 this->bUpdateHUD_ = false; 44 47 } 45 48 46 49 Controller::~Controller() 47 50 { 51 if (this->isInitialized() && this->hud_) 52 delete this->hud_; 53 } 54 55 void Controller::changedControllableEntity() 56 { 57 if (this->bUpdateHUD_) 58 { 59 this->updateHUD(); 60 this->bUpdateHUD_ = false; 61 } 62 63 if (this->hud_) 64 this->hud_->setOwner(this->getControllableEntity()); 65 } 66 67 void Controller::updateHUD() 68 { 69 if (this->hud_) 70 { 71 delete this->hud_; 72 this->hud_ = 0; 73 } 74 75 if (this->hudtemplate_ != "") 76 { 77 this->hud_ = new OverlayGroup(this); 78 this->hud_->addTemplate(this->hudtemplate_); 79 this->hud_->setOwner(this->getControllableEntity()); 80 } 48 81 } 49 82 } -
code/trunk/src/orxonox/objects/controllers/Controller.h
r2087 r2662 47 47 { return this->player_; } 48 48 49 virtual inline void setControllableEntity(ControllableEntity* entity) 50 { this->controllableEntity_ = entity; } 51 virtual inline ControllableEntity* getControllableEntity() const 49 inline void setControllableEntity(ControllableEntity* entity) 50 { 51 if (entity != this->controllableEntity_) 52 { 53 this->controllableEntity_ = entity; 54 this->changedControllableEntity(); 55 } 56 } 57 inline ControllableEntity* getControllableEntity() const 52 58 { return this->controllableEntity_; } 59 virtual void changedControllableEntity(); 60 61 inline void setHUDTemplate(const std::string& name) 62 { 63 if (name != this->hudtemplate_) 64 { 65 this->hudtemplate_ = name; 66 if (this->controllableEntity_) 67 this->updateHUD(); 68 else 69 this->bUpdateHUD_ = true; 70 } 71 } 72 inline const std::string& getHUDTemplate() const 73 { return this->hudtemplate_; } 74 75 inline OverlayGroup* getHUD() const 76 { return this->hud_; } 53 77 54 78 protected: 79 void updateHUD(); 80 55 81 PlayerInfo* player_; 56 82 ControllableEntity* controllableEntity_; 83 std::string hudtemplate_; 84 OverlayGroup* hud_; 85 bool bUpdateHUD_; 57 86 }; 58 87 } -
code/trunk/src/orxonox/objects/controllers/HumanController.cc
r2087 r2662 33 33 #include "core/ConsoleCommand.h" 34 34 #include "objects/worldentities/ControllableEntity.h" 35 #include "objects/worldentities/pawns/Pawn.h" 36 #include "objects/gametypes/Gametype.h" 35 37 36 38 namespace orxonox … … 44 46 SetConsoleCommand(HumanController, fire, true).keybindMode(KeybindMode::OnHold); 45 47 SetConsoleCommand(HumanController, altFire, true).keybindMode(KeybindMode::OnHold); 48 SetConsoleCommand(HumanController, boost, true).keybindMode(KeybindMode::OnHold); 46 49 SetConsoleCommand(HumanController, greet, true); 47 50 SetConsoleCommand(HumanController, use, true); 48 51 SetConsoleCommand(HumanController, switchCamera, true); 52 SetConsoleCommand(HumanController, mouseLook, true); 53 SetConsoleCommand(HumanController, suicide, true); 54 SetConsoleCommand(HumanController, addBots, true).defaultValues(1); 55 SetConsoleCommand(HumanController, killBots, true).defaultValues(0); 56 SetConsoleCommand(HumanController, dropItems, true); 49 57 50 58 CreateUnloadableFactory(HumanController); … … 103 111 { 104 112 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 105 HumanController::localController_s->controllableEntity_->fire( );113 HumanController::localController_s->controllableEntity_->fire(WeaponMode::fire); 106 114 } 107 115 … … 109 117 { 110 118 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 111 HumanController::localController_s->controllableEntity_->altFire(); 119 HumanController::localController_s->controllableEntity_->fire(WeaponMode::altFire); 120 } 121 122 void HumanController::boost() 123 { 124 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 125 HumanController::localController_s->controllableEntity_->boost(); 112 126 } 113 127 … … 129 143 HumanController::localController_s->controllableEntity_->switchCamera(); 130 144 } 145 146 void HumanController::mouseLook() 147 { 148 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 149 HumanController::localController_s->controllableEntity_->mouseLook(); 150 } 151 152 void HumanController::suicide() 153 { 154 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 155 { 156 Pawn* pawn = dynamic_cast<Pawn*>(HumanController::localController_s->controllableEntity_); 157 if (pawn) 158 pawn->kill(); 159 } 160 } 161 162 void HumanController::addBots(unsigned int amount) 163 { 164 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && HumanController::localController_s->controllableEntity_->getGametype()) 165 HumanController::localController_s->controllableEntity_->getGametype()->addBots(amount); 166 } 167 168 void HumanController::killBots(unsigned int amount) 169 { 170 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && HumanController::localController_s->controllableEntity_->getGametype()) 171 HumanController::localController_s->controllableEntity_->getGametype()->killBots(amount); 172 } 173 174 void HumanController::dropItems() 175 { 176 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 177 HumanController::localController_s->controllableEntity_->dropItems(); 178 } 131 179 } -
code/trunk/src/orxonox/objects/controllers/HumanController.h
r2087 r2662 54 54 static void altFire(); 55 55 56 static void boost(); 56 57 static void greet(); 57 58 static void use(); 58 59 static void switchCamera(); 60 static void mouseLook(); 61 static void dropItems(); 62 63 static void suicide(); 64 65 static void addBots(unsigned int amount); 66 static void killBots(unsigned int amount = 0); 59 67 60 68 private: -
code/trunk/src/orxonox/objects/gametypes/Gametype.cc
r2171 r2662 34 34 35 35 #include "core/CoreIncludes.h" 36 #include "core/ConfigValueIncludes.h" 37 #include "core/Template.h" 38 #include "core/Core.h" 39 #include "overlays/OverlayGroup.h" 36 40 #include "objects/infos/PlayerInfo.h" 41 #include "objects/infos/Bot.h" 37 42 #include "objects/worldentities/pawns/Spectator.h" 38 43 #include "objects/worldentities/SpawnPoint.h" 44 #include "objects/worldentities/Camera.h" 45 #include "Settings.h" 39 46 40 47 #include "network/Host.h" … … 44 51 CreateUnloadableFactory(Gametype); 45 52 46 Gametype::Gametype(BaseObject* creator) : BaseObject(creator) 53 Gametype::Gametype(BaseObject* creator) : BaseObject(creator), gtinfo_(creator) 47 54 { 48 55 RegisterObject(Gametype); 49 56 57 this->setGametype(this); 58 50 59 this->defaultControllableEntity_ = Class(Spectator); 51 60 52 this->bStarted_ = false;53 this->bEnded_ = false;54 61 this->bAutoStart_ = false; 55 62 this->bForceSpawn_ = false; 63 this->numberOfBots_ = 0; 56 64 57 65 this->initialStartCountdown_ = 3; 58 this->startCountdown_ = 0; 59 this->bStartCountdownRunning_ = false; 66 67 this->setConfigValues(); 68 69 this->addBots(this->numberOfBots_); 70 71 // load the corresponding score board 72 if (Core::showsGraphics() && this->scoreboardTemplate_ != "") 73 { 74 this->scoreboard_ = new OverlayGroup(this); 75 this->scoreboard_->addTemplate(this->scoreboardTemplate_); 76 this->scoreboard_->setGametype(this); 77 } 78 else 79 this->scoreboard_ = 0; 80 } 81 82 void Gametype::setConfigValues() 83 { 84 SetConfigValue(initialStartCountdown_, 3.0f); 85 SetConfigValue(bAutoStart_, false); 86 SetConfigValue(bForceSpawn_, false); 87 SetConfigValue(numberOfBots_, 0); 88 SetConfigValue(scoreboardTemplate_, "defaultScoreboard"); 60 89 } 61 90 62 91 void Gametype::tick(float dt) 63 92 { 64 if (this->bStartCountdownRunning_ && !this->bStarted_) 65 this->startCountdown_ -= dt; 66 67 if (!this->bStarted_) 93 SUPER(Gametype, tick, dt); 94 95 if (this->gtinfo_.bStartCountdownRunning_ && !this->gtinfo_.bStarted_) 96 this->gtinfo_.startCountdown_ -= dt; 97 98 if (!this->gtinfo_.bStarted_) 68 99 this->checkStart(); 69 100 else … … 76 107 { 77 108 COUT(0) << "game started" << std::endl; 78 this-> bStarted_ = true;109 this->gtinfo_.bStarted_ = true; 79 110 80 111 this->spawnPlayersIfRequested(); … … 84 115 { 85 116 COUT(0) << "game ended" << std::endl; 86 this-> bEnded_ = true;117 this->gtinfo_.bEnded_ = true; 87 118 } 88 119 89 120 void Gametype::playerEntered(PlayerInfo* player) 90 121 { 91 this->players_[player] = PlayerState::Joined;122 this->players_[player].state_ = PlayerState::Joined; 92 123 93 124 std::string message = player->getName() + " entered the game"; … … 98 129 void Gametype::playerLeft(PlayerInfo* player) 99 130 { 100 std::map<PlayerInfo*, Player State::Enum>::iterator it = this->players_.find(player);131 std::map<PlayerInfo*, Player>::iterator it = this->players_.find(player); 101 132 if (it != this->players_.end()) 102 133 { … … 140 171 void Gametype::pawnKilled(Pawn* victim, Pawn* killer) 141 172 { 142 } 143 144 void Gametype::playerScored(PlayerInfo* player) 145 { 173 if (victim && victim->getPlayer()) 174 { 175 std::string message; 176 if (killer) 177 { 178 if (killer->getPlayer()) 179 message = victim->getPlayer()->getName() + " was killed by " + killer->getPlayer()->getName(); 180 else 181 message = victim->getPlayer()->getName() + " was killed"; 182 } 183 else 184 message = victim->getPlayer()->getName() + " died"; 185 186 COUT(0) << message << std::endl; 187 Host::Broadcast(message); 188 } 189 190 if (victim && victim->getPlayer()) 191 { 192 std::map<PlayerInfo*, Player>::iterator it = this->players_.find(victim->getPlayer()); 193 if (it != this->players_.end()) 194 { 195 it->second.state_ = PlayerState::Dead; 196 it->second.killed_++; 197 198 // Reward killer 199 if (killer) 200 { 201 std::map<PlayerInfo*, Player>::iterator itKiller = this->players_.find(killer->getPlayer()); 202 if (itKiller != this->players_.end()) 203 { 204 this->playerScored(itKiller->second); 205 } 206 else 207 COUT(2) << "Warning: Killing Pawn was not in the playerlist" << std::endl; 208 } 209 210 ControllableEntity* entity = this->defaultControllableEntity_.fabricate(victim->getCreator()); 211 if (victim->getCamera()) 212 { 213 entity->setPosition(victim->getCamera()->getWorldPosition()); 214 entity->setOrientation(victim->getCamera()->getWorldOrientation()); 215 } 216 else 217 { 218 entity->setPosition(victim->getWorldPosition()); 219 entity->setOrientation(victim->getWorldOrientation()); 220 } 221 it->first->startControl(entity); 222 } 223 else 224 COUT(2) << "Warning: Killed Pawn was not in the playerlist" << std::endl; 225 } 226 } 227 228 void Gametype::playerScored(Player& player) 229 { 230 player.frags_++; 146 231 } 147 232 … … 150 235 if (this->spawnpoints_.size() > 0) 151 236 { 152 srand(time(0));153 rnd();154 155 237 unsigned int randomspawn = (unsigned int)rnd(this->spawnpoints_.size()); 156 238 unsigned int index = 0; … … 168 250 void Gametype::assignDefaultPawnsIfNeeded() 169 251 { 170 for (std::map<PlayerInfo*, PlayerState::Enum>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) 171 { 172 if (!it->first->getControllableEntity() && (!it->first->isReadyToSpawn() || !this->bStarted_)) 173 { 174 SpawnPoint* spawn = this->getBestSpawnPoint(it->first); 175 if (spawn) 176 { 177 // force spawn at spawnpoint with default pawn 178 ControllableEntity* entity = this->defaultControllableEntity_.fabricate(spawn); 179 spawn->spawn(entity); 180 it->first->startControl(entity); 181 it->second = PlayerState::Dead; 252 for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) 253 { 254 if (!it->first->getControllableEntity()) 255 { 256 it->second.state_ = PlayerState::Dead; 257 258 if (!it->first->isReadyToSpawn() || !this->gtinfo_.bStarted_) 259 { 260 SpawnPoint* spawn = this->getBestSpawnPoint(it->first); 261 if (spawn) 262 { 263 // force spawn at spawnpoint with default pawn 264 ControllableEntity* entity = this->defaultControllableEntity_.fabricate(spawn); 265 spawn->spawn(entity); 266 it->first->startControl(entity); 267 it->second.state_ = PlayerState::Dead; 268 } 269 else 270 { 271 COUT(1) << "Error: No SpawnPoints in current Gametype" << std::endl; 272 abort(); 273 } 274 } 275 } 276 } 277 } 278 279 void Gametype::checkStart() 280 { 281 if (!this->gtinfo_.bStarted_) 282 { 283 if (this->gtinfo_.bStartCountdownRunning_) 284 { 285 if (this->gtinfo_.startCountdown_ <= 0) 286 { 287 this->gtinfo_.bStartCountdownRunning_ = false; 288 this->gtinfo_.startCountdown_ = 0; 289 this->start(); 290 } 291 } 292 else if (this->players_.size() > 0) 293 { 294 if (this->bAutoStart_) 295 { 296 this->start(); 182 297 } 183 298 else 184 299 { 185 COUT(1) << "Error: No SpawnPoints in current Gametype" << std::endl;186 abort();187 }188 }189 }190 }191 192 void Gametype::checkStart()193 {194 if (!this->bStarted_)195 {196 if (this->bStartCountdownRunning_)197 {198 if (this->startCountdown_ <= 0)199 {200 this->bStartCountdownRunning_ = false;201 this->startCountdown_ = 0;202 this->start();203 }204 }205 else if (this->players_.size() > 0)206 {207 if (this->bAutoStart_)208 {209 this->start();210 }211 else212 {213 300 bool allplayersready = true; 214 for (std::map<PlayerInfo*, PlayerState::Enum>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) 301 bool hashumanplayers = false; 302 for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) 215 303 { 216 304 if (!it->first->isReadyToSpawn()) 217 305 allplayersready = false; 218 } 219 if (allplayersready) 220 { 221 this->startCountdown_ = this->initialStartCountdown_; 222 this->bStartCountdownRunning_ = true; 306 if (it->first->isHumanPlayer()) 307 hashumanplayers = true; 308 } 309 if (allplayersready && hashumanplayers) 310 { 311 this->gtinfo_.startCountdown_ = this->initialStartCountdown_; 312 this->gtinfo_.bStartCountdownRunning_ = true; 223 313 } 224 314 } … … 229 319 void Gametype::spawnPlayersIfRequested() 230 320 { 231 for (std::map<PlayerInfo*, Player State::Enum>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)321 for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) 232 322 if (it->first->isReadyToSpawn() || this->bForceSpawn_) 233 323 this->spawnPlayer(it->first); … … 236 326 void Gametype::spawnDeadPlayersIfRequested() 237 327 { 238 for (std::map<PlayerInfo*, Player State::Enum>::iterator it = this->players_.begin(); it != this->players_.end(); ++it)239 if (it->second == PlayerState::Dead)328 for (std::map<PlayerInfo*, Player>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) 329 if (it->second.state_ == PlayerState::Dead) 240 330 if (it->first->isReadyToSpawn() || this->bForceSpawn_) 241 331 this->spawnPlayer(it->first); … … 248 338 { 249 339 player->startControl(spawnpoint->spawn()); 250 this->players_[player] = PlayerState::Alive;340 this->players_[player].state_ = PlayerState::Alive; 251 341 } 252 342 else … … 256 346 } 257 347 } 348 349 void Gametype::addBots(unsigned int amount) 350 { 351 for (unsigned int i = 0; i < amount; ++i) 352 new Bot(this); 353 } 354 355 void Gametype::killBots(unsigned int amount) 356 { 357 unsigned int i = 0; 358 for (ObjectList<Bot>::iterator it = ObjectList<Bot>::begin(); (it != ObjectList<Bot>::end()) && ((amount == 0) || (i < amount)); ) 359 { 360 if (it->getGametype() == this) 361 { 362 delete (*(it++)); 363 ++i; 364 } 365 } 366 } 258 367 } -
code/trunk/src/orxonox/objects/gametypes/Gametype.h
r2171 r2662 38 38 #include "objects/worldentities/ControllableEntity.h" 39 39 #include "objects/Tickable.h" 40 #include "objects/infos/GametypeInfo.h" 40 41 41 42 namespace orxonox … … 52 53 } 53 54 55 struct Player 56 { 57 PlayerInfo* info_; 58 PlayerState::Enum state_; 59 int frags_; 60 int killed_; 61 }; 62 54 63 class _OrxonoxExport Gametype : public BaseObject, public Tickable 55 64 { … … 60 69 virtual ~Gametype() {} 61 70 71 void setConfigValues(); 72 62 73 virtual void tick(float dt); 63 74 75 inline const GametypeInfo* getGametypeInfo() const 76 { return &this->gtinfo_; } 77 64 78 inline bool hasStarted() const 65 { return this-> bStarted_; }79 { return this->gtinfo_.bStarted_; } 66 80 inline bool hasEnded() const 67 { return this-> bEnded_; }81 { return this->gtinfo_.bEnded_; } 68 82 69 83 virtual void start(); … … 75 89 virtual void playerChangedName(PlayerInfo* player); 76 90 77 virtual void playerScored(Player Info*player);91 virtual void playerScored(Player& player); 78 92 79 93 virtual void pawnKilled(Pawn* victim, Pawn* killer = 0); … … 81 95 virtual void pawnPostSpawn(Pawn* pawn); 82 96 83 inline const std::map<PlayerInfo*, Player State::Enum>& getPlayers() const97 inline const std::map<PlayerInfo*, Player>& getPlayers() const 84 98 { return this->players_; } 85 99 … … 88 102 89 103 inline bool isStartCountdownRunning() const 90 { return this-> bStartCountdownRunning_; }104 { return this->gtinfo_.bStartCountdownRunning_; } 91 105 inline float getStartCountdown() const 92 { return this->startCountdown_; } 106 { return this->gtinfo_.startCountdown_; } 107 108 void addBots(unsigned int amount); 109 void killBots(unsigned int amount = 0); 110 111 inline unsigned int getNumberOfPlayers() const 112 { return this->players_.size(); } 93 113 94 114 private: … … 104 124 void spawnDeadPlayersIfRequested(); 105 125 106 bool bStarted_;107 bool bEnded_; 126 GametypeInfo gtinfo_; 127 108 128 bool bAutoStart_; 109 129 bool bForceSpawn_; 110 130 111 131 float initialStartCountdown_; 112 float startCountdown_; 113 bool bStartCountdownRunning_; 132 unsigned int numberOfBots_; 114 133 115 std::map<PlayerInfo*, Player State::Enum> players_;134 std::map<PlayerInfo*, Player> players_; 116 135 std::set<SpawnPoint*> spawnpoints_; 117 136 SubclassIdentifier<ControllableEntity> defaultControllableEntity_; 137 138 OverlayGroup* scoreboard_; 139 140 // Config Values 141 std::string scoreboardTemplate_; 118 142 }; 119 143 } -
code/trunk/src/orxonox/objects/infos/CMakeLists.txt
r2171 r2662 1 1 SET( SRC_FILES 2 Bot.cc 2 3 Info.cc 3 4 PlayerInfo.cc 4 5 HumanPlayer.cc 6 GametypeInfo.cc 5 7 ) 6 8 -
code/trunk/src/orxonox/objects/infos/HumanPlayer.cc
r2171 r2662 37 37 #include "objects/controllers/HumanController.h" 38 38 #include "objects/gametypes/Gametype.h" 39 #include "overlays/OverlayGroup.h" 39 40 40 41 namespace orxonox … … 63 64 { 64 65 SetConfigValue(nick_, "Player").callback(this, &HumanPlayer::configvaluecallback_changednick); 66 SetConfigValue(hudtemplate_, "defaultHUD").callback(this, &HumanPlayer::configvaluecallback_changedHUDTemplate); 65 67 } 66 68 67 69 void HumanPlayer::registerVariables() 68 70 { 69 REGISTERSTRING(this->synchronize_nick_, direction::toserver, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_changednick));71 registerVariable(this->synchronize_nick_, variableDirection::toserver, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_changednick)); 70 72 71 REGISTERDATA(this->clientID_, direction::toclient, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_clientIDchanged));72 REGISTERDATA(this->server_initialized_, direction::toclient, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_server_initialized));73 REGISTERDATA(this->client_initialized_, direction::toserver, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_client_initialized));73 registerVariable(this->clientID_, variableDirection::toclient, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_clientIDchanged)); 74 registerVariable(this->server_initialized_, variableDirection::toclient, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_server_initialized)); 75 registerVariable(this->client_initialized_, variableDirection::toserver, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_client_initialized)); 74 76 } 75 77 … … 83 85 this->setName(this->nick_); 84 86 } 87 } 88 89 void HumanPlayer::configvaluecallback_changedHUDTemplate() 90 { 91 this->changedController(); 85 92 } 86 93 … … 99 106 100 107 if (!Core::isMaster()) 101 this->setObjectMode( direction::bidirectional);108 this->setObjectMode(objectDirection::bidirectional); 102 109 else 103 110 this->setName(this->nick_); … … 138 145 this->networkcallback_clientIDchanged(); 139 146 } 147 148 void HumanPlayer::changedController() 149 { 150 if (this->getController()) 151 { 152 this->getController()->setHUDTemplate(this->hudtemplate_); 153 154 if (this->getController() && this->getController()->getHUD()) 155 this->getController()->getHUD()->setOwner(this->getControllableEntity()); 156 } 157 } 140 158 } -
code/trunk/src/orxonox/objects/infos/HumanPlayer.h
r2171 r2662 33 33 34 34 #include "PlayerInfo.h" 35 #include "core/Identifier.h"36 #include "objects/controllers/Controller.h"37 35 38 36 namespace orxonox … … 53 51 void setClientID(unsigned int clientID); 54 52 53 virtual void changedController(); 54 55 55 protected: 56 56 void configvaluecallback_changednick(); 57 void configvaluecallback_changedHUDTemplate(); 57 58 void networkcallback_changednick(); 58 59 void networkcallback_clientIDchanged(); … … 62 63 std::string nick_; 63 64 std::string synchronize_nick_; 65 std::string hudtemplate_; 64 66 bool server_initialized_; 65 67 bool client_initialized_; -
code/trunk/src/orxonox/objects/infos/Info.h
r2171 r2662 32 32 #include "OrxonoxPrereqs.h" 33 33 34 #include "network/ Synchronisable.h"34 #include "network/synchronisable/Synchronisable.h" 35 35 #include "core/BaseObject.h" 36 36 -
code/trunk/src/orxonox/objects/infos/PlayerInfo.cc
r2171 r2662 46 46 this->bLocalPlayer_ = false; 47 47 this->bReadyToSpawn_ = false; 48 this->bSetUnreadyAfterSpawn_ = true; 48 49 this->controller_ = 0; 49 50 this->controllableEntity_ = 0; … … 64 65 this->controller_ = 0; 65 66 } 67 68 if (this->getGametype()) 69 this->getGametype()->playerLeft(this); 66 70 } 67 71 } … … 69 73 void PlayerInfo::registerVariables() 70 74 { 71 REGISTERSTRING(this->name_, direction::toclient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::changedName));72 REGISTERDATA (this->controllableEntityID_, direction::toclient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedcontrollableentityID));73 REGISTERDATA (this->bReadyToSpawn_, direction::toserver);75 registerVariable(this->name_, variableDirection::toclient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::changedName)); 76 registerVariable(this->controllableEntityID_, variableDirection::toclient, new NetworkCallback<PlayerInfo>(this, &PlayerInfo::networkcallback_changedcontrollableentityID)); 77 registerVariable(this->bReadyToSpawn_, variableDirection::toserver); 74 78 } 75 79 76 80 void PlayerInfo::changedName() 77 81 { 82 SUPER(PlayerInfo, changedName); 83 78 84 if (this->isInitialized() && this->getGametype()) 79 85 this->getGametype()->playerChangedName(this); … … 109 115 if (this->controllableEntity_) 110 116 this->controller_->setControllableEntity(this->controllableEntity_); 117 this->changedController(); 111 118 } 112 119 113 void PlayerInfo::startControl(ControllableEntity* entity )120 void PlayerInfo::startControl(ControllableEntity* entity, bool callback) 114 121 { 122 if (entity == this->controllableEntity_) 123 return; 124 115 125 if (this->controllableEntity_) 116 this->stopControl(this->controllableEntity_ );126 this->stopControl(this->controllableEntity_, callback); 117 127 118 128 this->controllableEntity_ = entity; … … 122 132 this->controllableEntityID_ = entity->getObjectID(); 123 133 entity->setPlayer(this); 124 this->bReadyToSpawn_ = false;134 this->bReadyToSpawn_ &= (!this->bSetUnreadyAfterSpawn_); 125 135 } 126 136 else -
code/trunk/src/orxonox/objects/infos/PlayerInfo.h
r2171 r2662 65 65 { return this->bReadyToSpawn_; } 66 66 67 void startControl(ControllableEntity* entity );67 void startControl(ControllableEntity* entity, bool callback = true); 68 68 void stopControl(ControllableEntity* entity, bool callback = true); 69 69 … … 71 71 { return this->controllableEntity_; } 72 72 73 inline Controller* getController() const 74 { return this->controller_; } 75 virtual void changedController() {} 76 73 77 protected: 74 78 void createController(); 75 void networkcallback_changedcontrollableentityID();76 79 77 80 bool bHumanPlayer_; 78 81 bool bLocalPlayer_; 82 bool bSetUnreadyAfterSpawn_; 83 SubclassIdentifier<Controller> defaultController_; 84 unsigned int clientID_; 85 86 private: 87 void networkcallback_changedcontrollableentityID(); 88 79 89 bool bReadyToSpawn_; 80 SubclassIdentifier<Controller> defaultController_;81 90 Controller* controller_; 82 91 ControllableEntity* controllableEntity_; 83 92 unsigned int controllableEntityID_; 84 unsigned int clientID_;85 93 }; 86 94 } -
code/trunk/src/orxonox/objects/pickup/CMakeLists.txt
r2131 r2662 1 1 SET( SRC_FILES 2 ShipEquipmentClasses.cc 3 ShipItem.cc 2 PickupSpawner.cc 3 BaseItem.cc 4 Turbo.cc 5 ShipEquipment.cc 4 6 ) 5 7 -
code/trunk/src/orxonox/objects/pickup/ShipEquipment.h
r2094 r2662 1 2 1 #ifndef _ShipEquipment_H__ 3 2 #define _ShipEquipment_H__ 4 3 #include <string> 5 #include <multimap> 4 #include <map> 5 6 /* 7 multimap<std::string, BaseItem*> equipment_; 8 equipment_.insert(pair<std::string, BaseItem*>("Weapon", new BaseItem()));*/ 6 9 7 10 8 /* 9 multimap<std::string, Item*> equipment_;10 equipment_.insert(pair<std::string, Item*>("Weapon", new Item()));*/ 11 /* std::map<std::itemtype, BaseItem*> EQClasses; 12 EQClasses["jacke"] = 0; 13 BaseItem* item = itemMap_["jacke"]; 11 14 12 15 if (itemMap_["jacke"]) 16 if (itemMap_.find("jacke") != itemMap_.end()) */ 13 17 namespace orxonox 14 18 { 19 class BaseItem; 20 /** 21 @brief 22 ShipEquipment is the inventory of a player. It's part of the Pawn class. 23 24 */ 15 25 class _OrxonoxExport ShipEquipment 16 26 { 17 27 public: 18 void AddItem(Shipitem toAddItem); 19 void RemoveItem(Shipitem toRemoveItem); 20 bool CheckifValid(Shipitem toBeChecked); 21 int 22 28 inline int getSpace() 29 { 30 return Usable.size()+Trunk.size(); 31 }; 32 bool insert(BaseItem* item); 33 bool erase (BaseItem* item); 34 //void print(std::multimap<std::string, BaseItem*> eut); 35 void eraseAll(); 36 //bool checkSlot(BaseItem* item); 37 BaseItem* checkSlot(BaseItem* item); 38 // const std::multimap<std::string, BaseItem*>& getEquipment() const { return this->Equipment; } 39 inline std::multimap<std::string, BaseItem*>& getEquipment() {return this->Equipment;} 40 inline std::multimap<std::string, BaseItem*>& getUsable() {return this->Usable;} 41 inline std::multimap<std::string, BaseItem*>& getTrunk() {return this->Trunk;} 42 inline Pawn* getPlayer() {return this->player ;} 43 inline void setPlayer(Pawn* setplayer) 44 {this->player = setplayer;} 23 45 private: 24 std::multimap<std::string, Item*> Equipment; 46 Pawn* player;//!< Is a pointer to the belonging player 47 std::multimap<std::string, BaseItem*> Equipment;//!< the Equipment for permanent Items 48 std::multimap<std::string, BaseItem*> Usable;//!< Where Usables are stored 49 std::multimap<std::string, BaseItem*> Trunk;//!< Every other Item is stored here 25 50 }; 26 51 } … … 39 64 40 65 41 42 43 44 45 66 #endif -
code/trunk/src/orxonox/objects/pickup/ShipEquipmentClasses.cc
r2094 r2662 57 57 } 58 58 break; 59 default:;60 59 } 61 60 case Useable: 62 61 return CheckifSpace(); 63 case default:;64 62 } 65 63 return true; … … 67 65 68 66 /*Adds the Item to the Ship*/ 69 void ShipEquipment::AddItem(Ship item* toAddItem)67 void ShipEquipment::AddItem(ShipItem* toAddItem) 70 68 { 71 69 if(CheckifValid(toAddItem)==true) … … 90 88 } 91 89 } 90 91 /*Adds the Item to the Ship*/ 92 void ShipEquipment::AddItem(Shipitem* toAddItem) 93 { 94 if(CheckifValid(toAddItem)==true) 95 { 96 switch(toAddItem.CheckType()){ 97 case Permanent: 98 Equipment.insert ( pair<std::string, ShipItem*>(toAddItem.itemname,toAddItem) ); 99 break; 100 case Usable: 101 Usable.insert ( pair<std::string, ShipItem*>(toAddItem.itemname,toAddItem) ); 102 break; 103 case Trunk: 104 Trunk.insert ( pair<std::string, ShipItem*>(toAddItem.itemname,toAddItem) ); 105 break; 106 } 107 } 108 else if(toAddItem.CheckType()==Permanent) 109 { 110 if(CheckifSpace()==true) 111 Trunk.insert ( pair<std::string, ShipItem*>(toAddItem.itemname,toAddItem) ); 112 } 113 } 114 115 void ShipEquipment::SwitchItem(Permanent* toSwitchItem) 116 { 117 multimap<string, ShipItem*>::iterator it; 118 string equippedname; 119 equippedname=GetNameofPermanent(toSwitchItem.CheckSubType()); 120 it=Equipment.find(equippedname); 121 Trunk.insert (find(equippedname)); 122 Equipment.erase (it); 123 Equipment.insert(pair<std::string, ShipItem*>(toSwitchItem.itemname,toSwitchItem) 124 } 125 126 string ShipEquipment::GetNameofPermanent (subItemTypePermanent NametoGet) 127 { 128 multimap<string, ShipItem*>::iterator it; 129 for ( it=Equipment.begin() ; it != Equipment.end(); it++ ){ 130 if((*it).second->CheckSubType()==NametoGet){ 131 return (*it).first.itemname; 132 } 133 } 134 return 0; 135 } 92 136 } -
code/trunk/src/orxonox/objects/pickup/ShipEquipmentClasses.h
r2094 r2662 8 8 9 9 /* 10 multimap<std::string, Item*> equipment_;11 equipment_.insert(pair<std::string, Item*>("Weapon", newItem()));*/10 multimap<std::string, BaseItem*> equipment_; 11 equipment_.insert(pair<std::string, BaseItem*>("Weapon", new BaseItem()));*/ 12 12 13 13 14 /* std::map<std::itemtype, Item*> EQClasses;14 /* std::map<std::itemtype, BaseItem*> EQClasses; 15 15 EQClasses["jacke"] = 0; 16 Item* item = itemMap_["jacke"];16 BaseItem* item = itemMap_["jacke"]; 17 17 18 18 if (itemMap_["jacke"]) … … 23 23 { 24 24 public: 25 void AddItem(Shipitem* toAddItem);25 /*void AddItem(Shipitem* toAddItem); 26 26 void RemoveItem(Shipitem* toRemoveItem); 27 27 bool CheckifValid(Shipitem* toBeChecked); 28 28 bool CheckifSpace(); 29 void SwitchItem(Permanent* toSwitchItem); 30 string GetNameofPermanent (subItemTypePermanent NametoGet);*/ //holt den Namen des getragenen Items im jeweiligen Slot. 29 31 30 32 private: 31 multimap<std::string, ShipItem*> Equipment;32 multimap<std::string, ShipItem*> Usable;33 multimap<std::string, ShipItem*> Trunk;33 multimap<std::string, BaseItem*> Equipment; 34 multimap<std::string, BaseItem*> Usable; 35 multimap<std::string, BaseItem*> Trunk; 34 36 }; 35 37 } -
code/trunk/src/orxonox/objects/pickup/ShipItem.cc
r2089 r2662 5 5 itemtype ShipItem::CheckType() 6 6 { 7 return this .type;7 return this->type; 8 8 } 9 9 10 10 subItemTypePermanent CheckSubType() 11 11 { 12 return this .subtype_permanent;12 return this->subtype_permanent; 13 13 } 14 15 subItemTypePowerups CheckSubType() 16 { 17 return this->subtype_powerups; 18 } 19 subItemTypeUsable CheckSubType() 20 { 21 return this->subtype_usables; 22 } 23 14 24 } -
code/trunk/src/orxonox/objects/pickup/ShipItem.h
r2094 r2662 21 21 public: 22 22 itemType CheckType(); 23 virtual23 //virtual ChecksubType(); 24 24 25 25 private: … … 27 27 string itemname; 28 28 }; 29 30 29 31 30 /* Useables are Items the Player can choose when to activate and then show an instant action/effect … … 37 36 Rockets, 38 37 Repairkits, 39 Triggers, 38 Triggers, //trigger events usable by the player (Quests f.exp.) 40 39 Boosters, 41 40 Shields, -
code/trunk/src/orxonox/objects/pickup/Usable.h
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/objects/quest/AddQuest.cc
- Property svn:mergeinfo changed
r2261 r2662 28 28 29 29 /** 30 @file AddQuest.cc 31 @brief 32 Implementation of the AddQuest class. 30 @file 31 @brief Implementation of the AddQuest class. 33 32 */ 34 33 … … 45 44 #include "Quest.h" 46 45 47 namespace orxonox {48 46 namespace orxonox 47 { 49 48 CreateFactory(AddQuest); 50 49 … … 109 108 } 110 109 111 COUT(3) << "Quest {" << this->getQuestId() << "} successfully added to player ." << std::endl;110 COUT(3) << "Quest {" << this->getQuestId() << "} successfully added to player: " << player << " ." << std::endl; 112 111 return true; 113 112 } -
code/trunk/src/orxonox/objects/quest/AddQuest.h
- Property svn:mergeinfo changed
r2261 r2662 28 28 29 29 /** 30 @file AddQuest.h 31 @brief 32 Definition of the AddQuest class. 30 @file 31 @brief Definition of the AddQuest class. 33 32 */ 34 33 … … 43 42 #include "ChangeQuestStatus.h" 44 43 45 namespace orxonox {46 44 namespace orxonox 45 { 47 46 /** 48 47 @brief … … 58 57 { 59 58 public: 60 61 62 63 64 65 59 AddQuest(BaseObject* creator); 60 virtual ~AddQuest(); 61 62 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a AddQuest object through XML. 63 64 virtual bool invoke(PlayerInfo* player); //!< Invokes the QuestEffect. 66 65 67 66 }; -
code/trunk/src/orxonox/objects/quest/AddQuestHint.cc
- Property svn:mergeinfo changed
r2261 r2662 28 28 29 29 /** 30 @file AddQuestHint.cc 31 @brief 32 Implementation of the AddQuestHint class. 30 @file 31 @brief Implementation of the AddQuestHint class. 33 32 */ 34 33 … … 44 43 #include "QuestHint.h" 45 44 46 namespace orxonox {47 45 namespace orxonox 46 { 48 47 CreateFactory(AddQuestHint); 49 48 … … 130 129 } 131 130 132 COUT(3) << "QuestHint {" << this->getHintId() << "} successfully added to player ." << std::endl;131 COUT(3) << "QuestHint {" << this->getHintId() << "} successfully added to player: " << player << " ." << std::endl; 133 132 return true; 134 133 -
code/trunk/src/orxonox/objects/quest/AddQuestHint.h
- Property svn:mergeinfo changed
r2261 r2662 28 28 29 29 /** 30 @file AddQuestHint.h 31 @brief 32 Definition of the AddQuestHint class. 30 @file 31 @brief Definition of the AddQuestHint class. 33 32 */ 34 33 … … 42 41 #include "QuestEffect.h" 43 42 44 namespace orxonox {45 43 namespace orxonox 44 { 46 45 /** 47 46 @brief … … 73 72 inline const std::string & getHintId(void) const 74 73 { return this->hintId_; } 74 75 75 bool setHintId(const std::string & id); //!< Sets the id of the QuestHint. 76 76 -
code/trunk/src/orxonox/objects/quest/AddReward.cc
- Property svn:mergeinfo changed
r2261 r2662 28 28 29 29 /** 30 @file AddReward.cc 31 @brief 32 Implementation of the AddReward class. 30 @file 31 @brief Implementation of the AddReward class. 33 32 */ 34 33 … … 41 40 #include "Rewardable.h" 42 41 43 namespace orxonox {44 42 namespace orxonox 43 { 45 44 CreateFactory(AddReward); 46 45 … … 106 105 bool AddReward::invoke(PlayerInfo* player) 107 106 { 107 COUT(3) << "AddReward on player: " << player << " ." << std::endl; 108 108 109 bool check = true; 109 110 for ( std::list<Rewardable*>::iterator reward = this->rewards_.begin(); reward != this->rewards_.end(); ++reward ) … … 111 112 check = check && (*reward)->reward(player); 112 113 } 114 115 COUT(3) << "Rewardable successfully added to player." << player << " ." << std::endl; 113 116 114 117 return check; -
code/trunk/src/orxonox/objects/quest/AddReward.h
- Property svn:mergeinfo changed
r2261 r2662 28 28 29 29 /** 30 @file AddReward.h 31 @brief 32 Definition of the AddReward class. 30 @file 31 @brief Definition of the AddReward class. 33 32 */ 34 33 … … 43 42 #include "QuestEffect.h" 44 43 45 namespace orxonox {46 44 namespace orxonox 45 { 47 46 /** 48 47 @brief … … 78 77 inline void addRewardable(Rewardable* reward) 79 78 { this->rewards_.push_back(reward); } 79 80 80 const Rewardable* getRewardables(unsigned int index) const; //!< Returns the Rewardable object at the given index. 81 81 -
code/trunk/src/orxonox/objects/quest/CMakeLists.txt
r2261 r2662 14 14 QuestHint.cc 15 15 QuestItem.cc 16 QuestListener.cc 16 17 QuestManager.cc 17 18 Rewardable.cc -
code/trunk/src/orxonox/objects/quest/ChangeQuestStatus.cc
- Property svn:mergeinfo changed
r2261 r2662 28 28 29 29 /** 30 @file ChangeQuestStatus.cc 31 @brief 32 Implementation of the ChangeQuestStatus class. 30 @file 31 @brief Implementation of the ChangeQuestStatus class. 33 32 */ 34 33 … … 40 39 #include "QuestItem.h" 41 40 42 namespace orxonox {43 41 namespace orxonox 42 { 44 43 /** 45 44 @brief -
code/trunk/src/orxonox/objects/quest/ChangeQuestStatus.h
- Property svn:mergeinfo changed
r2261 r2662 28 28 29 29 /** 30 @file ChangeQuestStatus.h 31 @brief 32 Definition of the ChangeQuestStatus class. 30 @file 31 @brief Definition of the ChangeQuestStatus class. 33 32 */ 34 33 … … 43 42 #include "QuestEffect.h" 44 43 45 namespace orxonox {46 44 namespace orxonox 45 { 47 46 /** 48 47 @brief … … 63 62 protected: 64 63 /** 65 66 64 @brief Returns the id of the Quest. 65 @return Returns the id of the Quest. 67 66 */ 68 67 inline const std::string & getQuestId(void) const -
code/trunk/src/orxonox/objects/quest/CompleteQuest.cc
- Property svn:mergeinfo changed
r2261 r2662 28 28 29 29 /** 30 @file CompleteQuest.cc 31 @brief 32 Implementation of the CompleteQuest class. 30 @file 31 @brief Implementation of the CompleteQuest class. 33 32 */ 34 33 … … 43 42 #include "Quest.h" 44 43 45 namespace orxonox {46 44 namespace orxonox 45 { 47 46 CreateFactory(CompleteQuest); 48 47 -
code/trunk/src/orxonox/objects/quest/CompleteQuest.h
- Property svn:mergeinfo changed
r2261 r2662 28 28 29 29 /** 30 @file CompleteQuest.h 31 @brief 32 Definition of the CompleteQuest class. 30 @file 31 @brief Definition of the CompleteQuest class. 33 32 */ 34 33 … … 43 42 #include "ChangeQuestStatus.h" 44 43 45 namespace orxonox {46 44 namespace orxonox 45 { 47 46 /** 48 47 @brief -
code/trunk/src/orxonox/objects/quest/FailQuest.cc
- Property svn:mergeinfo changed
r2261 r2662 28 28 29 29 /** 30 @file FailQuest.cc 31 @brief 32 Implementation of the FailQuest class. 30 @file 31 @brief Implementation of the FailQuest class. 33 32 */ 34 33 … … 43 42 #include "Quest.h" 44 43 45 namespace orxonox {46 44 namespace orxonox 45 { 47 46 CreateFactory(FailQuest); 48 47 -
code/trunk/src/orxonox/objects/quest/FailQuest.h
- Property svn:mergeinfo changed
r2261 r2662 28 28 29 29 /** 30 @file FailQuest.h 31 @brief 32 Definition of the FailQuest class. 30 @file 31 @brief Definition of the FailQuest class. 33 32 */ 34 33 … … 43 42 #include "ChangeQuestStatus.h" 44 43 45 namespace orxonox {46 44 namespace orxonox 45 { 47 46 /** 48 47 @brief -
code/trunk/src/orxonox/objects/quest/GlobalQuest.cc
- Property svn:mergeinfo changed
r2261 r2662 28 28 29 29 /** 30 @file GlobalQuest.cc 31 @brief 32 Implementation of the GlobalQuest class. 30 @file 31 @brief Implementation of the GlobalQuest class. 33 32 */ 34 33 … … 38 37 #include "orxonox/objects/infos/PlayerInfo.h" 39 38 #include "core/CoreIncludes.h" 39 #include "core/Super.h" 40 40 #include "util/Exception.h" 41 41 42 42 #include "QuestEffect.h" 43 43 44 namespace orxonox {45 44 namespace orxonox 45 { 46 46 CreateFactory(GlobalQuest); 47 47 … … 88 88 bool GlobalQuest::fail(PlayerInfo* player) 89 89 { 90 if( this->isFailable(player)) //!< Check whether the Quest can be failed.91 { 92 this->setStatus(player, questStatus::failed);93 94 //! Iterate through all players possessing this Quest.95 for(std::set<PlayerInfo*>::const_iterator it = players_.begin(); it != players_.end(); it++)96 {97 QuestEffect::invokeEffects(*it, this->getFailEffectList());98 }99 100 return true;101 }102 103 COUT(4) << "A non-completable quest was trying to be failed." << std::endl; 104 return false;90 if(!this->isFailable(player)) //!< Check whether the Quest can be failed. 91 { 92 COUT(4) << "A non-completable quest was trying to be failed." << std::endl; 93 return false; 94 } 95 96 Quest::fail(player); 97 98 //! Iterate through all players possessing this Quest. 99 for(std::set<PlayerInfo*>::const_iterator it = players_.begin(); it != players_.end(); it++) 100 { 101 QuestEffect::invokeEffects(*it, this->getFailEffectList()); 102 } 103 104 return true; 105 105 } 106 106 … … 117 117 bool GlobalQuest::complete(PlayerInfo* player) 118 118 { 119 if( this->isCompletable(player)) //!< Check whether the Quest can be completed.120 { 121 this->setStatus(player, questStatus::completed);122 123 //! Iterate through all players possessing the Quest.124 for(std::set<PlayerInfo*>::const_iterator it = players_.begin(); it != players_.end(); it++)125 {126 QuestEffect::invokeEffects(*it, this->getCompleteEffectList());127 }128 129 QuestEffect::invokeEffects(player, this->rewards_); //!< Invoke reward QuestEffects on the player completing the Quest.130 return true;131 }132 133 COUT(4) << "A non-completable quest was trying to be completed." << std::endl;134 return false;119 if(!this->isCompletable(player)) //!< Check whether the Quest can be completed. 120 { 121 COUT(4) << "A non-completable quest was trying to be completed." << std::endl; 122 return false; 123 } 124 125 //! Iterate through all players possessing the Quest. 126 for(std::set<PlayerInfo*>::const_iterator it = players_.begin(); it != players_.end(); it++) 127 { 128 QuestEffect::invokeEffects(*it, this->getCompleteEffectList()); 129 } 130 131 Quest::complete(player); 132 133 QuestEffect::invokeEffects(player, this->rewards_); //!< Invoke reward QuestEffects on the player completing the Quest. 134 return true; 135 135 } 136 136 … … 207 207 } 208 208 209 return questStatus::inactive;209 return questStatus::inactive; 210 210 } 211 211 -
code/trunk/src/orxonox/objects/quest/GlobalQuest.h
- Property svn:mergeinfo changed
r2261 r2662 28 28 29 29 /** 30 @file GlobalQuest.h 31 @brief 32 Definition of the GlobalQuest class. 30 @file 31 @brief Definition of the GlobalQuest class. 33 32 */ 34 33 … … 44 43 #include "Quest.h" 45 44 46 namespace orxonox {47 45 namespace orxonox 46 { 48 47 /** 49 48 @brief … … 56 55 <QuestDescription title="Title" description="Description." /> //The description of the quest. 57 56 <subquests> 58 <Quest id ="questId1" /> //A list of n subquest, be aware, each of the <Quest /> tags must have a description and so on and so forth as well.59 ...60 <Quest id="questIdn" />61 </subquests>62 <hints>63 <QuestHint id="hintId1" /> //A list of n QuestHints, see QuestHint for the full XML representation of those.64 ...65 <QuestHint id="hintIdn" />66 </hints>57 <Quest id ="questId1" /> //A list of n subquest, be aware, each of the <Quest /> tags must have a description and so on and so forth as well. 58 ... 59 <Quest id="questIdn" /> 60 </subquests> 61 <hints> 62 <QuestHint id="hintId1" /> //A list of n QuestHints, see QuestHint for the full XML representation of those. 63 ... 64 <QuestHint id="hintIdn" /> 65 </hints> 67 66 <fail-effects> 68 67 <QuestEffect /> //A list of QuestEffects, invoked on all players possessing this quest, when the Quest is failed, see QuestEffect for the full XML representation. -
code/trunk/src/orxonox/objects/quest/LocalQuest.cc
- Property svn:mergeinfo changed
r2261 r2662 28 28 29 29 /** 30 @file LocalQuest.cc 31 @brief 32 Implementation of the LocalQuest class. 30 @file 31 @brief Implementation of the LocalQuest class. 33 32 */ 34 33 … … 37 36 38 37 #include "core/CoreIncludes.h" 38 #include "core/Super.h" 39 39 #include "util/Exception.h" 40 40 … … 42 42 #include "QuestEffect.h" 43 43 44 namespace orxonox {45 44 namespace orxonox 45 { 46 46 CreateFactory(LocalQuest); 47 47 … … 86 86 bool LocalQuest::fail(PlayerInfo* player) 87 87 { 88 if(this->isFailable(player)) //!< Checks whether the quest can be failed. 89 { 90 this->setStatus(player, questStatus::failed); 91 QuestEffect::invokeEffects(player, this->getFailEffectList()); //!< Invoke the failEffects. 92 return true; 93 } 94 95 COUT(4) << "A non-failable quest was trying to be failed." << std::endl; 96 return false; 88 if(!this->isFailable(player)) //!< Checks whether the quest can be failed. 89 { 90 COUT(4) << "A non-failable quest was trying to be failed." << std::endl; 91 return false; 92 } 93 94 Quest::fail(player); 95 96 QuestEffect::invokeEffects(player, this->getFailEffectList()); //!< Invoke the failEffects. 97 return true; 97 98 } 98 99 … … 108 109 bool LocalQuest::complete(PlayerInfo* player) 109 110 { 110 if(this->isCompletable(player)) //!< Checks whether the Quest can be completed. 111 { 112 this->setStatus(player, questStatus::completed); 113 QuestEffect::invokeEffects(player, this->getCompleteEffectList()); //!< Invoke the complete QuestEffects. 114 return true; 115 } 116 117 COUT(4) << "A non-completable quest was trying to be completed." << std::endl; 118 return false; 111 if(!this->isCompletable(player)) //!< Checks whether the Quest can be completed. 112 { 113 COUT(4) << "A non-completable quest was trying to be completed." << std::endl; 114 return false; 115 } 116 117 Quest::complete(player); 118 119 QuestEffect::invokeEffects(player, this->getCompleteEffectList()); //!< Invoke the complete QuestEffects. 120 return true; 119 121 } 120 122 -
code/trunk/src/orxonox/objects/quest/LocalQuest.h
- Property svn:mergeinfo changed
r2261 r2662 28 28 29 29 /** 30 @file LocalQuest.h 31 @brief 32 Definition of the LocalQuest class. 30 @file 31 @brief Definition of the LocalQuest class. 33 32 */ 34 33 … … 44 43 #include "Quest.h" 45 44 46 namespace orxonox {47 45 namespace orxonox 46 { 48 47 /** 49 48 @brief … … 56 55 <QuestDescription title="Title" description="Description." /> //The description of the quest. 57 56 <subquests> 58 <Quest id ="questId1" /> //A list of n subquest, be aware, each of the <Quest /> tags must have a description and so on and so forth as well.59 ...60 <Quest id="questIdn" />61 </subquests>62 <hints>63 <QuestHint id="hintId1" /> //A list of n QuestHints, see QuestHint for the full XML representation of those.64 ...65 <QuestHint id="hintIdn" />66 </hints>57 <Quest id ="questId1" /> //A list of n subquest, be aware, each of the <Quest /> tags must have a description and so on and so forth as well. 58 ... 59 <Quest id="questIdn" /> 60 </subquests> 61 <hints> 62 <QuestHint id="hintId1" /> //A list of n QuestHints, see QuestHint for the full XML representation of those. 63 ... 64 <QuestHint id="hintIdn" /> 65 </hints> 67 66 <fail-effects> 68 67 <QuestEffect /> //A list of QuestEffects, invoked when the Quest is failed, see QuestEffect for the full XML representation. -
code/trunk/src/orxonox/objects/quest/Quest.cc
- Property svn:mergeinfo changed
r2261 r2662 28 28 29 29 /** 30 @file Quest.cc 31 @brief 32 Implementation of the Quest class. 30 @file 31 @brief Implementation of the Quest class. 33 32 */ 34 33 … … 43 42 #include "QuestHint.h" 44 43 #include "QuestEffect.h" 45 46 namespace orxonox { 47 44 #include "QuestListener.h" 45 46 namespace orxonox 47 { 48 48 /** 49 49 @brief … … 363 363 return this->getStatus(player) == questStatus::completed; 364 364 } 365 366 /** 367 @brief 368 Fails the Quest for an input player. 369 @param player 370 The player. 371 @return 372 Returns true if the Quest could be failed, false if not. 373 */ 374 bool Quest::fail(PlayerInfo* player) 375 { 376 QuestListener::advertiseStatusChange(this->listeners_, "fail"); //!< Tells the QuestListeners, that the status has changed to failed. 377 this->setStatus(player, questStatus::failed); 378 379 COUT(4) << "Quest {" << this->getId() << "} is failed for player: " << player << " ." <<std::endl; 380 381 this->getDescription()->sendFailQuestNotification(); 382 return true; 383 } 384 385 /** 386 @brief 387 Completes the Quest for an input player. 388 @param player 389 The player. 390 @return 391 Returns true if the Quest could be completed, false if not. 392 */ 393 bool Quest::complete(PlayerInfo* player) 394 { 395 QuestListener::advertiseStatusChange(this->listeners_, "complete"); //!< Tells the QuestListeners, that the status has changed to completed. 396 this->setStatus(player, questStatus::completed); 397 398 COUT(4) << "Quest {" << this->getId() << "} is completed for player: " << player << " ." <<std::endl; 399 400 this->getDescription()->sendCompleteQuestNotification(); 401 return true; 402 } 365 403 366 404 /** … … 374 412 bool Quest::start(PlayerInfo* player) 375 413 { 376 if(this->isStartable(player)) //!< Checks whether the quest can be started. 377 { 378 this->setStatus(player, questStatus::active); 379 return true; 380 } 381 382 COUT(4) << "A non-startable quest was trying to be started." << std::endl; 383 return false; 414 if(!this->isStartable(player)) //!< Checks whether the quest can be started. 415 { 416 COUT(4) << "A non-startable quest was trying to be started." << std::endl; 417 return false; 418 } 419 420 COUT(4) << "Quest {" << this->getId() << "} is started for player: " << player << " ." <<std::endl; 421 422 QuestListener::advertiseStatusChange(this->listeners_, "start"); //!< Tells the QuestListeners, that the status has changed to active. 423 424 this->setStatus(player, questStatus::active); 425 426 this->getDescription()->sendAddQuestNotification(); 427 return true; 428 } 429 430 /** 431 @brief 432 Adds a QuestListener to the list of QuestListeners listening to this Quest. 433 @param listener 434 The QuestListener to be added. 435 @return 436 Returns true if successful, false if not. 437 */ 438 bool Quest::addListener(QuestListener* listener) 439 { 440 if(listener == NULL) 441 { 442 COUT(2) << "A NULL-QuestListener was trying to be added to a Quests listeners." << std::endl; 443 return false; 444 } 445 446 this->listeners_.push_back(listener); 447 return true; 384 448 } 385 449 -
code/trunk/src/orxonox/objects/quest/Quest.h
- Property svn:mergeinfo changed
r2261 r2662 28 28 29 29 /** 30 @file Quest.h 31 @brief 32 Definition of the Quest class. 33 34 The Quest is the parent class of LocalQuest and GlobalQuest. 30 @file 31 @brief Definition of the Quest class. 32 The Quest is the parent class of LocalQuest and GlobalQuest. 35 33 */ 36 34 … … 47 45 #include "QuestItem.h" 48 46 49 namespace questStatus47 namespace orxonox 50 48 { 49 namespace questStatus 50 { 51 51 52 //!Different states of a Quest.53 enum Enum54 {55 inactive,56 active,57 failed,58 completed59 };52 //!Different states of a Quest. 53 enum Enum 54 { 55 inactive, 56 active, 57 failed, 58 completed 59 }; 60 60 61 } 62 63 namespace orxonox { 61 } 64 62 65 63 /** … … 90 88 { return this->parentQuest_; } 91 89 92 /** 93 @brief Returns the list of subquests. 94 @return Returns a reference to the list of subquests of the quest. 95 */ 96 inline const std::list<Quest*> & getSubQuestList(void) const 97 { return this->subQuests_; } 98 99 /** 100 @brief Returns the list of all QuestHints of this Quest. 101 @return Returns a reference to the list of QuestHints of the Quest. 102 */ 103 inline const std::list<QuestHint*> & getHintsList(void) const 104 { return this->hints_; } 105 106 bool isInactive(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'inactive'. 107 bool isActive(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'active'. 108 bool isFailed(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'failed'. 109 bool isCompleted(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'completed'. 110 111 bool start(PlayerInfo* player); //!< Sets a Quest to active. 112 virtual bool fail(PlayerInfo* player) = 0; //!< Fails the Quest. 113 virtual bool complete(PlayerInfo* player) = 0; //!< Completes the Quest. 90 /** 91 @brief Returns the list of subquests. 92 @return Returns a reference to the list of subquests of the quest. 93 */ 94 inline const std::list<Quest*> & getSubQuestList(void) const 95 { return this->subQuests_; } 96 97 /** 98 @brief Returns the list of all QuestHints of this Quest. 99 @return Returns a reference to the list of QuestHints of the Quest. 100 */ 101 inline const std::list<QuestHint*> & getHintsList(void) const 102 { return this->hints_; } 103 104 bool isInactive(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'inactive'. 105 bool isActive(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'active'. 106 bool isFailed(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'failed'. 107 bool isCompleted(const PlayerInfo* player) const; //!< Returns true if the quest status for the specific player is 'completed'. 108 109 bool start(PlayerInfo* player); //!< Sets a Quest to active. 110 virtual bool fail(PlayerInfo* player); //!< Fails the Quest. 111 virtual bool complete(PlayerInfo* player); //!< Completes the Quest. 112 113 bool addListener(QuestListener* listener); //!< Adds a QuestListener to the list of QuestListeners listening to this Quest. 114 114 115 115 protected: … … 131 131 { return this->failEffects_; } 132 132 133 134 135 136 137 133 /** 134 @brief Returns the list of complete QuestEffects. 135 @return Returns a reference to the list of complete QuestEffects. 136 */ 137 inline std::list<QuestEffect*> & getCompleteEffectList(void) 138 138 { return this->completeEffects_; } 139 139 … … 141 141 virtual bool setStatus(PlayerInfo* player, const questStatus::Enum & status) = 0; //!< Changes the status for a specific player. 142 142 143 private:143 private: 144 144 Quest* parentQuest_; //!< Pointer to the parentquest. 145 145 std::list<Quest*> subQuests_; //!< List of all the subquests. … … 149 149 std::list<QuestEffect*> failEffects_; //!< A list of all QuestEffects to be invoked, when the Quest has been failed. 150 150 std::list<QuestEffect*> completeEffects_; //!< A list of QuestEffects to be invoked, when the Quest has been completed. 151 152 std::list<QuestListener*> listeners_; //!< A list of QuestListeners, that listen to what exactly happens with this Quest. 151 153 152 154 bool setParentQuest(Quest* quest); //!< Sets the parentquest of the Quest. -
code/trunk/src/orxonox/objects/quest/QuestDescription.cc
- Property svn:mergeinfo changed
r2261 r2662 28 28 29 29 /** 30 @file QuestDescription.cc 31 @brief 32 Implementation of the QuestDescription class. 30 @file 31 @brief Implementation of the QuestDescription class. 33 32 */ 34 33 … … 38 37 39 38 #include "core/CoreIncludes.h" 39 #include "orxonox/overlays/notifications/Notification.h" 40 40 41 namespace orxonox {42 41 namespace orxonox 42 { 43 43 CreateFactory(QuestDescription); 44 44 … … 74 74 XMLPortParam(QuestDescription, "title", setTitle, getTitle, xmlelement, mode); 75 75 XMLPortParam(QuestDescription, "description", setDescription, getDescription, xmlelement, mode); 76 XMLPortParam(QuestDescription, "failMessage", setFailMessage, getFailMessage, xmlelement, mode); 77 XMLPortParam(QuestDescription, "completeMessage", setCompleteMessage, getCompleteMessage, xmlelement, mode); 76 78 77 79 COUT(3) << "New QuestDescription with title '" << this->getTitle() << "' created." << std::endl; 80 } 81 82 /** 83 @brief 84 This method is a helper for sending QuestDescriptions as Notifications. 85 @param item 86 The item the QuestDescription is for. 87 @param status 88 The status the QuestDescription us for. 89 @return 90 Returns true if successful. 91 */ 92 bool QuestDescription::notificationHelper(const std::string & item, const std::string & status) const 93 { 94 std::string message = ""; 95 std::string title = ""; 96 if(item == "hint") 97 { 98 title = "You received a hint: '" + this->title_ + "'"; 99 message = this->description_; 100 } 101 else if(item == "quest") 102 { 103 if(status == "start") 104 { 105 title = "You received a new quest: '" + this->title_ + "'"; 106 message = this->description_; 107 } 108 else if(status == "fail") 109 { 110 title = "You failed the quest: '" + this->title_ + "'"; 111 message = this->failMessage_; 112 } 113 else if(status == "complete") 114 { 115 title = "You successfully completed the quest: '" + this->title_ + "'"; 116 message = this->completeMessage_; 117 } 118 else 119 { 120 COUT(2) << "Bad input in notificationHelper, this should not be happening!" << std::endl; 121 return false; 122 } 123 } 124 else 125 { 126 COUT(2) << "Bad input in notificationHelper, this should not be happening!" << std::endl; 127 return false; 128 } 129 130 Notification* notification = new Notification(0, message, title, 30); 131 notification->send(); 132 return true; 78 133 } 79 134 -
code/trunk/src/orxonox/objects/quest/QuestDescription.h
- Property svn:mergeinfo changed
r2261 r2662 28 28 29 29 /** 30 @file QuestDescription.h 31 @brief 32 Definition of the QuestDescription class. 30 @file 31 @brief Definition of the QuestDescription class. 33 32 */ 34 33 … … 43 42 #include "core/XMLPort.h" 44 43 45 namespace orxonox {46 44 namespace orxonox 45 { 47 46 /** 48 47 @brief … … 52 51 Creating a QuestDescription through XML goes as follows: 53 52 54 <QuestDescription title="Title" description="Description Text" />53 <QuestDescription title="Title" description="Description Text" failMessage="You fail." completeMessage="You win!" /> 55 54 @author 56 55 Damian 'Mozork' Frick 57 56 */ 58 class _OrxonoxExport QuestDescription : public BaseObject {59 57 class _OrxonoxExport QuestDescription : public BaseObject 58 { 60 59 public: 61 60 QuestDescription(BaseObject* creator); … … 64 63 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a QuestDescription object through XML. 65 64 66 /**67 @brief Returns the title.68 @return Returns a string containing the title of the QuestDescription.69 */65 /** 66 @brief Returns the title. 67 @return Returns a string containing the title of the QuestDescription. 68 */ 70 69 inline const std::string & getTitle(void) const 71 70 { return this->title_; } 72 71 73 /**74 @brief Returns the description text.75 @return Returns a string containing the description text of the QuestDescription.76 */72 /** 73 @brief Returns the description text. 74 @return Returns a string containing the description text of the QuestDescription. 75 */ 77 76 inline const std::string & getDescription(void) const 78 77 { return this->description_; } 78 79 /** 80 @brief Returns the fail message. 81 @return Returns a string containing the fail message of the QuestDescription. 82 */ 83 inline const std::string & getFailMessage(void) const 84 { return this->failMessage_; } 85 86 /** 87 @brief Returns the complete message. 88 @return Returns a string containing the complete message of the QuestDescription. 89 */ 90 inline const std::string & getCompleteMessage(void) const 91 { return this->completeMessage_; } 92 93 /** 94 @brief Sends a Notification displaying that a QuestHint was added. 95 @return Returns true if successful. 96 */ 97 inline bool sendAddHintNotification(void) const 98 { return notificationHelper("hint", ""); } 99 100 /** 101 @brief Sends a Notification displaying that a Quest was added. 102 @return Returns true if successful. 103 */ 104 inline bool sendAddQuestNotification(void) const 105 { return notificationHelper("quest", "start"); } 106 107 /** 108 @brief Sends a Notification displaying that a Quest was failed. 109 @return Returns true if successful. 110 */ 111 inline bool sendFailQuestNotification(void) const 112 { return notificationHelper("quest", "fail"); } 113 114 /** 115 @brief Sends a Notification displaying that a Quest was completed. 116 @return Returns true if successful. 117 */ 118 inline bool sendCompleteQuestNotification(void) const 119 { return notificationHelper("quest", "complete"); } 79 120 80 121 private: 81 122 std::string title_; //!< The title. 82 123 std::string description_; //!< The description. 124 std::string failMessage_; //!< The message displayed when the Quest is failed. 125 std::string completeMessage_; //!< The message displayed when the Quest is completed. 126 127 bool notificationHelper(const std::string & item, const std::string & status) const; //!< Helper for sending QuestDescriptions as Notifications. 83 128 84 129 /** … … 89 134 { this->title_ = title; } 90 135 91 /**136 /** 92 137 @brief Sets the description text. 93 138 @param description The description text to be set. … … 96 141 { this->description_ = description; } 97 142 143 /** 144 @brief Sets the fail message. 145 @param message The fail message to be set. 146 */ 147 inline void setFailMessage(const std::string & message) 148 { this->failMessage_ = message; } 149 150 /** 151 @brief Sets the complete message. 152 @param message The complete message to be set. 153 */ 154 inline void setCompleteMessage(const std::string & message) 155 { this->completeMessage_ = message; } 156 98 157 }; 99 158 -
code/trunk/src/orxonox/objects/quest/QuestEffect.cc
- Property svn:mergeinfo changed
r2261 r2662 28 28 29 29 /** 30 @file QuestEffect.cc 31 @brief 32 Implementation of the QuestEffect class. 30 @file 31 @brief Implementation of the QuestEffect class. 33 32 */ 34 33 … … 40 39 #include "orxonox/objects/infos/PlayerInfo.h" 41 40 42 namespace orxonox {43 41 namespace orxonox 42 { 44 43 /** 45 44 @brief … … 71 70 Returns false if there was an error, view console of log for further detail. 72 71 */ 73 bool QuestEffect::invokeEffects(PlayerInfo* player, std::list<QuestEffect*> & effects)72 /*static*/ bool QuestEffect::invokeEffects(PlayerInfo* player, std::list<QuestEffect*> & effects) 74 73 { 75 74 bool check = true; 75 76 COUT(4) << "Invoking QuestEffects on player: " << player << " ." << std::endl; 76 77 77 78 for (std::list<QuestEffect*>::iterator effect = effects.begin(); effect != effects.end(); effect++) -
code/trunk/src/orxonox/objects/quest/QuestEffect.h
- Property svn:mergeinfo changed
r2261 r2662 28 28 29 29 /** 30 @file QuestEffect.h 31 @brief 32 Definition of the QuestEffect class. 30 @file 31 @brief Definition of the QuestEffect class. 33 32 */ 34 33 … … 42 41 #include "core/BaseObject.h" 43 42 44 namespace orxonox {45 43 namespace orxonox 44 { 46 45 /** 47 46 @brief -
code/trunk/src/orxonox/objects/quest/QuestEffectBeacon.cc
r2262 r2662 28 28 29 29 /** 30 @file QuestEffectBeacon.cc 31 @brief 32 Implementation of the QuestEffectBeacon class. 30 @file 31 @brief Implementation of the QuestEffectBeacon class. 33 32 */ 34 33 … … 46 45 #include "QuestEffect.h" 47 46 48 namespace orxonox {49 47 namespace orxonox 48 { 50 49 CreateFactory(QuestEffectBeacon); 51 50 … … 54 53 Constructor. Registers the object and initializes defaults. 55 54 */ 56 QuestEffectBeacon::QuestEffectBeacon(BaseObject* creator) : PositionableEntity(creator)55 QuestEffectBeacon::QuestEffectBeacon(BaseObject* creator) : StaticEntity(creator) 57 56 { 58 57 RegisterObject(QuestEffectBeacon); 59 58 60 59 this->status_ = QuestEffectBeaconStatus::active; 61 this->times_ = INFINITE ;60 this->times_ = INFINITE_TIME; 62 61 } 63 62 … … 91 90 SUPER(QuestEffectBeacon, processEvent, event); 92 91 93 SetSubclassEvent(QuestEffectBeacon, "execute", execute, event, PlayerTrigger);92 SetSubclassEvent(QuestEffectBeacon, "execute", execute, event, PlayerTrigger); 94 93 } 95 94 … … 145 144 this->decrementTimes(); //!< Decrement the number of times the beacon can be used. 146 145 return true; 147 }148 149 return false;146 } 147 148 return false; 150 149 } 151 150 … … 187 186 return false; 188 187 } 189 if(this->getTimes() == INFINITE ) //!< If times is infinity the QuestEffectBeacon can be executed an infinite number fo times.188 if(this->getTimes() == INFINITE_TIME) //!< If times is infinity the QuestEffectBeacon can be executed an infinite number fo times. 190 189 { 191 190 return true; … … 193 192 194 193 this->times_ = this->times_ - 1; //!< Decrement number of times the QuestEffectBeacon can be executed. 195 if(this->getTimes() == 0) //!< Set the QuestEffectBeacon to inactive when the number of times it can be executed is reduced to 0.196 {194 if(this->getTimes() == 0) //!< Set the QuestEffectBeacon to inactive when the number of times it can be executed is reduced to 0. 195 { 197 196 this->status_ = QuestEffectBeaconStatus::inactive; 198 }197 } 199 198 200 199 return true; … … 213 212 bool QuestEffectBeacon::setTimes(const int & n) 214 213 { 215 if(n < 0 && n != INFINITE )214 if(n < 0 && n != INFINITE_TIME) 216 215 { 217 216 return false; -
code/trunk/src/orxonox/objects/quest/QuestEffectBeacon.h
r2262 r2662 28 28 29 29 /** 30 @file QuestEffectBeacon.h 31 @brief 32 Definition of the QuestEffectBeacon class. 30 @file 31 @brief Definition of the QuestEffectBeacon class. 33 32 */ 34 33 … … 38 37 #include "OrxonoxPrereqs.h" 39 38 40 #include "orxonox/objects/worldentities/ PositionableEntity.h"39 #include "orxonox/objects/worldentities/StaticEntity.h" 41 40 42 namespace QuestEffectBeaconStatus41 namespace orxonox 43 42 { 43 namespace QuestEffectBeaconStatus 44 { 44 45 45 //! The status of the beacon, can be either active or inactive.46 enum Enum47 {48 inactive,49 active50 };46 //! The status of the beacon, can be either active or inactive. 47 enum Enum 48 { 49 inactive, 50 active 51 }; 51 52 52 } 53 54 namespace orxonox { 53 } 55 54 56 55 /** … … 61 60 A QuestEffectBeacon can be inactive or active. 62 61 63 Creating a QuestEffectBeacon through XML goes as follows:64 65 <QuestEffectBeacon times=n> //Where 'n' is eighter a number >= 0, which means the QuestEffectBeacon can be executed n times. Or n = -1, which means the QuestEffectBeacon can be executed an infinite number of times.62 Creating a QuestEffectBeacon through XML goes as follows: 63 64 <QuestEffectBeacon times=n> //Where 'n' is eighter a number >= 0, which means the QuestEffectBeacon can be executed n times. Or n = -1, which means the QuestEffectBeacon can be executed an infinite number of times. 66 65 <effects> 67 66 <QuestEffect /> //A list of QuestEffects, invoked when the QuestEffectBeacon is executed, see QuestEffect for the full XML representation. … … 70 69 </effects> 71 70 <events> 72 <execute>73 <EventListener event=eventIdString />74 </execute>75 </events>76 <attached>77 <PlayerTrigger name=eventIdString /> //A PlayerTrigger triggering the execution of the QuestEffectBeacon.78 </attached>79 </QuestEffectBeacon>71 <execute> 72 <EventListener event=eventIdString /> 73 </execute> 74 </events> 75 <attached> 76 <PlayerTrigger name=eventIdString /> //A PlayerTrigger triggering the execution of the QuestEffectBeacon. 77 </attached> 78 </QuestEffectBeacon> 80 79 @author 81 80 Damian 'Mozork' Frick 82 81 */ 83 class _OrxonoxExport QuestEffectBeacon : public PositionableEntity82 class _OrxonoxExport QuestEffectBeacon : public StaticEntity 84 83 { 85 public:86 QuestEffectBeacon(BaseObject* creator);87 virtual ~QuestEffectBeacon();88 89 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a QuestEffectBeacon object through XML.90 91 virtual void processEvent(Event& event); //!< Processes an event for this QuestEffectBeacon.92 93 bool execute(bool b, PlayerTrigger* trigger); //!< Executes the QuestEffects of the QuestEffectBeacon.94 95 /**96 @brief Tests whether the QuestEffectBeacon is active.97 @return Returns true if the QuestEffectBeacon is active, fals if not.98 */99 inline bool isActive(void)100 { return this->status_ == QuestEffectBeaconStatus::active; }101 102 bool setActive(bool activate); //!< Set the status of the QuestEffectBeacon.103 104 protected:84 public: 85 QuestEffectBeacon(BaseObject* creator); 86 virtual ~QuestEffectBeacon(); 87 88 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a QuestEffectBeacon object through XML. 89 90 virtual void processEvent(Event& event); //!< Processes an event for this QuestEffectBeacon. 91 92 bool execute(bool b, PlayerTrigger* trigger); //!< Executes the QuestEffects of the QuestEffectBeacon. 93 94 /** 95 @brief Tests whether the QuestEffectBeacon is active. 96 @return Returns true if the QuestEffectBeacon is active, fals if not. 97 */ 98 inline bool isActive(void) 99 { return this->status_ == QuestEffectBeaconStatus::active; } 100 101 bool setActive(bool activate); //!< Set the status of the QuestEffectBeacon. 102 103 protected: 105 104 bool decrementTimes(void); //!< Decrement the number of times the QuestEffectBeacon can still be executed. 106 105 … … 111 110 inline const int & getTimes(void) const 112 111 { return this->times_; } 113 112 114 113 private: 115 static const int INFINITE = -1; //!< Constant to avoid using magic numbers.116 114 static const int INFINITE_TIME = -1; //!< Constant to avoid using magic numbers. 115 117 116 std::list<QuestEffect*> effects_; //!< The list of QuestEffects to be invoked on the executing player. 118 117 int times_; //!< Number of times the beacon can be exectued. -
code/trunk/src/orxonox/objects/quest/QuestHint.cc
- Property svn:mergeinfo changed
r2261 r2662 28 28 29 29 /** 30 @file QuestHint.cc 31 @brief 32 Implementation of the QuestHint class. 30 @file 31 @brief Implementation of the QuestHint class. 33 32 */ 34 33 … … 41 40 #include "orxonox/objects/infos/PlayerInfo.h" 42 41 #include "QuestManager.h" 42 #include "QuestDescription.h" 43 43 #include "Quest.h" 44 44 45 namespace orxonox {46 45 namespace orxonox 46 { 47 47 CreateFactory(QuestHint); 48 48 … … 122 122 { 123 123 this->playerStatus_[player] = questHintStatus::active; 124 125 this->getDescription()->sendAddHintNotification(); 124 126 return true; 125 127 } -
code/trunk/src/orxonox/objects/quest/QuestHint.h
- Property svn:mergeinfo changed
r2261 r2662 28 28 29 29 /** 30 @file QuestHint.h 31 @brief 32 Definition of the QuestHint class. 30 @file 31 @brief Definition of the QuestHint class. 33 32 */ 34 33 … … 44 43 #include "QuestItem.h" 45 44 46 namespace questHintStatus47 {48 49 //! The status of the hint.50 enum Enum51 {52 inactive,53 active54 };55 56 }57 58 45 namespace orxonox 59 46 { 47 namespace questHintStatus 48 { 49 50 //! The state of the hint. 51 enum Enum 52 { 53 inactive, 54 active 55 }; 56 57 } 60 58 61 59 /** … … 96 94 private: 97 95 Quest* quest_; //!< The Quest the QuestHint belongs to. 98 std::map<const PlayerInfo*, questHintStatus::Enum> playerStatus_; //!< List of the stat us for each player, with the Player-pointer as key.96 std::map<const PlayerInfo*, questHintStatus::Enum> playerStatus_; //!< List of the states for each player, with the Player-pointer as key. 99 97 100 98 }; -
code/trunk/src/orxonox/objects/quest/QuestItem.cc
- Property svn:mergeinfo changed
r2261 r2662 28 28 29 29 /** 30 @file QuestItem.cc 31 @brief 32 Implementation of the QuestItem class. 30 @file 31 @brief Implementation of the QuestItem class. 33 32 */ 34 33 … … 40 39 #include "QuestDescription.h" 41 40 42 namespace orxonox {43 41 namespace orxonox 42 { 44 43 /** 45 44 @brief … … 99 98 @return 100 99 Returns true if the string is likely to be of the required form. 101 @todo102 Clarify form, more vigorous checks.103 100 */ 104 bool QuestItem::isId(const std::string & id)101 /*static*/ bool QuestItem::isId(const std::string & id) 105 102 { 106 103 return id.size() >= 32; -
code/trunk/src/orxonox/objects/quest/QuestItem.h
- Property svn:mergeinfo changed
r2261 r2662 28 28 29 29 /** 30 @file QuestItem.h 31 @brief 32 Definition of the QuestItem class. 33 34 The QuestItem is the parent class of Quest and QuestHint. 30 @file 31 @brief Definition of the QuestItem class. 32 The QuestItem is the parent class of Quest and QuestHint. 35 33 */ 36 34 … … 46 44 #include "core/XMLPort.h" 47 45 48 namespace orxonox { 49 50 46 namespace orxonox 47 { 51 48 /** 52 49 @brief … … 67 64 /** 68 65 @brief Returns the id of this QuestItem. 69 @return Returns the id of the QuestItem.66 @return Returns the id of the QuestItem. 70 67 */ 71 68 inline const std::string & getId(void) const 72 69 { return this->id_; } 73 /** 74 @brief Returns the QuestDescription of the QuestItem. 75 @return Returns a pointer to the QuestDescription object of the QuestItem. 76 */ 70 71 /** 72 @brief Returns the QuestDescription of the QuestItem. 73 @return Returns a pointer to the QuestDescription object of the QuestItem. 74 */ 77 75 inline const QuestDescription* getDescription(void) const 78 76 { return this->description_; } -
code/trunk/src/orxonox/objects/quest/QuestManager.cc
- Property svn:mergeinfo changed
r2261 r2662 28 28 29 29 /** 30 @file QuestManager.cc 31 @brief 32 Implementation of the QuestManager class. 30 @file 31 @brief Implementation of the QuestManager class. 33 32 */ 34 33 … … 42 41 #include "QuestHint.h" 43 42 44 namespace orxonox {45 43 namespace orxonox 44 { 46 45 //! All Quests registered by their id's. 47 46 std::map<std::string, Quest*> QuestManager::questMap_s; … … 76 75 Returns true if successful, false if not. 77 76 */ 78 bool QuestManager::registerQuest(Quest* quest)77 /*static*/ bool QuestManager::registerQuest(Quest* quest) 79 78 { 80 79 if(quest == NULL) //!< Doh! Just as if there were actual quests behind NULL-pointers. … … 108 107 Returns true if successful, false if not. 109 108 */ 110 bool QuestManager::registerHint(QuestHint* hint)109 /*static*/ bool QuestManager::registerHint(QuestHint* hint) 111 110 { 112 111 if(hint == NULL) //!< Still not liking NULL-pointers. … … 142 141 Throws an exception if the given questId is invalid. 143 142 */ 144 Quest* QuestManager::findQuest(const std::string & questId)143 /*static*/ Quest* QuestManager::findQuest(const std::string & questId) 145 144 { 146 145 if(!QuestItem::isId(questId)) //!< Check vor validity of the given id. … … 176 175 Throws an exception if the given hintId is invalid. 177 176 */ 178 QuestHint* QuestManager::findHint(const std::string & hintId)177 /*static*/ QuestHint* QuestManager::findHint(const std::string & hintId) 179 178 { 180 179 if(!QuestItem::isId(hintId)) //!< Check vor validity of the given id. -
code/trunk/src/orxonox/objects/quest/QuestManager.h
- Property svn:mergeinfo changed
r2261 r2662 28 28 29 29 /** 30 @file QuestManager.h 31 @brief 32 Definition of the QuestManager class. 30 @file 31 @brief Definition of the QuestManager class. 33 32 */ 34 33 … … 43 42 #include "core/BaseObject.h" 44 43 45 namespace orxonox {46 44 namespace orxonox 45 { 47 46 /** 48 47 @brief -
code/trunk/src/orxonox/objects/quest/Rewardable.cc
- Property svn:mergeinfo changed
r2261 r2662 28 28 29 29 /** 30 @file Rewardable.cc 31 @brief 32 Implementation of the Rewardable class. 30 @file 31 @brief Implementation of the Rewardable class. 33 32 */ 34 33 … … 38 37 #include "core/CoreIncludes.h" 39 38 40 namespace orxonox {41 39 namespace orxonox 40 { 42 41 /** 43 42 @brief -
code/trunk/src/orxonox/objects/quest/Rewardable.h
- Property svn:mergeinfo changed
r2261 r2662 28 28 29 29 /** 30 @file Rewardable.h 31 @brief 32 Definition of the Rewardable class. 30 @file 31 @brief Definition of the Rewardable class. 33 32 */ 34 33 … … 40 39 #include "core/BaseObject.h" 41 40 42 namespace orxonox {43 41 namespace orxonox 42 { 44 43 /** 45 44 @brief … … 52 51 class _OrxonoxExport Rewardable : public BaseObject 53 52 { 54 55 53 public: 56 54 Rewardable(BaseObject* creator); … … 61 59 Method to transcribe a rewardable object to the player. 62 60 Must be implemented by every class inheriting from Rewardable. 63 @param player61 @param player 64 62 A pointer to the ControllableEntity, do whatever you want with it. 65 @return63 @return 66 64 Return true if successful. 67 65 */ 68 virtual bool reward(PlayerInfo* player) = 0; //!<66 virtual bool reward(PlayerInfo* player) = 0; 69 67 70 68 }; -
code/trunk/src/orxonox/objects/weaponSystem/CMakeLists.txt
r2131 r2662 2 2 Munition.cc 3 3 Weapon.cc 4 WeaponPack.cc 4 5 WeaponSet.cc 5 6 WeaponSlot.cc … … 7 8 ) 8 9 9 #ADD_SOURCE_DIRECTORY(SRC_FILES munitions)10 #ADD_SOURCE_DIRECTORY(SRC_FILES projectiles)11 #ADD_SOURCE_DIRECTORY(SRC_FILES weapons)10 ADD_SOURCE_DIRECTORY(SRC_FILES munitions) 11 ADD_SOURCE_DIRECTORY(SRC_FILES projectiles) 12 ADD_SOURCE_DIRECTORY(SRC_FILES weapons) 12 13 13 14 ADD_SOURCE_FILES(SRC_FILES) -
code/trunk/src/orxonox/objects/weaponSystem/Munition.cc
r2097 r2662 37 37 namespace orxonox 38 38 { 39 CreateFactory(Munition); 40 39 41 Munition::Munition(BaseObject* creator) : BaseObject(creator) 40 42 { … … 46 48 } 47 49 50 unsigned int Munition::bullets() 51 { 52 if (this->bullets_ > 0) 53 return bullets_; 54 else 55 return 0; 56 } 57 58 unsigned int Munition::magazines() 59 { 60 if (this->magazines_ > 0) 61 return magazines_; 62 else 63 return 0; 64 } 65 66 void Munition::setMaxBullets(unsigned int amount) 67 { this->maxBullets_ = amount; } 68 69 void Munition::setMaxMagazines(unsigned int amount) 70 { this->maxMagazines_ = amount; } 71 72 void Munition::removeBullets(unsigned int amount) 73 { 74 if ( this->bullets_ != 0 ) 75 this->bullets_ = this->bullets_ - amount; 76 } 77 78 void Munition::removeMagazines(unsigned int amount) 79 { 80 if ( this->magazines_ != 0 ) 81 this->magazines_ = this->magazines_ - amount; 82 } 83 84 void Munition::addBullets(unsigned int amount) 85 { 86 if ( this->bullets_ == this->maxBullets_ ) 87 { 88 //cannot add bullets to actual magazine 89 } 90 else 91 this->bullets_ = this->bullets_ + amount; 92 } 93 94 void Munition::addMagazines(unsigned int amount) 95 { 96 if ( this->magazines_ == this->maxMagazines_ ) 97 { 98 //no more capacity for another magazine 99 } 100 else 101 this->magazines_ = this->magazines_ + amount; 102 } 103 104 105 void Munition::fillBullets() 106 { 107 //COUT(0) << "Munition::fillBullets maxBullets_=" << this->maxBullets_ << std::endl; 108 this->bullets_ = this->maxBullets_; 109 } 110 111 void Munition::fillMagazines() 112 { 113 this->magazines_ = this->maxMagazines_; 114 } 115 48 116 void Munition::XMLPort(Element& xmlelement, XMLPort::Mode mode) 49 117 { 50 118 SUPER(Munition, XMLPort, xmlelement, mode); 51 119 } 52 120 -
code/trunk/src/orxonox/objects/weaponSystem/Munition.h
r2106 r2662 34 34 #include "core/BaseObject.h" 35 35 36 #include "Weapon.h" 37 36 38 37 39 namespace orxonox … … 45 47 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 46 48 49 void setMaxBullets(unsigned int amount); 50 void setMaxMagazines(unsigned int amount); 51 52 void fillBullets(); 53 void fillMagazines(); 54 55 unsigned int bullets(); 56 unsigned int magazines(); 57 58 void removeBullets(unsigned int k); 59 void removeMagazines(unsigned int k); 60 void addBullets(unsigned int k); 61 void addMagazines(unsigned int k); 47 62 48 63 private: 49 64 50 65 protected: 66 unsigned int bullets_; 67 unsigned int magazines_; 68 unsigned int maxBullets_; 69 unsigned int maxMagazines_; 51 70 }; 52 71 } -
code/trunk/src/orxonox/objects/weaponSystem/Weapon.cc
r2098 r2662 37 37 namespace orxonox 38 38 { 39 Weapon::Weapon(BaseObject* creator) : BaseObject(creator) 39 CreateFactory(Weapon); 40 41 Weapon::Weapon(BaseObject* creator) : StaticEntity(creator) 40 42 { 41 43 RegisterObject(Weapon); 44 this->bulletReadyToShoot_ = true; 45 this->magazineReadyToShoot_ = true; 46 this->parentWeaponSystem_ = 0; 47 this->attachedToWeaponSlot_ = 0; 48 this->munition_ = 0; 49 this->bulletLoadingTime_ = 0; 50 this->magazineLoadingTime_ = 0; 51 this->bReloading_ = false; 42 52 43 this->loadingTime_ = 0; 44 this->munition_ = 0; 45 53 this->setObjectMode(0x0); 46 54 } 47 55 … … 50 58 } 51 59 52 void Weapon::addMunition() 60 61 void Weapon::XMLPort(Element& xmlelement, XMLPort::Mode mode) 53 62 { 63 SUPER(Weapon, XMLPort, xmlelement, mode); 64 XMLPortParam(Weapon, "munitionType", setMunitionType, getMunitionType, xmlelement, mode); 65 XMLPortParam(Weapon, "bulletLoadingTime", setBulletLoadingTime, getBulletLoadingTime, xmlelement, mode); 66 XMLPortParam(Weapon, "magazineLoadingTime", setMagazineLoadingTime, getMagazineLoadingTime, xmlelement, mode); 67 } 68 69 void Weapon::setWeapon() 70 { 71 this->munition_->fillBullets(); 72 this->munition_->fillMagazines(); 73 } 74 75 76 void Weapon::fire() 77 { 78 //COUT(0) << "LaserGun::fire, this=" << this << std::endl; 79 if ( this->bulletReadyToShoot_ && this->magazineReadyToShoot_ && !this->bReloading_) 80 { 81 //COUT(0) << "LaserGun::fire - ready to shoot" << std::endl; 82 //COUT(0) << "LaserGun::fire - bullets" << this->munition_->bullets() << std::endl; 83 this->bulletReadyToShoot_ = false; 84 if ( this->munition_->bullets() > 0) 85 { 86 //shoot 87 this->takeBullets(); 88 this->createProjectile(); 89 } 90 //if there are no bullets, but magazines 91 else if ( this->munition_->magazines() > 0 && this->munition_->bullets() == 0 ) 92 { 93 //COUT(0) << "LaserGun::fire - no bullets" << std::endl; 94 this->takeMagazines(); 95 } 96 else 97 { 98 //COUT(0) << "LaserGun::fire - no magazines" << std::endl; 99 //actions 100 } 101 } 102 else 103 { 104 //COUT(0) << "LaserGun::fire - weapon not reloaded - bullets remaining:" << this->munition_->bullets() << std::endl; 105 //actions 106 } 54 107 55 108 } 56 109 57 void Weapon::XMLPort(Element& xmlelement, XMLPort::Mode mode) 110 111 void Weapon::bulletTimer(float bulletLoadingTime) 58 112 { 59 113 //COUT(0) << "Weapon::bulletTimer started" << std::endl; 114 this->bReloading_ = true; 115 this->bulletReloadTimer_.setTimer( bulletLoadingTime , false , this , createExecutor(createFunctor(&Weapon::bulletReloaded))); 116 } 117 void Weapon::magazineTimer(float magazineLoadingTime) 118 { 119 //COUT(0) << "Weapon::magazineTimer started" << std::endl; 120 this->bReloading_ = true; 121 this->magazineReloadTimer_.setTimer( magazineLoadingTime , false , this , createExecutor(createFunctor(&Weapon::magazineReloaded))); 60 122 } 61 123 62 void Weapon:: fire()124 void Weapon::bulletReloaded() 63 125 { 126 this->bReloading_ = false; 127 this->bulletReadyToShoot_ = true; 128 } 64 129 130 void Weapon::magazineReloaded() 131 { 132 this->bReloading_ = false; 133 this->munition_->fillBullets(); 134 this->magazineReadyToShoot_ = true; 135 this->bulletReadyToShoot_ = true; 65 136 } 137 138 139 void Weapon::attachNeededMunition(std::string munitionName) 140 { 141 //COUT(0) << "Weapon::attachNeededMunition, parentWeaponSystem=" << this->parentWeaponSystem_ << std::endl; 142 //if munition type already exists attach it, else create a new one of this type and attach it to the weapon and to the WeaponSystem 143 if (this->parentWeaponSystem_) 144 { 145 //COUT(0) << "Weapon::attachNeededMunition " << munitionName << std::endl; 146 Munition* munition = this->parentWeaponSystem_->getMunitionType(munitionName); 147 if ( munition ) 148 this->munition_ = munition; 149 else 150 { 151 //create new munition with identifier 152 //COUT(0) << "Weapon::attachNeededMunition, create new Munition of Type " << munitionName << std::endl; 153 this->munitionIdentifier_ = ClassByString(munitionName); 154 this->munition_ = this->munitionIdentifier_.fabricate(this); 155 this->parentWeaponSystem_->setNewMunition(munitionName, this->munition_); 156 } 157 } 158 } 159 160 161 /*get and set functions 162 * 163 */ 164 165 void Weapon::setMunitionType(std::string munitionType) 166 { this->munitionType_ = munitionType; } 167 168 const std::string Weapon::getMunitionType() 169 { return this->munitionType_; } 170 171 void Weapon::setBulletLoadingTime(float loadingTime) 172 { this->bulletLoadingTime_ = loadingTime; } 173 174 const float Weapon::getBulletLoadingTime() 175 { return this->bulletLoadingTime_; } 176 177 void Weapon::setMagazineLoadingTime(float loadingTime) 178 { this->magazineLoadingTime_ = loadingTime; } 179 180 const float Weapon::getMagazineLoadingTime() 181 { return this->magazineLoadingTime_; } 182 183 184 Munition * Weapon::getAttachedMunition(std::string munitionType) 185 { 186 //COUT(0) << "Weapon::getAttachedMunition, parentWeaponSystem_="<< this->parentWeaponSystem_ << std::endl; 187 this->munition_ = this->parentWeaponSystem_->getMunitionType(munitionType); 188 //COUT(0) << "Weapon::getAttachedMunition, munition_="<< this->munition_ << std::endl; 189 return this->munition_; 190 } 191 192 void Weapon::takeBullets() { }; 193 void Weapon::createProjectile() { }; 194 void Weapon::takeMagazines() { }; 195 66 196 } -
code/trunk/src/orxonox/objects/weaponSystem/Weapon.h
r2106 r2662 33 33 34 34 #include "core/BaseObject.h" 35 #include "tools/BillboardSet.h" 36 #include "tools/Timer.h" 37 #include "core/Identifier.h" 35 38 39 #include "WeaponSystem.h" 40 #include "Munition.h" 41 42 #include "objects/worldentities/StaticEntity.h" 36 43 37 44 namespace orxonox 38 45 { 39 class _OrxonoxExport Weapon : public BaseObject46 class _OrxonoxExport Weapon : public StaticEntity 40 47 { 41 48 public: … … 45 52 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 46 53 47 void addMunition();48 54 virtual void fire(); 55 void attachNeededMunition(std::string munitionType); 56 Munition * getAttachedMunition(std::string munitiontype); 57 58 //reloading 59 void bulletTimer(float bulletLoadingTime); 60 void magazineTimer(float magazineLoadingTime); 61 void bulletReloaded(); 62 void magazineReloaded(); 63 64 virtual void setMunitionType(std::string munitionType); 65 virtual const std::string getMunitionType(); 66 virtual void setBulletLoadingTime(float loadingTime); 67 virtual const float getBulletLoadingTime(); 68 virtual void setMagazineLoadingTime(float loadingTime); 69 virtual const float getMagazineLoadingTime(); 70 71 virtual void takeBullets(); 72 virtual void takeMagazines(); 73 virtual void createProjectile(); 74 75 inline void setParentWeaponSystem(WeaponSystem *parentWeaponSystem) 76 { this->parentWeaponSystem_=parentWeaponSystem; }; 77 inline WeaponSystem * getParentWeaponSystem() 78 { return this->parentWeaponSystem_; }; 79 80 inline void setAttachedToWeaponSlot(WeaponSlot * wSlot) 81 { this->attachedToWeaponSlot_ = wSlot; } 82 inline WeaponSlot * getAttachedToWeaponSlot() 83 { return this->attachedToWeaponSlot_; } 84 85 virtual void setWeapon(); 49 86 50 87 private: 51 int loadingTime_;52 Munition *munition_;53 88 89 protected: 90 bool bReloading_; 91 bool bulletReadyToShoot_; 92 bool magazineReadyToShoot_; 93 float bulletLoadingTime_; 94 float magazineLoadingTime_; 95 std::string munitionType_; 54 96 97 WeaponSlot * attachedToWeaponSlot_; 98 Munition * munition_; 99 WeaponSystem * parentWeaponSystem_; 55 100 101 SubclassIdentifier<Munition> munitionIdentifier_; 102 103 Timer<Weapon> bulletReloadTimer_; 104 Timer<Weapon> magazineReloadTimer_; 56 105 }; 57 106 } -
code/trunk/src/orxonox/objects/weaponSystem/WeaponSet.cc
r2098 r2662 33 33 #include "core/XMLPort.h" 34 34 #include "util/Debug.h" 35 #include "objects/worldentities/pawns/Pawn.h" 35 36 36 37 #include "WeaponSet.h" 38 #include "WeaponPack.h" 37 39 38 40 namespace orxonox 39 41 { 42 CreateFactory(WeaponSet); 43 40 44 WeaponSet::WeaponSet(BaseObject* creator, int k) : BaseObject(creator) 41 45 { … … 43 47 44 48 this->parentWeaponSystem_ = 0; 45 46 for (int i=0;i<k;i++) 47 { 48 attachWeaponSlot(new WeaponSlot(this)); 49 } 49 this->attachedWeaponPack_ = 0; 50 50 } 51 51 … … 54 54 } 55 55 56 //Vorwärtsdeklaration 57 WeaponSystem * parentWeaponSystem_; 56 void WeaponSet::attachWeaponPack(WeaponPack *wPack) 57 { 58 //COUT(0) << "WeaponSet::attachWeaponPack" << std::endl; 59 //COUT(0) << "........ parentWeaponSystem_=" << this->parentWeaponSystem_ << std::endl; 60 //COUT(0) << "........ this->parentWeaponSystem_->getWeaponSlotSize()" << this->parentWeaponSystem_->getWeaponSlotSize() << std::endl; 61 //COUT(0) << "........ wPack->getSize()" << wPack->getSize() << std::endl; 62 if ( this->parentWeaponSystem_->getWeaponSlotSize()>0 && wPack->getSize()>0 && ( wPack->getSize() <= this->parentWeaponSystem_->getWeaponSlotSize() ) ) 63 { 64 //COUT(0) << "WeaponSet::attachWeaponPack after if" << std::endl; 65 this->attachedWeaponPack_ = wPack; 66 int wPackWeapon = 0; //WeaponCounter for Attaching 67 //should be possible to choose which slot to use 68 for ( int i=0; i < wPack->getSize() ; i++ ) 69 { 70 //at the moment this function only works for one weaponPack in the entire WeaponSystem... 71 if ( this->parentWeaponSystem_->getWeaponSlotPointer(i)->getAttachedWeapon() == 0 && this->parentWeaponSystem_->getWeaponSlotPointer(i) != 0) //if slot not full 72 { 73 //COUT(0) << "WeaponSet::attachWeaponPack attaching Weapon" << std::endl; 74 this->setWeaponSlots_.push_back( this->parentWeaponSystem_->getWeaponSlotPointer(i) ); 75 this->parentWeaponSystem_->getWeaponSlotPointer(i)->attachWeapon( wPack->getWeaponPointer(wPackWeapon) ); 76 this->parentWeaponSystem_->getParentPawn()->attach( wPack->getWeaponPointer(wPackWeapon) ); 77 wPackWeapon++; 78 } 79 else 80 { 81 for (int k=0; k < this->parentWeaponSystem_->getWeaponSlotSize(); k++) 82 { 83 if ( this->parentWeaponSystem_->getWeaponSlotPointer(k)->getAttachedWeapon() == 0 ) 84 { 85 //COUT(0) << "WeaponSet::attachWeaponPack mode 2 k="<< k << std::endl; 86 this->setWeaponSlots_.push_back( this->parentWeaponSystem_->getWeaponSlotPointer(k) ); 87 this->parentWeaponSystem_->getWeaponSlotPointer(k)->attachWeapon( wPack->getWeaponPointer(wPackWeapon) ); 88 this->parentWeaponSystem_->getParentPawn()->attach( wPack->getWeaponPointer(wPackWeapon) ); 89 wPackWeapon++; 90 } 91 } 92 } 93 } 94 } 95 } 58 96 59 void WeaponSet::attachWeaponSlot(WeaponSlot *wSlot)60 {61 this->weaponSlots_.push_back(wSlot);62 }63 97 64 98 void WeaponSet::fire() 65 99 { 66 for (int i=0; i < (int) this->weaponSlots_.size(); i++)67 { 68 this->weaponSlots_[i]->fire();69 }100 //fires all WeaponSlots available for this weaponSet attached from the WeaponPack 101 //COUT(0) << "WeaponSet::fire from Pack: " << this->attachedWeaponPack_ << std::endl; 102 if (this->attachedWeaponPack_) 103 this->attachedWeaponPack_->fire(); 70 104 } 71 105 72 WeaponSlot * WeaponSet::getWeaponSlotPointer(unsigned int n) 73 { 74 if (n < this->weaponSlots_.size()) 75 return this->weaponSlots_[n]; 76 else 77 return 0; 78 } 106 void WeaponSet::setFireMode(const unsigned int firemode) 107 { this->firemode_ = firemode; } 79 108 109 const unsigned int WeaponSet::getFireMode() const 110 { return this->firemode_; } 80 111 81 112 void WeaponSet::XMLPort(Element& xmlelement, XMLPort::Mode mode) 82 113 { 83 114 SUPER(WeaponSet, XMLPort, xmlelement, mode); 115 XMLPortParam(WeaponSet, "firemode", setFireMode, getFireMode, xmlelement, mode); 84 116 } 85 117 -
code/trunk/src/orxonox/objects/weaponSystem/WeaponSet.h
r2106 r2662 48 48 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 49 49 50 void attachWeapon Slot(WeaponSlot *wSlot);50 void attachWeaponPack(WeaponPack *wPack); 51 51 void fire(); 52 WeaponSlot * getWeaponSlotPointer(unsigned int n); 52 53 void setFireMode(const unsigned int firemode); 54 const unsigned int getFireMode() const; 53 55 54 56 inline void setParentWeaponSystem(WeaponSystem *parentWeaponSystem) … … 58 60 59 61 private: 60 std::vector<WeaponSlot *> weaponSlots_;61 62 WeaponSystem *parentWeaponSystem_; 63 std::vector<WeaponSlot *> setWeaponSlots_; 64 unsigned int firemode_; 65 WeaponPack * attachedWeaponPack_; 62 66 }; 63 67 } -
code/trunk/src/orxonox/objects/weaponSystem/WeaponSlot.cc
r2098 r2662 36 36 37 37 38 39 38 namespace orxonox 40 39 { 41 WeaponSlot::WeaponSlot(BaseObject* creator) : BaseObject(creator) 40 CreateFactory(WeaponSlot); 41 42 WeaponSlot::WeaponSlot(BaseObject* creator) : StaticEntity(creator) 42 43 { 43 44 RegisterObject(WeaponSlot); 44 45 45 46 this->unlimitedAmmo_ = false; 46 47 47 this->attachedWeapon_ = 0; 48 this-> parentWeaponSet_ = 0;48 this->setObjectMode(0x0); 49 49 } 50 50 … … 53 53 } 54 54 55 void WeaponSlot::attachWeapon(Weapon *weaponName)56 {57 58 }59 55 60 56 /*sets the munition type … … 67 63 } 68 64 65 69 66 void WeaponSlot::fire() 70 67 { 68 if ( this->attachedWeapon_ ) 69 //COUT(0) << "WeaponSlot::fire" << std::endl; 70 this->attachedWeapon_->fire(); 71 } 71 72 72 }73 73 74 74 void WeaponSlot::XMLPort(Element& xmlelement, XMLPort::Mode mode) 75 75 { 76 SUPER(WeaponSlot, XMLPort, xmlelement, mode); 77 } 76 78 79 void WeaponSlot::attachWeapon(Weapon *weapon) 80 { 81 this->attachedWeapon_ = weapon; 82 weapon->setAttachedToWeaponSlot(this); 83 //COUT(0) << "WeaponSlot::attachWeapon position=" << this->getWorldPosition() << std::endl; 84 weapon->setPosition(this->getPosition()); 85 } 86 87 Weapon * WeaponSlot::getAttachedWeapon() const 88 { 89 return this->attachedWeapon_; 77 90 } 78 91 } -
code/trunk/src/orxonox/objects/weaponSystem/WeaponSlot.h
r2106 r2662 32 32 #include "OrxonoxPrereqs.h" 33 33 34 #include "core/BaseObject.h"35 36 37 34 #include "Weapon.h" 38 35 #include "objects/worldentities/StaticEntity.h" 39 36 40 37 namespace orxonox 41 38 { 42 class _OrxonoxExport WeaponSlot : public BaseObject39 class _OrxonoxExport WeaponSlot : public StaticEntity 43 40 { 44 41 public: … … 48 45 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 49 46 50 void attachWeapon(Weapon *weaponName); 47 void attachWeapon(Weapon *weapon); 48 Weapon * getAttachedWeapon() const; 51 49 void setAmmoType(bool isUnlimited); 52 50 void fire(); 53 51 54 inline void setParentWeaponSet(WeaponSet *parentWeaponSet) 55 { parentWeaponSet_=parentWeaponSet; } 56 inline WeaponSet * getParentWeaponSet() 57 { return parentWeaponSet_; } 58 52 inline void setParentWeaponSystem(WeaponSystem *parentWeaponSystem) 53 { parentWeaponSystem_=parentWeaponSystem; } 54 inline WeaponSystem * getParentWeaponSystem() 55 { return parentWeaponSystem_; } 59 56 60 57 … … 63 60 bool unlimitedAmmo_; 64 61 65 WeaponS et *parentWeaponSet_;62 WeaponSystem *parentWeaponSystem_; 66 63 }; 67 64 } -
code/trunk/src/orxonox/objects/weaponSystem/WeaponSystem.cc
- Property svn:mergeinfo changed
r2261 r2662 37 37 #include "WeaponSystem.h" 38 38 39 39 40 /* WEAPONSYSTEM 40 41 * creates the WeaponSystem and the ability to use weapons and munition … … 45 46 namespace orxonox 46 47 { 48 CreateFactory(WeaponSystem); 49 47 50 WeaponSystem::WeaponSystem(BaseObject* creator) : BaseObject(creator) 48 51 { … … 50 53 51 54 this->activeWeaponSet_ = 0; 52 this->parent SpaceShip_ = 0;55 this->parentPawn_ = 0; 53 56 } 54 57 … … 57 60 } 58 61 59 //creates empty weaponSet 62 void WeaponSystem::attachWeaponPack(WeaponPack *wPack, unsigned int firemode) 63 { 64 if (firemode < this->weaponSets_.size()) 65 this->weaponSets_[firemode]->attachWeaponPack(wPack); 66 this->weaponPacks_.push_back(wPack); 67 } 68 69 void WeaponSystem::attachWeaponSlot(WeaponSlot *wSlot) 70 { 71 wSlot->setParentWeaponSystem(this); 72 this->weaponSlots_.push_back(wSlot); 73 } 74 60 75 void WeaponSystem::attachWeaponSet(WeaponSet *wSet) 61 76 { 77 wSet->setParentWeaponSystem(this); 62 78 this->weaponSets_.push_back(wSet); 63 wSet->setParentWeaponSystem(this);64 79 } 65 80 81 void WeaponSystem::setNewMunition(std::string munitionType, Munition * munitionToAdd) 82 { 83 this->munitionSet_[munitionType] = munitionToAdd; 84 } 85 86 //returns the Pointer to the munitionType 87 Munition * WeaponSystem::getMunitionType(std::string munitionType) 88 { 89 //COUT(0) << "WeaponSystem::getMunitionType " << munitionType << std::endl; 90 std::map<std::string, Munition *>::const_iterator it = this->munitionSet_.find(munitionType); 91 if (it != this->munitionSet_.end()) 92 return it->second; 93 else 94 return 0; 95 } 96 97 98 /* 66 99 //the first weaponSet is at n=0 67 100 void WeaponSystem::setActiveWeaponSet(unsigned int n) … … 69 102 if (n < this->weaponSets_.size()) 70 103 this->activeWeaponSet_ = this->weaponSets_[n]; 104 else 105 this->activeWeaponSet_ = this->weaponSets_[0]; 106 } 107 */ 108 109 110 //n is the n'th weaponSet, starting with zero 111 //SpaceShip.cc only needs to have the keybinding to a specific Set-number n 112 void WeaponSystem::fire(WeaponMode::Enum n) 113 { 114 int set = 0; 115 switch (n) 116 { 117 case WeaponMode::fire: 118 set = 0; 119 break; 120 case WeaponMode::altFire: 121 set = 1; 122 break; 123 case WeaponMode::altFire2: 124 set = 2; 125 break; 126 } 127 //COUT(0) << "WeaponSystem::fire" << std::endl; 128 if (set < (int)this->weaponSets_.size()) 129 //COUT(0) << "WeaponSystem::fire - after if" << std::endl; 130 this->weaponSets_[set]->fire(); 71 131 } 72 132 73 //n is the n'th weaponSet, starting with zero74 //Spaceship.cc only needs to have the keybinding to a specific Set-number n75 void WeaponSystem::fire(unsigned int n)76 {77 if (n < this->weaponSets_.size())78 this->weaponSets_[n]->fire();79 }80 81 void WeaponSystem::fire()82 {83 if (this->activeWeaponSet_)84 this->activeWeaponSet_->fire();85 }86 133 87 134 WeaponSet * WeaponSystem::getWeaponSetPointer(unsigned int n) … … 93 140 } 94 141 142 WeaponSlot * WeaponSystem::getWeaponSlotPointer(unsigned int n) 143 { 144 if (n < this->weaponSlots_.size()) 145 return this->weaponSlots_[n]; 146 else 147 return 0; 148 } 149 150 WeaponPack * WeaponSystem::getWeaponPackPointer(unsigned int n) 151 { 152 if (n < this->weaponPacks_.size()) 153 return this->weaponPacks_[n]; 154 else 155 return 0; 156 } 157 95 158 void WeaponSystem::XMLPort(Element& xmlelement, XMLPort::Mode mode) 96 159 { 97 160 SUPER(WeaponSystem, XMLPort, xmlelement, mode); 98 161 } 99 162 -
code/trunk/src/orxonox/objects/weaponSystem/WeaponSystem.h
- Property svn:mergeinfo changed
r2261 r2662 36 36 37 37 #include "WeaponSet.h" 38 #include "WeaponPack.h" 38 39 39 40 namespace orxonox 40 41 { 42 41 43 class _OrxonoxExport WeaponSystem : public BaseObject 42 44 { … … 47 49 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 48 50 51 void attachWeaponSlot(WeaponSlot *wSlot); 49 52 void attachWeaponSet(WeaponSet *wSet); 50 void fire(); 51 void fire(unsigned int n); 52 void setActiveWeaponSet(unsigned int n); 53 //void fire(); 54 void fire(WeaponMode::Enum fireMode); 55 //void setActiveWeaponSet(unsigned int n); 56 void attachWeaponPack(WeaponPack * wPack, unsigned int firemode); 53 57 WeaponSet * getWeaponSetPointer(unsigned int n); 58 WeaponSlot * getWeaponSlotPointer(unsigned int n); 59 WeaponPack * getWeaponPackPointer(unsigned int n); 60 void setNewMunition(std::string munitionType, Munition * munitionToAdd); 61 Munition * getMunitionType(std::string munitionType); 54 62 55 inline void setParent SpaceShip(SpaceShip *parentSpaceShip)56 { parent SpaceShip_=parentSpaceShip; }57 inline SpaceShip * getParentSpaceShip()58 { return parent SpaceShip_; }63 inline void setParentPawn(Pawn *parentPawn) 64 { parentPawn_=parentPawn; } 65 inline Pawn * getParentPawn() 66 { return parentPawn_; } 59 67 68 inline int getWeaponSlotSize() 69 { return this->weaponSlots_.size(); } 60 70 61 71 private: 62 72 std::vector<WeaponSet *> weaponSets_; 73 std::vector<WeaponSlot *> weaponSlots_; 74 std::vector<WeaponPack *> weaponPacks_; 75 std::map<std::string, Munition *> munitionSet_; 63 76 WeaponSet *activeWeaponSet_; 64 65 SpaceShip *parentSpaceShip_; 77 Pawn *parentPawn_; 66 78 }; 67 79 } -
code/trunk/src/orxonox/objects/weaponSystem/munitions/LaserGunMunition.cc
r2097 r2662 37 37 namespace orxonox 38 38 { 39 LaserGunMunition::LaserGunMunition(BaseObject* creator) : BaseObject(creator) 39 CreateFactory(LaserGunMunition); 40 41 LaserGunMunition::LaserGunMunition(BaseObject* creator) : Munition(creator) 40 42 { 41 43 RegisterObject(LaserGunMunition); 44 45 this->maxBullets_ = 40; 46 this->maxMagazines_ = 100; 42 47 } 43 48 -
code/trunk/src/orxonox/objects/weaponSystem/munitions/LaserGunMunition.h
r2106 r2662 33 33 34 34 #include "core/BaseObject.h" 35 35 #include "../Munition.h" 36 36 37 37 namespace orxonox 38 38 { 39 class _OrxonoxExport LaserGunMunition : public BaseObject39 class _OrxonoxExport LaserGunMunition : public Munition 40 40 { 41 41 public: … … 47 47 48 48 private: 49 int bullets_;50 int magazines_;51 int maxBullets_;52 int maxMagazines_;53 49 54 50 -
code/trunk/src/orxonox/objects/weaponSystem/projectiles/BillboardProjectile.cc
r2099 r2662 30 30 #include "BillboardProjectile.h" 31 31 32 #include <OgreBillboard .h>32 #include <OgreBillboardSet.h> 33 33 34 #include "core/Core.h" 34 35 #include "core/CoreIncludes.h" 36 #include "objects/Scene.h" 35 37 36 38 namespace orxonox … … 38 40 CreateFactory(BillboardProjectile); 39 41 40 BillboardProjectile::BillboardProjectile(BaseObject* creator , Weapon* owner) : Projectile(creator, owner)42 BillboardProjectile::BillboardProjectile(BaseObject* creator) : Projectile(creator) 41 43 { 42 44 RegisterObject(BillboardProjectile); 43 45 44 this->billboard_.setBillboardSet("Examples/Flare", ColourValue(1.0, 1.0, 0.5), 1); 45 this->attachObject(this->billboard_.getBillboardSet()); 46 this->scale(0.5); 46 if (Core::showsGraphics()) 47 { 48 assert(this->getScene()->getSceneManager()); // getScene() was already checked by WorldEntity 49 this->billboard_.setBillboardSet(this->getScene()->getSceneManager(), "Examples/Flare", ColourValue(0.5, 0.5, 0.7, 0.8), 1); 50 this->attachOgreObject(this->billboard_.getBillboardSet()); 51 } 52 53 this->setScale(0.2); 47 54 } 48 55 49 56 BillboardProjectile::~BillboardProjectile() 50 57 { 51 if (this->isInitialized() && this->owner_)52 this->detachO bject(this->billboard_.getBillboardSet());58 if (this->isInitialized() && Core::showsGraphics() && this->billboard_.getBillboardSet()) 59 this->detachOgreObject(this->billboard_.getBillboardSet()); 53 60 } 54 61 55 62 void BillboardProjectile::setColour(const ColourValue& colour) 56 63 { 57 this->billboard_. getBillboardSet()->getBillboard(0)->setColour(colour);64 this->billboard_.setColour(colour); 58 65 } 59 66 … … 61 68 { 62 69 SUPER(BillboardProjectile, changedVisibility); 70 63 71 this->billboard_.setVisible(this->isVisible()); 64 72 } -
code/trunk/src/orxonox/objects/weaponSystem/projectiles/BillboardProjectile.h
r2099 r2662 41 41 { 42 42 public: 43 BillboardProjectile(BaseObject* creator , Weapon* owner = 0);43 BillboardProjectile(BaseObject* creator); 44 44 virtual ~BillboardProjectile(); 45 45 -
code/trunk/src/orxonox/objects/weaponSystem/projectiles/ParticleProjectile.cc
r2099 r2662 30 30 #include "ParticleProjectile.h" 31 31 32 #include "SpaceShip.h" 32 #include <OgreParticleSystem.h> 33 #include <OgreParticleEmitter.h> 34 35 #include "core/Core.h" 33 36 #include "core/CoreIncludes.h" 34 37 #include "core/ConfigValueIncludes.h" 38 #include "objects/Scene.h" 35 39 36 40 namespace orxonox … … 38 42 CreateFactory(ParticleProjectile); 39 43 40 ParticleProjectile::ParticleProjectile(BaseObject* creator , Weapon* owner) : BillboardProjectile(creator, owner)44 ParticleProjectile::ParticleProjectile(BaseObject* creator) : BillboardProjectile(creator) 41 45 { 42 46 RegisterObject(ParticleProjectile); 43 47 44 this->particles_ = new ParticleInterface("Orxonox/shot2", LODParticle::normal); 45 this->particles_->addToSceneNode(this->getNode()); 46 this->particles_->setKeepParticlesInLocalSpace(true); 47 if (this->owner_) 48 if (Core::showsGraphics()) 48 49 { 50 this->particles_ = new ParticleInterface(this->getScene()->getSceneManager(), "Orxonox/shot3_small", LODParticle::normal); 51 this->attachOgreObject(this->particles_->getParticleSystem()); 52 this->particles_->setKeepParticlesInLocalSpace(0); 53 54 this->particles_->getAllEmitters()->setDirection(-WorldEntity::FRONT); 49 55 } 50 // else 51 // { 52 // this->particles_ = 0; 53 // } 54 55 this->setConfigValues(); 56 else 57 this->particles_ = 0; 56 58 } 57 59 … … 59 61 { 60 62 if (this->isInitialized() && this->particles_) 63 { 64 this->detachOgreObject(this->particles_->getParticleSystem()); 61 65 delete this->particles_; 62 } 63 64 void ParticleProjectile::setConfigValues() 65 { 66 SetConfigValue(speed_, 5000.0).description("The speed of a projectile in units per second").callback((Projectile*)this, &ParticleProjectile::speedChanged); 66 } 67 67 } 68 68 … … 70 70 { 71 71 SUPER(ParticleProjectile, changedVisibility); 72 this->particles_->setEnabled(this->isVisible());73 }74 72 75 bool ParticleProjectile::create(){ 76 if(!Projectile::create()) 77 return false; 78 this->particles_->getAllEmitters()->setDirection(-this->getOrientation()*Vector3(1,0,0)); 79 return true; 73 if (this->particles_) 74 this->particles_->setEnabled(this->isVisible()); 80 75 } 81 76 } -
code/trunk/src/orxonox/objects/weaponSystem/projectiles/ParticleProjectile.h
r2099 r2662 41 41 { 42 42 public: 43 ParticleProjectile(BaseObject* creator , Weapon* owner = 0);43 ParticleProjectile(BaseObject* creator); 44 44 virtual ~ParticleProjectile(); 45 45 virtual void changedVisibility(); 46 void setConfigValues();47 48 virtual bool create();49 46 50 47 private: -
code/trunk/src/orxonox/objects/weaponSystem/projectiles/Projectile.cc
r2100 r2662 40 40 #include "objects/worldentities/Model.h" 41 41 #include "objects/worldentities/ParticleSpawner.h" 42 #include "Settings.h" 42 #include "objects/collisionshapes/SphereCollisionShape.h" 43 #include "core/Core.h" 43 44 44 45 namespace orxonox 45 46 { 46 float Projectile::speed_s = 5000; 47 48 Projectile::Projectile(BaseObject* creator, Weapon* owner) : MovableEntity(creator), owner_(owner) 47 Projectile::Projectile(BaseObject* creator) : MovableEntity(creator) 49 48 { 50 49 RegisterObject(Projectile); 51 50 52 51 this->setConfigValues(); 53 this-> explosionTemplateName_ = "Orxonox/explosion3";54 this-> smokeTemplateName_ = "Orxonox/smoke4";52 this->bDestroy_ = false; 53 this->owner_ = 0; 55 54 56 this->setStatic(false); 57 this->translate(Vector3(55, 0, 0), Ogre::Node::TS_LOCAL); 55 // Get notification about collisions 58 56 59 if ( this->owner_)57 if (Core::isMaster()) 60 58 { 61 this->setOrientation(this->owner_->getOrientation()); 62 this->setPosition(this->owner_->getPosition()); 63 this->setVelocity(this->owner_->getInitialDir() * this->speed_); 59 this->enableCollisionCallback(); 60 61 this->setCollisionType(Kinematic); 62 63 SphereCollisionShape* shape = new SphereCollisionShape(this); 64 shape->setRadius(10); 65 this->attachCollisionShape(shape); 66 67 this->destroyTimer_.setTimer(this->lifetime_, false, this, createExecutor(createFunctor(&Projectile::destroyObject))); 64 68 } 65 66 if(!orxonox::Settings::isClient()) //only if not on client67 this->destroyTimer_.setTimer(this->lifetime_, false, this, createExecutor(createFunctor(&Projectile::destroyObject)));68 69 } 69 70 … … 76 77 SetConfigValue(damage_, 15.0).description("The damage caused by the projectile"); 77 78 SetConfigValue(lifetime_, 4.0).description("The time in seconds a projectile stays alive"); 78 SetConfigValue(speed_, 5000.0).description("The speed of a projectile in units per second").callback(this, &Projectile::speedChanged);79 79 } 80 80 81 void Projectile::speedChanged()82 {83 Projectile::speed_s = this->speed_;84 if (this->owner_)85 this->setVelocity(this->owner_->getInitialDir() * this->speed_);86 }87 81 88 82 void Projectile::tick(float dt) … … 93 87 return; 94 88 95 float radius; 96 for (ObjectList<Model>::iterator it = ObjectList<Model>::begin(); it; ++it) 97 { 98 // if ((*it) != this->owner_) 99 { 100 radius = it->getScale3D().x * 3.0; 101 102 if (this->getPosition().squaredDistance(it->getPosition()) <= (radius*radius)) 103 { 104 // hit 105 ParticleSpawner* explosion = new ParticleSpawner(this->explosionTemplateName_, LODParticle::low, 2.0); 106 explosion->setPosition(this->getPosition()); 107 explosion->create(); 108 ParticleSpawner* smoke = new ParticleSpawner(this->smokeTemplateName_, LODParticle::normal, 2.0, 0.0); 109 smoke->setPosition(this->getPosition()); 110 // smoke->getParticleInterface()->setSpeedFactor(3.0); 111 smoke->create(); 112 delete this; 113 return; 114 } 115 } 116 } 89 if (this->bDestroy_) 90 delete this; 117 91 } 118 92 119 93 void Projectile::destroyObject() 120 94 { 121 delete this; 95 if (Core::isMaster()) 96 delete this; 122 97 } 123 98 124 bool Projectile::create(){ 125 return WorldEntity::create(); 99 bool Projectile::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint) 100 { 101 if (!this->bDestroy_ && Core::isMaster()) 102 { 103 this->bDestroy_ = true; 104 105 if (this->owner_) 106 { 107 { 108 ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator()); 109 effect->setPosition(this->getPosition()); 110 effect->setOrientation(this->getOrientation()); 111 effect->setDestroyAfterLife(true); 112 effect->setSource("Orxonox/explosion3"); 113 effect->setLifetime(2.0f); 114 } 115 { 116 ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator()); 117 effect->setPosition(this->getPosition()); 118 effect->setOrientation(this->getOrientation()); 119 effect->setDestroyAfterLife(true); 120 effect->setSource("Orxonox/smoke4"); 121 effect->setLifetime(3.0f); 122 } 123 } 124 125 Pawn* victim = dynamic_cast<Pawn*>(otherObject); 126 if (victim) 127 victim->damage(this->damage_, this->owner_); 128 } 129 return false; 130 } 131 132 void Projectile::destroyedPawn(Pawn* pawn) 133 { 134 if (this->owner_ == pawn) 135 this->owner_ = 0; 126 136 } 127 137 } -
code/trunk/src/orxonox/objects/weaponSystem/projectiles/Projectile.h
r2099 r2662 33 33 34 34 #include "objects/worldentities/MovableEntity.h" 35 #include "objects/worldentities/pawns/Pawn.h" 35 36 #include "tools/Timer.h" 36 37 37 38 namespace orxonox 38 39 { 39 class _OrxonoxExport Projectile : public MovableEntity 40 class _OrxonoxExport Projectile : public MovableEntity, public PawnListener 40 41 { 41 42 public: 43 Projectile(BaseObject* creator); 42 44 virtual ~Projectile(); 45 43 46 void setConfigValues(); 44 void speedChanged();45 47 void destroyObject(); 48 46 49 virtual void tick(float dt); 50 virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint); 51 virtual void destroyedPawn(Pawn* pawn); 47 52 48 virtual bool create(); 49 50 static float getSpeed() 51 { return Projectile::speed_s; } 52 53 protected: 54 Projectile(BaseObject* creator, Weapon* owner = 0); 55 SpaceShip* owner_; 53 inline void setOwner(Pawn* owner) 54 { this->owner_ = owner; } 55 inline Pawn* getOwner() const 56 { return this->owner_; } 56 57 57 58 private: 58 std::string explosionTemplateName_; 59 std::string smokeTemplateName_; 60 protected: 61 static float speed_s; 62 float speed_; 63 private: 59 Pawn* owner_; 64 60 float lifetime_; 65 61 float damage_; 62 bool bDestroy_; 66 63 Timer<Projectile> destroyTimer_; 67 64 }; -
code/trunk/src/orxonox/objects/weaponSystem/weapons/CMakeLists.txt
r2131 r2662 1 1 SET( SRC_FILES 2 Fusion.cc 2 3 LaserGun.cc 3 Missile.cc4 # Missile.cc 4 5 ) 5 6 -
code/trunk/src/orxonox/objects/weaponSystem/weapons/LaserGun.cc
r2097 r2662 34 34 #include "util/Debug.h" 35 35 36 #include "LaserGun.h" 37 36 38 37 39 namespace orxonox 38 40 { 41 CreateFactory(LaserGun); 42 39 43 LaserGun::LaserGun(BaseObject* creator) : Weapon(creator) 40 44 { 41 45 RegisterObject(LaserGun); 42 46 43 projectileColor_ = ColourValue(1.0, 1.0, 0.5) 47 this->speed_ = 1250; 48 44 49 } 45 50 … … 48 53 } 49 54 50 LaserGun::fire()55 void LaserGun::takeBullets() 51 56 { 52 BillboardProjectile* projectile = new ParticleProjectile(this); 53 projectile->setColour(this->projectileColor_); 54 projectile->create(); 55 if (projectile->getClassID() == 0) 56 { 57 COUT(3) << "generated projectile with classid 0" << std::endl; // TODO: remove this output 58 } 59 60 projectile->setObjectMode(0x3); 57 //COUT(0) << "LaserGun::takeBullets" << std::endl; 58 this->munition_->removeBullets(1); 59 this->bulletTimer(this->bulletLoadingTime_); 61 60 } 62 61 63 LaserGun::addMunition()62 void LaserGun::takeMagazines() 64 63 { 65 //this->munition_ = ; 64 this->munition_->removeMagazines(1); 65 this->magazineTimer(this->magazineLoadingTime_); 66 66 } 67 67 68 void LaserGun:: XMLPort(Element& xmlelement, XMLPort::Mode mode)68 void LaserGun::createProjectile() 69 69 { 70 71 }72 73 ColorValue LaserGun::getProjectileColor()74 {75 return projectileColor_;70 //COUT(0) << "LaserGun::createProjectile" << std::endl; 71 BillboardProjectile* projectile = new ParticleProjectile(this); 72 projectile->setOrientation(this->getWorldOrientation()); 73 projectile->setPosition(this->getWorldPosition()); 74 projectile->setVelocity(this->getWorldOrientation() * WorldEntity::FRONT * this->speed_); 75 projectile->setOwner(this->getParentWeaponSystem()->getParentPawn()); 76 76 } 77 77 } -
code/trunk/src/orxonox/objects/weaponSystem/weapons/LaserGun.h
r2106 r2662 34 34 #include "core/BaseObject.h" 35 35 36 #include "LaserGunMunition.h" 37 #include "tools/BillboardSet.h" 36 #include "../munitions/LaserGunMunition.h" 38 37 #include "util/Math.h" 38 #include "../Weapon.h" 39 #include "../projectiles/BillboardProjectile.h" 40 #include "../projectiles/ParticleProjectile.h" 39 41 40 42 namespace orxonox … … 46 48 virtual ~LaserGun(); 47 49 48 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);49 50 ColourValue LaserGun::getProjectileColour();50 virtual void takeBullets(); 51 virtual void takeMagazines(); 52 virtual void createProjectile(); 51 53 52 54 private: 53 ColorValue projectileColor_; 54 55 55 float speed_; 56 56 57 57 }; -
code/trunk/src/orxonox/objects/worldentities/Backlight.cc
- Property svn:mergeinfo changed
r2261 r2662 30 30 #include "Backlight.h" 31 31 32 #include <OgreBillboard.h>33 32 #include <OgreRibbonTrail.h> 34 33 #include <OgreSceneManager.h> 35 34 35 #include "core/Core.h" 36 36 #include "core/CoreIncludes.h" 37 #include "core/ConfigValueIncludes.h"38 37 #include "core/Executor.h" 39 #include "util/Math.h" 40 #include "GraphicsEngine.h" 38 #include "core/XMLPort.h" 39 #include "objects/Scene.h" 40 #include "util/Exception.h" 41 41 42 42 namespace orxonox … … 44 44 CreateFactory(Backlight); 45 45 46 float Backlight::timeFactor_s = 1.0; 47 48 Backlight::Backlight(float maxspeed, float brakingtime, float scale) 46 Backlight::Backlight(BaseObject* creator) : FadingBillboard(creator) 49 47 { 50 48 RegisterObject(Backlight); 51 49 52 this->setConfigValues(); 53 this->traillength_ = 1; 54 55 this->configure(maxspeed, brakingtime, scale); 56 } 57 58 bool Backlight::create(){ 59 if(!WorldEntity::create()) 60 return false; 61 62 this->getNode()->setInheritScale(false); 63 64 this->billboard_.setBillboardSet("Flares/backlightflare"); 65 this->attachObject(this->billboard_.getBillboardSet()); 66 67 this->ribbonTrail_ = GraphicsEngine::getInstance().getLevelSceneManager()->createRibbonTrail(this->getName() + "RibbonTrail"); 68 this->ribbonTrailNode_ = GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->createChildSceneNode(this->getName() + "RibbonTrailNode"); 69 this->ribbonTrailNode_->attachObject(this->ribbonTrail_); 70 this->ribbonTrail_->addNode(this->getNode()); 71 72 73 this->ribbonTrail_->setTrailLength(this->maxTraillength_); 74 this->ribbonTrail_->setMaterialName("Trail/backlighttrail"); 75 76 //this->setTimeFactor(Orxonox::getInstance().getTimeFactor()); 77 this->setTimeFactor(1.0f); 78 79 this->ribbonTrail_->setMaxChainElements(this->maxTrailsegments_); 80 this->ribbonTrail_->setTrailLength(this->traillength_ = 2 * this->maxTrailsegments_); 81 this->ribbonTrail_->setInitialWidth(0, this->width_ * this->getScale()); 82 this->ribbonTrail_->setWidthChange(0, this->width_ * this->getScale() / this->maxLifeTime_ * Backlight::timeFactor_s); 83 return true; 50 this->ribbonTrail_ = 0; 51 this->ribbonTrailNode_ = 0; 52 53 this->width_ = 0; 54 this->length_ = 1.0f; 55 this->lifetime_ = 0.001f; 56 this->maxelements_ = 1; 57 58 this->tickcount_ = 0; 59 60 if (Core::showsGraphics()) 61 { 62 if (!this->getScene()) 63 ThrowException(AbortLoading, "Can't create Backlight, no scene given."); 64 if (!this->getScene()->getSceneManager()) 65 ThrowException(AbortLoading, "Can't create Backlight, no scene manager given."); 66 if (!this->getScene()->getRootSceneNode()) 67 ThrowException(AbortLoading, "Can't create Backlight, no root scene node given."); 68 69 this->ribbonTrail_ = this->getScene()->getSceneManager()->createRibbonTrail(this->getNode()->getName()); 70 71 this->ribbonTrailNode_ = this->getScene()->getRootSceneNode()->createChildSceneNode(); 72 this->ribbonTrailNode_->attachObject(this->ribbonTrail_); 73 74 this->ribbonTrail_->setMaxChainElements(this->maxelements_); 75 this->ribbonTrail_->setTrailLength(this->length_); 76 this->ribbonTrail_->setInitialWidth(0, 0); 77 } 78 79 this->registerVariables(); 84 80 } 85 81 … … 88 84 if (this->isInitialized()) 89 85 { 90 this->detachObject(this->billboard_.getBillboardSet()); 91 GraphicsEngine::getInstance().getLevelSceneManager()->destroySceneNode(this->getName() + "RibbonTrailNode"); 92 GraphicsEngine::getInstance().getLevelSceneManager()->destroyRibbonTrail(this->ribbonTrail_); 93 } 94 } 95 96 void Backlight::setConfigValues() 97 { 98 SetConfigValue(maxLifeTime_, 4.0).description("The maximal amount of seconds the trail behind a SpaceShip stays visible"); 99 SetConfigValue(trailSegmentLength_, 50).description("The length of one segment of the trail behind a SpaceShip (lower values make it more smooth)"); 100 SetConfigValue(width_, 7.0).description("The width of the trail"); 101 } 102 103 void Backlight::setTimeFactor(float factor) 104 { 105 Backlight::timeFactor_s = factor; 106 float change = Backlight::timeFactor_s / this->maxLifeTime_; 107 this->ribbonTrail_->setWidthChange(0, this->width_ * change); 108 this->updateColourChange(); 109 } 110 111 void Backlight::updateColourChange() 112 { 113 this->ribbonTrail_->setColourChange(0, ColourValue(0, 0, 0, this->maxTraillength_ / this->traillength_ / this->maxLifeTime_ * Backlight::timeFactor_s)); 114 } 115 116 117 void Backlight::XMLPort(Element& xmlelement, XMLPort::Mode mode){ 118 SUPER(Backlight, XMLPort, xmlelement, mode); 119 120 Backlight::create(); 86 if (this->ribbonTrail_) 87 { 88 if (this->ribbonTrailNode_) 89 { 90 this->ribbonTrailNode_->detachObject(this->ribbonTrail_); 91 this->getScene()->getSceneManager()->destroySceneNode(this->ribbonTrailNode_->getName()); 92 } 93 this->getScene()->getSceneManager()->destroyRibbonTrail(this->ribbonTrail_); 94 } 95 } 96 } 97 98 void Backlight::XMLPort(Element& xmlelement, XMLPort::Mode mode) 99 { 100 SUPER(Backlight, XMLPort, xmlelement, mode); 101 102 XMLPortParam(Backlight, "length", setLength, getLength, xmlelement, mode).defaultValues(100.0f); 103 XMLPortParam(Backlight, "width", setWidth, getWidth, xmlelement, mode).defaultValues(1.0f); 104 XMLPortParam(Backlight, "elements", setMaxElements, getMaxElements, xmlelement, mode).defaultValues(10); 105 XMLPortParam(Backlight, "lifetime", setLifetime, getLifetime, xmlelement, mode).defaultValues(1.0f); 106 XMLPortParam(Backlight, "trailmaterial", setTrailMaterial, getTrailMaterial, xmlelement, mode); 107 } 108 109 void Backlight::registerVariables() 110 { 111 registerVariable(this->width_, variableDirection::toclient, new NetworkCallback<Backlight>(this, &Backlight::update_width)); 112 registerVariable(this->lifetime_, variableDirection::toclient, new NetworkCallback<Backlight>(this, &Backlight::update_lifetime)); 113 registerVariable(this->length_, variableDirection::toclient, new NetworkCallback<Backlight>(this, &Backlight::update_length)); 114 registerVariable(this->maxelements_, variableDirection::toclient, new NetworkCallback<Backlight>(this, &Backlight::update_maxelements)); 115 registerVariable(this->trailmaterial_, variableDirection::toclient, new NetworkCallback<Backlight>(this, &Backlight::update_trailmaterial)); 116 } 117 118 void Backlight::changedColour() 119 { 120 FadingBillboard::changedColour(); 121 122 if (this->ribbonTrail_ && this->tickcount_ >= 2) 123 this->ribbonTrail_->setInitialColour(0, this->getFadedColour()); 124 } 125 126 void Backlight::update_width() 127 { 128 if (this->ribbonTrail_ && this->tickcount_ >= 2) 129 this->ribbonTrail_->setInitialWidth(0, this->width_ * this->getWorldScale()); 130 this->update_lifetime(); 131 } 132 133 void Backlight::update_lifetime() 134 { 135 if (this->ribbonTrail_ && this->tickcount_ >= 2) 136 { 137 this->ribbonTrail_->setWidthChange(0, this->width_ * this->getWorldScale() / this->lifetime_ * this->getTimeFactor()); 138 this->ribbonTrail_->setColourChange(0, 0, 0, 0, 1.0f / this->lifetime_ * this->getTimeFactor()); 139 } 140 } 141 142 void Backlight::update_length() 143 { 144 if (this->ribbonTrail_ && this->tickcount_ >= 2) 145 this->ribbonTrail_->setTrailLength(this->length_ * this->getWorldScale()); 146 } 147 148 void Backlight::update_maxelements() 149 { 150 if (this->ribbonTrail_ && this->tickcount_ >= 2) 151 this->ribbonTrail_->setMaxChainElements(this->maxelements_); 152 } 153 154 void Backlight::update_trailmaterial() 155 { 156 if (this->ribbonTrail_ && this->tickcount_ >= 2) 157 this->ribbonTrail_->setMaterialName(this->trailmaterial_); 158 } 159 160 void Backlight::changedVisibility() 161 { 162 SUPER(Backlight, changedVisibility); 163 164 if (this->ribbonTrail_) 165 this->ribbonTrail_->setVisible(this->isVisible()); 166 } 167 168 void Backlight::startturnonoff() 169 { 170 FadingBillboard::startturnonoff(); 171 172 if (this->ribbonTrail_ && this->isActive() && this->isVisible()) 173 this->ribbonTrail_->setVisible(true); 174 } 175 176 void Backlight::stopturnonoff() 177 { 178 this->postprocessingtime_ = max(0.0f, this->lifetime_ - this->turnofftime_); 179 180 FadingBillboard::stopturnonoff(); 181 182 if (this->ribbonTrail_) 183 this->ribbonTrail_->setInitialColour(0, this->getFadedColour()); 184 } 185 186 void Backlight::poststopturnonoff() 187 { 188 FadingBillboard::poststopturnonoff(); 189 190 if (this->ribbonTrail_) 191 this->ribbonTrail_->setVisible(false); 192 } 193 194 void Backlight::changedScale() 195 { 196 SUPER(Backlight, changedScale); 197 198 this->update_width(); 199 this->update_length(); 121 200 } 122 201 123 202 void Backlight::tick(float dt) 124 203 { 204 if (this->tickcount_ < 2) 205 { 206 ++this->tickcount_; 207 if (this->tickcount_ == 2) 208 { 209 this->changedColour(); 210 this->update_width(); 211 this->update_lifetime(); 212 this->update_length(); 213 this->update_maxelements(); 214 this->update_trailmaterial(); 215 if (this->ribbonTrail_) 216 this->ribbonTrail_->addNode(this->node_); 217 } 218 } 219 125 220 SUPER(Backlight, tick, dt); 126 221 127 if (this->isActive()) 128 { 129 if (this->traillength_ < this->maxTraillength_) 130 { 131 this->traillength_ = min<float>(this->maxTraillength_, this->traillength_ + dt * this->maxTraillength_ / this->maxLifeTime_); 132 this->updateColourChange(); 133 } 134 } 135 else 136 { 137 if (this->traillength_ > 1) 138 { 139 this->traillength_ = max<float>(1, this->traillength_ - this->brakefactor_ * dt * this->maxTraillength_ / this->maxLifeTime_); 140 this->updateColourChange(); 141 } 142 } 143 144 this->ribbonTrail_->setTrailLength(this->traillength_); 145 } 146 147 void Backlight::setColour(const ColourValue& colour) 148 { 149 this->billboard_.getBillboardSet()->getBillboard(0)->setColour(colour); 150 this->ribbonTrail_->setInitialColour(0, ColourValue(colour.r / 4 + 0.75, colour.g / 4 + 0.75, colour.b / 4 + 0.75)); 151 } 152 153 void Backlight::configure(float maxspeed, float brakingtime, float scale) 154 { 155 this->maxTraillength_ = this->maxLifeTime_ * maxspeed; 156 this->maxTrailsegments_ = (size_t)(this->maxTraillength_ / this->trailSegmentLength_); 157 158 this->brakefactor_ = this->maxLifeTime_ / brakingtime; 159 160 this->scale(scale); 161 } 162 163 void Backlight::changedVisibility() 164 { 165 SUPER(Backlight, changedVisibility); 166 167 this->billboard_.setVisible(this->isVisible()); 168 this->ribbonTrail_->setVisible(this->isVisible()); 222 if (this->ribbonTrail_ && this->changedirection_ != 0) 223 { 224 // we use alpha_blend, only adjust alpha 225 const ColourValue& colour = this->getColour(); 226 this->ribbonTrail_->setInitialColour(0, colour.r, colour.g, colour.b, this->getFadedColour().a); 227 } 228 } 229 230 void Backlight::changedTimeFactor(float factor_new, float factor_old) 231 { 232 this->update_lifetime(); 169 233 } 170 234 } -
code/trunk/src/orxonox/objects/worldentities/Backlight.h
- Property svn:mergeinfo changed
r2261 r2662 31 31 32 32 #include "OrxonoxPrereqs.h" 33 34 #include "PositionableEntity.h" 35 #include "tools/BillboardSet.h" 33 #include "FadingBillboard.h" 34 #include "gamestates/GSRoot.h" 36 35 37 36 namespace orxonox 38 37 { 39 class _OrxonoxExport Backlight : public PositionableEntity38 class _OrxonoxExport Backlight : public FadingBillboard, public TimeFactorListener 40 39 { 41 40 public: 42 Backlight( float maxspeed = 1.0, float brakingtime = 1.0, float scale = 1.0);41 Backlight(BaseObject* creator); 43 42 virtual ~Backlight(); 44 43 45 void setConfigValues();46 44 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 45 void registerVariables(); 46 47 47 virtual void tick(float dt); 48 48 virtual void changedVisibility(); 49 virtual bool create();50 49 51 void setColour(const ColourValue& colour); 52 void setTimeFactor(float factor); 50 inline void setWidth(float width) 51 { this->width_ = width; this->update_width(); } 52 inline float getWidth() const 53 { return this->width_; } 54 55 inline void setLifetime(float lifetime) 56 { this->lifetime_ = lifetime; this->update_lifetime(); } 57 inline float getLifetime() const 58 { return this->lifetime_; } 59 60 inline void setLength(float length) 61 { this->length_ = length; this->update_length(); } 62 inline float getLength() const 63 { return this->length_; } 64 65 inline void setMaxElements(size_t maxelements) 66 { this->maxelements_ = maxelements; this->update_maxelements(); } 67 inline size_t getMaxElements() const 68 { return this->maxelements_; } 69 70 inline void setTrailMaterial(const std::string& material) 71 { this->trailmaterial_ = material; this->update_trailmaterial(); } 72 inline const std::string& getTrailMaterial() const 73 { return this->trailmaterial_; } 74 75 virtual void changedScale(); 76 77 protected: 78 virtual void changedTimeFactor(float factor_new, float factor_old); 53 79 54 80 private: 55 void configure(float maxspeed, float brakingtime, float scale = 1); 56 void updateColourChange(); 81 virtual void startturnonoff(); 82 virtual void stopturnonoff(); 83 virtual void poststopturnonoff(); 84 virtual void changedColour(); 85 void update_width(); 86 void update_lifetime(); 87 void update_length(); 88 void update_maxelements(); 89 void update_trailmaterial(); 57 90 58 static float timeFactor_s; 59 BillboardSet billboard_; 91 Ogre::RibbonTrail* ribbonTrail_; 60 92 Ogre::SceneNode* ribbonTrailNode_; 61 Ogre::RibbonTrail* ribbonTrail_;62 63 float maxLifeTime_;64 float trailSegmentLength_;65 93 float width_; 66 67 float brakefactor_; 68 69 float maxTraillength_; 70 float traillength_; 71 72 size_t maxTrailsegments_; 94 float length_; 95 float lifetime_; 96 size_t maxelements_; 97 std::string trailmaterial_; 98 char tickcount_; 73 99 }; 74 100 } -
code/trunk/src/orxonox/objects/worldentities/Billboard.cc
r2171 r2662 30 30 #include "Billboard.h" 31 31 32 #include <OgreBillboardSet.h> 33 32 34 #include "core/CoreIncludes.h" 33 35 #include "core/XMLPort.h" 36 #include "core/Core.h" 34 37 #include "objects/Scene.h" 35 38 … … 38 41 CreateFactory(Billboard); 39 42 40 Billboard::Billboard(BaseObject* creator) : PositionableEntity(creator)43 Billboard::Billboard(BaseObject* creator) : StaticEntity(creator) 41 44 { 42 45 RegisterObject(Billboard); 46 47 this->material_ = ""; 48 this->colour_ = ColourValue::White; 43 49 44 50 this->registerVariables(); … … 50 56 { 51 57 if (this->isInitialized() && this->billboard_.getBillboardSet()) 52 this-> getNode()->detachObject(this->billboard_.getName());58 this->detachOgreObject(this->billboard_.getBillboardSet()); 53 59 } 54 60 } … … 64 70 void Billboard::registerVariables() 65 71 { 66 REGISTERSTRING(this->material_, direction::toclient, new NetworkCallback<Billboard>(this, &Billboard::changedMaterial));67 REGISTERDATA (this->colour_, direction::toclient, new NetworkCallback<Billboard>(this, &Billboard::changedColour));72 registerVariable(this->material_, variableDirection::toclient, new NetworkCallback<Billboard>(this, &Billboard::changedMaterial)); 73 registerVariable(this->colour_, variableDirection::toclient, new NetworkCallback<Billboard>(this, &Billboard::changedColour)); 68 74 } 69 75 70 76 void Billboard::changedMaterial() 71 77 { 78 if (this->material_ == "") 79 return; 80 72 81 if (!this->billboard_.getBillboardSet()) 73 82 { 74 if (this->getScene() && this->getScene()->getSceneManager())83 if (this->getScene() && Core::showsGraphics()) 75 84 { 76 85 this->billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->material_, this->colour_, 1); 77 86 if (this->billboard_.getBillboardSet()) 78 this->getNode()->attachObject(this->billboard_.getBillboardSet());87 this->attachOgreObject(this->billboard_.getBillboardSet()); 79 88 this->billboard_.setVisible(this->isVisible()); 80 89 } … … 88 97 if (!this->billboard_.getBillboardSet()) 89 98 { 90 if (this->getScene() && this->getScene()->getSceneManager()) 99 /* 100 if (this->getScene() && Core::showsGraphics() && (this->material_ != "")) 91 101 { 92 102 this->billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->material_, this->colour_, 1); 93 103 if (this->billboard_.getBillboardSet()) 94 this-> getNode()->attachObject(this->billboard_.getBillboardSet());104 this->attachOgreObject(this->billboard_.getBillboardSet()); 95 105 this->billboard_.setVisible(this->isVisible()); 96 106 } 107 */ 97 108 } 98 109 else -
code/trunk/src/orxonox/objects/worldentities/Billboard.h
r2087 r2662 31 31 32 32 #include "OrxonoxPrereqs.h" 33 #include " PositionableEntity.h"33 #include "StaticEntity.h" 34 34 #include "util/Math.h" 35 35 #include "tools/BillboardSet.h" … … 37 37 namespace orxonox 38 38 { 39 class _OrxonoxExport Billboard : public PositionableEntity39 class _OrxonoxExport Billboard : public StaticEntity 40 40 { 41 41 public: … … 61 61 { return this->colour_; } 62 62 63 protected: 64 inline BillboardSet& getBillboardSet() 65 { return this->billboard_; } 66 67 virtual void changedColour(); 68 63 69 private: 64 70 void changedMaterial(); 65 void changedColour();66 71 67 72 BillboardSet billboard_; -
code/trunk/src/orxonox/objects/worldentities/BlinkingBillboard.cc
r2171 r2662 68 68 void BlinkingBillboard::registerVariables() 69 69 { 70 // REGISTERDATA(this->amplitude_, direction::toclient);71 // REGISTERDATA(this->frequency_, direction::toclient);72 // REGISTERDATA(this->phase_, direction::toclient);70 // registerVariable(this->amplitude_, variableDirection::toclient); 71 // registerVariable(this->frequency_, variableDirection::toclient); 72 // registerVariable(this->phase_, variableDirection::toclient); 73 73 } 74 74 75 75 void BlinkingBillboard::tick(float dt) 76 76 { 77 SUPER(BlinkingBillboard, tick, dt); 78 77 79 if (Core::isMaster() && this->isActive()) 78 80 { -
code/trunk/src/orxonox/objects/worldentities/CMakeLists.txt
r2131 r2662 1 1 SET( SRC_FILES 2 2 WorldEntity.cc 3 PositionableEntity.cc3 StaticEntity.cc 4 4 MovableEntity.cc 5 MobileEntity.cc 5 6 ControllableEntity.cc 6 Model.cc 7 8 Backlight.cc 7 9 Billboard.cc 8 10 BlinkingBillboard.cc 11 ExplosionChunk.cc 12 FadingBillboard.cc 9 13 Light.cc 10 14 Camera.cc 11 15 CameraPosition.cc 12 SpawnPoint.cc16 Model.cc 13 17 ParticleEmitter.cc 14 18 ParticleSpawner.cc 15 # Backlight.cc 19 Planet.cc 20 SpawnPoint.cc 16 21 ) 17 22 -
code/trunk/src/orxonox/objects/worldentities/Camera.cc
- Property svn:mergeinfo changed
r2261 r2662 36 36 #include <OgreSceneManager.h> 37 37 #include <OgreSceneNode.h> 38 #include <OgreViewport.h>39 38 40 39 #include "util/Exception.h" … … 48 47 CreateFactory(Camera); 49 48 50 Camera::Camera(BaseObject* creator) : PositionableEntity(creator)49 Camera::Camera(BaseObject* creator) : StaticEntity(creator) 51 50 { 52 51 RegisterObject(Camera); 53 52 54 if (!this->getScene() || !this->getScene()->getSceneManager()) 55 ThrowException(AbortLoading, "Can't create Camera, no scene or no scene manager given."); 53 if (!this->getScene()) 54 ThrowException(AbortLoading, "Can't create Camera, no scene."); 55 if (!this->getScene()->getSceneManager()) 56 ThrowException(AbortLoading, "Can't create Camera, no scene-manager given."); 57 if (!this->getScene()->getRootSceneNode()) 58 ThrowException(AbortLoading, "Can't create Camera, no root-scene-node given."); 56 59 57 60 this->camera_ = this->getScene()->getSceneManager()->createCamera(getUniqueNumberString()); 58 this->getNode()->attachObject(this->camera_); 61 this->cameraNode_ = this->getScene()->getRootSceneNode()->createChildSceneNode(); 62 this->attachNode(this->cameraNode_); 63 this->cameraNode_->attachObject(this->camera_); 59 64 60 65 this->bHasFocus_ = false; … … 66 71 this->setConfigValues(); 67 72 this->configvaluecallback_changedNearClipDistance(); 68 69 this->requestFocus(); // ! HACK ! REMOVE THIS !70 73 } 71 74 … … 75 78 { 76 79 this->releaseFocus(); 80 81 this->cameraNode_->detachAllObjects(); 82 this->getScene()->getSceneManager()->destroyCamera(this->camera_); 83 84 if (this->bDrag_) 85 this->detachNode(this->cameraNode_); 86 87 if (this->getScene()->getSceneManager()) 88 this->getScene()->getSceneManager()->destroySceneNode(this->cameraNode_->getName()); 77 89 } 78 90 } … … 90 102 void Camera::tick(float dt) 91 103 { 92 /* 93 // this stuff here may need some adjustments 94 float coeff = (this->bDrag_) ? min(1.0f, 15.0f * dt) : (1.0f); 104 SUPER(Camera, tick, dt); 95 105 96 Vector3 offset = this->getNode()->getWorldPosition() - this->cameraNode_->getWorldPosition(); 97 this->cameraNode_->translate(coeff * offset); 106 if (this->bDrag_) 107 { 108 // this stuff here may need some adjustments 109 float coeff = min(1.0f, 15.0f * dt); 98 110 99 this->cameraNode_->setOrientation(Quaternion::Slerp(coeff, this->cameraNode_->getWorldOrientation(), this->getWorldOrientation(), false)); 100 */ 111 Vector3 offset = this->getWorldPosition() - this->cameraNode_->getWorldPosition(); 112 this->cameraNode_->translate(coeff * offset); 113 114 this->cameraNode_->setOrientation(Quaternion::Slerp(coeff, this->cameraNode_->getWorldOrientation(), this->getWorldOrientation(), true)); 115 //this->cameraNode_->setOrientation(this->getWorldOrientation()); 116 } 101 117 } 102 118 … … 120 136 } 121 137 122 void Camera::setFocus( Ogre::Viewport* viewport)138 void Camera::setFocus() 123 139 { 124 140 this->bHasFocus_ = true; 125 viewport->setCamera(this->camera_); 141 CameraManager::getInstance().useCamera(this->camera_); 142 } 143 144 void Camera::setDrag(bool bDrag) 145 { 146 if (bDrag != this->bDrag_) 147 { 148 this->bDrag_ = bDrag; 149 150 if (!bDrag) 151 { 152 this->attachNode(this->cameraNode_); 153 this->cameraNode_->setPosition(Vector3::ZERO); 154 this->cameraNode_->setOrientation(Quaternion::IDENTITY); 155 } 156 else 157 { 158 this->detachNode(this->cameraNode_); 159 this->cameraNode_->setPosition(this->getWorldPosition()); 160 this->cameraNode_->setOrientation(this->getWorldOrientation()); 161 } 162 } 126 163 } 127 164 } -
code/trunk/src/orxonox/objects/worldentities/Camera.h
- Property svn:mergeinfo changed
r2261 r2662 33 33 34 34 #include <OgrePrerequisites.h> 35 #include "objects/worldentities/ PositionableEntity.h"35 #include "objects/worldentities/StaticEntity.h" 36 36 #include "objects/Tickable.h" 37 37 38 38 namespace orxonox 39 39 { 40 class _OrxonoxExport Camera : public PositionableEntity, public Tickable40 class _OrxonoxExport Camera : public StaticEntity, public Tickable 41 41 { 42 42 friend class CameraManager; … … 55 55 { return this->bHasFocus_; } 56 56 57 inline void setDrag(bool bDrag) 58 { this->bDrag_ = bDrag; } 57 void setDrag(bool bDrag); 59 58 inline bool getDrag() const 60 59 { return this->bDrag_; } … … 62 61 private: 63 62 void removeFocus(); 64 void setFocus( Ogre::Viewport* viewport);63 void setFocus(); 65 64 void configvaluecallback_changedNearClipDistance(); 66 65 67 Ogre::Camera* camera_; 68 float nearClipDistance_; 69 bool bHasFocus_; 70 bool bDrag_; 66 Ogre::Camera* camera_; 67 Ogre::SceneNode* cameraNode_; 68 float nearClipDistance_; 69 bool bHasFocus_; 70 bool bDrag_; 71 71 }; 72 72 } -
code/trunk/src/orxonox/objects/worldentities/CameraPosition.cc
r2087 r2662 38 38 CreateFactory(CameraPosition); 39 39 40 CameraPosition::CameraPosition(BaseObject* creator) : PositionableEntity(creator)40 CameraPosition::CameraPosition(BaseObject* creator) : StaticEntity(creator) 41 41 { 42 42 RegisterObject(CameraPosition); 43 43 44 44 this->bDrag_ = false; 45 this->bAllowMouseLook_ = false; 45 46 46 47 this->setObjectMode(0x0); … … 56 57 57 58 XMLPortParam(CameraPosition, "drag", setDrag, getDrag, xmlelement, mode).defaultValues(false); 59 XMLPortParam(CameraPosition, "mouselook", setAllowMouseLook, getAllowMouseLook, xmlelement, mode).defaultValues(false); 58 60 } 59 61 60 62 void CameraPosition::attachCamera(Camera* camera) 61 63 { 62 camera->setDrag(this->bDrag_); 64 if (!this->bDrag_) 65 camera->setDrag(false); 66 63 67 this->attach(camera); 68 69 if (this->bDrag_) 70 camera->setDrag(true); 64 71 } 65 72 } -
code/trunk/src/orxonox/objects/worldentities/CameraPosition.h
r2087 r2662 32 32 #include "OrxonoxPrereqs.h" 33 33 34 #include "objects/worldentities/ PositionableEntity.h"34 #include "objects/worldentities/StaticEntity.h" 35 35 36 36 namespace orxonox 37 37 { 38 class _OrxonoxExport CameraPosition : public PositionableEntity38 class _OrxonoxExport CameraPosition : public StaticEntity 39 39 { 40 40 public: … … 49 49 { return this->bDrag_; } 50 50 51 inline void setAllowMouseLook(bool bAllow) 52 { this->bAllowMouseLook_ = bAllow; } 53 inline bool getAllowMouseLook() const 54 { return this->bAllowMouseLook_; } 55 51 56 void attachCamera(Camera* camera); 52 57 53 58 private: 54 59 bool bDrag_; 60 bool bAllowMouseLook_; 55 61 }; 56 62 } -
code/trunk/src/orxonox/objects/worldentities/ControllableEntity.cc
r2171 r2662 23 23 * Fabian 'x3n' Landau 24 24 * Co-authors: 25 * ...25 * Reto Grieder 26 26 * 27 27 */ … … 30 30 #include "ControllableEntity.h" 31 31 32 #include <OgreSceneManager.h> 33 32 34 #include "core/CoreIncludes.h" 35 #include "core/ConfigValueIncludes.h" 33 36 #include "core/Core.h" 34 37 #include "core/XMLPort.h" 35 38 #include "core/Template.h" 36 39 40 #include "objects/Scene.h" 37 41 #include "objects/infos/PlayerInfo.h" 38 42 #include "objects/worldentities/Camera.h" 39 43 #include "objects/worldentities/CameraPosition.h" 44 #include "objects/gametypes/Gametype.h" 40 45 #include "overlays/OverlayGroup.h" 41 46 … … 44 49 CreateFactory(ControllableEntity); 45 50 46 ControllableEntity::ControllableEntity(BaseObject* creator) : WorldEntity(creator)51 ControllableEntity::ControllableEntity(BaseObject* creator) : MobileEntity(creator) 47 52 { 48 53 RegisterObject(ControllableEntity); 49 54 50 this->bControlled_ = false; 55 this->bHasLocalController_ = false; 56 this->bHasHumanController_ = false; 57 51 58 this->server_overwrite_ = 0; 52 59 this->client_overwrite_ = 0; … … 56 63 this->camera_ = 0; 57 64 this->bDestroyWhenPlayerLeft_ = false; 58 59 this->velocity_ = Vector3::ZERO; 60 this->acceleration_ = Vector3::ZERO; 61 62 this->server_position_ = Vector3::ZERO; 63 this->client_position_ = Vector3::ZERO; 64 this->server_velocity_ = Vector3::ZERO; 65 this->client_velocity_ = Vector3::ZERO; 66 this->server_orientation_ = Quaternion::IDENTITY; 67 this->client_orientation_ = Quaternion::IDENTITY; 68 65 this->cameraPositionRootNode_ = this->node_->createChildSceneNode(); 66 this->bMouseLook_ = false; 67 this->mouseLookSpeed_ = 200; 68 69 this->gtinfo_ = 0; 70 this->gtinfoID_ = OBJECTID_UNKNOWN; 71 this->changedGametype(); 72 73 this->server_position_ = Vector3::ZERO; 74 this->client_position_ = Vector3::ZERO; 75 this->server_linear_velocity_ = Vector3::ZERO; 76 this->client_linear_velocity_ = Vector3::ZERO; 77 this->server_orientation_ = Quaternion::IDENTITY; 78 this->client_orientation_ = Quaternion::IDENTITY; 79 this->server_angular_velocity_ = Vector3::ZERO; 80 this->client_angular_velocity_ = Vector3::ZERO; 81 82 83 this->setConfigValues(); 84 this->setPriority( priority::very_high ); 69 85 this->registerVariables(); 70 86 } … … 74 90 if (this->isInitialized()) 75 91 { 76 if (this->bControlled_) 77 this->stopLocalControl(); 92 this->bDestroyWhenPlayerLeft_ = false; 93 94 if (this->bHasLocalController_ && this->bHasHumanController_) 95 this->stopLocalHumanControl(); 96 97 if (this->getPlayer() && this->getPlayer()->getControllableEntity() == this) 98 this->getPlayer()->stopControl(this, false); 78 99 79 100 if (this->hud_) … … 83 104 delete this->camera_; 84 105 85 if (this->getPlayer() && this->getPlayer()->getControllableEntity() == this) 86 this->getPlayer()->stopControl(this, false); 106 for (std::list<CameraPosition*>::const_iterator it = this->cameraPositions_.begin(); it != this->cameraPositions_.end(); ++it) 107 delete (*it); 108 109 if (this->getScene()->getSceneManager()) 110 this->getScene()->getSceneManager()->destroySceneNode(this->cameraPositionRootNode_->getName()); 87 111 } 88 112 } … … 98 122 } 99 123 124 void ControllableEntity::setConfigValues() 125 { 126 SetConfigValue(mouseLookSpeed_, 3.0f); 127 } 128 129 void ControllableEntity::changedGametype() 130 { 131 //SUPER(ControllableEntity, changedGametype); 132 WorldEntity::changedGametype(); 133 134 this->gtinfo_ = 0; 135 this->gtinfoID_ = OBJECTID_UNKNOWN; 136 137 if (this->getGametype() && this->getGametype()->getGametypeInfo()) 138 { 139 this->gtinfo_ = this->getGametype()->getGametypeInfo(); 140 this->gtinfoID_ = this->gtinfo_->getObjectID(); 141 } 142 } 143 100 144 void ControllableEntity::addCameraPosition(CameraPosition* position) 101 145 { 102 this->attach(position); 146 if (position->getAllowMouseLook()) 147 position->attachToNode(this->cameraPositionRootNode_); 148 else 149 this->attach(position); 103 150 this->cameraPositions_.push_back(position); 104 151 } … … 141 188 else 142 189 { 143 this-> attach(this->camera_);190 this->camera_->attachToNode(this->cameraPositionRootNode_); 144 191 } 145 192 } 193 } 194 195 void ControllableEntity::mouseLook() 196 { 197 this->bMouseLook_ = !this->bMouseLook_; 198 199 if (!this->bMouseLook_) 200 this->cameraPositionRootNode_->setOrientation(Quaternion::IDENTITY); 201 } 202 203 void ControllableEntity::rotateYaw(const Vector2& value) 204 { 205 if (this->bMouseLook_) 206 this->cameraPositionRootNode_->yaw(Radian(value.y * this->mouseLookSpeed_), Ogre::Node::TS_LOCAL); 207 } 208 209 void ControllableEntity::rotatePitch(const Vector2& value) 210 { 211 if (this->bMouseLook_) 212 this->cameraPositionRootNode_->pitch(Radian(value.y * this->mouseLookSpeed_), Ogre::Node::TS_LOCAL); 213 } 214 215 void ControllableEntity::rotateRoll(const Vector2& value) 216 { 217 if (this->bMouseLook_) 218 this->cameraPositionRootNode_->roll(Radian(value.y * this->mouseLookSpeed_), Ogre::Node::TS_LOCAL); 146 219 } 147 220 … … 156 229 this->player_ = player; 157 230 this->playerID_ = player->getObjectID(); 158 this->bControlled_ = (player->isLocalPlayer() && player->isHumanPlayer()); 159 if (this->bControlled_) 160 { 161 this->startLocalControl(); 231 this->bHasLocalController_ = player->isLocalPlayer(); 232 this->bHasHumanController_ = player->isHumanPlayer(); 233 234 if (this->bHasLocalController_ && this->bHasHumanController_) 235 { 236 this->startLocalHumanControl(); 162 237 163 238 if (!Core::isMaster()) 164 239 { 165 240 this->client_overwrite_ = this->server_overwrite_; 166 COUT(0) << "CE: bidirectional synchronization" << std::endl; 167 this->setObjectMode(direction::bidirectional); 241 this->setObjectMode(objectDirection::bidirectional); 168 242 } 169 243 } … … 172 246 void ControllableEntity::removePlayer() 173 247 { 174 if (this->b Controlled_)175 this->stopLocal Control();248 if (this->bHasLocalController_ && this->bHasHumanController_) 249 this->stopLocalHumanControl(); 176 250 177 251 this->player_ = 0; 178 252 this->playerID_ = OBJECTID_UNKNOWN; 179 this->bControlled_ = false; 180 this->setObjectMode(direction::toclient); 253 this->bHasLocalController_ = false; 254 this->bHasHumanController_ = false; 255 this->setObjectMode(objectDirection::toclient); 181 256 182 257 if (this->bDestroyWhenPlayerLeft_) … … 195 270 } 196 271 197 void ControllableEntity::startLocalControl() 198 { 199 // std::cout << this->getObjectID() << " ###### start local control" << std::endl; 200 this->camera_ = new Camera(this); 201 this->camera_->requestFocus(); 202 if (this->cameraPositionTemplate_ != "") 203 this->addTemplate(this->cameraPositionTemplate_); 204 if (this->cameraPositions_.size() > 0) 205 this->cameraPositions_.front()->attachCamera(this->camera_); 206 else 207 this->attach(this->camera_); 208 209 if (this->hudtemplate_ != "") 210 { 211 this->hud_ = new OverlayGroup(this); 212 this->hud_->addTemplate(this->hudtemplate_); 213 } 214 } 215 216 void ControllableEntity::stopLocalControl() 217 { 218 // std::cout << "###### stop local control" << std::endl; 219 this->camera_->detachFromParent(); 220 delete this->camera_; 221 this->camera_ = 0; 222 223 delete this->hud_; 224 this->hud_ = 0; 272 void ControllableEntity::networkcallback_changedgtinfoID() 273 { 274 if (this->gtinfoID_ != OBJECTID_UNKNOWN) 275 { 276 this->gtinfo_ = dynamic_cast<GametypeInfo*>(Synchronisable::getSynchronisable(this->gtinfoID_)); 277 278 if (!this->gtinfo_) 279 this->gtinfoID_ = OBJECTID_UNKNOWN; 280 } 281 } 282 283 void ControllableEntity::startLocalHumanControl() 284 { 285 if (!this->camera_) 286 { 287 this->camera_ = new Camera(this); 288 this->camera_->requestFocus(); 289 if (this->cameraPositionTemplate_ != "") 290 this->addTemplate(this->cameraPositionTemplate_); 291 if (this->cameraPositions_.size() > 0) 292 this->cameraPositions_.front()->attachCamera(this->camera_); 293 else 294 this->camera_->attachToNode(this->cameraPositionRootNode_); 295 } 296 297 if (!this->hud_) 298 { 299 if (this->hudtemplate_ != "") 300 { 301 this->hud_ = new OverlayGroup(this); 302 this->hud_->addTemplate(this->hudtemplate_); 303 this->hud_->setOwner(this); 304 } 305 } 306 } 307 308 void ControllableEntity::stopLocalHumanControl() 309 { 310 if (this->camera_) 311 { 312 this->camera_->detachFromParent(); 313 delete this->camera_; 314 this->camera_ = 0; 315 } 316 317 if (this->hud_) 318 { 319 delete this->hud_; 320 this->hud_ = 0; 321 } 225 322 } 226 323 227 324 void ControllableEntity::tick(float dt) 228 325 { 326 MobileEntity::tick(dt); 327 229 328 if (this->isActive()) 230 329 { 231 this->velocity_ += (dt * this->acceleration_); 232 this->node_->translate(dt * this->velocity_, Ogre::Node::TS_LOCAL); 233 234 if (Core::isMaster()) 330 // Check whether Bullet doesn't do the physics for us 331 if (!this->isDynamic()) 235 332 { 236 this->server_velocity_ = this->velocity_; 237 this->server_position_ = this->node_->getPosition(); 333 if (Core::isMaster()) 334 { 335 this->server_position_ = this->getPosition(); 336 this->server_orientation_ = this->getOrientation(); 337 this->server_linear_velocity_ = this->getVelocity(); 338 this->server_angular_velocity_ = this->getAngularVelocity(); 339 } 340 else if (this->bHasLocalController_) 341 { 342 this->client_position_ = this->getPosition(); 343 this->client_orientation_ = this->getOrientation(); 344 this->client_linear_velocity_ = this->getVelocity(); 345 this->client_angular_velocity_ = this->getAngularVelocity(); 346 } 238 347 } 239 else if (this->bControlled_)240 {241 // COUT(2) << "setting client position" << endl;242 this->client_velocity_ = this->velocity_;243 this->client_position_ = this->node_->getPosition();244 }245 348 } 246 349 } … … 248 351 void ControllableEntity::registerVariables() 249 352 { 250 REGISTERSTRING(this->cameraPositionTemplate_, direction::toclient); 251 252 REGISTERDATA(this->client_overwrite_, direction::toserver); 253 254 REGISTERDATA(this->server_position_, direction::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerPosition)); 255 REGISTERDATA(this->server_velocity_, direction::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerVelocity)); 256 REGISTERDATA(this->server_orientation_, direction::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerOrientation)); 257 REGISTERDATA(this->server_overwrite_, direction::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processOverwrite)); 258 259 REGISTERDATA(this->client_position_, direction::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientPosition)); 260 REGISTERDATA(this->client_velocity_, direction::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientVelocity)); 261 REGISTERDATA(this->client_orientation_, direction::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientOrientation)); 262 263 264 REGISTERDATA(this->playerID_, direction::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedplayerID)); 353 registerVariable(this->cameraPositionTemplate_, variableDirection::toclient); 354 registerVariable(this->hudtemplate_, variableDirection::toclient); 355 356 registerVariable(this->server_position_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerPosition)); 357 registerVariable(this->server_linear_velocity_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerLinearVelocity)); 358 registerVariable(this->server_orientation_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerOrientation)); 359 registerVariable(this->server_angular_velocity_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerAngularVelocity)); 360 361 registerVariable(this->server_overwrite_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processOverwrite)); 362 registerVariable(this->client_overwrite_, variableDirection::toserver); 363 364 registerVariable(this->client_position_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientPosition)); 365 registerVariable(this->client_linear_velocity_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientLinearVelocity)); 366 registerVariable(this->client_orientation_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientOrientation)); 367 registerVariable(this->client_angular_velocity_, variableDirection::toserver, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processClientAngularVelocity)); 368 369 registerVariable(this->playerID_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedplayerID)); 370 registerVariable(this->gtinfoID_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::networkcallback_changedgtinfoID)); 265 371 } 266 372 267 373 void ControllableEntity::processServerPosition() 268 374 { 269 if (!this->b Controlled_)270 this->node_->setPosition(this->server_position_);271 } 272 273 void ControllableEntity::processServer Velocity()274 { 275 if (!this->b Controlled_)276 this->velocity_ = this->server_velocity_;375 if (!this->bHasLocalController_) 376 MobileEntity::setPosition(this->server_position_); 377 } 378 379 void ControllableEntity::processServerLinearVelocity() 380 { 381 if (!this->bHasLocalController_) 382 MobileEntity::setVelocity(this->server_linear_velocity_); 277 383 } 278 384 279 385 void ControllableEntity::processServerOrientation() 280 386 { 281 if (!this->bControlled_) 282 this->node_->setOrientation(this->server_orientation_); 387 if (!this->bHasLocalController_) 388 MobileEntity::setOrientation(this->server_orientation_); 389 } 390 391 void ControllableEntity::processServerAngularVelocity() 392 { 393 if (!this->bHasLocalController_) 394 MobileEntity::setAngularVelocity(this->server_angular_velocity_); 283 395 } 284 396 285 397 void ControllableEntity::processOverwrite() 286 398 { 287 if (this->b Controlled_)399 if (this->bHasLocalController_) 288 400 { 289 401 this->setPosition(this->server_position_); 290 this->setVelocity(this->server_velocity_);291 402 this->setOrientation(this->server_orientation_); 403 this->setVelocity(this->server_linear_velocity_); 404 this->setAngularVelocity(this->server_angular_velocity_); 292 405 293 406 this->client_overwrite_ = this->server_overwrite_; … … 299 412 if (this->server_overwrite_ == this->client_overwrite_) 300 413 { 301 // COUT(2) << "callback: setting client position" << endl; 302 this->node_->setPosition(this->client_position_); 303 this->server_position_ = this->client_position_; 304 } 305 // else 306 // COUT(2) << "callback: not setting client position" << endl; 307 } 308 309 void ControllableEntity::processClientVelocity() 414 MobileEntity::setPosition(this->client_position_); 415 this->server_position_ = this->getPosition(); 416 } 417 } 418 419 void ControllableEntity::processClientLinearVelocity() 310 420 { 311 421 if (this->server_overwrite_ == this->client_overwrite_) 312 422 { 313 this->velocity_ = this->client_velocity_;314 this->server_ velocity_ = this->client_velocity_;423 MobileEntity::setVelocity(this->client_linear_velocity_); 424 this->server_linear_velocity_ = this->getVelocity(); 315 425 } 316 426 } … … 320 430 if (this->server_overwrite_ == this->client_overwrite_) 321 431 { 322 this->node_->setOrientation(this->client_orientation_); 323 this->server_orientation_ = this->client_orientation_; 324 } 325 } 326 432 MobileEntity::setOrientation(this->client_orientation_); 433 this->server_orientation_ = this->getOrientation(); 434 } 435 } 436 437 void ControllableEntity::processClientAngularVelocity() 438 { 439 if (this->server_overwrite_ == this->client_overwrite_) 440 { 441 MobileEntity::setAngularVelocity(this->client_angular_velocity_); 442 this->server_angular_velocity_ = this->getAngularVelocity(); 443 } 444 } 327 445 328 446 void ControllableEntity::setPosition(const Vector3& position) … … 330 448 if (Core::isMaster()) 331 449 { 332 this->node_->setPosition(position);333 this->server_position_ = position;450 MobileEntity::setPosition(position); 451 this->server_position_ = this->getPosition(); 334 452 ++this->server_overwrite_; 335 453 } 336 else if (this->bControlled_) 337 { 338 this->node_->setPosition(position); 339 this->client_position_ = position; 454 else if (this->bHasLocalController_) 455 { 456 MobileEntity::setPosition(position); 457 this->client_position_ = this->getPosition(); 458 } 459 } 460 461 void ControllableEntity::setOrientation(const Quaternion& orientation) 462 { 463 if (Core::isMaster()) 464 { 465 MobileEntity::setOrientation(orientation); 466 this->server_orientation_ = this->getOrientation(); 467 ++this->server_overwrite_; 468 } 469 else if (this->bHasLocalController_) 470 { 471 MobileEntity::setOrientation(orientation); 472 this->client_orientation_ = this->getOrientation(); 340 473 } 341 474 } … … 345 478 if (Core::isMaster()) 346 479 { 347 this->velocity_ = velocity;348 this->server_ velocity_ = velocity;480 MobileEntity::setVelocity(velocity); 481 this->server_linear_velocity_ = this->getVelocity(); 349 482 ++this->server_overwrite_; 350 483 } 351 else if (this->b Controlled_)352 { 353 this->velocity_ = velocity;354 this->client_ velocity_ = velocity;355 } 356 } 357 358 void ControllableEntity:: translate(const Vector3& distance, Ogre::Node::TransformSpace relativeTo)484 else if (this->bHasLocalController_) 485 { 486 MobileEntity::setVelocity(velocity); 487 this->client_linear_velocity_ = this->getVelocity(); 488 } 489 } 490 491 void ControllableEntity::setAngularVelocity(const Vector3& velocity) 359 492 { 360 493 if (Core::isMaster()) 361 494 { 362 this->node_->translate(distance, relativeTo);363 this->server_ position_ = this->node_->getPosition();495 MobileEntity::setAngularVelocity(velocity); 496 this->server_angular_velocity_ = this->getAngularVelocity(); 364 497 ++this->server_overwrite_; 365 498 } 366 else if (this->bControlled_) 367 { 368 this->node_->translate(distance, relativeTo); 369 this->client_position_ = this->node_->getPosition(); 370 } 371 } 372 373 void ControllableEntity::setOrientation(const Quaternion& orientation) 374 { 499 else if (this->bHasLocalController_) 500 { 501 MobileEntity::setAngularVelocity(velocity); 502 this->client_angular_velocity_ = this->getAngularVelocity(); 503 } 504 } 505 506 void ControllableEntity::setWorldTransform(const btTransform& worldTrans) 507 { 508 MobileEntity::setWorldTransform(worldTrans); 375 509 if (Core::isMaster()) 376 510 { 377 this->node_->setOrientation(orientation); 378 this->server_orientation_ = orientation; 379 ++this->server_overwrite_; 380 } 381 else if (this->bControlled_) 382 { 383 this->node_->setOrientation(orientation); 384 this->client_orientation_ = orientation; 385 } 386 } 387 388 void ControllableEntity::rotate(const Quaternion& rotation, Ogre::Node::TransformSpace relativeTo) 389 { 390 if (Core::isMaster()) 391 { 392 this->node_->rotate(rotation, relativeTo); 393 this->server_orientation_ = this->node_->getOrientation(); 394 ++this->server_overwrite_; 395 } 396 else if (this->bControlled_) 397 { 398 this->node_->rotate(rotation, relativeTo); 399 this->client_orientation_ = this->node_->getOrientation(); 400 } 401 } 402 403 void ControllableEntity::yaw(const Degree& angle, Ogre::Node::TransformSpace relativeTo) 404 { 405 if (Core::isMaster()) 406 { 407 this->node_->yaw(angle, relativeTo); 408 this->server_orientation_ = this->node_->getOrientation(); 409 ++this->server_overwrite_; 410 } 411 else if (this->bControlled_) 412 { 413 this->node_->yaw(angle, relativeTo); 414 this->client_orientation_ = this->node_->getOrientation(); 415 } 416 } 417 418 void ControllableEntity::pitch(const Degree& angle, Ogre::Node::TransformSpace relativeTo) 419 { 420 if (Core::isMaster()) 421 { 422 this->node_->pitch(angle, relativeTo); 423 this->server_orientation_ = this->node_->getOrientation(); 424 ++this->server_overwrite_; 425 } 426 else if (this->bControlled_) 427 { 428 this->node_->pitch(angle, relativeTo); 429 this->client_orientation_ = this->node_->getOrientation(); 430 } 431 } 432 433 void ControllableEntity::roll(const Degree& angle, Ogre::Node::TransformSpace relativeTo) 434 { 435 if (Core::isMaster()) 436 { 437 this->node_->roll(angle, relativeTo); 438 this->server_orientation_ = this->node_->getOrientation(); 439 ++this->server_overwrite_; 440 } 441 else if (this->bControlled_) 442 { 443 this->node_->roll(angle, relativeTo); 444 this->client_orientation_ = this->node_->getOrientation(); 445 } 446 } 447 448 void ControllableEntity::lookAt(const Vector3& target, Ogre::Node::TransformSpace relativeTo, const Vector3& localDirectionVector) 449 { 450 if (Core::isMaster()) 451 { 452 this->node_->lookAt(target, relativeTo, localDirectionVector); 453 this->server_orientation_ = this->node_->getOrientation(); 454 ++this->server_overwrite_; 455 } 456 else if (this->bControlled_) 457 { 458 this->node_->lookAt(target, relativeTo, localDirectionVector); 459 this->client_orientation_ = this->node_->getOrientation(); 460 } 461 } 462 463 void ControllableEntity::setDirection(const Vector3& direction, Ogre::Node::TransformSpace relativeTo, const Vector3& localDirectionVector) 464 { 465 if (Core::isMaster()) 466 { 467 this->node_->setDirection(direction, relativeTo, localDirectionVector); 468 this->server_orientation_ = this->node_->getOrientation(); 469 ++this->server_overwrite_; 470 } 471 else if (this->bControlled_) 472 { 473 this->node_->setDirection(direction, relativeTo, localDirectionVector); 474 this->client_orientation_ = this->node_->getOrientation(); 511 this->server_position_ = this->getPosition(); 512 this->server_orientation_ = this->getOrientation(); 513 this->server_linear_velocity_ = this->getVelocity(); 514 this->server_angular_velocity_ = this->getAngularVelocity(); 515 } 516 else if (this->bHasLocalController_) 517 { 518 this->client_position_ = this->getPosition(); 519 this->client_orientation_ = this->getOrientation(); 520 this->client_linear_velocity_ = this->getVelocity(); 521 this->client_angular_velocity_ = this->getAngularVelocity(); 475 522 } 476 523 } -
code/trunk/src/orxonox/objects/worldentities/ControllableEntity.h
r2087 r2662 23 23 * Fabian 'x3n' Landau 24 24 * Co-authors: 25 * ...25 * Reto Grieder 26 26 * 27 27 */ … … 32 32 #include "OrxonoxPrereqs.h" 33 33 34 #include " WorldEntity.h"35 #include "objects/ Tickable.h"34 #include "MobileEntity.h" 35 #include "objects/weaponSystem/WeaponSystem.h" 36 36 37 37 namespace orxonox 38 38 { 39 class _OrxonoxExport ControllableEntity : public WorldEntity, public Tickable39 class _OrxonoxExport ControllableEntity : public MobileEntity 40 40 { 41 41 public: … … 46 46 virtual void tick(float dt); 47 47 void registerVariables(); 48 void setConfigValues(); 49 50 virtual void changedGametype(); 48 51 49 52 virtual void setPlayer(PlayerInfo* player); … … 61 64 virtual void moveUpDown(const Vector2& value) {} 62 65 63 virtual void rotateYaw(const Vector2& value) {}64 virtual void rotatePitch(const Vector2& value) {}65 virtual void rotateRoll(const Vector2& value) {}66 virtual void rotateYaw(const Vector2& value); 67 virtual void rotatePitch(const Vector2& value); 68 virtual void rotateRoll(const Vector2& value); 66 69 67 virtual void fire() {} 68 virtual void altFire() {} 70 inline void moveFrontBack(float value) 71 { this->moveFrontBack(Vector2(value, 0)); } 72 inline void moveRightLeft(float value) 73 { this->moveRightLeft(Vector2(value, 0)); } 74 inline void moveUpDown(float value) 75 { this->moveUpDown(Vector2(value, 0)); } 69 76 77 inline void rotateYaw(float value) 78 { this->rotateYaw(Vector2(value, 0)); } 79 inline void rotatePitch(float value) 80 { this->rotatePitch(Vector2(value, 0)); } 81 inline void rotateRoll(float value) 82 { this->rotateRoll(Vector2(value, 0)); } 83 84 virtual void fire(WeaponMode::Enum fireMode) {} 85 virtual void altFire(WeaponMode::Enum fireMode) {} 86 87 virtual void boost() {} 70 88 virtual void greet() {} 71 89 virtual void use() {} 90 virtual void dropItems() {} 72 91 virtual void switchCamera(); 92 virtual void mouseLook(); 73 93 74 inline const Vector3& getVelocity() const75 { return this->velocity_; }76 inline const Vector3& getAcceleration() const77 { return this->acceleration_; }78 94 inline const std::string& getHudTemplate() const 79 95 { return this->hudtemplate_; } 80 81 using WorldEntity::setPosition;82 using WorldEntity::translate;83 using WorldEntity::setOrientation;84 using WorldEntity::rotate;85 using WorldEntity::yaw;86 using WorldEntity::pitch;87 using WorldEntity::roll;88 using WorldEntity::lookAt;89 using WorldEntity::setDirection;90 91 void setPosition(const Vector3& position);92 void translate(const Vector3& distance, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);93 void setOrientation(const Quaternion& orientation);94 void rotate(const Quaternion& rotation, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);95 void yaw(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);96 void pitch(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);97 void roll(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL);98 void lookAt(const Vector3& target, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);99 void setDirection(const Vector3& direction, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z);100 101 void setVelocity(const Vector3& velocity);102 inline void setVelocity(float x, float y, float z)103 { this->velocity_.x = x; this->velocity_.y = y; this->velocity_.z = z; }104 105 inline void setAcceleration(const Vector3& acceleration)106 { this->acceleration_ = acceleration; }107 inline void setAcceleration(float x, float y, float z)108 { this->acceleration_.x = x; this->acceleration_.y = y; this->acceleration_.z = z; }109 96 110 97 inline Camera* getCamera() const … … 123 110 { return this->cameraPositionTemplate_; } 124 111 112 using WorldEntity::setPosition; 113 using WorldEntity::setOrientation; 114 using MobileEntity::setVelocity; 115 using MobileEntity::setAngularVelocity; 116 117 void setPosition(const Vector3& position); 118 void setOrientation(const Quaternion& orientation); 119 void setVelocity(const Vector3& velocity); 120 void setAngularVelocity(const Vector3& velocity); 121 122 inline bool hasLocalController() const 123 { return this->bHasLocalController_; } 124 inline bool hasHumanController() const 125 { return this->bHasHumanController_; } 126 127 inline const GametypeInfo* getGametypeInfo() const 128 { return this->gtinfo_; } 129 130 inline bool isInMouseLook() const 131 { return this->bMouseLook_; } 132 inline float getMouseLookSpeed() const 133 { return this->mouseLookSpeed_; } 134 125 135 protected: 126 virtual void startLocal Control();127 virtual void stopLocal Control();136 virtual void startLocalHumanControl(); 137 virtual void stopLocalHumanControl(); 128 138 129 139 inline void setHudTemplate(const std::string& name) 130 140 { this->hudtemplate_ = name; } 131 132 inline bool isLocallyControlled() const133 { return this->bControlled_; }134 135 Vector3 acceleration_;136 141 137 142 private: … … 140 145 141 146 void processServerPosition(); 142 void processServer Velocity();147 void processServerLinearVelocity(); 143 148 void processServerOrientation(); 149 void processServerAngularVelocity(); 144 150 145 151 void processClientPosition(); 146 void processClient Velocity();152 void processClientLinearVelocity(); 147 153 void processClientOrientation(); 154 void processClientAngularVelocity(); 148 155 149 156 void networkcallback_changedplayerID(); 157 void networkcallback_changedgtinfoID(); 158 159 // Bullet btMotionState related 160 void setWorldTransform(const btTransform& worldTrans); 150 161 151 162 unsigned int server_overwrite_; 152 163 unsigned int client_overwrite_; 153 164 154 Vector3 velocity_; 165 bool bHasLocalController_; 166 bool bHasHumanController_; 167 bool bDestroyWhenPlayerLeft_; 155 168 156 bool bControlled_;157 169 Vector3 server_position_; 158 170 Vector3 client_position_; 159 Vector3 server_ velocity_;160 Vector3 client_ velocity_;171 Vector3 server_linear_velocity_; 172 Vector3 client_linear_velocity_; 161 173 Quaternion server_orientation_; 162 174 Quaternion client_orientation_; 175 Vector3 server_angular_velocity_; 176 Vector3 client_angular_velocity_; 163 177 164 178 PlayerInfo* player_; 165 179 unsigned int playerID_; 180 166 181 std::string hudtemplate_; 167 182 OverlayGroup* hud_; 183 168 184 Camera* camera_; 169 bool bDestroyWhenPlayerLeft_; 170 185 bool bMouseLook_; 186 float mouseLookSpeed_; 187 Ogre::SceneNode* cameraPositionRootNode_; 171 188 std::list<CameraPosition*> cameraPositions_; 172 189 std::string cameraPositionTemplate_; 190 191 const GametypeInfo* gtinfo_; 192 unsigned int gtinfoID_; 173 193 }; 174 194 } -
code/trunk/src/orxonox/objects/worldentities/Light.cc
r2171 r2662 36 36 37 37 #include "util/String.h" 38 #include "util/Convert.h" 38 #include "util/Exception.h" 39 #include "core/Core.h" 39 40 #include "core/CoreIncludes.h" 40 41 #include "core/XMLPort.h" … … 43 44 namespace orxonox 44 45 { 45 unsigned int Light::lightCounter_s = 0;46 47 46 CreateFactory(Light); 48 47 49 Light::Light(BaseObject* creator) : PositionableEntity(creator)48 Light::Light(BaseObject* creator) : StaticEntity(creator) 50 49 { 51 50 RegisterObject(Light); 52 51 53 if (this->getScene() && this->getScene()->getSceneManager()) 54 this->light_ = this->getScene()->getSceneManager()->createLight("Light" + convertToString(Light::lightCounter_s++)); 55 this->getNode()->attachObject(this->light_); 52 this->light_ = 0; 53 this->diffuse_ = ColourValue::White; 54 this->specular_ = ColourValue::White; 55 this->type_ = Ogre::Light::LT_POINT; 56 this->attenuation_ = Vector4(100000, 1, 0, 0); 57 this->spotlightRange_ = Vector3(40.0f, 30.0f, 1.0f); 58 59 if (Core::showsGraphics()) 60 { 61 if (!this->getScene()) 62 ThrowException(AbortLoading, "Can't create Light, no scene given."); 63 if (!this->getScene()->getSceneManager()) 64 ThrowException(AbortLoading, "Can't create Light, no scene manager given."); 65 66 if (this->getScene() && this->getScene()->getSceneManager()) 67 { 68 this->light_ = this->getScene()->getSceneManager()->createLight("Light" + getUniqueNumberString()); 69 this->light_->setDirection(WorldEntity::FRONT); 70 this->attachOgreObject(this->light_); 71 72 this->updateType(); 73 this->updateDiffuseColour(); 74 this->updateSpecularColour(); 75 this->updateAttenuation(); 76 this->updateSpotlightRange(); 77 } 78 } 56 79 57 80 this->registerVariables(); … … 71 94 SUPER(Light, XMLPort, xmlelement, mode); 72 95 73 XMLPortParam(Light, "type", setTypeString, getTypeString, xmlelement, mode).defaultValues("point"); 74 XMLPortParamExternTemplate(Light, Ogre::Light, this->light_, "diffuse", setDiffuseColour, getDiffuseColour, xmlelement, mode, const ColourValue&); 75 XMLPortParamExternTemplate(Light, Ogre::Light, this->light_, "specular", setSpecularColour, getSpecularColour, xmlelement, mode, const ColourValue&); 76 XMLPortParamExternTemplate(Light, Ogre::Light, this->light_, "direction", setDirection, getDirection, xmlelement, mode, const Vector3&); 96 XMLPortParam(Light, "type", setTypeString, getTypeString, xmlelement, mode).defaultValues("point"); 97 XMLPortParam(Light, "diffuse", setDiffuseColour, getDiffuseColour, xmlelement, mode).defaultValues(ColourValue::White); 98 XMLPortParam(Light, "specular", setSpecularColour, getSpecularColour, xmlelement, mode).defaultValues(ColourValue::White); 99 XMLPortParam(Light, "attenuation", setAttenuation, getAttenuation, xmlelement, mode).defaultValues(Vector4(100000, 1, 0, 0)); 100 XMLPortParam(Light, "spotlightrange", setSpotlightRange, getSpotlightRange, xmlelement, mode).defaultValues(Vector3(40.0f, 30.0f, 1.0f)); 77 101 } 78 102 79 103 void Light::registerVariables() 80 104 { 81 REGISTERDATA(this->type_, direction::toclient, new NetworkCallback<Light>(this, &Light::changedType)); 82 REGISTERDATA(this->light_->getDiffuseColour(), direction::toclient); 83 REGISTERDATA(this->light_->getSpecularColour(), direction::toclient); 84 REGISTERDATA(this->light_->getDirection(), direction::toclient); 105 registerVariable((int&)this->type_, variableDirection::toclient, new NetworkCallback<Light>(this, &Light::updateType)); 106 registerVariable(this->diffuse_, variableDirection::toclient, new NetworkCallback<Light>(this, &Light::updateDiffuseColour)); 107 registerVariable(this->specular_, variableDirection::toclient, new NetworkCallback<Light>(this, &Light::updateSpecularColour)); 108 registerVariable(this->attenuation_, variableDirection::toclient, new NetworkCallback<Light>(this, &Light::updateAttenuation)); 109 registerVariable(this->spotlightRange_, variableDirection::toclient, new NetworkCallback<Light>(this, &Light::updateSpotlightRange)); 85 110 } 86 111 87 const std::string& Light::getName() const112 void Light::updateDiffuseColour() 88 113 { 89 114 if (this->light_) 90 return this->light_->getName(); 91 else 92 return BLANKSTRING; 115 this->light_->setDiffuseColour(this->diffuse_); 93 116 } 94 117 95 void Light:: setDiffuseColour(const ColourValue& colour)118 void Light::updateSpecularColour() 96 119 { 97 120 if (this->light_) 98 this->light_->set DiffuseColour(colour);121 this->light_->setSpecularColour(this->specular_); 99 122 } 100 123 101 const ColourValue& Light::getDiffuseColour() const124 void Light::updateAttenuation() 102 125 { 103 if (this->light_) 104 return this->light_->getDiffuseColour(); 105 else 106 return ColourValue::White; 126 if (this->light_ && this->type_ != Ogre::Light::LT_DIRECTIONAL) 127 this->light_->setAttenuation(this->attenuation_.x, this->attenuation_.y, this->attenuation_.z, this->attenuation_.w); 107 128 } 108 129 109 void Light:: setSpecularColour(const ColourValue& colour)130 void Light::updateSpotlightRange() 110 131 { 111 if (this->light_) 112 this->light_->setSpecularColour(colour); 113 } 114 115 const ColourValue& Light::getSpecularColour() const 116 { 117 if (this->light_) 118 return this->light_->getSpecularColour(); 119 else 120 return ColourValue::White; 121 } 122 123 void Light::setDirection(const Vector3& direction) 124 { 125 if (this->light_) 126 this->light_->setDirection(direction); 127 } 128 129 const Vector3& Light::getDirection() const 130 { 131 if (this->light_) 132 return this->light_->getDirection(); 133 else 134 return Vector3::ZERO; 132 if (this->light_ && this->type_ == Ogre::Light::LT_SPOTLIGHT) 133 this->light_->setSpotlightRange(Degree(this->spotlightRange_.x), Degree(this->spotlightRange_.y), this->spotlightRange_.z); 135 134 } 136 135 … … 157 156 case Ogre::Light::LT_POINT: 158 157 default: 159 return "poin T";158 return "point"; 160 159 } 161 160 } 162 161 163 void Light:: changedType()162 void Light::updateType() 164 163 { 165 this->light_->setType(this->type_); 164 if (this->light_) 165 { 166 this->light_->setType(this->type_); 167 168 if (this->type_ != Ogre::Light::LT_DIRECTIONAL) 169 this->updateAttenuation(); 170 if (this->type_ == Ogre::Light::LT_SPOTLIGHT) 171 this->updateSpotlightRange(); 172 } 166 173 } 167 174 … … 170 177 SUPER(Light, changedVisibility); 171 178 172 this->light_->setVisible(this->isVisible()); 179 if (this->light_) 180 this->light_->setVisible(this->isVisible()); 173 181 } 174 182 } -
code/trunk/src/orxonox/objects/worldentities/Light.h
r2087 r2662 31 31 32 32 #include "OrxonoxPrereqs.h" 33 #include " PositionableEntity.h"33 #include "StaticEntity.h" 34 34 35 35 #include <string> … … 40 40 namespace orxonox 41 41 { 42 class _OrxonoxExport Light : public PositionableEntity42 class _OrxonoxExport Light : public StaticEntity 43 43 { 44 44 public: … … 54 54 { return this->light_; } 55 55 56 const std::string& getName() const;57 58 56 inline void setType(Ogre::Light::LightTypes type) 59 { this->type_ = type; this-> changedType(); }60 Ogre::Light::LightTypes getType() const57 { this->type_ = type; this->updateType(); } 58 inline Ogre::Light::LightTypes getType() const 61 59 { return this->type_; } 62 60 63 void setDiffuseColour(const ColourValue& colour); 64 const ColourValue& getDiffuseColour() const; 61 inline void setDiffuseColour(const ColourValue& colour) 62 { this->diffuse_ = colour; this->updateDiffuseColour(); } 63 inline const ColourValue& getDiffuseColour() const 64 { return this->diffuse_; } 65 65 66 void setSpecularColour(const ColourValue& colour); 67 const ColourValue& getSpecularColour() const; 66 inline void setSpecularColour(const ColourValue& colour) 67 { this->specular_ = colour; this->updateSpecularColour(); } 68 inline const ColourValue& getSpecularColour() const 69 { return this->specular_; } 68 70 69 void setDirection(const Vector3& direction); 70 const Vector3& getDirection() const; 71 /** 72 @brief Sets the attenuation parameters of the light source i.e. how it diminishes with distance. 73 74 @param attenuation.x range (The absolute upper range of the light in world units) 75 @param attenuation.y constant (The constant factor in the attenuation formula: 1.0 means never attenuate, 0.0 is complete attenuation) 76 @param attenuation.z linear (The linear factor in the attenuation formula: 1 means attenuate evenly over the distance) 77 @param attenuation.w quadratic (The quadratic factor in the attenuation formula: adds a curvature to the attenuation formula) 78 79 Quote from the Ogre API: 80 Lights normally get fainter the further they are away. Also, each light is given a maximum range beyond which it cannot affect any objects. 81 Light attenuation is not applicable to directional lights since they have an infinite range and constant intensity. 82 This follows a standard attenuation approach - see any good 3D text for the details of what they mean since i don't have room here! 83 84 Quote from the Ogre wiki: 85 "Using these numbers, the light has 100% intensity at 0 distance, and 86 trails off to near black at a distance equal to the Range. Keep in mind 87 that most of the light falls in the first 20% of the range." 88 89 Range Constant Linear Quadratic 90 3250, 1.0, 0.0014, 0.000007 91 600, 1.0, 0.007, 0.0002 92 325, 1.0, 0.014, 0.0007 93 200, 1.0, 0.022, 0.0019 94 160, 1.0, 0.027, 0.0028 95 100, 1.0, 0.045, 0.0075 96 65, 1.0, 0.07, 0.017 97 50, 1.0, 0.09, 0.032 98 32, 1.0, 0.14, 0.07 99 20, 1.0, 0.22, 0.20 100 13, 1.0, 0.35, 0.44 101 7, 1.0, 0.7, 1.8 102 */ 103 inline void setAttenuation(const Vector4& attenuation) 104 { this->attenuation_ = attenuation; this->updateAttenuation(); } 105 inline const Vector4& getAttenuation() const 106 { return this->attenuation_; } 107 108 /** 109 @brief Sets the range of a spotlight, i.e. the angle of the inner and outer cones and the rate of falloff between them. 110 111 @param spotlightRange.x innerAngle (The angle covered by the bright inner cone) 112 @param spotlightRange.x outerAngle (The angle covered by the outer cone) 113 @param spotlightRange.x falloff (The rate of falloff between the inner and outer cones. 1.0 means a linear falloff, less means slower falloff, higher means faster falloff.) 114 */ 115 inline void setSpotlightRange(const Vector3& spotlightRange) 116 { this->spotlightRange_ = spotlightRange; this->updateSpotlightRange(); } 117 inline const Vector3& getSpotlightRange() const 118 { return this->spotlightRange_; } 71 119 72 120 private: … … 74 122 std::string getTypeString() const; 75 123 76 void changedType(); 124 void updateType(); 125 void updateDiffuseColour(); 126 void updateSpecularColour(); 127 void updateAttenuation(); 128 void updateSpotlightRange(); 77 129 78 static unsigned int lightCounter_s;79 130 Ogre::Light* light_; 80 131 Ogre::Light::LightTypes type_; 81 132 ColourValue diffuse_; 133 ColourValue specular_; 134 Vector4 attenuation_; 135 Vector3 spotlightRange_; 82 136 }; 83 137 } -
code/trunk/src/orxonox/objects/worldentities/MobileEntity.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/worldentities/MobileEntity.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/worldentities/Model.cc
r2171 r2662 29 29 #include "OrxonoxStableHeaders.h" 30 30 31 #include <OgreEntity.h> 31 32 #include "Model.h" 32 33 #include "core/CoreIncludes.h" … … 38 39 CreateFactory(Model); 39 40 40 Model::Model(BaseObject* creator) : PositionableEntity(creator)41 Model::Model(BaseObject* creator) : StaticEntity(creator) 41 42 { 42 43 RegisterObject(Model); 44 45 this->bCastShadows_ = true; 43 46 44 47 this->registerVariables(); … … 48 51 { 49 52 if (this->isInitialized() && this->mesh_.getEntity()) 50 this-> getNode()->detachObject(this->mesh_.getEntity());53 this->detachOgreObject(this->mesh_.getEntity()); 51 54 } 52 55 … … 61 64 void Model::registerVariables() 62 65 { 63 REGISTERSTRING(this->meshSrc_, direction::toclient, new NetworkCallback<Model>(this, &Model::changedMesh));64 REGISTERDATA(this->bCastShadows_, direction::toclient, new NetworkCallback<Model>(this, &Model::changedShadows));66 registerVariable(this->meshSrc_, variableDirection::toclient, new NetworkCallback<Model>(this, &Model::changedMesh)); 67 registerVariable(this->bCastShadows_, variableDirection::toclient, new NetworkCallback<Model>(this, &Model::changedShadows)); 65 68 } 66 69 67 70 void Model::changedMesh() 68 71 { 69 if (this->mesh_.getEntity()) 70 this->getNode()->detachObject(this->mesh_.getEntity()); 72 if (Core::showsGraphics()) 73 { 74 if (this->mesh_.getEntity()) 75 this->detachOgreObject(this->mesh_.getEntity()); 71 76 72 this->mesh_.setMeshSource(this->getScene()->getSceneManager(), this->meshSrc_);77 this->mesh_.setMeshSource(this->getScene()->getSceneManager(), this->meshSrc_); 73 78 74 if (this->mesh_.getEntity()) 75 { 76 this->getNode()->attachObject(this->mesh_.getEntity()); 77 this->mesh_.getEntity()->setCastShadows(this->bCastShadows_); 78 this->mesh_.setVisible(this->isVisible()); 79 if (this->mesh_.getEntity()) 80 { 81 this->attachOgreObject(this->mesh_.getEntity()); 82 this->mesh_.getEntity()->setCastShadows(this->bCastShadows_); 83 this->mesh_.setVisible(this->isVisible()); 84 } 79 85 } 80 86 } -
code/trunk/src/orxonox/objects/worldentities/Model.h
r2087 r2662 31 31 32 32 #include "OrxonoxPrereqs.h" 33 #include " PositionableEntity.h"33 #include "StaticEntity.h" 34 34 #include "tools/Mesh.h" 35 35 36 36 namespace orxonox 37 37 { 38 class _OrxonoxExport Model : public PositionableEntity38 class _OrxonoxExport Model : public StaticEntity 39 39 { 40 40 public: … … 70 70 } 71 71 72 #endif /* _ PositionableEntity_H__ */72 #endif /* _Model_H__ */ -
code/trunk/src/orxonox/objects/worldentities/MovableEntity.cc
r2171 r2662 22 22 * Author: 23 23 * Fabian 'x3n' Landau 24 * Reto Grieder 24 25 * Co-authors: 25 26 * ... … … 33 34 #include "core/XMLPort.h" 34 35 #include "core/Executor.h" 35 #include " tools/Timer.h"36 #include "core/Core.h" 36 37 37 38 namespace orxonox 38 39 { 39 40 static const float MAX_RESYNCHRONIZE_TIME = 3.0f; 41 static const float CONTINUOUS_SYNCHRONIZATION_TIME = 10.0f; 40 42 41 43 CreateFactory(MovableEntity); 42 44 43 MovableEntity::MovableEntity(BaseObject* creator) : WorldEntity(creator)45 MovableEntity::MovableEntity(BaseObject* creator) : MobileEntity(creator) 44 46 { 45 47 RegisterObject(MovableEntity); 46 48 47 this->velocity_ = Vector3::ZERO; 48 this->acceleration_ = Vector3::ZERO; 49 this->rotationAxis_ = Vector3::ZERO; 50 this->rotationRate_ = 0; 51 this->momentum_ = 0; 49 this->overwrite_position_ = Vector3::ZERO; 50 this->overwrite_orientation_ = Quaternion::IDENTITY; 52 51 53 this->overwrite_position_ = Vector3::ZERO; 54 this->overwrite_orientation_ = Quaternion::IDENTITY; 52 this->continuousResynchroTimer_ = 0; 53 54 this->setPriority(priority::low); 55 55 56 56 this->registerVariables(); … … 59 59 MovableEntity::~MovableEntity() 60 60 { 61 if (this->isInitialized()) 62 if (this->continuousResynchroTimer_) 63 delete this->continuousResynchroTimer_; 61 64 } 62 65 … … 64 67 { 65 68 SUPER(MovableEntity, XMLPort, xmlelement, mode); 66 67 XMLPortParamTemplate(MovableEntity, "velocity", setVelocity, getVelocity, xmlelement, mode, const Vector3&);68 XMLPortParamTemplate(MovableEntity, "rotationaxis", setRotationAxis, getRotationAxis, xmlelement, mode, const Vector3&);69 XMLPortParamTemplate(MovableEntity, "rotationrate", setRotationRate, getRotationRate, xmlelement, mode, const Degree&);70 }71 72 void MovableEntity::tick(float dt)73 {74 if (this->isActive())75 {76 this->velocity_ += (dt * this->acceleration_);77 this->node_->translate(dt * this->velocity_);78 79 this->rotationRate_ += (dt * this->momentum_);80 this->node_->rotate(this->rotationAxis_, this->rotationRate_ * dt);81 }82 69 } 83 70 84 71 void MovableEntity::registerVariables() 85 72 { 86 REGISTERDATA(this->velocity_.x, direction::toclient); 87 REGISTERDATA(this->velocity_.y, direction::toclient); 88 REGISTERDATA(this->velocity_.z, direction::toclient); 73 registerVariable(this->linearVelocity_, variableDirection::toclient, new NetworkCallback<MovableEntity>(this, &MovableEntity::processLinearVelocity)); 74 registerVariable(this->angularVelocity_, variableDirection::toclient, new NetworkCallback<MovableEntity>(this, &MovableEntity::processAngularVelocity)); 89 75 90 REGISTERDATA(this->rotationAxis_.x, direction::toclient); 91 REGISTERDATA(this->rotationAxis_.y, direction::toclient); 92 REGISTERDATA(this->rotationAxis_.z, direction::toclient); 93 94 REGISTERDATA(this->rotationRate_, direction::toclient); 95 96 REGISTERDATA(this->overwrite_position_, direction::toclient, new NetworkCallback<MovableEntity>(this, &MovableEntity::overwritePosition)); 97 REGISTERDATA(this->overwrite_orientation_, direction::toclient, new NetworkCallback<MovableEntity>(this, &MovableEntity::overwriteOrientation)); 98 } 99 100 void MovableEntity::overwritePosition() 101 { 102 this->node_->setPosition(this->overwrite_position_); 103 } 104 105 void MovableEntity::overwriteOrientation() 106 { 107 this->node_->setOrientation(this->overwrite_orientation_); 76 registerVariable(this->overwrite_position_, variableDirection::toclient, new NetworkCallback<MovableEntity>(this, &MovableEntity::overwritePosition)); 77 registerVariable(this->overwrite_orientation_, variableDirection::toclient, new NetworkCallback<MovableEntity>(this, &MovableEntity::overwriteOrientation)); 108 78 } 109 79 110 80 void MovableEntity::clientConnected(unsigned int clientID) 111 81 { 112 new Timer<MovableEntity>(rnd() * MAX_RESYNCHRONIZE_TIME, false, this, createExecutor(createFunctor(&MovableEntity::resynchronize)), true);82 this->resynchronizeTimer_.setTimer(rnd() * MAX_RESYNCHRONIZE_TIME, false, this, createExecutor(createFunctor(&MovableEntity::resynchronize))); 113 83 } 114 84 … … 119 89 void MovableEntity::resynchronize() 120 90 { 91 if (Core::isMaster() && !this->continuousResynchroTimer_) 92 { 93 // Resynchronise every few seconds because we only work with velocities (no positions) 94 continuousResynchroTimer_ = new Timer<MovableEntity>(CONTINUOUS_SYNCHRONIZATION_TIME + rnd(-1, 1), 95 true, this, createExecutor(createFunctor(&MovableEntity::resynchronize)), false); 96 } 97 121 98 this->overwrite_position_ = this->getPosition(); 122 99 this->overwrite_orientation_ = this->getOrientation(); 123 100 } 124 125 void MovableEntity::setPosition(const Vector3& position)126 {127 this->node_->setPosition(position);128 this->overwrite_position_ = this->node_->getPosition();129 }130 131 void MovableEntity::translate(const Vector3& distance, Ogre::Node::TransformSpace relativeTo)132 {133 this->node_->translate(distance, relativeTo);134 this->overwrite_position_ = this->node_->getPosition();135 }136 137 void MovableEntity::setOrientation(const Quaternion& orientation)138 {139 this->node_->setOrientation(orientation);140 this->overwrite_orientation_ = this->node_->getOrientation();141 }142 143 void MovableEntity::rotate(const Quaternion& rotation, Ogre::Node::TransformSpace relativeTo)144 {145 this->node_->rotate(rotation, relativeTo);146 this->overwrite_orientation_ = this->node_->getOrientation();147 }148 149 void MovableEntity::yaw(const Degree& angle, Ogre::Node::TransformSpace relativeTo)150 {151 this->node_->yaw(angle, relativeTo);152 this->overwrite_orientation_ = this->node_->getOrientation();153 }154 155 void MovableEntity::pitch(const Degree& angle, Ogre::Node::TransformSpace relativeTo)156 {157 this->node_->pitch(angle, relativeTo);158 this->overwrite_orientation_ = this->node_->getOrientation();159 }160 161 void MovableEntity::roll(const Degree& angle, Ogre::Node::TransformSpace relativeTo)162 {163 this->node_->roll(angle, relativeTo);164 this->overwrite_orientation_ = this->node_->getOrientation();165 }166 167 void MovableEntity::lookAt(const Vector3& target, Ogre::Node::TransformSpace relativeTo, const Vector3& localDirectionVector)168 {169 this->node_->lookAt(target, relativeTo, localDirectionVector);170 this->overwrite_orientation_ = this->node_->getOrientation();171 }172 173 void MovableEntity::setDirection(const Vector3& direction, Ogre::Node::TransformSpace relativeTo, const Vector3& localDirectionVector)174 {175 this->node_->setDirection(direction, relativeTo, localDirectionVector);176 this->overwrite_orientation_ = this->node_->getOrientation();177 }178 101 } -
code/trunk/src/orxonox/objects/worldentities/MovableEntity.h
r2171 r2662 22 22 * Author: 23 23 * Fabian 'x3n' Landau 24 * Reto Grieder 24 25 * Co-authors: 25 26 * ... … … 32 33 #include "OrxonoxPrereqs.h" 33 34 34 #include "WorldEntity.h" 35 #include "objects/Tickable.h" 35 #include "MobileEntity.h" 36 36 #include "network/ClientConnectionListener.h" 37 #include "tools/Timer.h" 37 38 38 39 namespace orxonox 39 40 { 40 class _OrxonoxExport MovableEntity : public WorldEntity, public Tickable, public ClientConnectionListener41 class _OrxonoxExport MovableEntity : public MobileEntity, public ClientConnectionListener 41 42 { 42 43 public: … … 45 46 46 47 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 47 virtual void tick(float dt);48 48 void registerVariables(); 49 49 50 50 using WorldEntity::setPosition; 51 using WorldEntity::translate;52 51 using WorldEntity::setOrientation; 53 using WorldEntity::rotate;54 using WorldEntity::yaw;55 using WorldEntity::pitch;56 using WorldEntity::roll;57 using WorldEntity::lookAt;58 using WorldEntity::setDirection;59 52 60 void setPosition(const Vector3& position); 61 void translate(const Vector3& distance, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL); 62 void setOrientation(const Quaternion& orientation); 63 void rotate(const Quaternion& rotation, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL); 64 void yaw(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL); 65 void pitch(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL); 66 void roll(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL); 67 void lookAt(const Vector3& target, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z); 68 void setDirection(const Vector3& direction, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z); 69 70 inline void setVelocity(const Vector3& velocity) 71 { this->velocity_ = velocity; } 72 inline void setVelocity(float x, float y, float z) 73 { this->velocity_.x = x; this->velocity_.y = y; this->velocity_.z = z; } 74 inline const Vector3& getVelocity() const 75 { return this->velocity_; } 76 77 inline void setAcceleration(const Vector3& acceleration) 78 { this->acceleration_ = acceleration; } 79 inline void setAcceleration(float x, float y, float z) 80 { this->acceleration_.x = x; this->acceleration_.y = y; this->acceleration_.z = z; } 81 inline const Vector3& getAcceleration() const 82 { return this->acceleration_; } 83 84 inline void setRotationAxis(const Vector3& axis) 85 { this->rotationAxis_ = axis; this->rotationAxis_.normalise(); } 86 inline void setRotationAxis(float x, float y, float z) 87 { this->rotationAxis_.x = x; this->rotationAxis_.y = y; this->rotationAxis_.z = z; rotationAxis_.normalise(); } 88 inline const Vector3& getRotationAxis() const 89 { return this->rotationAxis_; } 90 91 inline void setRotationRate(const Degree& angle) 92 { this->rotationRate_ = angle; } 93 inline void setRotationRate(const Radian& angle) 94 { this->rotationRate_ = angle; } 95 inline const Degree& getRotationRate() const 96 { return this->rotationRate_; } 97 98 inline void setMomentum(const Degree& angle) 99 { this->momentum_ = angle; } 100 inline void setMomentum(const Radian& angle) 101 { this->momentum_ = angle; } 102 inline const Degree& getMomentum() const 103 { return this->momentum_; } 53 inline void setPosition(const Vector3& position) 54 { MobileEntity::setPosition(position); this->overwrite_position_ = this->getPosition(); } 55 inline void setOrientation(const Quaternion& orientation) 56 { MobileEntity::setOrientation(orientation); this->overwrite_orientation_ = this->getOrientation(); } 104 57 105 58 private: … … 108 61 void resynchronize(); 109 62 110 void overwritePosition(); 111 void overwriteOrientation(); 63 inline void processLinearVelocity() 64 { this->setVelocity(this->linearVelocity_); } 65 inline void processAngularVelocity() 66 { this->setAngularVelocity(this->angularVelocity_); } 112 67 113 Vector3 velocity_; 114 Vector3 acceleration_; 115 Vector3 rotationAxis_; 116 Degree rotationRate_; 117 Degree momentum_; 68 inline void overwritePosition() 69 { this->setPosition(this->overwrite_position_); } 70 inline void overwriteOrientation() 71 { this->setOrientation(this->overwrite_orientation_); } 118 72 119 Vector3 overwrite_position_;73 Vector3 overwrite_position_; 120 74 Quaternion overwrite_orientation_; 75 76 Timer<MovableEntity> resynchronizeTimer_; 77 Timer<MovableEntity>* continuousResynchroTimer_; 121 78 }; 122 79 } -
code/trunk/src/orxonox/objects/worldentities/ParticleEmitter.cc
r2171 r2662 33 33 34 34 #include "OrxonoxStableHeaders.h" 35 #include "ParticleEmitter.h" 35 36 36 #include "ParticleEmitter.h"37 #include <OgreParticleSystem.h> 37 38 38 39 #include "tools/ParticleInterface.h" … … 46 47 CreateFactory(ParticleEmitter); 47 48 48 ParticleEmitter::ParticleEmitter(BaseObject* creator) : PositionableEntity(creator)49 ParticleEmitter::ParticleEmitter(BaseObject* creator) : StaticEntity(creator) 49 50 { 50 51 RegisterObject(ParticleEmitter); 51 52 52 if ( !this->getScene() || !this->getScene()->getSceneManager())53 ThrowException(AbortLoading, "Can't create Camera, no scene or no scene manager given.");53 if (Core::showsGraphics() && (!this->getScene() || !this->getScene()->getSceneManager())) 54 ThrowException(AbortLoading, "Can't create ParticleEmitter, no scene or no scene manager given."); 54 55 55 56 this->particles_ = 0; … … 62 63 { 63 64 if (this->isInitialized() && this->particles_) 65 { 66 this->detachOgreObject(this->particles_->getParticleSystem()); 64 67 delete this->particles_; 68 } 65 69 } 66 70 … … 75 79 void ParticleEmitter::registerVariables() 76 80 { 77 REGISTERSTRING(this->source_, direction::toclient, new NetworkCallback<ParticleEmitter>(this, &ParticleEmitter::sourceChanged));78 REGISTERDATA (this->LOD_, direction::toclient, new NetworkCallback<ParticleEmitter>(this, &ParticleEmitter::LODchanged));81 registerVariable(this->source_, variableDirection::toclient, new NetworkCallback<ParticleEmitter>(this, &ParticleEmitter::sourceChanged)); 82 registerVariable((int&)(this->LOD_), variableDirection::toclient, new NetworkCallback<ParticleEmitter>(this, &ParticleEmitter::LODchanged)); 79 83 } 80 84 … … 98 102 { 99 103 if (this->particles_) 104 { 100 105 delete this->particles_; 106 this->particles_ = 0; 107 } 101 108 102 if ( this->getScene() && this->getScene()->getSceneManager())109 if (Core::showsGraphics() && this->getScene() && this->getScene()->getSceneManager()) 103 110 { 104 111 try 105 112 { 106 113 this->particles_ = new ParticleInterface(this->getScene()->getSceneManager(), this->source_, this->LOD_); 107 this-> particles_->addToSceneNode(this->getNode());114 this->attachOgreObject(this->particles_->getParticleSystem()); 108 115 this->particles_->setVisible(this->isVisible()); 109 116 this->particles_->setEnabled(this->isActive()); … … 115 122 } 116 123 } 117 else118 this->particles_ = 0;119 124 } 120 125 -
code/trunk/src/orxonox/objects/worldentities/ParticleEmitter.h
r2087 r2662 31 31 32 32 #include "OrxonoxPrereqs.h" 33 #include " PositionableEntity.h"33 #include "StaticEntity.h" 34 34 35 35 namespace orxonox 36 36 { 37 class _OrxonoxExport ParticleEmitter : public PositionableEntity37 class _OrxonoxExport ParticleEmitter : public StaticEntity 38 38 { 39 39 public: -
code/trunk/src/orxonox/objects/worldentities/ParticleSpawner.cc
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/objects/worldentities/ParticleSpawner.h
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/objects/worldentities/SpawnPoint.cc
r2087 r2662 38 38 CreateFactory(SpawnPoint); 39 39 40 SpawnPoint::SpawnPoint(BaseObject* creator) : PositionableEntity(creator)40 SpawnPoint::SpawnPoint(BaseObject* creator) : StaticEntity(creator) 41 41 { 42 42 RegisterObject(SpawnPoint); -
code/trunk/src/orxonox/objects/worldentities/SpawnPoint.h
r2087 r2662 34 34 #include "core/Identifier.h" 35 35 #include "core/Template.h" 36 #include "PositionableEntity.h"37 36 #include "objects/worldentities/pawns/Pawn.h" 37 #include "objects/worldentities/StaticEntity.h" 38 38 39 39 namespace orxonox 40 40 { 41 class _OrxonoxExport SpawnPoint : public PositionableEntity41 class _OrxonoxExport SpawnPoint : public StaticEntity 42 42 { 43 43 public: -
code/trunk/src/orxonox/objects/worldentities/StaticEntity.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/worldentities/StaticEntity.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/trunk/src/orxonox/objects/worldentities/WorldEntity.cc
r2171 r2662 22 22 * Author: 23 23 * Fabian 'x3n' Landau 24 * Reto Grieder (physics) 24 25 * Co-authors: 25 26 * ... … … 31 32 32 33 #include <cassert> 34 #include <OgreSceneNode.h> 33 35 #include <OgreSceneManager.h> 34 36 #include "BulletDynamics/Dynamics/btRigidBody.h" 37 38 #include "util/Exception.h" 39 #include "util/Convert.h" 35 40 #include "core/CoreIncludes.h" 36 41 #include "core/XMLPort.h" 37 #include "util/Convert.h"38 #include "util/Exception.h"39 42 40 43 #include "objects/Scene.h" 44 #include "objects/collisionshapes/WorldEntityCollisionShape.h" 41 45 42 46 namespace orxonox … … 49 53 const Vector3 WorldEntity::UP = Vector3::UNIT_Y; 50 54 55 /** 56 @brief 57 Creates a new WorldEntity that may immediately be used. 58 All the default values are being set here. 59 */ 51 60 WorldEntity::WorldEntity(BaseObject* creator) : BaseObject(creator), Synchronisable(creator) 52 61 { … … 64 73 this->node_->setOrientation(Quaternion::IDENTITY); 65 74 75 76 // Default behaviour does not include physics 77 this->physicalBody_ = 0; 78 this->bPhysicsActive_ = false; 79 this->bPhysicsActiveSynchronised_ = false; 80 this->bPhysicsActiveBeforeAttaching_ = false; 81 this->collisionShape_ = new WorldEntityCollisionShape(this); 82 this->collisionType_ = None; 83 this->collisionTypeSynchronised_ = None; 84 this->mass_ = 0; 85 this->childrenMass_ = 0; 86 // Using bullet default values 87 this->restitution_ = 0; 88 this->angularFactor_ = 1; 89 this->linearDamping_ = 0; 90 this->angularDamping_ = 0; 91 this->friction_ = 0.5; 92 this->bCollisionCallbackActive_ = false; 93 this->bCollisionResponseActive_ = true; 94 66 95 this->registerVariables(); 67 96 } 68 97 98 /** 99 @brief 100 Destroys the WorldEntity AND ALL its children with it. 101 */ 69 102 WorldEntity::~WorldEntity() 70 103 { 71 104 if (this->isInitialized()) 72 105 { 106 if (this->parent_) 107 this->detachFromParent(); 108 109 for (std::set<WorldEntity*>::const_iterator it = this->children_.begin(); it != this->children_.end(); ) 110 delete (*(it++)); 111 112 if (this->physicalBody_) 113 { 114 this->deactivatePhysics(); 115 delete this->physicalBody_; 116 } 117 delete this->collisionShape_; 118 73 119 this->node_->detachAllObjects(); 74 if (this->getScene()->getSceneManager()) 75 this->getScene()->getSceneManager()->destroySceneNode(this->node_->getName()); 120 this->node_->removeAllChildren(); 121 122 OrxAssert(this->getScene()->getSceneManager(), "No SceneManager defined in a WorldEntity."); 123 this->getScene()->getSceneManager()->destroySceneNode(this->node_->getName()); 76 124 } 77 125 } … … 81 129 SUPER(WorldEntity, XMLPort, xmlelement, mode); 82 130 83 XMLPortParamTemplate(WorldEntity, "position", setPosition, getPosition,xmlelement, mode, const Vector3&);131 XMLPortParamTemplate(WorldEntity, "position", setPosition, getPosition, xmlelement, mode, const Vector3&); 84 132 XMLPortParamTemplate(WorldEntity, "orientation", setOrientation, getOrientation, xmlelement, mode, const Quaternion&); 85 XMLPortParamLoadOnly(WorldEntity, "lookat", lookAt_xmlport, xmlelement, mode); 86 XMLPortParamLoadOnly(WorldEntity, "direction", setDirection_xmlport, xmlelement, mode); 87 XMLPortParamLoadOnly(WorldEntity, "yaw", yaw_xmlport, xmlelement, mode); 88 XMLPortParamLoadOnly(WorldEntity, "pitch", pitch_xmlport, xmlelement, mode); 89 XMLPortParamLoadOnly(WorldEntity, "roll", roll_xmlport, xmlelement, mode); 90 XMLPortParamTemplate(WorldEntity, "scale3D", setScale3D, getScale3D, xmlelement, mode, const Vector3&); 91 XMLPortParam(WorldEntity, "scale", setScale, getScale, xmlelement, mode); 92 133 XMLPortParamTemplate(WorldEntity, "scale3D", setScale3D, getScale3D, xmlelement, mode, const Vector3&); 134 XMLPortParam (WorldEntity, "scale", setScale, getScale, xmlelement, mode); 135 XMLPortParamLoadOnly(WorldEntity, "lookat", lookAt_xmlport, xmlelement, mode); 136 XMLPortParamLoadOnly(WorldEntity, "direction", setDirection_xmlport, xmlelement, mode); 137 XMLPortParamLoadOnly(WorldEntity, "yaw", yaw_xmlport, xmlelement, mode); 138 XMLPortParamLoadOnly(WorldEntity, "pitch", pitch_xmlport, xmlelement, mode); 139 XMLPortParamLoadOnly(WorldEntity, "roll", roll_xmlport, xmlelement, mode); 140 141 // Physics 142 XMLPortParam(WorldEntity, "collisionType", setCollisionTypeStr, getCollisionTypeStr, xmlelement, mode); 143 XMLPortParam(WorldEntity, "collisionResponse", setCollisionResponse, hasCollisionResponse, xmlelement, mode); 144 XMLPortParam(WorldEntity, "mass", setMass, getMass, xmlelement, mode); 145 XMLPortParam(WorldEntity, "restitution", setRestitution, getRestitution, xmlelement, mode); 146 XMLPortParam(WorldEntity, "angularFactor", setAngularFactor, getAngularFactor, xmlelement, mode); 147 XMLPortParam(WorldEntity, "linearDamping", setLinearDamping, getLinearDamping, xmlelement, mode); 148 XMLPortParam(WorldEntity, "angularDamping", setAngularDamping, getAngularDamping, xmlelement, mode); 149 XMLPortParam(WorldEntity, "friction", setFriction, getFriction, xmlelement, mode); 150 151 // Other attached WorldEntities 93 152 XMLPortObject(WorldEntity, WorldEntity, "attached", attach, getAttachedObject, xmlelement, mode); 153 // Attached collision shapes 154 XMLPortObject(WorldEntity, CollisionShape, "collisionShapes", attachCollisionShape, getAttachedCollisionShape, xmlelement, mode); 94 155 } 95 156 96 157 void WorldEntity::registerVariables() 97 158 { 98 REGISTERDATA(this->bActive_, direction::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedActivity)); 99 REGISTERDATA(this->bVisible_, direction::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedVisibility)); 100 101 REGISTERDATA(this->getScale3D().x, direction::toclient); 102 REGISTERDATA(this->getScale3D().y, direction::toclient); 103 REGISTERDATA(this->getScale3D().z, direction::toclient); 104 105 REGISTERDATA(this->parentID_, direction::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::updateParent)); 106 } 107 108 void WorldEntity::updateParent() 159 registerVariable(this->mainStateName_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedMainState)); 160 161 registerVariable(this->bActive_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedActivity)); 162 registerVariable(this->bVisible_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedVisibility)); 163 164 registerVariable(this->getScale3D(), variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::scaleChanged)); 165 166 // Physics stuff 167 registerVariable(this->mass_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::massChanged)); 168 registerVariable(this->restitution_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::restitutionChanged)); 169 registerVariable(this->angularFactor_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::angularFactorChanged)); 170 registerVariable(this->linearDamping_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::linearDampingChanged)); 171 registerVariable(this->angularDamping_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::angularDampingChanged)); 172 registerVariable(this->friction_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::frictionChanged)); 173 registerVariable(this->bCollisionCallbackActive_, 174 variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::collisionCallbackActivityChanged)); 175 registerVariable(this->bCollisionResponseActive_, 176 variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::collisionResponseActivityChanged)); 177 registerVariable((int&)this->collisionTypeSynchronised_, 178 variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::collisionTypeChanged)); 179 registerVariable(this->bPhysicsActiveSynchronised_, 180 variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::physicsActivityChanged)); 181 182 // Attach to parent if necessary 183 registerVariable(this->parentID_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::parentChanged)); 184 } 185 186 /** 187 @brief 188 Network function that object this instance to its correct parent. 189 */ 190 void WorldEntity::parentChanged() 109 191 { 110 192 if (this->parentID_ != OBJECTID_UNKNOWN) … … 116 198 } 117 199 200 /** 201 @brief 202 Attaches this object to a parent SceneNode. 203 @Remarks 204 Only use this method if you know exactly what you're doing! 205 Normally, attaching works internally by attaching WE's. 206 */ 207 void WorldEntity::attachToNode(Ogre::SceneNode* node) 208 { 209 Ogre::Node* parent = this->node_->getParent(); 210 if (parent) 211 parent->removeChild(this->node_); 212 node->addChild(this->node_); 213 } 214 215 /** 216 @brief 217 Detaches this object from a parent SceneNode. 218 @Remarks 219 Only use this method if you know exactly what you're doing! 220 Normally, attaching works internally by attaching WE's. 221 */ 222 void WorldEntity::detachFromNode(Ogre::SceneNode* node) 223 { 224 node->removeChild(this->node_); 225 // this->getScene()->getRootSceneNode()->addChild(this->node_); 226 } 227 228 /** 229 @brief 230 Network callback for the collision type. Only change the type if it was valid. 231 */ 232 void WorldEntity::collisionTypeChanged() 233 { 234 if (this->collisionTypeSynchronised_ != Dynamic && 235 this->collisionTypeSynchronised_ != Kinematic && 236 this->collisionTypeSynchronised_ != Static && 237 this->collisionTypeSynchronised_ != None) 238 { 239 CCOUT(1) << "Error when collsion Type was received over network. Unknown enum value:" << this->collisionTypeSynchronised_ << std::endl; 240 } 241 else if (this->collisionTypeSynchronised_ != collisionType_) 242 { 243 if (this->parent_) 244 CCOUT(2) << "Warning: Network connection tried to set the collision type of an attached WE. Ignoring." << std::endl; 245 else 246 this->setCollisionType(this->collisionTypeSynchronised_); 247 } 248 } 249 250 //! Network callback for this->bPhysicsActive_ 251 void WorldEntity::physicsActivityChanged() 252 { 253 if (this->bPhysicsActiveSynchronised_) 254 this->activatePhysics(); 255 else 256 this->deactivatePhysics(); 257 } 258 259 //! Function sets whether Bullet should issue a callback on collisions 260 void WorldEntity::collisionCallbackActivityChanged() 261 { 262 if (this->hasPhysics()) 263 { 264 if (this->bCollisionCallbackActive_) 265 this->physicalBody_->setCollisionFlags(this->physicalBody_->getCollisionFlags() | 266 btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK); 267 else 268 this->physicalBody_->setCollisionFlags(this->physicalBody_->getCollisionFlags() & 269 ~btCollisionObject::CF_CUSTOM_MATERIAL_CALLBACK); 270 } 271 } 272 273 //! Function sets whether Bullet should react itself to a collision 274 void WorldEntity::collisionResponseActivityChanged() 275 { 276 if (this->hasPhysics()) 277 { 278 if (this->bCollisionResponseActive_) 279 this->physicalBody_->setCollisionFlags(this->physicalBody_->getCollisionFlags() & 280 ~btCollisionObject::CF_NO_CONTACT_RESPONSE); 281 else 282 this->physicalBody_->setCollisionFlags(this->physicalBody_->getCollisionFlags() | 283 btCollisionObject::CF_NO_CONTACT_RESPONSE); 284 } 285 } 286 287 /** 288 @brief 289 Attaches a child WorldEntity to this object. This calls notifyBeingAttached() 290 of the child WE. 291 @Note 292 The collision shape of the child object gets attached nevertheless. That also means 293 that you can change the collision shape of the child and it correctly cascadeds the changes to this instance. 294 Be aware of this implication: When implementing attaching of kinematic objects to others, you have to change 295 this behaviour because you then might not want to merge the collision shapes. 296 */ 118 297 void WorldEntity::attach(WorldEntity* object) 119 298 { 120 if (object ->getParent())121 object->detachFromParent();122 else123 {124 Ogre::Node* parent = object->node_->getParent();125 if (parent) 126 parent->removeChild(object->node_);127 }128 129 this-> node_->addChild(object->node_);299 if (object == this) 300 { 301 COUT(2) << "Warning: Can't attach a WorldEntity to itself." << std::endl; 302 return; 303 } 304 305 if (!object->notifyBeingAttached(this)) 306 return; 307 308 this->attachNode(object->node_); 130 309 this->children_.insert(object); 131 object->parent_ = this; 132 object->parentID_ = this->getObjectID(); 133 } 134 310 311 this->attachCollisionShape(object->collisionShape_); 312 // mass 313 this->childrenMass_ += object->getMass(); 314 recalculateMassProps(); 315 } 316 317 /** 318 @brief 319 Function gets called when this object is being attached to a new parent. 320 321 This operation is only allowed if the collision types "like" each other. 322 - You cannot a attach a non physical object to a physical one. 323 - Dynamic object can NOT be attached at all. 324 - It is also not possible to attach a kinematic to a dynamic one. 325 - Attaching of kinematic objects otherwise is not yet supported. 326 */ 327 bool WorldEntity::notifyBeingAttached(WorldEntity* newParent) 328 { 329 // check first whether attaching is even allowed 330 if (this->hasPhysics()) 331 { 332 if (!newParent->hasPhysics()) 333 { 334 COUT(2) << "Warning: Cannot attach a physical object to a non physical one." << std::endl; 335 return false; 336 } 337 else if (this->isDynamic()) 338 { 339 COUT(2) << "Warning: Cannot attach a dynamic object to a WorldEntity." << std::endl; 340 return false; 341 } 342 else if (this->isKinematic() && newParent->isDynamic()) 343 { 344 COUT(2) << "Warning: Cannot attach a kinematic object to a dynamic one." << std::endl; 345 return false; 346 } 347 else if (this->isKinematic()) 348 { 349 COUT(2) << "Warning: Cannot attach a kinematic object to a static or kinematic one: Not yet implemented." << std::endl; 350 return false; 351 } 352 } 353 354 if (this->isPhysicsActive()) 355 this->bPhysicsActiveBeforeAttaching_ = true; 356 this->deactivatePhysics(); 357 358 if (this->parent_) 359 this->detachFromParent(); 360 361 this->parent_ = newParent; 362 this->parentID_ = newParent->getObjectID(); 363 364 // apply transform to collision shape 365 this->collisionShape_->setPosition(this->getPosition()); 366 this->collisionShape_->setOrientation(this->getOrientation()); 367 // TODO: Scale 368 369 return true; 370 } 371 372 /** 373 @brief 374 Detaches a child WorldEntity from this instance. 375 */ 135 376 void WorldEntity::detach(WorldEntity* object) 136 377 { 137 this->node_->removeChild(object->node_); 378 if (this->children_.find(object) == this->children_.end()) 379 { 380 CCOUT(2) << "Warning: Cannot detach an object that is not a child." << std::endl; 381 return; 382 } 383 384 // collision shapes 385 this->detachCollisionShape(object->collisionShape_); 386 387 // mass 388 if (object->getMass() > 0.0f) 389 { 390 this->childrenMass_ -= object->getMass(); 391 recalculateMassProps(); 392 } 393 394 this->detachNode(object->node_); 138 395 this->children_.erase(object); 139 object->parent_ = 0; 140 object->parentID_ = OBJECTID_UNKNOWN; 141 142 // this->getScene()->getRootSceneNode()->addChild(object->node_); 143 } 144 145 WorldEntity* WorldEntity::getAttachedObject(unsigned int index) const 396 397 object->notifyDetached(); 398 } 399 400 /** 401 @brief 402 Function gets called when the object has been detached from its parent. 403 */ 404 void WorldEntity::notifyDetached() 405 { 406 this->parent_ = 0; 407 this->parentID_ = OBJECTID_UNKNOWN; 408 409 // reset orientation of the collisionShape (cannot be set within a WE usually) 410 this->collisionShape_->setPosition(Vector3::ZERO); 411 this->collisionShape_->setOrientation(Quaternion::IDENTITY); 412 // TODO: Scale 413 414 if (this->bPhysicsActiveBeforeAttaching_) 415 { 416 this->activatePhysics(); 417 this->bPhysicsActiveBeforeAttaching_ = false; 418 } 419 } 420 421 //! Returns an attached object (merely for XMLPort). 422 WorldEntity* WorldEntity::getAttachedObject(unsigned int index) 146 423 { 147 424 unsigned int i = 0; … … 154 431 return 0; 155 432 } 433 434 //! Attaches an Ogre::SceneNode to this WorldEntity. 435 void WorldEntity::attachNode(Ogre::SceneNode* node) 436 { 437 Ogre::Node* parent = node->getParent(); 438 if (parent) 439 parent->removeChild(node); 440 this->node_->addChild(node); 441 } 442 443 //! Detaches an Ogre::SceneNode from this WorldEntity. 444 void WorldEntity::detachNode(Ogre::SceneNode* node) 445 { 446 this->node_->removeChild(node); 447 // this->getScene()->getRootSceneNode()->addChild(node); 448 } 449 450 //! Attaches an Ogre::MovableObject to this WorldEntity. 451 void WorldEntity::attachOgreObject(Ogre::MovableObject* object) 452 { 453 this->node_->attachObject(object); 454 } 455 456 //! Detaches an Ogre::MovableObject from this WorldEntity. 457 void WorldEntity::detachOgreObject(Ogre::MovableObject* object) 458 { 459 this->node_->detachObject(object); 460 } 461 462 //! Detaches an Ogre::MovableObject (by string) from this WorldEntity. 463 Ogre::MovableObject* WorldEntity::detachOgreObject(const Ogre::String& name) 464 { 465 return this->node_->detachObject(name); 466 } 467 468 //! Attaches a collision Shape to this object (delegated to the internal CompoundCollisionShape) 469 void WorldEntity::attachCollisionShape(CollisionShape* shape) 470 { 471 this->collisionShape_->attach(shape); 472 // Note: this->collisionShape_ already notifies us of any changes. 473 } 474 475 //! Detaches a collision Shape from this object (delegated to the internal CompoundCollisionShape) 476 void WorldEntity::detachCollisionShape(CollisionShape* shape) 477 { 478 // Note: The collision shapes may not be detached with this function! 479 this->collisionShape_->detach(shape); 480 // Note: this->collisionShape_ already notifies us of any changes. 481 } 482 483 //! Returns an attached collision Shape of this object (delegated to the internal CompoundCollisionShape) 484 CollisionShape* WorldEntity::getAttachedCollisionShape(unsigned int index) 485 { 486 return this->collisionShape_->getAttachedShape(index); 487 } 488 489 // Note: These functions are placed in WorldEntity.h as inline functions for the release build. 490 #ifndef _NDEBUG 491 const Vector3& WorldEntity::getPosition() const 492 { 493 return this->node_->getPosition(); 494 } 495 496 const Quaternion& WorldEntity::getOrientation() const 497 { 498 return this->node_->getOrientation(); 499 } 500 501 const Vector3& WorldEntity::getScale3D() const 502 { 503 return this->node_->getScale(); 504 } 505 #endif 506 507 //! Returns the position relative to the root space 508 const Vector3& WorldEntity::getWorldPosition() const 509 { 510 return this->node_->_getDerivedPosition(); 511 } 512 513 //! Returns the orientation relative to the root space 514 const Quaternion& WorldEntity::getWorldOrientation() const 515 { 516 return this->node_->_getDerivedOrientation(); 517 } 518 519 //! Returns the scaling applied relative to the root space in 3 coordinates 520 const Vector3& WorldEntity::getWorldScale3D() const 521 { 522 return this->node_->_getDerivedScale(); 523 } 524 525 /** 526 @brief 527 Returns the scaling applied relative to the root space in 3 coordinates 528 @return 529 Returns the scaling if it is uniform, 1.0f otherwise. 530 */ 531 float WorldEntity::getWorldScale() const 532 { 533 Vector3 scale = this->getWorldScale3D(); 534 return (scale.x == scale.y && scale.x == scale.z) ? scale.x : 1; 535 } 536 537 /** 538 @brief 539 Sets the three dimensional scaling of this object. 540 @Note 541 Scaling physical objects has not yet been implemented and is therefore forbidden. 542 */ 543 void WorldEntity::setScale3D(const Vector3& scale) 544 { 545 /* 546 HACK HACK HACK 547 if (bScalePhysics && this->hasPhysics() && scale != Vector3::UNIT_SCALE) 548 { 549 CCOUT(2) << "Warning: Cannot set the scale of a physical object: Not yet implemented. Ignoring scaling." << std::endl; 550 return; 551 } 552 HACK HACK HACK 553 */ 554 this->node_->setScale(scale); 555 556 this->changedScale(); 557 } 558 559 /** 560 @brief 561 Translates this WorldEntity by a vector. 562 @param relativeTo 563 @see TransformSpace::Enum 564 */ 565 void WorldEntity::translate(const Vector3& distance, TransformSpace::Enum relativeTo) 566 { 567 switch (relativeTo) 568 { 569 case TransformSpace::Local: 570 // position is relative to parent so transform downwards 571 this->setPosition(this->getPosition() + this->getOrientation() * distance); 572 break; 573 case TransformSpace::Parent: 574 this->setPosition(this->getPosition() + distance); 575 break; 576 case TransformSpace::World: 577 // position is relative to parent so transform upwards 578 if (this->node_->getParent()) 579 setPosition(getPosition() + (node_->getParent()->_getDerivedOrientation().Inverse() * distance) 580 / node_->getParent()->_getDerivedScale()); 581 else 582 this->setPosition(this->getPosition() + distance); 583 break; 584 } 585 } 586 587 /** 588 @brief 589 Rotates this WorldEntity by a quaternion. 590 @param relativeTo 591 @see TransformSpace::Enum 592 */ 593 void WorldEntity::rotate(const Quaternion& rotation, TransformSpace::Enum relativeTo) 594 { 595 switch(relativeTo) 596 { 597 case TransformSpace::Local: 598 this->setOrientation(this->getOrientation() * rotation); 599 break; 600 case TransformSpace::Parent: 601 // Rotations are normally relative to local axes, transform up 602 this->setOrientation(rotation * this->getOrientation()); 603 break; 604 case TransformSpace::World: 605 // Rotations are normally relative to local axes, transform up 606 this->setOrientation(this->getOrientation() * this->getWorldOrientation().Inverse() 607 * rotation * this->getWorldOrientation()); 608 break; 609 } 610 } 611 612 /** 613 @brief 614 Makes this WorldEntity look a specific target location. 615 @param relativeTo 616 @see TransformSpace::Enum 617 @param localDirectionVector 618 The vector which normally describes the natural direction of the object, usually -Z. 619 */ 620 void WorldEntity::lookAt(const Vector3& target, TransformSpace::Enum relativeTo, const Vector3& localDirectionVector) 621 { 622 Vector3 origin; 623 switch (relativeTo) 624 { 625 case TransformSpace::Local: 626 origin = Vector3::ZERO; 627 break; 628 case TransformSpace::Parent: 629 origin = this->getPosition(); 630 break; 631 case TransformSpace::World: 632 origin = this->getWorldPosition(); 633 break; 634 } 635 this->setDirection(target - origin, relativeTo, localDirectionVector); 636 } 637 638 /** 639 @brief 640 Makes this WorldEntity look in specific direction. 641 @param relativeTo 642 @see TransformSpace::Enum 643 @param localDirectionVector 644 The vector which normally describes the natural direction of the object, usually -Z. 645 */ 646 void WorldEntity::setDirection(const Vector3& direction, TransformSpace::Enum relativeTo, const Vector3& localDirectionVector) 647 { 648 Quaternion savedOrientation(this->getOrientation()); 649 Ogre::Node::TransformSpace ogreRelativeTo; 650 switch (relativeTo) 651 { 652 case TransformSpace::Local: 653 ogreRelativeTo = Ogre::Node::TS_LOCAL; break; 654 case TransformSpace::Parent: 655 ogreRelativeTo = Ogre::Node::TS_PARENT; break; 656 case TransformSpace::World: 657 ogreRelativeTo = Ogre::Node::TS_WORLD; break; 658 } 659 this->node_->setDirection(direction, ogreRelativeTo, localDirectionVector); 660 Quaternion newOrientation(this->node_->getOrientation()); 661 this->node_->setOrientation(savedOrientation); 662 this->setOrientation(newOrientation); 663 } 664 665 //! Activates physics if the CollisionType is not None. 666 void WorldEntity::activatePhysics() 667 { 668 if (this->isActive() && this->hasPhysics() && !this->isPhysicsActive() && !this->parent_) 669 { 670 this->getScene()->addPhysicalObject(this); 671 this->bPhysicsActive_ = true; 672 this->bPhysicsActiveSynchronised_ = true; 673 } 674 } 675 676 //! Deactivates physics but the CollisionType does not change. 677 void WorldEntity::deactivatePhysics() 678 { 679 if (this->isPhysicsActive()) 680 { 681 this->getScene()->removePhysicalObject(this); 682 this->bPhysicsActive_ = false; 683 this->bPhysicsActiveSynchronised_ = false; 684 } 685 } 686 687 //! Tells whether the object has already been added to the Bullet physics World. 688 bool WorldEntity::addedToPhysicalWorld() const 689 { 690 return this->physicalBody_ && this->physicalBody_->isInWorld(); 691 } 692 693 /** 694 @brief 695 Sets the CollisionType. This alters the object significantly! @see CollisionType. 696 @Note 697 Operation does not work on attached WorldEntities. 698 */ 699 void WorldEntity::setCollisionType(CollisionType type) 700 { 701 if (this->collisionType_ == type) 702 return; 703 704 // If we are already attached to a parent, this would be a bad idea.. 705 if (this->parent_) 706 { 707 CCOUT(2) << "Warning: Cannot set the collision type of a WorldEntity with a parent." << std::endl; 708 return; 709 } 710 711 // Check for type legality. Could be StaticEntity or MobileEntity. 712 if (!this->isCollisionTypeLegal(type)) 713 return; 714 715 if (this->isPhysicsActive()) 716 this->deactivatePhysics(); 717 718 bool bReactivatePhysics = true; 719 if (this->hasPhysics() && !this->isPhysicsActive()) 720 bReactivatePhysics = false; 721 722 // Check whether we have to create or destroy. 723 if (type != None && this->collisionType_ == None) 724 { 725 /* 726 HACK HACK HACK 727 // Check whether there was some scaling applied. 728 if (!this->node_->getScale().positionEquals(Vector3(1, 1, 1), 0.001)) 729 { 730 CCOUT(2) << "Warning: Cannot create a physical body if there is scaling applied to the node: Not yet implemented." << std::endl; 731 return; 732 } 733 HACK HACK HACK 734 */ 735 // Create new rigid body 736 btRigidBody::btRigidBodyConstructionInfo bodyConstructionInfo(0, this, this->collisionShape_->getCollisionShape()); 737 this->physicalBody_ = new btRigidBody(bodyConstructionInfo); 738 this->physicalBody_->setUserPointer(this); 739 this->physicalBody_->setActivationState(DISABLE_DEACTIVATION); 740 } 741 else if (type == None && this->collisionType_ != None) 742 { 743 // Destroy rigid body 744 assert(this->physicalBody_); 745 deactivatePhysics(); 746 delete this->physicalBody_; 747 this->physicalBody_ = 0; 748 this->collisionType_ = None; 749 this->collisionTypeSynchronised_ = None; 750 return; 751 } 752 753 // Change type 754 switch (type) 755 { 756 case Dynamic: 757 this->physicalBody_->setCollisionFlags(this->physicalBody_->getCollisionFlags() & !(btCollisionObject::CF_STATIC_OBJECT | btCollisionObject::CF_KINEMATIC_OBJECT)); 758 break; 759 case Kinematic: 760 this->physicalBody_->setCollisionFlags(this->physicalBody_->getCollisionFlags() & !btCollisionObject::CF_STATIC_OBJECT | btCollisionObject::CF_KINEMATIC_OBJECT); 761 break; 762 case Static: 763 this->physicalBody_->setCollisionFlags(this->physicalBody_->getCollisionFlags() & !btCollisionObject::CF_KINEMATIC_OBJECT | btCollisionObject::CF_STATIC_OBJECT); 764 break; 765 case None: 766 assert(false); // Doesn't happen 767 return; 768 } 769 this->collisionType_ = type; 770 this->collisionTypeSynchronised_ = type; 771 772 // update mass and inertia tensor 773 recalculateMassProps(); 774 internalSetPhysicsProps(); 775 collisionCallbackActivityChanged(); 776 collisionResponseActivityChanged(); 777 if (bReactivatePhysics) 778 activatePhysics(); 779 } 780 781 //! Sets the CollisionType by string (used for the XMLPort) 782 void WorldEntity::setCollisionTypeStr(const std::string& typeStr) 783 { 784 std::string typeStrLower = getLowercase(typeStr); 785 CollisionType type; 786 if (typeStrLower == "dynamic") 787 type = Dynamic; 788 else if (typeStrLower == "static") 789 type = Static; 790 else if (typeStrLower == "kinematic") 791 type = Kinematic; 792 else if (typeStrLower == "none") 793 type = None; 794 else 795 ThrowException(ParseError, std::string("Attempting to set an unknown collision type: '") + typeStr + "'."); 796 this->setCollisionType(type); 797 } 798 799 //! Gets the CollisionType by string (used for the XMLPort) 800 std::string WorldEntity::getCollisionTypeStr() const 801 { 802 switch (this->getCollisionType()) 803 { 804 case Dynamic: 805 return "dynamic"; 806 case Kinematic: 807 return "kinematic"; 808 case Static: 809 return "static"; 810 case None: 811 return "none"; 812 default: 813 assert(false); 814 return ""; 815 } 816 } 817 818 /** 819 @brief 820 Recalculates the accumulated child mass and calls recalculateMassProps() 821 and notifies the parent of the change. 822 @Note 823 Called by a child WE 824 */ 825 void WorldEntity::notifyChildMassChanged() 826 { 827 // Note: CollisionShape changes of a child get handled over the internal CompoundCollisionShape already 828 // Recalculate mass 829 this->childrenMass_ = 0.0f; 830 for (std::set<WorldEntity*>::const_iterator it = this->children_.begin(); it != this->children_.end(); ++it) 831 this->childrenMass_ += (*it)->getMass(); 832 recalculateMassProps(); 833 // Notify parent WE 834 if (this->parent_) 835 parent_->notifyChildMassChanged(); 836 } 837 838 /** 839 @brief 840 Undertakes the necessary steps to change the collision shape in Bullet, even at runtime. 841 @Note 842 - called by this->collisionShape_ 843 - May have a REALLY big overhead when called continuously at runtime, because then we need 844 to remove the physical body from Bullet and add it again. 845 */ 846 void WorldEntity::notifyCollisionShapeChanged() 847 { 848 if (hasPhysics()) 849 { 850 // Bullet doesn't like sudden changes of the collision shape, so we remove and add it again 851 if (this->addedToPhysicalWorld()) 852 { 853 this->deactivatePhysics(); 854 this->physicalBody_->setCollisionShape(this->collisionShape_->getCollisionShape()); 855 this->activatePhysics(); 856 } 857 else 858 this->physicalBody_->setCollisionShape(this->collisionShape_->getCollisionShape()); 859 } 860 recalculateMassProps(); 861 } 862 863 //! Updates all mass dependent parameters (mass, inertia tensor and child mass) 864 void WorldEntity::recalculateMassProps() 865 { 866 // Store local inertia for faster access. Evaluates to (0,0,0) if there is no collision shape. 867 float totalMass = this->mass_ + this->childrenMass_; 868 this->collisionShape_->calculateLocalInertia(totalMass, this->localInertia_); 869 if (this->hasPhysics()) 870 { 871 if (this->isStatic()) 872 { 873 // Just set everything to zero 874 this->physicalBody_->setMassProps(0.0f, btVector3(0, 0, 0)); 875 } 876 else if ((this->mass_ + this->childrenMass_) == 0.0f) 877 { 878 // Use default values to avoid very large or very small values 879 CCOUT(4) << "Warning: Setting the internal physical mass to 1.0 because mass_ is 0.0" << std::endl; 880 btVector3 inertia(0, 0, 0); 881 this->collisionShape_->calculateLocalInertia(1.0f, inertia); 882 this->physicalBody_->setMassProps(1.0f, inertia); 883 } 884 else 885 { 886 this->physicalBody_->setMassProps(totalMass, this->localInertia_); 887 } 888 } 889 } 890 891 //! Copies our own parameters for restitution, angular factor, dampings and friction to the bullet rigid body. 892 void WorldEntity::internalSetPhysicsProps() 893 { 894 if (this->hasPhysics()) 895 { 896 this->physicalBody_->setRestitution(this->restitution_); 897 this->physicalBody_->setAngularFactor(this->angularFactor_); 898 this->physicalBody_->setDamping(this->linearDamping_, this->angularDamping_); 899 this->physicalBody_->setFriction(this->friction_); 900 } 901 } 156 902 } -
code/trunk/src/orxonox/objects/worldentities/WorldEntity.h
r2171 r2662 22 22 * Author: 23 23 * Fabian 'x3n' Landau 24 * Reto Grieder (physics) 24 25 * Co-authors: 25 26 * ... … … 32 33 #include "OrxonoxPrereqs.h" 33 34 34 #define OGRE_FORCE_ANGLE_TYPES 35 35 #ifdef _NDEBUG 36 36 #include <OgreSceneNode.h> 37 38 #include "network/Synchronisable.h" 37 #else 38 #include <OgrePrerequisites.h> 39 #endif 40 #include "LinearMath/btMotionState.h" 41 42 #include "util/Math.h" 39 43 #include "core/BaseObject.h" 40 #include " util/Math.h"44 #include "network/synchronisable/Synchronisable.h" 41 45 42 46 namespace orxonox 43 47 { 44 class _OrxonoxExport WorldEntity : public BaseObject, public Synchronisable 48 /** 49 @brief 50 The WorldEntity represents everything that can be put in a Scene at a certain location. 51 52 It is supposed to be the base class of everything you would call an 'object' in a Scene. 53 The class itself is abstract which means you cannot use it directly. You may use StaticEntity 54 as the simplest derivative or (derived from MobileEntity) MovableEntity and ControllableEntity 55 as more advanced ones. 56 57 The basic task of the WorldEntity is provide a location, a direction and a scaling and the possibility 58 to create an entire hierarchy of derivated objects. 59 It is also the basis for the physics interface to the Bullet physics engine. 60 Every WorldEntity can have a specific collision type: @see CollisionType 61 This would then imply that every scene object could have any collision type. To limit this, you can always 62 override this->isCollisionTypeLegal(CollisionType). Return false if the collision type is not supported 63 for a specific object. 64 There is also support for attaching WorldEntities with physics to each other. Currently, the collision shape 65 of both objects simply get merged into one larger shape (for static collision type). 66 The phyiscal body that is internally stored and administrated has the following supported properties: 67 - Restitution, angular factor, linear damping, angular damping, fricition, mass and collision shape. 68 You can get more information at the corresponding set function. 69 70 Collision shapes: These are controlled by the internal WorldEntityCollisionShape. @see WorldEntityCollisionShape. 71 */ 72 class _OrxonoxExport WorldEntity : public BaseObject, public Synchronisable, public btMotionState 45 73 { 74 friend class Scene; 75 46 76 public: 47 77 WorldEntity(BaseObject* creator); … … 51 81 void registerVariables(); 52 82 53 inline Ogre::SceneNode* getNode() const83 inline const Ogre::SceneNode* getNode() const 54 84 { return this->node_; } 55 85 … … 64 94 inline void setPosition(float x, float y, float z) 65 95 { this->setPosition(Vector3(x, y, z)); } 66 inline const Vector3& getPosition() const 67 { return this->node_->getPosition(); } 68 inline const Vector3& getWorldPosition() const 69 { return this->node_->getWorldPosition(); } 70 71 virtual void translate(const Vector3& distance, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL) = 0; 72 inline void translate(float x, float y, float z, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL) 96 const Vector3& getPosition() const; 97 const Vector3& getWorldPosition() const; 98 99 void translate(const Vector3& distance, TransformSpace::Enum relativeTo = TransformSpace::Parent); 100 inline void translate(float x, float y, float z, TransformSpace::Enum relativeTo = TransformSpace::Parent) 73 101 { this->translate(Vector3(x, y, z), relativeTo); } 102 103 virtual inline const Vector3& getVelocity() const 104 { return Vector3::ZERO; } 74 105 75 106 virtual void setOrientation(const Quaternion& orientation) = 0; … … 80 111 inline void setOrientation(const Vector3& axis, const Degree& angle) 81 112 { this->setOrientation(Quaternion(angle, axis)); } 82 inline const Quaternion& getOrientation() const 83 { return this->node_->getOrientation(); } 84 inline const Quaternion& getWorldOrientation() const 85 { return this->node_->getWorldOrientation(); } 86 87 virtual void rotate(const Quaternion& rotation, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL) = 0; 88 inline void rotate(const Vector3& axis, const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL) 113 const Quaternion& getOrientation() const; 114 const Quaternion& getWorldOrientation() const; 115 116 void rotate(const Quaternion& rotation, TransformSpace::Enum relativeTo = TransformSpace::Local); 117 inline void rotate(const Vector3& axis, const Degree& angle, TransformSpace::Enum relativeTo = TransformSpace::Local) 89 118 { this->rotate(Quaternion(angle, axis), relativeTo); } 90 inline void rotate(const Vector3& axis, const Radian& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL) 91 { this->rotate(Quaternion(angle, axis), relativeTo); } 92 93 virtual void yaw(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL) = 0; 94 inline void yaw(const Radian& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL) 95 { this->yaw(Degree(angle), relativeTo); } 96 virtual void pitch(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL) = 0; 97 inline void pitch(const Radian& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL) 98 { this->pitch(Degree(angle), relativeTo); } 99 virtual void roll(const Degree& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL) = 0; 100 inline void roll(const Radian& angle, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL) 101 { this->roll(Degree(angle), relativeTo); } 102 103 virtual void lookAt(const Vector3& target, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z) = 0; 104 virtual void setDirection(const Vector3& direction, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z) = 0; 105 inline void setDirection(float x, float y, float z, Ogre::Node::TransformSpace relativeTo = Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z) 119 120 inline void yaw(const Degree& angle, TransformSpace::Enum relativeTo = TransformSpace::Local) 121 { this->rotate(Quaternion(angle, Vector3::UNIT_Y), relativeTo); } 122 inline void pitch(const Degree& angle, TransformSpace::Enum relativeTo = TransformSpace::Local) 123 { this->rotate(Quaternion(angle, Vector3::UNIT_X), relativeTo); } 124 inline void roll(const Degree& angle, TransformSpace::Enum relativeTo = TransformSpace::Local) 125 { this->rotate(Quaternion(angle, Vector3::UNIT_Z), relativeTo); } 126 127 void lookAt(const Vector3& target, TransformSpace::Enum relativeTo = TransformSpace::Parent, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z); 128 void setDirection(const Vector3& direction, TransformSpace::Enum relativeTo = TransformSpace::Local, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z); 129 inline void setDirection(float x, float y, float z, TransformSpace::Enum relativeTo = TransformSpace::Local, const Vector3& localDirectionVector = Vector3::NEGATIVE_UNIT_Z) 106 130 { this->setDirection(Vector3(x, y, z), relativeTo, localDirectionVector); } 107 131 108 inline void setScale3D(const Vector3& scale) 109 { this->node_->setScale(scale); } 132 virtual void setScale3D(const Vector3& scale); 110 133 inline void setScale3D(float x, float y, float z) 111 { this-> node_->setScale(x, y, z); }112 inline const Vector3& getScale3D(void) const113 { return this->node_->getScale(); }134 { this->setScale3D(Vector3(x, y, z)); } 135 const Vector3& getScale3D(void) const; 136 const Vector3& getWorldScale3D() const; 114 137 115 138 inline void setScale(float scale) 116 { this-> node_->setScale(scale, scale, scale); }139 { this->setScale3D(scale, scale, scale); } 117 140 inline float getScale() const 118 141 { Vector3 scale = this->getScale3D(); return (scale.x == scale.y && scale.x == scale.z) ? scale.x : 1; } 142 float getWorldScale() const; 119 143 120 144 inline void scale3D(const Vector3& scale) 121 { this-> node_->scale(scale); }145 { this->setScale3D(this->getScale3D() * scale); } 122 146 inline void scale3D(float x, float y, float z) 123 { this-> node_->scale(x, y, z); }147 { this->scale3D(Vector3(x, y, z)); } 124 148 inline void scale(float scale) 125 { this->node_->scale(scale, scale, scale); } 149 { this->scale3D(scale, scale, scale); } 150 151 virtual void changedScale() {} 126 152 127 153 void attach(WorldEntity* object); 128 154 void detach(WorldEntity* object); 129 WorldEntity* getAttachedObject(unsigned int index) const;155 WorldEntity* getAttachedObject(unsigned int index); 130 156 inline const std::set<WorldEntity*>& getAttachedObjects() const 131 157 { return this->children_; } 158 159 void attachOgreObject(Ogre::MovableObject* object); 160 void detachOgreObject(Ogre::MovableObject* object); 161 Ogre::MovableObject* detachOgreObject(const Ogre::String& name); 132 162 133 163 inline void attachToParent(WorldEntity* parent) … … 138 168 { return this->parent_; } 139 169 170 void attachNode(Ogre::SceneNode* node); 171 void detachNode(Ogre::SceneNode* node); 172 void attachToNode(Ogre::SceneNode* node); 173 void detachFromNode(Ogre::SceneNode* node); 174 175 void notifyChildPropsChanged(); 176 140 177 protected: 141 178 Ogre::SceneNode* node_; 142 179 143 180 private: 144 void updateParent();145 146 181 inline void lookAt_xmlport(const Vector3& target) 147 182 { this->lookAt(target); } … … 155 190 { this->roll(angle); } 156 191 192 // network callbacks 193 void parentChanged(); 194 inline void scaleChanged() 195 { this->setScale3D(this->getScale3D()); } 196 157 197 WorldEntity* parent_; 158 198 unsigned int parentID_; 159 199 std::set<WorldEntity*> children_; 200 201 202 ///////////// 203 // Physics // 204 ///////////// 205 206 public: 207 /** 208 @brief 209 Denotes the possible types of physical objects in a Scene. 210 211 Dynamic: The object is influenced by its physical environment, like for instance little ball. 212 Kinematic: The object can only influence other dynamic objects. It's movement is coordinated by your own saying. 213 Static: Like kinematic but the object is not allowed to move during the simulation. 214 None: The object has no physics at all. 215 */ 216 enum CollisionType 217 { 218 Dynamic, 219 Kinematic, 220 Static, 221 None 222 }; 223 224 //! Tells whether the object has any connection to the Bullet physics engine. If hasPhysics() is false, the object may still have a velocity. 225 bool hasPhysics() const { return getCollisionType() != None ; } 226 //! @see CollisionType 227 bool isStatic() const { return getCollisionType() == Static ; } 228 //! @see CollisionType 229 bool isKinematic() const { return getCollisionType() == Kinematic; } 230 //! @see CollisionType 231 bool isDynamic() const { return getCollisionType() == Dynamic ; } 232 //! Tells whether physics has been activated (you can temporarily deactivate it) 233 bool isPhysicsActive() const { return this->bPhysicsActive_; } 234 bool addedToPhysicalWorld() const; 235 236 void activatePhysics(); 237 void deactivatePhysics(); 238 239 //! Returns the CollisionType. @see CollisionType. 240 inline CollisionType getCollisionType() const 241 { return this->collisionType_; } 242 void setCollisionType(CollisionType type); 243 244 void setCollisionTypeStr(const std::string& type); 245 std::string getCollisionTypeStr() const; 246 247 //! Sets the mass of this object. Note that the total mass may be influenced by attached objects! 248 inline void setMass(float mass) 249 { this->mass_ = mass; recalculateMassProps(); } 250 //! Returns the mass of this object without its children. 251 inline float getMass() const 252 { return this->mass_; } 253 254 //! Returns the total mass of this object with all its attached children. 255 inline float getTotalMass() const 256 { return this->mass_ + this->childrenMass_; } 257 258 /** 259 @brief 260 Returns the diagonal elements of the inertia tensor when calculated in local coordinates. 261 @Note 262 The local inertia tensor cannot be set, but is calculated by Bullet according to the collisionShape. 263 With compound collision shapes, an approximation is used. 264 */ 265 inline const btVector3& getLocalInertia() const 266 { return this->localInertia_; } 267 268 /** 269 @brief 270 Sets how much reaction is applied in a collision. 271 272 Consider two equal spheres colliding with equal velocities: 273 Restitution 1 means that both spheres simply reverse their velocity (no loss of energy) 274 Restitution 0 means that both spheres will immediately stop moving 275 (maximum loss of energy without violating of the preservation of momentum) 276 */ 277 inline void setRestitution(float restitution) 278 { this->restitution_ = restitution; internalSetPhysicsProps(); } 279 //! Returns the restitution parameter. @see setRestitution. 280 inline float getRestitution() const 281 { return this->restitution_; } 282 283 /** 284 @brief 285 Sets an artificial parameter that tells how much torque is applied when you apply a non-central force. 286 287 Normally the angular factor is 1, which means it's physically 'correct'. Howerver if you have a player 288 character that should not rotate when hit sideways, you can set the angular factor to 0. 289 */ 290 inline void setAngularFactor(float angularFactor) 291 { this->angularFactor_ = angularFactor; internalSetPhysicsProps(); } 292 //! Returns the angular factor. @see setAngularFactor. 293 inline float getAngularFactor() const 294 { return this->angularFactor_; } 295 296 //! Applies a mass independent damping. Velocities will simply diminish exponentially. 297 inline void setLinearDamping(float linearDamping) 298 { this->linearDamping_ = linearDamping; internalSetPhysicsProps(); } 299 //! Returns the linear damping. @see setLinearDamping. 300 inline float getLinearDamping() const 301 { return this->linearDamping_; } 302 303 //! Applies a tensor independent rotation damping. Angular velocities will simply diminish exponentially. 304 inline void setAngularDamping(float angularDamping) 305 { this->angularDamping_ = angularDamping; internalSetPhysicsProps(); } 306 //! Returns the angular damping. @see setAngularDamping. 307 inline float getAngularDamping() const 308 { return this->angularDamping_; } 309 310 //! Applies friction to the object. Friction occurs when two objects collide. 311 inline void setFriction(float friction) 312 { this->friction_ = friction; internalSetPhysicsProps(); } 313 //! Returns the amount of friction applied to the object. 314 inline float getFriction() const 315 { return this->friction_; } 316 317 void attachCollisionShape(CollisionShape* shape); 318 void detachCollisionShape(CollisionShape* shape); 319 CollisionShape* getAttachedCollisionShape(unsigned int index); 320 321 void notifyCollisionShapeChanged(); 322 void notifyChildMassChanged(); 323 324 /** 325 @brief 326 Virtual function that gets called when this object collides with another. 327 @param otherObject 328 The object this one has collided into. 329 @pram contactPoint 330 Contact point provided by Bullet. Holds more information and can me modified. See return value. 331 @Return 332 Returning false means that no modification to the contactPoint has been made. Return true otherwise! 333 @Note 334 Condition is that enableCollisionCallback() was called. 335 */ 336 virtual inline bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint) 337 { return false; } /* With false, Bullet assumes no modification to the collision objects. */ 338 339 //! Enables the collidesAgainst(.) function. The object doesn't respond to collision otherwise! 340 inline void enableCollisionCallback() 341 { this->bCollisionCallbackActive_ = true; this->collisionCallbackActivityChanged(); } 342 //! Disables the collidesAgainst(.) function. @see enableCollisionCallback() 343 inline void disableCollisionCallback() 344 { this->bCollisionCallbackActive_ = false; this->collisionCallbackActivityChanged(); } 345 //! Tells whether there could be a collision callback via collidesAgainst(.) 346 inline bool isCollisionCallbackActive() const 347 { return this->bCollisionCallbackActive_; } 348 349 //! Enables or disables collision response (default is of course on) 350 inline void setCollisionResponse(bool value) 351 { this->bCollisionResponseActive_ = value; this->collisionResponseActivityChanged(); } 352 //! Tells whether there could be a collision response 353 inline bool hasCollisionResponse() 354 { return this->bCollisionResponseActive_; } 355 356 protected: 357 /** 358 @brief 359 Function checks whether the requested collision type is legal to this object. 360 361 You can override this function in a derived class to constrain the collision to e.g. None or Dynamic. 362 A projectile may not prove very useful if there is no physical body. Simply set the CollisionType 363 in its constructor and override this method. But be careful that a derived classe's virtual functions 364 don't yet exist in the constructor if a base class. 365 */ 366 virtual bool isCollisionTypeLegal(CollisionType type) const = 0; 367 368 btRigidBody* physicalBody_; //!< Bullet rigid body. Everything physical is applied to this instance. 369 370 private: 371 void recalculateMassProps(); 372 void internalSetPhysicsProps(); 373 374 bool notifyBeingAttached(WorldEntity* newParent); 375 void notifyDetached(); 376 377 // network callbacks 378 void collisionTypeChanged(); 379 void physicsActivityChanged(); 380 void collisionCallbackActivityChanged(); 381 void collisionResponseActivityChanged(); 382 //! Network callback workaround to call a function when the value changes. 383 inline void massChanged() 384 { this->setMass(this->mass_); } 385 //! Network callback workaround to call a function when the value changes. 386 inline void restitutionChanged() 387 { this->setRestitution(this->restitution_); } 388 //! Network callback workaround to call a function when the value changes. 389 inline void angularFactorChanged() 390 { this->setAngularFactor(this->angularFactor_); } 391 //! Network callback workaround to call a function when the value changes. 392 inline void linearDampingChanged() 393 { this->setLinearDamping(this->linearDamping_); } 394 //! Network callback workaround to call a function when the value changes. 395 inline void angularDampingChanged() 396 { this->setAngularDamping(this->angularDamping_); } 397 //! Network callback workaround to call a function when the value changes. 398 inline void frictionChanged() 399 { this->setFriction(this->friction_); } 400 401 CollisionType collisionType_; //!< @see setCollisionType 402 CollisionType collisionTypeSynchronised_; //!< Network synchronised variable for collisionType_ 403 bool bPhysicsActive_; //!< @see isPhysicsActive 404 bool bPhysicsActiveSynchronised_; //!< Network synchronised variable for bPhysicsActive_ 405 //! When attaching objects hierarchically this variable tells this object (as child) whether physics was activated before attaching (because the deactivate physics while being attached). 406 bool bPhysicsActiveBeforeAttaching_; 407 WorldEntityCollisionShape* collisionShape_; //!< Attached collision shapes go here 408 btScalar mass_; //!< @see setMass 409 btVector3 localInertia_; //!< @see getLocalInertia 410 btScalar restitution_; //!< @see setRestitution 411 btScalar angularFactor_; //!< @see setAngularFactor 412 btScalar linearDamping_; //!< @see setLinearDamping 413 btScalar angularDamping_; //!< @see setAngularDamping 414 btScalar friction_; //!< @see setFriction 415 btScalar childrenMass_; //!< Sum of all the children's masses 416 bool bCollisionCallbackActive_; //!< @see enableCollisionCallback 417 bool bCollisionResponseActive_; //!< Tells whether the object should respond to collisions 160 418 }; 419 420 // Inline heavily used functions for release builds. In debug, we better avoid including OgreSceneNode here. 421 #ifdef _NDEBUG 422 inline const Vector3& WorldEntity::getPosition() const 423 { return this->node_->getPosition(); } 424 inline const Quaternion& WorldEntity::getOrientation() const 425 { return this->node_->getrOrientation(); } 426 inline const Vector3& WorldEntity::getScale3D(void) const 427 { return this->node_->getScale(); } 428 #endif 429 430 SUPER_FUNCTION(5, WorldEntity, changedScale, false); 161 431 } 162 432 -
code/trunk/src/orxonox/objects/worldentities/pawns/Pawn.cc
r2171 r2662 30 30 #include "Pawn.h" 31 31 32 #include "core/Core.h" 32 33 #include "core/CoreIncludes.h" 33 34 #include "core/XMLPort.h" 34 35 #include "util/Math.h" 36 #include "PawnManager.h" 35 37 #include "objects/infos/PlayerInfo.h" 36 38 #include "objects/gametypes/Gametype.h" 37 #include "objects/weaponSystem/WeaponSystem.h" 39 #include "objects/worldentities/ParticleSpawner.h" 40 #include "objects/worldentities/ExplosionChunk.h" 38 41 39 42 namespace orxonox … … 45 48 RegisterObject(Pawn); 46 49 47 this->bAlive_ = false; 50 PawnManager::touch(); 51 this->bAlive_ = true; 52 this->fire_ = 0x0; 53 this->firehack_ = 0x0; 48 54 49 55 this->health_ = 0; … … 52 58 53 59 this->lastHitOriginator_ = 0; 54 this->weaponSystem_ = 0; 55 56 /* 57 //WeaponSystem 58 weaponSystem_ = new WeaponSystem(); 59 WeaponSet * weaponSet1 = new WeaponSet(1); 60 this->weaponSystem_->attachWeaponSet(weaponSet1); 61 this->weaponSystem_->getWeaponSetPointer(0)->getWeaponSlotPointer(0)->setAmmoType(true); 62 */ 60 61 this->spawnparticleduration_ = 3.0f; 62 63 this->getPickUp().setPlayer(this); 64 65 if (Core::isMaster()) 66 { 67 this->weaponSystem_ = new WeaponSystem(this); 68 this->weaponSystem_->setParentPawn(this); 69 } 70 else 71 this->weaponSystem_ = 0; 72 73 this->setRadarObjectColour(ColourValue::Red); 74 this->setRadarObjectShape(RadarViewable::Dot); 63 75 64 76 this->registerVariables(); … … 67 79 Pawn::~Pawn() 68 80 { 81 if (this->isInitialized()) 82 { 83 for (ObjectList<PawnListener>::iterator it = ObjectList<PawnListener>::begin(); it != ObjectList<PawnListener>::end(); ++it) 84 it->destroyedPawn(this); 85 86 if (this->weaponSystem_) 87 delete this->weaponSystem_; 88 } 69 89 } 70 90 … … 73 93 SUPER(Pawn, XMLPort, xmlelement, mode); 74 94 75 XMLPortParam(Pawn, "health", setHealth, getHeal ht, xmlelement, mode).defaultValues(100);95 XMLPortParam(Pawn, "health", setHealth, getHealth, xmlelement, mode).defaultValues(100); 76 96 XMLPortParam(Pawn, "maxhealth", setMaxHealth, getMaxHealth, xmlelement, mode).defaultValues(200); 77 97 XMLPortParam(Pawn, "initialhealth", setInitialHealth, getInitialHealth, xmlelement, mode).defaultValues(100); 98 XMLPortParam(Pawn, "spawnparticlesource", setSpawnParticleSource, getSpawnParticleSource, xmlelement, mode); 99 XMLPortParam(Pawn, "spawnparticleduration", setSpawnParticleDuration, getSpawnParticleDuration, xmlelement, mode).defaultValues(3.0f); 100 XMLPortParam(Pawn, "explosionchunks", setExplosionChunks, getExplosionChunks, xmlelement, mode).defaultValues(7); 101 102 XMLPortObject(Pawn, WeaponSlot, "weaponslots", setWeaponSlot, getWeaponSlot, xmlelement, mode); 103 XMLPortObject(Pawn, WeaponSet, "weaponsets", setWeaponSet, getWeaponSet, xmlelement, mode); 104 XMLPortObject(Pawn, WeaponPack, "weapons", setWeaponPack, getWeaponPack, xmlelement, mode); 78 105 } 79 106 80 107 void Pawn::registerVariables() 81 108 { 82 REGISTERDATA(this->bAlive_, direction::toclient); 83 REGISTERDATA(this->health_, direction::toclient); 109 registerVariable(this->bAlive_, variableDirection::toclient); 110 registerVariable(this->health_, variableDirection::toclient); 111 registerVariable(this->initialHealth_, variableDirection::toclient); 112 registerVariable(this->fire_, variableDirection::toserver); 84 113 } 85 114 … … 87 116 { 88 117 SUPER(Pawn, tick, dt); 118 119 if (this->weaponSystem_) 120 { 121 if (this->fire_ & WeaponMode::fire) 122 this->weaponSystem_->fire(WeaponMode::fire); 123 if (this->fire_ & WeaponMode::altFire) 124 this->weaponSystem_->fire(WeaponMode::altFire); 125 if (this->fire_ & WeaponMode::altFire2) 126 this->weaponSystem_->fire(WeaponMode::altFire2); 127 } 128 this->fire_ = this->firehack_; 129 this->firehack_ = 0x0; 89 130 90 131 if (this->health_ <= 0) … … 119 160 } 120 161 121 void Pawn::spawn ()162 void Pawn::spawneffect() 122 163 { 123 164 // play spawn effect 165 if (this->spawnparticlesource_ != "") 166 { 167 ParticleSpawner* effect = new ParticleSpawner(this->getCreator()); 168 effect->setPosition(this->getPosition()); 169 effect->setOrientation(this->getOrientation()); 170 effect->setDestroyAfterLife(true); 171 effect->setSource(this->spawnparticlesource_); 172 effect->setLifetime(this->spawnparticleduration_); 173 } 124 174 } 125 175 126 176 void Pawn::death() 127 177 { 178 // Set bAlive_ to false and wait for PawnManager to do the destruction 128 179 this->bAlive_ = false; 180 181 this->setDestroyWhenPlayerLeft(false); 182 129 183 if (this->getGametype()) 130 184 this->getGametype()->pawnKilled(this, this->lastHitOriginator_); 185 131 186 if (this->getPlayer()) 132 187 this->getPlayer()->stopControl(this); 133 188 134 delete this; 135 189 if (Core::isMaster()) 190 this->deatheffect(); 191 } 192 193 void Pawn::deatheffect() 194 { 136 195 // play death effect 137 } 138 139 void Pawn::fire() 140 { 141 if (this->weaponSystem_) 142 this->weaponSystem_->fire(); 196 { 197 ParticleSpawner* effect = new ParticleSpawner(this->getCreator()); 198 effect->setPosition(this->getPosition()); 199 effect->setOrientation(this->getOrientation()); 200 effect->setDestroyAfterLife(true); 201 effect->setSource("Orxonox/explosion2b"); 202 effect->setLifetime(4.0f); 203 } 204 { 205 ParticleSpawner* effect = new ParticleSpawner(this->getCreator()); 206 effect->setPosition(this->getPosition()); 207 effect->setOrientation(this->getOrientation()); 208 effect->setDestroyAfterLife(true); 209 effect->setSource("Orxonox/smoke6"); 210 effect->setLifetime(4.0f); 211 } 212 { 213 ParticleSpawner* effect = new ParticleSpawner(this->getCreator()); 214 effect->setPosition(this->getPosition()); 215 effect->setOrientation(this->getOrientation()); 216 effect->setDestroyAfterLife(true); 217 effect->setSource("Orxonox/sparks"); 218 effect->setLifetime(4.0f); 219 } 220 for (unsigned int i = 0; i < this->numexplosionchunks_; ++i) 221 { 222 ExplosionChunk* chunk = new ExplosionChunk(this->getCreator()); 223 chunk->setPosition(this->getPosition()); 224 225 } 226 } 227 228 void Pawn::fire(WeaponMode::Enum fireMode) 229 { 230 this->firehack_ |= fireMode; 143 231 } 144 232 … … 146 234 { 147 235 this->setHealth(this->initialHealth_); 148 this->spawn(); 236 if (Core::isMaster()) 237 this->spawneffect(); 238 } 239 240 void Pawn::dropItems() 241 { 242 pickUp.eraseAll(); 243 } 244 245 void Pawn::setWeaponSlot(WeaponSlot * wSlot) 246 { 247 this->attach(wSlot); 248 if (this->weaponSystem_) 249 this->weaponSystem_->attachWeaponSlot(wSlot); 250 } 251 252 WeaponSlot * Pawn::getWeaponSlot(unsigned int index) const 253 { 254 if (this->weaponSystem_) 255 return this->weaponSystem_->getWeaponSlotPointer(index); 256 else 257 return 0; 258 } 259 260 void Pawn::setWeaponPack(WeaponPack * wPack) 261 { 262 if (this->weaponSystem_) 263 { 264 wPack->setParentWeaponSystem(this->weaponSystem_); 265 wPack->setParentWeaponSystemToAllWeapons(this->weaponSystem_); 266 this->weaponSystem_->attachWeaponPack( wPack,wPack->getFireMode() ); 267 wPack->attachNeededMunitionToAllWeapons(); 268 } 269 } 270 271 WeaponPack * Pawn::getWeaponPack(unsigned int firemode) const 272 { 273 if (this->weaponSystem_) 274 return this->weaponSystem_->getWeaponPackPointer(firemode); 275 else 276 return 0; 277 } 278 279 void Pawn::setWeaponSet(WeaponSet * wSet) 280 { 281 if (this->weaponSystem_) 282 this->weaponSystem_->attachWeaponSet(wSet); 283 } 284 285 WeaponSet * Pawn::getWeaponSet(unsigned int index) const 286 { 287 if (this->weaponSystem_) 288 return this->weaponSystem_->getWeaponSetPointer(index); 289 else 290 return 0; 291 } 292 293 294 /////////////////// 295 // Pawn Listener // 296 /////////////////// 297 PawnListener::PawnListener() 298 { 299 RegisterRootObject(PawnListener); 149 300 } 150 301 } -
code/trunk/src/orxonox/objects/worldentities/pawns/Pawn.h
r2098 r2662 31 31 32 32 #include "OrxonoxPrereqs.h" 33 33 #include "objects/pickup/ShipEquipment.h" 34 34 #include "objects/worldentities/ControllableEntity.h" 35 #include "objects/RadarViewable.h" 36 #include "objects/weaponSystem/WeaponSystem.h" 35 37 36 38 namespace orxonox 37 39 { 38 class _OrxonoxExport Pawn : public ControllableEntity 40 class _OrxonoxExport Pawn : public ControllableEntity, public RadarViewable 39 41 { 40 42 public: … … 54 56 inline void removeHealth(float health) 55 57 { this->setHealth(this->health_ - health); } 56 inline float getHeal ht() const58 inline float getHealth() const 57 59 { return this->health_; } 58 60 … … 74 76 virtual void kill(); 75 77 76 virtual void fire(); 77 78 virtual void fire(WeaponMode::Enum fireMode); 78 79 virtual void postSpawn(); 79 80 81 void setWeaponSlot(WeaponSlot * wSlot); 82 WeaponSlot * getWeaponSlot(unsigned int index) const; 83 void setWeaponPack(WeaponPack * wPack); 84 WeaponPack * getWeaponPack(unsigned int firemode) const; 85 void setWeaponSet(WeaponSet * wSet); 86 WeaponSet * getWeaponSet(unsigned int index) const; 87 88 inline const WorldEntity* getWorldEntity() const 89 { return const_cast<Pawn*>(this); } 90 91 inline void setSpawnParticleSource(const std::string& source) 92 { this->spawnparticlesource_ = source; } 93 inline const std::string& getSpawnParticleSource() const 94 { return this->spawnparticlesource_; } 95 96 inline void setSpawnParticleDuration(float duration) 97 { this->spawnparticleduration_ = duration; } 98 inline float getSpawnParticleDuration() const 99 { return this->spawnparticleduration_; } 100 101 inline void setExplosionChunks(unsigned int chunks) 102 { this->numexplosionchunks_ = chunks; } 103 inline unsigned int getExplosionChunks() const 104 { return this->numexplosionchunks_; } 105 106 inline ShipEquipment& getPickUp() 107 {return this->pickUp;} 108 109 virtual void dropItems(); 110 80 111 protected: 81 virtual void spawn();82 112 virtual void death(); 113 virtual void deatheffect(); 114 virtual void spawneffect(); 83 115 116 ShipEquipment pickUp; 84 117 bool bAlive_; 118 85 119 86 120 float health_; … … 91 125 92 126 WeaponSystem* weaponSystem_; 127 unsigned int fire_; 128 unsigned int firehack_; 129 130 std::string spawnparticlesource_; 131 float spawnparticleduration_; 132 unsigned int numexplosionchunks_; 133 }; 134 135 class _OrxonoxExport PawnListener : virtual public OrxonoxClass 136 { 137 friend class Pawn; 138 139 public: 140 PawnListener(); 141 virtual ~PawnListener() {} 142 143 protected: 144 virtual void destroyedPawn(Pawn* pawn) = 0; 93 145 }; 94 146 } -
code/trunk/src/orxonox/objects/worldentities/pawns/SpaceShip.cc
r2171 r2662 30 30 #include "SpaceShip.h" 31 31 32 #include "BulletDynamics/Dynamics/btRigidBody.h" 33 34 #include "util/Math.h" 35 #include "util/Exception.h" 32 36 #include "core/CoreIncludes.h" 33 37 #include "core/ConfigValueIncludes.h" 38 #include "core/Template.h" 34 39 #include "core/XMLPort.h" 35 #include " util/Math.h"40 #include "objects/items/Engine.h" 36 41 37 42 namespace orxonox 38 43 { 44 const float orientationGain = 100; 39 45 CreateFactory(SpaceShip); 40 46 … … 43 49 RegisterObject(SpaceShip); 44 50 45 this->zeroDegree_ = 0; 46 47 this->maxSpeed_ = 0; 48 this->maxSecondarySpeed_ = 0; 49 this->maxRotation_ = 0; 50 this->translationAcceleration_ = 0; 51 this->rotationAcceleration_ = 0; 52 this->translationDamping_ = 0; 53 54 this->yawRotation_ = 0; 55 this->pitchRotation_ = 0; 56 this->rollRotation_ = 0; 51 this->primaryThrust_ = 100; 52 this->auxilaryThrust_ = 30; 53 this->rotationThrust_ = 10; 54 55 this->localLinearAcceleration_.setValue(0, 0, 0); 56 this->localAngularAcceleration_.setValue(0, 0, 0); 57 this->bBoost_ = false; 58 this->bPermanentBoost_ = false; 59 this->steering_ = Vector3::ZERO; 60 this->engine_ = 0; 61 57 62 58 63 this->bInvertYAxis_ = false; 59 64 60 65 this->setDestroyWhenPlayerLeft(true); 66 67 // SpaceShip is always a physical object per default 68 // Be aware of this call: The collision type legality check will not reach derived classes! 69 this->setCollisionType(WorldEntity::Dynamic); 70 // Get notification about collisions 71 this->enableCollisionCallback(); 61 72 62 73 this->setConfigValues(); … … 66 77 SpaceShip::~SpaceShip() 67 78 { 79 if (this->isInitialized() && this->engine_) 80 delete this->engine_; 68 81 } 69 82 … … 72 85 SUPER(SpaceShip, XMLPort, xmlelement, mode); 73 86 74 XMLPortParam(SpaceShip, "maxspeed", setMaxSpeed, getMaxSpeed, xmlelement, mode); 75 XMLPortParam(SpaceShip, "maxsecondaryspeed", setMaxSecondarySpeed, getMaxSecondarySpeed, xmlelement, mode); 76 XMLPortParam(SpaceShip, "maxrotation", setMaxRotation, getMaxRotation, xmlelement, mode); 77 XMLPortParam(SpaceShip, "transacc", setTransAcc, getTransAcc, xmlelement, mode); 78 XMLPortParam(SpaceShip, "rotacc", setRotAcc, getRotAcc, xmlelement, mode); 79 XMLPortParam(SpaceShip, "transdamp", setTransDamp, getTransDamp, xmlelement, mode); 87 XMLPortParam(SpaceShip, "engine", setEngineTemplate, getEngineTemplate, xmlelement, mode); 88 XMLPortParamVariable(SpaceShip, "primaryThrust", primaryThrust_, xmlelement, mode); 89 XMLPortParamVariable(SpaceShip, "auxilaryThrust", auxilaryThrust_, xmlelement, mode); 90 XMLPortParamVariable(SpaceShip, "rotationThrust", rotationThrust_, xmlelement, mode); 80 91 } 81 92 82 93 void SpaceShip::registerVariables() 83 94 { 84 REGISTERDATA(this->maxSpeed_, direction::toclient); 85 REGISTERDATA(this->maxSecondarySpeed_, direction::toclient); 86 REGISTERDATA(this->maxRotation_, direction::toclient); 87 REGISTERDATA(this->translationAcceleration_, direction::toclient); 88 REGISTERDATA(this->rotationAcceleration_, direction::toclient); 89 REGISTERDATA(this->translationDamping_, direction::toclient); 95 registerVariable(this->primaryThrust_, variableDirection::toclient); 96 registerVariable(this->auxilaryThrust_, variableDirection::toclient); 97 registerVariable(this->rotationThrust_, variableDirection::toclient); 90 98 } 91 99 … … 95 103 } 96 104 105 bool SpaceShip::isCollisionTypeLegal(WorldEntity::CollisionType type) const 106 { 107 if (type != WorldEntity::Dynamic) 108 { 109 CCOUT(1) << "Error: Cannot tell a SpaceShip not to be dynamic! Ignoring." << std::endl; 110 assert(false); // Only in debug mode 111 return false; 112 } 113 else 114 return true; 115 } 116 97 117 void SpaceShip::tick(float dt) 98 118 { 99 if (this->isLocallyControlled()) 119 SUPER(SpaceShip, tick, dt); 120 121 if (this->hasLocalController()) 100 122 { 101 // ##################################### 102 // ############# STEERING ############## 103 // ##################################### 104 105 Vector3 velocity = this->getVelocity(); 106 if (velocity.x > this->maxSecondarySpeed_) 107 velocity.x = this->maxSecondarySpeed_; 108 if (velocity.x < -this->maxSecondarySpeed_) 109 velocity.x = -this->maxSecondarySpeed_; 110 if (velocity.y > this->maxSecondarySpeed_) 111 velocity.y = this->maxSecondarySpeed_; 112 if (velocity.y < -this->maxSecondarySpeed_) 113 velocity.y = -this->maxSecondarySpeed_; 114 if (velocity.z > this->maxSecondarySpeed_) 115 velocity.z = this->maxSecondarySpeed_; 116 if (velocity.z < -this->maxSpeed_) 117 velocity.z = -this->maxSpeed_; 118 119 // normalize velocity and acceleration 120 for (size_t dimension = 0; dimension < 3; ++dimension) 123 /* 124 this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() * getMass() * this->auxilaryThrust_); 125 this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() * getMass() * this->auxilaryThrust_); 126 if (this->localLinearAcceleration_.z() > 0) 127 this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->auxilaryThrust_); 128 else 129 this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->primaryThrust_); 130 this->physicalBody_->applyCentralForce(physicalBody_->getWorldTransform().getBasis() * this->localLinearAcceleration_); 131 this->localLinearAcceleration_.setValue(0, 0, 0); 132 */ 133 if (!this->isInMouseLook()) 121 134 { 122 if (this->acceleration_[dimension] == 0) 135 this->localAngularAcceleration_ *= this->getLocalInertia() * this->rotationThrust_; 136 this->physicalBody_->applyTorque(physicalBody_->getWorldTransform().getBasis() * this->localAngularAcceleration_); 137 this->localAngularAcceleration_.setValue(0, 0, 0); 138 } 139 } 140 } 141 142 void SpaceShip::moveFrontBack(const Vector2& value) 143 { 144 this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() - value.x); 145 this->steering_.z = -value.x; 146 } 147 148 void SpaceShip::moveRightLeft(const Vector2& value) 149 { 150 this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() + value.x); 151 this->steering_.x = value.x; 152 } 153 154 void SpaceShip::moveUpDown(const Vector2& value) 155 { 156 this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() + value.x); 157 this->steering_.y = value.x; 158 } 159 160 void SpaceShip::rotateYaw(const Vector2& value) 161 { 162 this->localAngularAcceleration_.setY(this->localAngularAcceleration_.y() - value.x); 163 164 Pawn::rotateYaw(value); 165 } 166 167 void SpaceShip::rotatePitch(const Vector2& value) 168 { 169 this->localAngularAcceleration_.setX(this->localAngularAcceleration_.x() + value.x); 170 171 Pawn::rotatePitch(value); 172 } 173 174 void SpaceShip::rotateRoll(const Vector2& value) 175 { 176 this->localAngularAcceleration_.setZ(this->localAngularAcceleration_.z() + value.x); 177 178 Pawn::rotateRoll(value); 179 } 180 181 void SpaceShip::fire() 182 { 183 } 184 185 void SpaceShip::boost() 186 { 187 this->bBoost_ = true; 188 } 189 190 void SpaceShip::loadEngineTemplate() 191 { 192 if (this->enginetemplate_ != "") 193 { 194 Template* temp = Template::getTemplate(this->enginetemplate_); 195 196 if (temp) 197 { 198 Identifier* identifier = temp->getBaseclassIdentifier(); 199 200 if (identifier) 123 201 { 124 if (velocity[dimension] > 0) 202 BaseObject* object = identifier->fabricate(this); 203 this->engine_ = dynamic_cast<Engine*>(object); 204 205 if (this->engine_) 125 206 { 126 velocity[dimension] -= (this->translationDamping_ * dt); 127 if (velocity[dimension] < 0) 128 velocity[dimension] = 0; 207 this->engine_->addTemplate(temp); 208 this->engine_->addToSpaceShip(this); 129 209 } 130 else if (velocity[dimension] < 0)210 else 131 211 { 132 velocity[dimension] += (this->translationDamping_ * dt); 133 if (velocity[dimension] > 0) 134 velocity[dimension] = 0; 212 delete object; 135 213 } 136 214 } 137 215 } 138 139 this->setVelocity(velocity);140 216 } 141 142 143 SUPER(SpaceShip, tick, dt); 144 145 146 if (this->isLocallyControlled()) 147 { 148 this->yaw(this->yawRotation_ * dt); 149 if (this->bInvertYAxis_) 150 this->pitch(Degree(-this->pitchRotation_ * dt)); 151 else 152 this->pitch(Degree( this->pitchRotation_ * dt)); 153 this->roll(this->rollRotation_ * dt); 154 155 this->acceleration_.x = 0; 156 this->acceleration_.y = 0; 157 this->acceleration_.z = 0; 158 159 this->yawRotation_ = this->zeroDegree_; 160 this->pitchRotation_ = this->zeroDegree_; 161 this->rollRotation_ = this->zeroDegree_; 162 } 163 } 164 165 void SpaceShip::moveFrontBack(const Vector2& value) 166 { 167 this->acceleration_.z = -this->translationAcceleration_ * value.x; 168 } 169 170 void SpaceShip::moveRightLeft(const Vector2& value) 171 { 172 this->acceleration_.x = this->translationAcceleration_ * value.x; 173 } 174 175 void SpaceShip::moveUpDown(const Vector2& value) 176 { 177 this->acceleration_.y = this->translationAcceleration_ * value.x; 178 } 179 180 void SpaceShip::rotateYaw(const Vector2& value) 181 { 182 Degree temp = value.x * value.x * sgn(value.x) * this->rotationAcceleration_; 183 if (temp > this->maxRotation_) 184 temp = this->maxRotation_; 185 if (temp < -this->maxRotation_) 186 temp = -this->maxRotation_; 187 this->yawRotation_ = Degree(temp); 188 } 189 190 void SpaceShip::rotatePitch(const Vector2& value) 191 { 192 Degree temp = value.x * value.x * sgn(value.x) * this->rotationAcceleration_; 193 if (temp > this->maxRotation_) 194 temp = this->maxRotation_; 195 if (temp < -this->maxRotation_) 196 temp = -this->maxRotation_; 197 this->pitchRotation_ = Degree(temp); 198 } 199 200 void SpaceShip::rotateRoll(const Vector2& value) 201 { 202 Degree temp = value.x * value.x * sgn(value.x) * this->rotationAcceleration_; 203 if (temp > this->maxRotation_) 204 temp = this->maxRotation_; 205 if (temp < -this->maxRotation_) 206 temp = -this->maxRotation_; 207 this->rollRotation_ = Degree(temp); 208 } 209 210 void SpaceShip::fire() 211 { 217 } 218 219 void SpaceShip::setEngine(Engine* engine) 220 { 221 this->engine_ = engine; 222 if (engine && engine->getShip() != this) 223 engine->addToSpaceShip(this); 212 224 } 213 225 } -
code/trunk/src/orxonox/objects/worldentities/pawns/SpaceShip.h
r2087 r2662 32 32 #include "OrxonoxPrereqs.h" 33 33 34 #include "LinearMath/btVector3.h" 35 34 36 #include "Pawn.h" 35 37 … … 56 58 57 59 virtual void fire(); 60 virtual void boost(); 58 61 59 void setMaxSpeed(float value) 60 { this->maxSpeed_ = value; } 61 void setMaxSecondarySpeed(float value) 62 { this->maxSecondarySpeed_ = value; } 63 void setMaxRotation(const Degree& value) 64 { this->maxRotation_ = value; } 65 void setTransAcc(float value) 66 { this->translationAcceleration_ = value; } 67 void setRotAcc(const Degree& value) 68 { this->rotationAcceleration_ = value; } 69 void setTransDamp(float value) 70 { this->translationDamping_ = value; } 62 void setEngine(Engine* engine); 63 inline Engine* getEngine() const 64 { return this->engine_; } 71 65 72 inline float getMaxSpeed() const 73 { return this->maxSpeed_; } 74 inline float getMaxSecondarySpeed() const 75 { return this->maxSecondarySpeed_; } 76 inline float getMaxRotation() const 77 { return this->maxRotation_.valueDegrees(); } 78 inline float getTransAcc() const 79 { return this->translationAcceleration_; } 80 inline float getRotAcc() const 81 { return this->rotationAcceleration_.valueDegrees(); } 82 inline float getTransDamp() const 83 { return this->translationDamping_; } 66 inline void setSteeringDirection(const Vector3& direction) 67 { this->steering_ = direction; } 68 inline const Vector3& getSteeringDirection() const 69 { return this->steering_; } 70 71 inline void setBoost(bool bBoost) 72 { this->bBoost_ = bBoost; } 73 inline bool getBoost() const 74 { return this->bBoost_; } 75 76 inline void setEngineTemplate(const std::string& temp) 77 { this->enginetemplate_ = temp; this->loadEngineTemplate(); } 78 inline const std::string& getEngineTemplate() const 79 { return this->enginetemplate_; } 80 81 inline void setPermanentBoost(bool bPermanent) 82 { this->bPermanentBoost_ = bPermanent; } 83 inline bool getPermanentBoost() const 84 { return this->bPermanentBoost_; } 84 85 85 86 protected: 86 87 bool bInvertYAxis_; 87 88 88 float maxSpeed_; 89 float maxSecondarySpeed_; 90 float translationAcceleration_; 91 float translationDamping_; 89 bool bBoost_; 90 bool bPermanentBoost_; 91 Vector3 steering_; 92 float primaryThrust_; 93 float auxilaryThrust_; 94 float rotationThrust_; 95 btVector3 localLinearAcceleration_; 96 btVector3 localAngularAcceleration_; 92 97 93 Degree maxRotation_;94 Degree rotationAcceleration_;98 private: 99 virtual bool isCollisionTypeLegal(WorldEntity::CollisionType type) const; 95 100 96 Degree zeroDegree_; 97 Degree pitchRotation_; 98 Degree yawRotation_; 99 Degree rollRotation_; 101 private: 102 void loadEngineTemplate(); 103 104 std::string enginetemplate_; 105 Engine* engine_; 100 106 }; 101 107 } -
code/trunk/src/orxonox/objects/worldentities/pawns/Spectator.cc
r2171 r2662 30 30 #include "Spectator.h" 31 31 32 #include <OgreBillboardSet.h> 33 32 34 #include "core/CoreIncludes.h" 35 #include "core/ConfigValueIncludes.h" 33 36 #include "core/Core.h" 34 37 #include "objects/worldentities/Model.h" … … 49 52 RegisterObject(Spectator); 50 53 51 this->speed_ = 100; 52 this->rotationSpeed_ = 3; 54 this->speed_ = 200; 53 55 54 56 this->yaw_ = 0; 55 57 this->pitch_ = 0; 56 58 this->roll_ = 0; 59 this->localVelocity_ = Vector3::ZERO; 57 60 this->setHudTemplate("spectatorhud"); 58 this-> hudmode_ = 0;61 this->greetingFlare_ = 0; 59 62 60 63 this->setDestroyWhenPlayerLeft(true); 61 64 62 this->greetingFlare_ = new BillboardSet(); 63 this->greetingFlare_->setBillboardSet(this->getScene()->getSceneManager(), "Examples/Flare", ColourValue(1.0, 1.0, 0.8), Vector3(0, 20, 0), 1); 64 if (this->greetingFlare_->getBillboardSet()) 65 this->getNode()->attachObject(this->greetingFlare_->getBillboardSet()); 66 this->greetingFlare_->setVisible(false); 65 if (Core::showsGraphics()) 66 { 67 this->greetingFlare_ = new BillboardSet(); 68 this->greetingFlare_->setBillboardSet(this->getScene()->getSceneManager(), "Examples/Flare", ColourValue(1.0, 1.0, 0.8), Vector3(0, 20, 0), 1); 69 if (this->greetingFlare_->getBillboardSet()) 70 this->attachOgreObject(this->greetingFlare_->getBillboardSet()); 71 this->greetingFlare_->setVisible(false); 72 } 73 67 74 this->bGreetingFlareVisible_ = false; 68 75 this->bGreeting_ = false; 69 76 77 this->setConfigValues(); 70 78 this->registerVariables(); 71 79 } … … 78 86 { 79 87 if (this->greetingFlare_->getBillboardSet()) 80 this->getNode()->detachObject(this->greetingFlare_->getBillboardSet()); 88 this->detachOgreObject(this->greetingFlare_->getBillboardSet()); 89 81 90 delete this->greetingFlare_; 82 91 } … … 84 93 } 85 94 95 void Spectator::setConfigValues() 96 { 97 SetConfigValue(speed_, 200.0f); 98 } 99 86 100 void Spectator::registerVariables() 87 101 { 88 REGISTERDATA(this->bGreetingFlareVisible_, direction::toclient, new NetworkCallback<Spectator>(this, &Spectator::changedFlareVisibility)); 89 REGISTERDATA(this->bGreeting_, direction::toserver, new NetworkCallback<Spectator>(this, &Spectator::changedGreeting)); 90 REGISTERDATA(this->hudmode_, direction::toclient); 102 registerVariable(this->bGreetingFlareVisible_, variableDirection::toclient, new NetworkCallback<Spectator>(this, &Spectator::changedFlareVisibility)); 103 registerVariable(this->bGreeting_, variableDirection::toserver, new NetworkCallback<Spectator>(this, &Spectator::changedGreeting)); 91 104 } 92 105 … … 99 112 void Spectator::changedFlareVisibility() 100 113 { 101 this->greetingFlare_->setVisible(this->bGreetingFlareVisible_); 114 if ( this->greetingFlare_ ) 115 this->greetingFlare_->setVisible(this->bGreetingFlareVisible_); 102 116 } 103 117 104 118 void Spectator::tick(float dt) 105 119 { 106 this->updateHUD(); 107 108 if (this->isLocallyControlled()) 109 { 110 Vector3 velocity = this->getVelocity(); 111 velocity.normalise(); 112 this->setVelocity(velocity * this->speed_); 113 114 this->yaw(Radian(this->yaw_ * this->rotationSpeed_)); 115 this->pitch(Radian(this->pitch_ * this->rotationSpeed_)); 116 this->roll(Radian(this->roll_ * this->rotationSpeed_)); 120 if (this->hasLocalController()) 121 { 122 float localSpeedSquared = this->localVelocity_.squaredLength(); 123 float localSpeed; 124 if (localSpeedSquared > 1.0) 125 localSpeed = this->speed_ / sqrtf(localSpeedSquared); 126 else 127 localSpeed = this->speed_; 128 129 this->localVelocity_.x *= localSpeed; 130 this->localVelocity_.y *= localSpeed; 131 this->localVelocity_.z *= localSpeed; 132 this->setVelocity(this->getOrientation() * this->localVelocity_); 133 this->localVelocity_.x = 0; 134 this->localVelocity_.y = 0; 135 this->localVelocity_.z = 0; 136 137 if (!this->isInMouseLook()) 138 { 139 this->yaw(Radian(this->yaw_ * this->getMouseLookSpeed())); 140 this->pitch(Radian(this->pitch_ * this->getMouseLookSpeed())); 141 this->roll(Radian(this->roll_ * this->getMouseLookSpeed())); 142 } 117 143 118 144 this->yaw_ = this->pitch_ = this->roll_ = 0; … … 120 146 121 147 SUPER(Spectator, tick, dt); 122 123 if (this->isLocallyControlled())124 {125 this->setVelocity(Vector3::ZERO);126 }127 148 } 128 149 … … 131 152 ControllableEntity::setPlayer(player); 132 153 133 // this->setObjectMode(direction::toclient); 134 } 135 136 void Spectator::startLocalControl() 137 { 138 ControllableEntity::startLocalControl(); 139 // if (this->isLocallyControlled()) 140 // this->testmesh_->setVisible(false); 154 // this->setObjectMode(objectDirection::toclient); 155 } 156 157 void Spectator::startLocalHumanControl() 158 { 159 ControllableEntity::startLocalHumanControl(); 141 160 } 142 161 143 162 void Spectator::moveFrontBack(const Vector2& value) 144 163 { 145 this-> setVelocity(this->getVelocity() + value.y * this->speed_ * WorldEntity::FRONT);164 this->localVelocity_.z -= value.x; 146 165 } 147 166 148 167 void Spectator::moveRightLeft(const Vector2& value) 149 168 { 150 this-> setVelocity(this->getVelocity() + value.y * this->speed_ * WorldEntity::RIGHT);169 this->localVelocity_.x += value.x; 151 170 } 152 171 153 172 void Spectator::moveUpDown(const Vector2& value) 154 173 { 155 this-> setVelocity(this->getVelocity() + value.y * this->speed_ * WorldEntity::UP);174 this->localVelocity_.y += value.x; 156 175 } 157 176 158 177 void Spectator::rotateYaw(const Vector2& value) 159 178 { 160 this->yaw_ = value.y; 179 this->yaw_ -= value.y; 180 181 ControllableEntity::rotateYaw(value); 161 182 } 162 183 163 184 void Spectator::rotatePitch(const Vector2& value) 164 185 { 165 this->pitch_ = value.y; 186 this->pitch_ += value.y; 187 188 ControllableEntity::rotatePitch(value); 166 189 } 167 190 168 191 void Spectator::rotateRoll(const Vector2& value) 169 192 { 170 this->roll_ = value.y; 171 } 172 173 void Spectator::fire() 193 this->roll_ += value.y; 194 195 ControllableEntity::rotateRoll(value); 196 } 197 198 void Spectator::fire(WeaponMode::Enum fireMode) 174 199 { 175 200 if (this->getPlayer()) … … 187 212 } 188 213 } 189 190 void Spectator::updateHUD()191 {192 // <hack>193 if (Core::isMaster())194 {195 if (this->getPlayer() && this->getGametype())196 {197 if (!this->getGametype()->hasStarted() && !this->getGametype()->isStartCountdownRunning())198 {199 if (!this->getPlayer()->isReadyToSpawn())200 this->hudmode_ = 0;201 else202 this->hudmode_ = 1;203 }204 else if (!this->getGametype()->hasEnded())205 {206 if (this->getGametype()->isStartCountdownRunning())207 this->hudmode_ = 2 + 10*(int)ceil(this->getGametype()->getStartCountdown());208 else209 this->hudmode_ = 3;210 }211 else212 this->hudmode_ = 4;213 }214 else215 return;216 }217 218 if (this->getHUD())219 {220 std::string text;221 int hudmode = this->hudmode_ % 10;222 223 switch (hudmode)224 {225 case 0:226 text = "Press [Fire] to start the match";227 break;228 case 1:229 text = "Waiting for other players";230 break;231 case 2:232 text = convertToString((this->hudmode_ - 2) / 10);233 break;234 case 3:235 text = "Press [Fire] to respawn";236 break;237 case 4:238 text = "Game has ended";239 break;240 default:;241 }242 243 std::map<std::string, OrxonoxOverlay*>::const_iterator it = this->getHUD()->getOverlays().begin();244 for (; it != this->getHUD()->getOverlays().end(); ++it)245 {246 if (it->second->isA(Class(OverlayText)) && it->second->getName() == "state")247 {248 OverlayText* overlay = dynamic_cast<OverlayText*>(it->second);249 if (overlay)250 overlay->setCaption(text);251 break;252 }253 }254 }255 // </hack>256 }257 214 } -
code/trunk/src/orxonox/objects/worldentities/pawns/Spectator.h
r2087 r2662 42 42 virtual ~Spectator(); 43 43 44 void setConfigValues(); 44 45 void registerVariables(); 45 46 virtual void tick(float dt); 46 47 47 48 virtual void setPlayer(PlayerInfo* player); 48 virtual void startLocal Control();49 virtual void startLocalHumanControl(); 49 50 50 51 virtual void moveFrontBack(const Vector2& value); … … 56 57 virtual void rotateRoll(const Vector2& value); 57 58 58 virtual void fire( );59 virtual void fire(WeaponMode::Enum fireMode); 59 60 virtual void greet(); 60 61 … … 62 63 void changedGreeting(); 63 64 void changedFlareVisibility(); 64 void updateHUD();65 65 66 66 BillboardSet* greetingFlare_; … … 69 69 70 70 float speed_; 71 float rotationSpeed_;72 71 73 72 float yaw_; … … 75 74 float roll_; 76 75 77 int hudmode_;76 Vector3 localVelocity_; 78 77 }; 79 78 } -
code/trunk/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/objects/worldentities/triggers/DistanceTrigger.h
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/objects/worldentities/triggers/PlayerTrigger.cc
r2262 r2662 28 28 29 29 /** 30 @file PlayerTrigger.cc30 @file 31 31 @brief 32 32 Implementation of the PlayerTrigger class. 33 33 */ 34 34 … … 38 38 #include "core/CoreIncludes.h" 39 39 40 namespace orxonox {41 40 namespace orxonox 41 { 42 42 /** 43 43 @brief … … 47 47 { 48 48 RegisterObject(PlayerTrigger); 49 49 50 50 this->player_ = NULL; 51 51 this->isForPlayer_ = true; 52 52 } 53 53 54 54 /** 55 55 @brief … … 66 66 void PlayerTrigger::XMLPort(Element& xmlelement, XMLPort::Mode mode) 67 67 { 68 68 SUPER(PlayerTrigger, XMLPort, xmlelement, mode); 69 69 } 70 71 70 } -
code/trunk/src/orxonox/objects/worldentities/triggers/PlayerTrigger.h
r2262 r2662 28 28 29 29 /** 30 @file PlayerTrigger.h30 @file 31 31 @brief 32 32 Definition of the PlayerTrigger class. 33 33 */ 34 34 … … 40 40 #include "Trigger.h" 41 41 42 namespace orxonox {43 42 namespace orxonox 43 { 44 44 /** 45 45 @brief … … 50 50 class _OrxonoxExport PlayerTrigger : public Trigger 51 51 { 52 public: 53 PlayerTrigger(BaseObject* creator); 54 virtual ~PlayerTrigger(); 55 56 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a PlayerTrigger object through XML. 52 public: 53 PlayerTrigger(BaseObject* creator); 54 virtual ~PlayerTrigger(); 55 56 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a PlayerTrigger object through XML. 57 58 /** 59 @brief Returns the player that triggered the PlayerTrigger. 60 @return Returns a pointer to the ControllableEntity that triggered the PlayerTrigger. 61 */ 62 inline ControllableEntity* getTriggeringPlayer(void) const 63 { return this->player_; } 64 65 /** 66 @brief Checks whether the PlayerTrigger normally returns a ControllableEntity. 67 @return Returns true if the PlayerTrigger normally returns a ControllableEntity. 68 */ 69 inline bool isForPlayer(void) const 70 { return this->isForPlayer_; } 57 71 58 /** 59 @brief Returns the player that triggered the PlayerTrigger. 60 @return Returns a pointer to the ControllableEntity that triggered the PlayerTrigger. 61 */ 62 inline ControllableEntity* getTriggeringPlayer(void) const 63 { return this->player_; } 64 65 /** 66 @brief Checks whether the PlayerTrigger normally returns a ControllableEntity. 67 @return Returns true if the PlayerTrigger normally returns a ControllableEntity. 68 */ 69 inline bool isForPlayer(void) const 70 { return this->isForPlayer_; } 71 72 protected: 73 virtual bool isTriggered(TriggerMode mode) = 0; 74 75 /** 76 @brief Set the player that triggered the PlayerTrigger. This is normally done by classes inheriting vom PlayerTrigger. 77 @param player A pointer to the ControllableEntity that triggered the PlayerTrigger. 78 */ 79 inline void setTriggeringPlayer(ControllableEntity* player) 80 { this->player_ = player; } 72 protected: 73 virtual bool isTriggered(TriggerMode mode) = 0; 74 75 /** 76 @brief Set the player that triggered the PlayerTrigger. This is normally done by classes inheriting vom PlayerTrigger. 77 @param player A pointer to the ControllableEntity that triggered the PlayerTrigger. 78 */ 79 inline void setTriggeringPlayer(ControllableEntity* player) 80 { this->player_ = player; } 81 81 82 82 /** … … 84 84 @param isForPlayer Should be true when the PlayerTrigger schould be set to normally be triggered by ControllableEntities, false if not. 85 85 */ 86 87 88 89 90 91 92 86 inline void setForPlayer(bool isForPlayer) 87 { this->isForPlayer_ = isForPlayer; } 88 89 private: 90 ControllableEntity* player_; //!< The player that triggered the PlayerTrigger. 91 bool isForPlayer_; //!< Is true when the PlayerTrigger schould be set to normally be triggered by ControllableEntities. 92 93 93 }; 94 94 -
code/trunk/src/orxonox/objects/worldentities/triggers/Trigger.cc
- Property svn:mergeinfo changed
r2261 r2662 31 31 32 32 #include <OgreBillboard.h> 33 #include <OgreBillboardSet.h> 33 34 #include "util/Debug.h" 34 35 #include "core/CoreIncludes.h" 35 36 #include "core/ConsoleCommand.h" 36 37 #include "core/XMLPort.h" 38 #include "core/Core.h" 37 39 #include "objects/Scene.h" 38 40 … … 44 46 CreateFactory(Trigger); 45 47 46 Trigger::Trigger(BaseObject* creator) : PositionableEntity(creator)48 Trigger::Trigger(BaseObject* creator) : StaticEntity(creator) 47 49 { 48 50 RegisterObject(Trigger); … … 65 67 // this->bUpdating_ = false; 66 68 67 if (this->getScene() && this->getScene()->getSceneManager())69 if (this->getScene() && Core::showsGraphics()) 68 70 { 69 71 this->debugBillboard_.setBillboardSet(this->getScene()->getSceneManager(), "Examples/Flare", ColourValue(1.0, 0.0, 0.0), 1); … … 71 73 72 74 if (this->debugBillboard_.getBillboardSet()) 73 this->getNode()->attachObject(this->debugBillboard_.getBillboardSet());75 this->attachOgreObject(this->debugBillboard_.getBillboardSet()); 74 76 } 75 77 … … 106 108 if (!this->BaseObject::isActive()) 107 109 return; 110 111 SUPER(Trigger, tick, dt); 108 112 109 113 bool newTriggered = this->isTriggered() ^ this->bInvertMode_; -
code/trunk/src/orxonox/objects/worldentities/triggers/Trigger.h
- Property svn:mergeinfo changed
r2261 r2662 36 36 37 37 #include "objects/Tickable.h" 38 #include "objects/worldentities/ PositionableEntity.h"38 #include "objects/worldentities/StaticEntity.h" 39 39 #include "tools/BillboardSet.h" 40 40 … … 48 48 }; 49 49 50 class _OrxonoxExport Trigger : public PositionableEntity, public Tickable50 class _OrxonoxExport Trigger : public StaticEntity, public Tickable 51 51 { 52 52 public: -
code/trunk/src/orxonox/overlays/CMakeLists.txt
r2131 r2662 8 8 ADD_SOURCE_DIRECTORY(SRC_FILES debug) 9 9 ADD_SOURCE_DIRECTORY(SRC_FILES hud) 10 ADD_SOURCE_DIRECTORY(SRC_FILES notifications) 11 ADD_SOURCE_DIRECTORY(SRC_FILES stats) 10 12 11 13 ADD_SOURCE_FILES(SRC_FILES) -
code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc
r2171 r2662 61 61 RegisterObject(OrxonoxOverlay); 62 62 63 this->owner_ = 0; 64 this->group_ = 0; 65 63 66 if (!Core::showsGraphics()) 64 67 ThrowException(NoGraphics, "Can't create OrxonoxOverlay, graphics engine not initialized"); 65 66 // add this overlay to the static map of OrxonoxOverlays67 if (overlays_s.find(this->getName()) != overlays_s.end())68 {69 COUT(1) << "Overlay names should be unique or you cannnot access them via console. Name: \"" << this->getName() << "\"" << std::endl;70 }71 overlays_s[this->getName()] = this;72 68 73 69 // create the Ogre::Overlay … … 92 88 setPosition(Vector2(0.0f, 0.0f)); 93 89 setRotation(Degree(0.0)); 94 setAspectCorrection( true);90 setAspectCorrection(false); 95 91 setBackgroundMaterial(""); 96 92 } … … 130 126 131 127 XMLPortParam(OrxonoxOverlay, "size", setSize, getSize, xmlElement, mode); 132 XMLPortParam(OrxonoxOverlay, "pick Point", setPickPoint, getPickPoint, xmlElement, mode);128 XMLPortParam(OrxonoxOverlay, "pickpoint", setPickPoint, getPickPoint, xmlElement, mode); 133 129 XMLPortParam(OrxonoxOverlay, "position", setPosition, getPosition, xmlElement, mode); 134 130 XMLPortParam(OrxonoxOverlay, "rotation", setRotation, getRotation, xmlElement, mode); 135 XMLPortParam(OrxonoxOverlay, "correct Aspect", setAspectCorrection, getAspectCorrection, xmlElement, mode);131 XMLPortParam(OrxonoxOverlay, "correctaspect", setAspectCorrection, getAspectCorrection, xmlElement, mode); 136 132 XMLPortParam(OrxonoxOverlay, "background", setBackgroundMaterial, getBackgroundMaterial, xmlElement, mode); 137 133 } … … 139 135 void OrxonoxOverlay::changedName() 140 136 { 137 SUPER(OrxonoxOverlay, changedName); 138 141 139 OrxonoxOverlay::overlays_s.erase(this->getOldName()); 142 140 -
code/trunk/src/orxonox/overlays/OrxonoxOverlay.h
r2087 r2662 125 125 126 126 //! Gets the rotation angle applied to this overlay in degrees. 127 const Radian& getRotation() const { return this->angle_; }127 const Degree& getRotation() const { return this->angle_; } 128 128 129 129 //! Rotates the overlay by angle degrees. … … 154 154 virtual void changedVisibility(); 155 155 156 inline void setOwner(ControllableEntity* owner) 157 { 158 if (this->owner_ != owner) 159 { 160 this->owner_ = owner; 161 this->changedOwner(); 162 } 163 } 164 inline ControllableEntity* getOwner() const 165 { return this->owner_; } 166 virtual void changedOwner() {} 167 168 inline void setOverlayGroup(OverlayGroup* group) 169 { 170 if (group != this->group_) 171 { 172 this->group_ = group; 173 this->changedOverlayGroup(); 174 } 175 } 176 inline OverlayGroup* getOverlayGroup() const 177 { return this->group_; } 178 virtual void changedOverlayGroup() {} 179 156 180 protected: 157 181 virtual void angleChanged(); … … 172 196 Vector2 position_; //!< Position of the pickPoint on the screen. 173 197 Vector2 pickPoint_; //!< Point on the overlay to pick when translating 174 Radianangle_; //!< Rotation angle of the overlay198 Degree angle_; //!< Rotation angle of the overlay 175 199 RotationState rotState_; //!< horizontal, vertical or inbetween 176 200 … … 182 206 We could also use the ObjectList, but that doesn't guarantee XMLPort(.) was called and is slower. */ 183 207 static std::map<std::string, OrxonoxOverlay*> overlays_s; 208 ControllableEntity* owner_; 209 OverlayGroup* group_; 184 210 }; 211 212 SUPER_FUNCTION(7, OrxonoxOverlay, changedOwner, false); 213 SUPER_FUNCTION(8, OrxonoxOverlay, changedOverlayGroup, false); 185 214 } 186 215 -
code/trunk/src/orxonox/overlays/OverlayGroup.cc
r2087 r2662 55 55 RegisterObject(OverlayGroup); 56 56 57 this->owner_ = 0; 58 57 59 setScale(Vector2(1.0, 1.0)); 58 60 setScroll(Vector2(0.0, 0.0)); … … 113 115 hudElements_[element->getName()] = element; 114 116 element->setVisible(this->isVisible()); 117 if (this->owner_) 118 element->setOwner(this->owner_); 115 119 } 116 120 } … … 137 141 } 138 142 143 void OverlayGroup::setOwner(ControllableEntity* owner) 144 { 145 this->owner_ = owner; 146 147 for (std::map<std::string, OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it) 148 (*it).second->setOwner(owner); 149 } 139 150 140 151 //########### Console commands ############ -
code/trunk/src/orxonox/overlays/OverlayGroup.h
r2087 r2662 69 69 void changedVisibility(); 70 70 71 private: 71 void setOwner(ControllableEntity* owner); 72 inline ControllableEntity* getOwner() const 73 { return this->owner_; } 74 72 75 //! Scales each OrxonoxOverlay individually by scale. 73 76 void scale(const Vector2& scale) { this->setScale(scale * this->scale_); } … … 85 88 OrxonoxOverlay* getElement(unsigned int index); 86 89 90 private: 87 91 std::map<std::string, OrxonoxOverlay*> hudElements_; //!< Contains all the OrxonoxOverlays of the this group. 88 Vector2 scale_; //!< Current scale (independ ant of the elements).92 Vector2 scale_; //!< Current scale (independent of the elements). 89 93 Vector2 scroll_; //!< Current scrolling offset. 94 ControllableEntity* owner_; //!< The owner of this OverlayGroup 90 95 }; 91 96 } -
code/trunk/src/orxonox/overlays/OverlayText.cc
r2087 r2662 50 50 this->text_->setCharHeight(1.0); 51 51 52 setFont("Monofur");53 setColour(ColourValue(1.0, 1.0, 1.0, 1.0));54 setCaption("");55 setTextSize(1.0f);56 setAlignmentString("left");52 this->setFont("Monofur"); 53 this->setColour(ColourValue(1.0, 1.0, 1.0, 1.0)); 54 this->setCaption(""); 55 this->setTextSize(1.0f); 56 this->setAlignmentString("left"); 57 57 58 58 this->background_->addChild(this->text_); … … 69 69 SUPER(OverlayText, XMLPort, xmlElement, mode); 70 70 71 XMLPortParam(OverlayText, "font", setFont, getFont, xmlElement, mode); 72 XMLPortParam(OverlayText, "colour", setColour, getColour, xmlElement, mode); 73 XMLPortParam(OverlayText, "caption", setCaption, getCaption, xmlElement, mode); 74 XMLPortParam(OverlayText, "textSize", setTextSize, getTextSize, xmlElement, mode); 75 XMLPortParam(OverlayText, "align", setAlignmentString, getAlignmentString, xmlElement, mode); 71 XMLPortParam(OverlayText, "font", setFont, getFont, xmlElement, mode); 72 XMLPortParam(OverlayText, "colour", setColour, getColour, xmlElement, mode); 73 XMLPortParam(OverlayText, "caption", setCaption, getCaption, xmlElement, mode); 74 XMLPortParam(OverlayText, "textsize", setTextSize, getTextSize, xmlElement, mode); 75 XMLPortParam(OverlayText, "align", setAlignmentString, getAlignmentString, xmlElement, mode); 76 XMLPortParam(OverlayText, "spacewidth", setSpaceWidth, getSpaceWidth, xmlElement, mode); 76 77 } 77 78 -
code/trunk/src/orxonox/overlays/OverlayText.h
r2087 r2662 47 47 virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); 48 48 49 void setCaption(const std::string& caption) { this->text_->setCaption(caption); }50 std::string getCaption() const { return this->text_->getCaption(); }49 inline void setCaption(const std::string& caption) { this->text_->setCaption(caption); } 50 inline std::string getCaption() const { return this->text_->getCaption(); } 51 51 52 52 void setFont(const std::string& font); 53 const std::string& getFont() const { return this->text_->getFontName(); }53 inline const std::string& getFont() const { return this->text_->getFontName(); } 54 54 55 void setColour(const ColourValue& colour) { this->text_->setColour(colour); }56 const ColourValue& getColour() const { return this->text_->getColour(); }55 inline void setSpaceWidth(float width) { this->text_->setSpaceWidth(width); } 56 inline float getSpaceWidth() const { return this->text_->getSpaceWidth(); } 57 57 58 void setAlignment(Ogre::TextAreaOverlayElement::Alignment alignment) { this->text_->setAlignment(alignment); }59 Ogre::TextAreaOverlayElement::Alignment getAlignment() const { return this->text_->getAlignment(); }58 inline void setColour(const ColourValue& colour) { this->text_->setColour(colour); } 59 inline const ColourValue& getColour() const { return this->text_->getColour(); } 60 60 61 protected:62 virtual void sizeChanged();61 inline void setAlignment(Ogre::TextAreaOverlayElement::Alignment alignment) { this->text_->setAlignment(alignment); } 62 inline Ogre::TextAreaOverlayElement::Alignment getAlignment() const { return this->text_->getAlignment(); } 63 63 64 64 void setAlignmentString(const std::string& alignment); 65 65 std::string getAlignmentString() const; 66 66 67 void setTextSize(float size) { this->setSize(Vector2(size, size)); } 68 float getTextSize() const { return this->getSize().y; } 67 inline void setTextSize(float size) { this->setSize(Vector2(size, size)); } 68 inline float getTextSize() const { return this->getSize().y; } 69 70 protected: 71 virtual void sizeChanged(); 69 72 70 73 Ogre::TextAreaOverlayElement* text_; -
code/trunk/src/orxonox/overlays/debug/DebugFPSText.cc
r2087 r2662 49 49 void DebugFPSText::tick(float dt) 50 50 { 51 SUPER(DebugFPSText, tick, dt); 52 51 53 float fps = GraphicsEngine::getInstance().getAverageFramesPerSecond(); 52 54 this->setCaption(convertToString(fps)); -
code/trunk/src/orxonox/overlays/debug/DebugRTRText.cc
r2087 r2662 49 49 void DebugRTRText::tick(float dt) 50 50 { 51 SUPER(DebugRTRText, tick, dt); 52 51 53 float rtr = GraphicsEngine::getInstance().getAverageTickTime(); 52 54 this->setCaption(convertToString(rtr)); -
code/trunk/src/orxonox/overlays/hud/CMakeLists.txt
r2131 r2662 4 4 HUDRadar.cc 5 5 HUDSpeedBar.cc 6 HUDHealthBar.cc 6 7 ChatOverlay.cc 8 GametypeStatus.cc 7 9 ) 8 10 -
code/trunk/src/orxonox/overlays/hud/HUDBar.cc
r2087 r2662 51 51 RegisterObject(BarColour); 52 52 53 setColour(ColourValue(1.0, 1.0, 1.0, 1.0));54 setPosition(0.0);53 this->setColour(ColourValue(1.0, 1.0, 1.0, 1.0)); 54 this->setPosition(0.0); 55 55 } 56 56 … … 84 84 this->bar_->setMaterialName(materialname); 85 85 86 setValue(0.4567654f); 87 setRightToLeft(false); 88 setAutoColour(true); 86 this->value_ = 1.0f; // initielize with 1.0f to trigger a change when calling setValue(0.0f) on the line below 87 this->setValue(0.0f); // <-- 88 this->setRightToLeft(false); 89 this->setAutoColour(true); 90 this->currentColour_ = ColourValue::White; 89 91 90 92 this->background_->addChild(bar_); … … 101 103 SUPER(HUDBar, XMLPort, xmlElement, mode); 102 104 103 XMLPortParam(HUDBar, "initialValue", setValue, getValue, xmlElement, mode); 104 XMLPortParam(HUDBar, "rightToLeft", setRightToLeft, getRightToLeft, xmlElement, mode); 105 XMLPortParam(HUDBar, "autoColour", setAutoColour, getAutoColour, xmlElement, mode); 105 XMLPortParam(HUDBar, "initialvalue", setValue, getValue, xmlElement, mode); 106 XMLPortParam(HUDBar, "righttoleft", setRightToLeft, getRightToLeft, xmlElement, mode); 107 XMLPortParam(HUDBar, "autocolour", setAutoColour, getAutoColour, xmlElement, mode); 108 XMLPortParam(HUDBar, "bartexture", setBarTexture, getBarTexture, xmlElement, mode); 106 109 XMLPortObject(HUDBar, BarColour, "", addColour, getColour, xmlElement, mode); 107 110 } … … 130 133 { 131 134 this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, colour2); 135 this->currentColour_ = colour2; 132 136 } 133 137 else if (value1 < this->value_) 134 138 { 135 139 this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, colour1); 140 this->currentColour_ = colour1; 136 141 } 137 142 else … … 139 144 //float interpolationfactor = (this->value_ - value2) / (value1 - value2); 140 145 float interpolationfactor = interpolateSmooth((this->value_ - value2) / (value1 - value2), 0.0f, 1.0f); 141 this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, colour1 * interpolationfactor + colour2 * (1 - interpolationfactor)); 146 this->currentColour_ = colour1 * interpolationfactor + colour2 * (1 - interpolationfactor); 147 this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, this->currentColour_); 148 142 149 } 143 150 } … … 181 188 this->colours_.clear(); 182 189 } 190 191 void HUDBar::setBarTexture(const std::string& texture) 192 { 193 this->textureUnitState_->setTextureName(texture); 194 } 195 196 const std::string& HUDBar::getBarTexture() const 197 { 198 return this->textureUnitState_->getTextureName(); 199 } 183 200 } -
code/trunk/src/orxonox/overlays/hud/HUDBar.h
r2087 r2662 71 71 void clearColours(); 72 72 73 void setRightToLeft(bool r2l) { this->right2Left_ = r2l; this->valueChanged(); } 74 bool getRightToLeft() const { return this->right2Left_; } 73 inline void setRightToLeft(bool r2l) 74 { 75 if (r2l != this->right2Left_) 76 { 77 this->right2Left_ = r2l; 78 this->valueChanged(); 79 } 80 } 81 inline bool getRightToLeft() const 82 { return this->right2Left_; } 75 83 76 void setValue(float value) { this->value_ = clamp(value, 0.0f, 1.0f); this->valueChanged(); } 77 float getValue() const { return this->value_; } 84 inline void setValue(float value) 85 { 86 float temp = clamp(value, 0.0f, 1.0f); 87 if (temp != this->value_) 88 { 89 this->value_ = temp; 90 this->valueChanged(); 91 } 92 } 93 inline float getValue() const 94 { return this->value_; } 78 95 79 void setAutoColour(bool val) { this->autoColour_ = val; this->valueChanged(); } 80 bool getAutoColour() const { return this->autoColour_; } 96 inline void setAutoColour(bool val) 97 { 98 if (val != this->autoColour_) 99 { 100 this->autoColour_ = val; 101 this->valueChanged(); 102 103 if (!val) 104 this->currentColour_ = ColourValue::White; 105 } 106 } 107 inline bool getAutoColour() const 108 { return this->autoColour_; } 109 110 void setBarTexture(const std::string& texture); 111 const std::string& getBarTexture() const; 112 113 inline const ColourValue& getCurrentBarColour() const 114 { return this->currentColour_; } 81 115 82 116 protected: … … 90 124 bool autoColour_; //!< whether bar changes colour automatically 91 125 float value_; //!< progress of bar 126 ColourValue currentColour_; 92 127 93 128 Ogre::PanelOverlayElement* bar_; -
code/trunk/src/orxonox/overlays/hud/HUDNavigation.cc
r2087 r2662 129 129 void HUDNavigation::tick(float dt) 130 130 { 131 SUPER(HUDNavigation, tick, dt); 132 131 133 if (!Radar::getInstance().getFocus()) 132 134 { … … 149 151 */ 150 152 // transform to screen coordinates 151 Vector3 pos = /*transformationMatrix * */Radar::getInstance().getFocus()->get WorldPosition();153 Vector3 pos = /*transformationMatrix * */Radar::getInstance().getFocus()->getRVWorldPosition(); 152 154 153 155 bool outOfView; … … 223 225 /* 224 226 Vector3 aimpos = transformationMatrix * getPredictedPosition(SpaceShip::getLocalShip()->getPosition(), 225 Projectile::getSpeed(), Radar::getInstance().getFocus()->get WorldPosition(), Radar::getInstance().getFocus()->getOrientedVelocity());227 Projectile::getSpeed(), Radar::getInstance().getFocus()->getRVWorldPosition(), Radar::getInstance().getFocus()->getRVOrientedVelocity()); 226 228 */ 227 229 if (wasOutOfView_) … … 250 252 /* 251 253 if (Radar::getInstance().getFocus()) 252 return (Radar::getInstance().getFocus()->get WorldPosition() - SpaceShip::getLocalShip()->getPosition()).length();254 return (Radar::getInstance().getFocus()->getRVWorldPosition() - SpaceShip::getLocalShip()->getPosition()).length(); 253 255 else 254 256 */ -
code/trunk/src/orxonox/overlays/hud/HUDRadar.cc
r2087 r2662 40 40 #include "core/XMLPort.h" 41 41 #include "objects/Radar.h" 42 #include "objects/worldentities/WorldEntity.h" 43 #include "objects/worldentities/pawns/Pawn.h" 42 44 #include "tools/TextureGenerator.h" 43 45 … … 51 53 RegisterObject(HUDRadar); 52 54 53 marker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()55 this->marker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton() 54 56 .createOverlayElement("Panel", "HUDRadar_marker_" + getUniqueNumberString())); 55 marker_->setMaterialName("Orxonox/RadarMarker");56 overlay_->add2D(marker_);57 marker_->hide();57 this->marker_->setMaterialName("Orxonox/RadarMarker"); 58 this->overlay_->add2D(this->marker_); 59 this->marker_->hide(); 58 60 59 setRadarSensitivity(1.0f);60 setHalfDotSizeDistance(3000.0f);61 setMaximumDotSize(0.1f);61 this->setRadarSensitivity(1.0f); 62 this->setHalfDotSizeDistance(3000.0f); 63 this->setMaximumDotSize(0.1f); 62 64 63 shapeMaterials_[RadarViewable::Dot] = "RadarSquare.tga"; 64 shapeMaterials_[RadarViewable::Triangle] = "RadarSquare.tga"; 65 shapeMaterials_[RadarViewable::Square] = "RadarSquare.tga"; 65 this->shapeMaterials_[RadarViewable::Dot] = "RadarDot.tga"; 66 this->shapeMaterials_[RadarViewable::Triangle] = "RadarSquare.tga"; 67 this->shapeMaterials_[RadarViewable::Square] = "RadarSquare.tga"; 68 69 this->owner_ = 0; 66 70 } 67 71 … … 90 94 void HUDRadar::displayObject(RadarViewable* object, bool bIsMarked) 91 95 { 92 /* 96 if (object == (RadarViewable*)this->owner_) 97 return; 98 93 99 const WorldEntity* wePointer = object->getWorldEntity(); 94 100 95 101 // Just to be sure that we actually have a WorldEntity. 96 102 // We could do a dynamic_cast, but that would be a lot slower. 97 if (!wePointer )103 if (!wePointer || !this->owner_) 98 104 { 99 CCOUT(4) << "Cannot display a non-WorldEntitiy on the radar" << std::endl; 105 if (!wePointer) 106 CCOUT(2) << "Cannot display a non-WorldEntitiy on the radar" << std::endl; 107 if (!this->owner_) 108 CCOUT(2) << "No owner defined" << std::endl; 100 109 return; 101 110 } 102 */ 111 103 112 // try to find a panel already created 104 113 Ogre::PanelOverlayElement* panel; … … 112 121 // get right material 113 122 panel->setMaterialName(TextureGenerator::getMaterialName( 114 shapeMaterials_[object->getRadarObject Type()], object->getRadarObjectColour()));123 shapeMaterials_[object->getRadarObjectShape()], object->getRadarObjectColour())); 115 124 this->overlay_->add2D(panel); 116 125 this->itRadarDots_ = this->radarDots_.end(); … … 121 130 ++itRadarDots_; 122 131 std::string materialName = TextureGenerator::getMaterialName( 123 shapeMaterials_[object->getRadarObject Type()], object->getRadarObjectColour());132 shapeMaterials_[object->getRadarObjectShape()], object->getRadarObjectColour()); 124 133 if (materialName != panel->getMaterialName()) 125 134 panel->setMaterialName(materialName); 126 135 } 127 136 panel->show(); 128 /* 137 129 138 // set size to fit distance... 130 float distance = (wePointer->getWorldPosition() - SpaceShip::getLocalShip()->getPosition()).length();139 float distance = (wePointer->getWorldPosition() - this->owner_->getPosition()).length(); 131 140 // calculate the size with 1/distance dependency for simplicity (instead of exp(-distance * lambda) 132 141 float size = maximumDotSize_ * halfDotSizeDistance_ / (halfDotSizeDistance_ + distance); … … 134 143 135 144 // calc position on radar... 136 Vector2 coord = get2DViewcoordinates( SpaceShip::getLocalShip()->getPosition(), SpaceShip::getLocalShip()->getDir(), SpaceShip::getLocalShip()->getOrth(), wePointer->getWorldPosition());145 Vector2 coord = get2DViewcoordinates(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition()); 137 146 coord *= Ogre::Math::PI / 3.5; // small adjustment to make it fit the texture 138 147 panel->setPosition((1.0 + coord.x - size) * 0.5, (1.0 - coord.y - size) * 0.5); … … 144 153 this->marker_->setPosition((1.0 + coord.x - size * 1.5) * 0.5, (1.0 - coord.y - size * 1.5) * 0.5); 145 154 } 146 */147 155 } 148 156 … … 154 162 this->marker_->hide(); 155 163 } 164 165 void HUDRadar::changedOwner() 166 { 167 SUPER(HUDRadar, changedOwner); 168 169 this->owner_ = dynamic_cast<Pawn*>(this->getOwner()); 170 } 156 171 } -
code/trunk/src/orxonox/overlays/hud/HUDRadar.h
r2087 r2662 49 49 50 50 virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); 51 virtual void changedOwner(); 51 52 52 53 private: … … 76 77 77 78 float sensitivity_; 79 80 Pawn* owner_; 78 81 }; 79 82 } -
code/trunk/src/orxonox/overlays/hud/HUDSpeedBar.cc
r2087 r2662 31 31 #include "HUDSpeedBar.h" 32 32 #include "core/CoreIncludes.h" 33 #include "objects/worldentities/pawns/SpaceShip.h" 34 #include "objects/items/Engine.h" 33 35 34 36 namespace orxonox … … 41 43 RegisterObject(HUDSpeedBar); 42 44 45 this->owner_ = 0; 43 46 } 44 47 … … 49 52 void HUDSpeedBar::tick(float dt) 50 53 { 51 /* 52 SpaceShip* ship = SpaceShip::getLocalShip(); 53 if ( ship)54 SUPER(HUDSpeedBar, tick, dt); 55 56 if (this->owner_ && this->owner_->getEngine()) 54 57 { 55 float v = ship->getVelocity().length(); 56 float value = v / ship->getMaxSpeed(); 57 if (value != this->getValue()) 58 this->setValue(value); 58 float value = this->owner_->getVelocity().length() / (this->owner_->getEngine()->getMaxSpeedFront() * this->owner_->getEngine()->getSpeedFactor() * this->owner_->getEngine()->getBoostFactor()); 59 this->setValue(value); 59 60 } 60 */ 61 } 62 63 void HUDSpeedBar::changedOwner() 64 { 65 SUPER(HUDSpeedBar, changedOwner); 66 67 this->owner_ = dynamic_cast<SpaceShip*>(this->getOwner()); 61 68 } 62 69 } -
code/trunk/src/orxonox/overlays/hud/HUDSpeedBar.h
r2087 r2662 45 45 46 46 virtual void tick(float dt); 47 virtual void changedOwner(); 48 49 private: 50 SpaceShip* owner_; 47 51 }; 48 52 } -
code/trunk/src/orxonox/tools/BillboardSet.cc
r2171 r2662 34 34 35 35 #include <OgreSceneManager.h> 36 #include <OgreBillboardSet.h> 36 37 #include <OgreBillboard.h> 37 38 -
code/trunk/src/orxonox/tools/BillboardSet.h
r2087 r2662 33 33 34 34 #include <string> 35 #include <Ogre BillboardSet.h>35 #include <OgrePrerequisites.h> 36 36 37 37 #include "util/Math.h" … … 52 52 inline Ogre::BillboardSet* getBillboardSet() 53 53 { return this->billboardSet_; } 54 inline Ogre::SceneManager* getSceneManager() 55 { return this->scenemanager_; } 54 56 55 57 const std::string& getName() const; -
code/trunk/src/orxonox/tools/CMakeLists.txt
r2131 r2662 3 3 Mesh.cc 4 4 ParticleInterface.cc 5 Shader.cc 5 6 TextureGenerator.cc 6 7 Timer.cc -
code/trunk/src/orxonox/tools/Mesh.cc
r2171 r2662 31 31 32 32 #include <sstream> 33 #include <OgreEntity.h> 33 34 #include <OgreSceneManager.h> 34 35 #include <cassert> -
code/trunk/src/orxonox/tools/Mesh.h
r2087 r2662 33 33 34 34 #include <string> 35 #include <Ogre Entity.h>35 #include <OgrePrerequisites.h> 36 36 37 37 namespace orxonox -
code/trunk/src/orxonox/tools/ParticleInterface.cc
r2171 r2662 52 52 ParticleInterface::ParticleInterface(Ogre::SceneManager* scenemanager, const std::string& templateName, LODParticle::LOD detaillevel) 53 53 { 54 Register RootObject(ParticleInterface);54 RegisterObject(ParticleInterface); 55 55 56 56 assert(scenemanager); 57 57 58 58 this->scenemanager_ = scenemanager; 59 this->sceneNode_ = 0;60 59 this->particleSystem_ = 0; 61 60 … … 63 62 this->bVisible_ = true; 64 63 this->bAllowedByLOD_ = true; 64 this->speedFactor_ = 1.0f; 65 65 66 66 if (Core::showsGraphics()) … … 69 69 { 70 70 this->particleSystem_ = this->scenemanager_->createParticleSystem("particles" + getConvertedValue<unsigned int, std::string>(ParticleInterface::counter_s++), templateName); 71 this->particleSystem_->setSpeedFactor(1.0f); 72 // this->particleSystem_->setSpeedFactor(Orxonox::getInstance().getTimeFactor()); 71 this->setSpeedFactor(1.0f); 73 72 } 74 73 catch (...) … … 87 86 { 88 87 this->particleSystem_->removeAllEmitters(); 89 this->detachFromSceneNode();90 88 this->scenemanager_->destroyParticleSystem(this->particleSystem_); 91 }92 }93 94 void ParticleInterface::addToSceneNode(Ogre::SceneNode* sceneNode)95 {96 if (this->sceneNode_)97 this->detachFromSceneNode();98 99 if (this->particleSystem_)100 {101 this->sceneNode_ = sceneNode;102 this->sceneNode_->attachObject(this->particleSystem_);103 }104 }105 106 void ParticleInterface::detachFromSceneNode()107 {108 if (this->sceneNode_)109 {110 if (this->particleSystem_)111 this->sceneNode_->detachObject(this->particleSystem_);112 this->sceneNode_ = 0;113 89 } 114 90 } … … 224 200 void ParticleInterface::setSpeedFactor(float factor) 225 201 { 226 if (this->particleSystem_) 227 { 228 // this->particleSystem_->setSpeedFactor(Orxonox::getInstance().getTimeFactor() * factor); 229 this->particleSystem_->setSpeedFactor(1.0f * factor); 230 } 231 } 232 float ParticleInterface::getSpeedFactor() const 233 { 234 if (this->particleSystem_) 235 { 236 // return (this->particleSystem_->getSpeedFactor() / Orxonox::getInstance().getTimeFactor()); 237 return (this->particleSystem_->getSpeedFactor() / 1.0f); 238 } 239 else 240 return 1.0f; 202 this->speedFactor_ = factor; 203 204 if (this->particleSystem_) 205 this->particleSystem_->setSpeedFactor(factor * this->getTimeFactor()); 206 } 207 void ParticleInterface::changedTimeFactor(float factor_new, float factor_old) 208 { 209 this->setSpeedFactor(this->speedFactor_); 241 210 } 242 211 -
code/trunk/src/orxonox/tools/ParticleInterface.h
r2087 r2662 33 33 34 34 #include <string> 35 #include <OgreP articleEmitter.h>35 #include <OgrePrerequisites.h> 36 36 37 37 #include "core/OrxonoxClass.h" 38 38 #include "util/Math.h" 39 #include "gamestates/GSRoot.h" 39 40 40 41 #define getAllEmitters() \ … … 45 46 namespace orxonox 46 47 { 47 class _OrxonoxExport ParticleInterface : public OrxonoxClass48 class _OrxonoxExport ParticleInterface : public TimeFactorListener 48 49 { 49 50 public: … … 53 54 inline Ogre::ParticleSystem* getParticleSystem() const 54 55 { return this->particleSystem_; } 55 56 void addToSceneNode(Ogre::SceneNode* sceneNode);57 void detachFromSceneNode();58 56 59 57 Ogre::ParticleEmitter* createNewEmitter(); … … 69 67 unsigned int getNumAffectors() const; 70 68 71 float getSpeedFactor() const; 69 inline float getSpeedFactor() const 70 { return this->speedFactor_; } 72 71 void setSpeedFactor(float factor); 73 72 bool getKeepParticlesInLocalSpace() const; … … 90 89 { return ParticleInterface::currentParticleInterface_s; } 91 90 91 protected: 92 virtual void changedTimeFactor(float factor_new, float factor_old); 93 92 94 private: 93 95 void updateVisibility(); … … 96 98 static unsigned int counter_s; 97 99 98 Ogre::SceneNode* sceneNode_;99 100 Ogre::ParticleSystem* particleSystem_; 100 101 bool bVisible_; … … 102 103 bool bAllowedByLOD_; 103 104 unsigned int detaillevel_; //!< Detail level of this particle effect (0: off, 1: low, 2: normal, 3: high) 105 float speedFactor_; 104 106 Ogre::SceneManager* scenemanager_; 105 107 }; -
code/trunk/src/orxonox/tools/Timer.cc
r2087 r2662 96 96 this->time_ = 0; 97 97 98 Register RootObject(TimerBase);98 RegisterObject(TimerBase); 99 99 } 100 100 … … 137 137 { 138 138 // If active: Decrease the timer by the duration of the last frame 139 this->time_ -= time.getDeltaTimeMicroseconds();139 this->time_ -= (long long)(time.getDeltaTimeMicroseconds() * this->getTimeFactor()); 140 140 141 141 if (this->time_ <= 0) -
code/trunk/src/orxonox/tools/Timer.h
r2171 r2662 62 62 63 63 #include "OrxonoxPrereqs.h" 64 #include "core/Executor.h" 64 65 #include "core/OrxonoxClass.h" 66 #include "gamestates/GSRoot.h" 65 67 66 68 namespace orxonox … … 72 74 73 75 //! TimerBase is the parent of the Timer class. 74 class _OrxonoxExport TimerBase : public OrxonoxClass76 class _OrxonoxExport TimerBase : public TimeFactorListener 75 77 { 76 78 public: … … 159 161 this->bLoop_ = bLoop; 160 162 executor->setObject(object); 161 this->executor_ = (Executor*)executor;163 this->executor_ = static_cast<Executor*>(executor); 162 164 this->bActive_ = true; 163 165 … … 197 199 this->setInterval(interval); 198 200 this->bLoop_ = bLoop; 199 this->executor_ = (Executor*)executor;201 this->executor_ = executor; 200 202 this->bActive_ = true; 201 203 -
code/trunk/src/orxonox/tools/WindowEventListener.h
r1755 r2662 41 41 class _OrxonoxExport WindowEventListener : virtual public OrxonoxClass 42 42 { 43 public:44 WindowEventListener();45 virtual ~WindowEventListener() { }43 public: 44 WindowEventListener(); 45 virtual ~WindowEventListener() { } 46 46 47 47 /** Window has moved position */ -
code/trunk/src/tolua/tolua-5.1.pkg
- Property svn:mergeinfo changed
/code/branches/network/src/tolua/tolua-5.1.pkg (added) merged: 2356 /code/branches/physics/src/tolua/tolua-5.1.pkg (added) merged: 2192 /code/branches/physics_merge/src/tolua/tolua-5.1.pkg (added) merged: 2442 /code/branches/pickups2/src/tolua/tolua-5.1.pkg (added) merged: 2136 /code/branches/presentation/src/tolua/tolua-5.1.pkg (added) merged: 2371,2420,2459,2485,2492-2493,2500
- Property svn:mergeinfo changed
-
code/trunk/src/util
- Property svn:mergeinfo changed
/code/branches/network/src/util (added) merged: 2356 /code/branches/network64/src/util (added) merged: 2245 /code/branches/objecthierarchy2/src/util (added) merged: 2257,2259,2343-2345,2361 /code/branches/overlay/src/util (added) merged: 2180 /code/branches/physics/src/util (added) merged: 2192,2298,2305,2424 /code/branches/physics_merge/src/util (added) merged: 2442 /code/branches/pickups2/src/util (added) merged: 2136 /code/branches/presentation/src/util (added) merged: 2371,2420,2459,2485,2492-2493,2500,2535,2541-2542,2560
- Property svn:mergeinfo changed
-
code/trunk/src/util/Convert.h
r2171 r2662 460 460 else 461 461 *output = "false"; 462 return false;462 return true; 463 463 } 464 464 }; -
code/trunk/src/util/Exception.cc
- Property svn:mergeinfo changed
/code/branches/gui/src/core/Exception.cc reverse-merged: 1638,1664 /code/branches/network/src/util/Exception.cc (added) merged: 2356 /code/branches/physics/src/util/Exception.cc (added) merged: 2192 /code/branches/physics_merge/src/util/Exception.cc (added) merged: 2442 /code/branches/pickups2/src/util/Exception.cc (added) merged: 2136 /code/branches/presentation/src/util/Exception.cc (added) merged: 2371,2420,2459,2485,2492-2493,2500
- Property svn:mergeinfo changed
-
code/trunk/src/util/Exception.h
- Property svn:mergeinfo changed
/code/branches/gui/src/core/Exception.h reverse-merged: 1638,1642,1645,1652,1660,1663-1664,1670,1704 /code/branches/network/src/util/Exception.h (added) merged: 2356 /code/branches/objecthierarchy2/src/util/Exception.h (added) merged: 2257,2259 /code/branches/physics/src/util/Exception.h (added) merged: 2192,2298,2305 /code/branches/physics_merge/src/util/Exception.h (added) merged: 2442 /code/branches/pickups2/src/util/Exception.h (added) merged: 2136 /code/branches/presentation/src/util/Exception.h (added) merged: 2371,2420,2459,2485,2492-2493,2500
r2261 r2662 82 82 const char* filename, const char* functionName) \ 83 83 : Exception(description, lineNumber, filename, functionName) \ 84 { \ 85 /* Let the catcher decide whether to display the message below level 4 \ 86 Note: Don't place this code in Exception c'tor because getTypeName() \ 87 is still pure virtual at that time. */ \ 88 COUT(4) << this->getFullDescription() << std::endl; \ 89 } \ 84 { } \ 90 85 \ 91 86 ExceptionName##Exception(const std::string& description) \ 92 87 : Exception(description) \ 93 { COUT(4) << this->getFullDescription() << std::endl; }\88 { } \ 94 89 \ 95 90 ~ExceptionName##Exception() throw() { } \ … … 103 98 CREATE_ORXONOX_EXCEPTION(FileNotFound); 104 99 CREATE_ORXONOX_EXCEPTION(Argument); 100 CREATE_ORXONOX_EXCEPTION(PhysicsViolation); 101 CREATE_ORXONOX_EXCEPTION(ParseError); 105 102 CREATE_ORXONOX_EXCEPTION(PluginsNotFound); 106 103 CREATE_ORXONOX_EXCEPTION(InitialisationFailed); … … 111 108 } 112 109 113 #define ThrowException(Type, Description) \ 114 throw Type##Exception(Description, __LINE__, __FILE__, __FUNCTIONNAME__) 110 /** 111 @brief 112 Helper function that creates an exception, displays the message, but doesn't throw it. 113 */ 114 template <class T> 115 inline const T& InternalHandleException(const T& exception) 116 { 117 // let the catcher decide whether to display the message below level 4 118 COUT(4) << exception.getFullDescription() << std::endl; 119 return exception; 120 } 121 122 #define ThrowException(type, description) \ 123 throw InternalHandleException(type##Exception(description, __LINE__, __FILE__, __FUNCTIONNAME__)) 115 124 116 125 // define an assert macro that can display a message - Property svn:mergeinfo changed
-
code/trunk/src/util/Integers.h
r1755 r2662 49 49 typedef unsigned __int32 uint32_t; 50 50 typedef unsigned __int64 uint64_t; 51 #el if ORXONOX_COMPILER == ORXONOX_COMPILER_GCC52 # include "inttypes.h"51 #else 52 # include <inttypes.h> 53 53 #endif 54 54 -
code/trunk/src/util/Math.h
r2171 r2662 63 63 namespace orxonox 64 64 { 65 typedef Ogre::Radian Radian; 66 typedef Ogre::Degree Degree; 67 typedef Ogre::Vector2 Vector2; 68 typedef Ogre::Vector3 Vector3; 69 typedef Ogre::Vector4 Vector4; 70 typedef Ogre::Matrix3 Matrix3; 71 typedef Ogre::Matrix4 Matrix4; 72 typedef Ogre::Quaternion Quaternion; 73 typedef Ogre::ColourValue ColourValue; 65 using Ogre::Radian; 66 using Ogre::Degree; 67 using Ogre::Vector2; 68 using Ogre::Vector3; 69 using Ogre::Vector4; 70 using Ogre::Matrix3; 71 using Ogre::Matrix4; 72 using Ogre::Quaternion; 73 using Ogre::ColourValue; 74 75 // Also define our own transform space enum 76 namespace TransformSpace 77 { 78 /** 79 @brief 80 Enumeration denoting the spaces which a transform can be relative to. 81 */ 82 enum Enum 83 { 84 //! Transform is relative to the local space 85 Local, 86 //! Transform is relative to the space of the parent node 87 Parent, 88 //! Transform is relative to world space 89 World 90 }; 91 } 74 92 75 93 _UtilExport std::ostream& operator<<(std::ostream& out, const orxonox::Radian& radian); … … 174 192 inline T zeroise() 175 193 { 176 BOOST_STATIC_ASSERT(sizeof(T) == 0); 177 return T(); 194 // Default, raise a compiler error without including large boost header cascade. 195 T temp(); 196 *********temp; // If you reach this code, you abused zeroise()! 197 return temp; 178 198 } 179 199 -
code/trunk/src/util/MultiType.cc
r2171 r2662 45 45 switch (type) 46 46 { 47 case MT_null: 48 this->reset(); return true; 47 49 case MT_char: 48 50 return this->convert<char>(); break; -
code/trunk/src/util/MultiType.h
r2171 r2662 305 305 306 306 /** @brief Current content gets deleted. New type is MT_null */ 307 inline void reset() { if (this->value_) this->value_->reset(); } 308 309 template <typename T> inline void setType() { this->assignValue(T()); } /** @brief Resets the value and changes the internal type to T. */ 310 inline void setType(const MultiType& other) { this->setType(other.getType()); } /** @brief Resets the value and changes the internal type to the type of the other MultiType. */ 311 inline void setType(MT_Type type) { this->reset(); this->convert(type); this->reset(); } /** @brief Resets the value and changes the internal type to the given type. */ 307 inline void reset() { if (this->value_) delete this->value_; this->value_ = 0; } 308 /** @brief Current content gets overridden with default zero value */ 309 inline void resetValue() { if (this->value_) this->value_->reset(); } 310 311 template <typename T> inline void setType() { this->assignValue(T()); } /** @brief Resets the value and changes the internal type to T. */ 312 inline void setType(const MultiType& other) { this->setType(other.getType()); } /** @brief Resets the value and changes the internal type to the type of the other MultiType. */ 313 inline void setType(MT_Type type) { this->reset(); this->convert(type); this->resetValue(); } /** @brief Resets the value and changes the internal type to the given type. */ 312 314 313 315 /** @brief Returns the current type. */ -
code/trunk/src/util/OutputHandler.cc
r2171 r2662 100 100 @param buffer The OutputBuffer 101 101 */ 102 void OutputHandler::setOutputBuffer(OutputBuffer& buffer) 103 { 104 buffer.getStream() >> this->outputBuffer_->getStream().rdbuf(); 105 this->outputBuffer_ = &buffer; 102 void OutputHandler::setOutputBuffer(OutputBuffer* buffer) 103 { 104 if (buffer == NULL) 105 this->outputBuffer_ = &this->fallbackBuffer_; 106 else 107 { 108 buffer->getStream() >> this->outputBuffer_->getStream().rdbuf(); 109 this->outputBuffer_ = buffer; 110 } 106 111 } 107 112 -
code/trunk/src/util/OutputHandler.h
r2171 r2662 101 101 static int getSoftDebugLevel(OutputHandler::OutputDevice device = OutputHandler::LD_All); 102 102 103 void setOutputBuffer(OutputBuffer &buffer);103 void setOutputBuffer(OutputBuffer* buffer); 104 104 105 105 template <class T> -
code/trunk/src/util/SignalHandler.cc
- Property svn:mergeinfo changed
/code/branches/core3/src/orxonox/SignalHandler.cc reverse-merged: 1607,1678 /code/branches/network/src/util/SignalHandler.cc (added) merged: 2356 /code/branches/objecthierarchy2/src/util/SignalHandler.cc (added) merged: 2344-2345 /code/branches/physics_merge/src/util/SignalHandler.cc (added) merged: 2442 /code/branches/presentation/src/util/SignalHandler.cc (added) merged: 2371,2420,2459,2485,2492-2493,2500 /code/trunk/src/util/SignalHandler.cc (added) merged: 2-2085
r2261 r2662 35 35 #include "Debug.h" 36 36 37 #include <cassert>38 37 #include <iostream> 39 38 #include <cstdlib> … … 42 41 namespace orxonox 43 42 { 44 SignalHandler * SignalHandler::singletonRef= NULL;43 SignalHandler* SignalHandler::singletonRef_s = NULL; 45 44 } 46 45 … … 55 54 { 56 55 bool SignalHandler::bXAutoKeyRepeatOn_ = false; 57 58 SignalHandler::SignalHandler()59 {60 }61 56 62 57 /** … … 133 128 void SignalHandler::sigHandler( int sig ) 134 129 { 135 for ( SignalCallbackList::iterator it = SignalHandler::getInstance() ->callbackList.begin(); it != SignalHandler::getInstance()->callbackList.end(); it++ )130 for ( SignalCallbackList::iterator it = SignalHandler::getInstance().callbackList.begin(); it != SignalHandler::getInstance().callbackList.end(); it++ ) 136 131 { 137 132 (*(it->cb))( it->someData ); … … 184 179 if ( sigPid == 0 ) 185 180 { 186 getInstance() ->dontCatch();181 getInstance().dontCatch(); 187 182 // wait for message from parent when it has attached gdb 188 183 int someData; … … 237 232 238 233 char cmd[256]; 239 snprintf( cmd, 256, "file %s\nattach %d\nc\n", getInstance() ->appName.c_str(), sigPid );234 snprintf( cmd, 256, "file %s\nattach %d\nc\n", getInstance().appName.c_str(), sigPid ); 240 235 write( gdbIn[1], cmd, strlen(cmd) ); 241 236 … … 331 326 bt.insert(0, timeString); 332 327 333 FILE * f = fopen( getInstance() ->filename.c_str(), "a" );328 FILE * f = fopen( getInstance().filename.c_str(), "a" ); 334 329 335 330 if ( !f ) 336 331 { 337 perror( ( std::string( "could not append to " ) + getInstance() ->filename ).c_str() );332 perror( ( std::string( "could not append to " ) + getInstance().filename ).c_str() ); 338 333 exit(EXIT_FAILURE); 339 334 } … … 341 336 if ( fwrite( bt.c_str(), 1, bt.length(), f ) != bt.length() ) 342 337 { 343 COUT(0) << "could not write " << bt.length() << " byte to " << getInstance() ->filename << std::endl;338 COUT(0) << "could not write " << bt.length() << " byte to " << getInstance().filename << std::endl; 344 339 exit(EXIT_FAILURE); 345 340 } - Property svn:mergeinfo changed
-
code/trunk/src/util/SignalHandler.h
- Property svn:mergeinfo changed
/code/branches/core3/src/orxonox/SignalHandler.h reverse-merged: 1607 /code/branches/network/src/util/SignalHandler.h (added) merged: 2356 /code/branches/objecthierarchy2/src/util/SignalHandler.h (added) merged: 2344 /code/branches/physics_merge/src/util/SignalHandler.h (added) merged: 2442 /code/branches/presentation/src/util/SignalHandler.h (added) merged: 2371,2420,2459,2485,2492-2493,2500 /code/trunk/src/util/SignalHandler.h (added) merged: 2-2085
r2261 r2662 37 37 #include "UtilPrereqs.h" 38 38 39 #include <cassert> 39 40 #include <list> 40 41 #include <string> … … 68 69 class SignalHandler 69 70 { 70 private:71 SignalHandler();72 71 public: 73 inline static SignalHandler* getInstance() { if (!SignalHandler::singletonRef) SignalHandler::singletonRef = new SignalHandler(); return SignalHandler::singletonRef; } 74 ~SignalHandler(){ SignalHandler::singletonRef = NULL; } 72 SignalHandler() { assert(SignalHandler::singletonRef_s == 0); SignalHandler::singletonRef_s = this; } 73 ~SignalHandler() { assert(SignalHandler::singletonRef_s != 0); SignalHandler::singletonRef_s = NULL; } 74 inline static SignalHandler& getInstance() { assert(SignalHandler::singletonRef_s); return *SignalHandler::singletonRef_s; } 75 75 76 76 void registerCallback( SignalCallback cb, void * someData ); … … 87 87 SignalCallbackList callbackList; 88 88 89 static SignalHandler * singletonRef;89 static SignalHandler* singletonRef_s; 90 90 91 91 std::string appName; … … 104 104 { 105 105 public: 106 inline static SignalHandler* getInstance() { if (!SignalHandler::singletonRef) SignalHandler::singletonRef = new SignalHandler(); return SignalHandler::singletonRef; }; 107 void doCatch( const std::string & appName, const std::string & filename ) {}; 108 void dontCatch() {}; 109 void registerCallback( SignalCallback cb, void * someData ) {}; 106 SignalHandler() { assert(SignalHandler::singletonRef_s == 0); SignalHandler::singletonRef_s = this; } 107 ~SignalHandler() { assert(SignalHandler::singletonRef_s != 0); SignalHandler::singletonRef_s = 0; } 108 inline static SignalHandler& getInstance() { assert(SignalHandler::singletonRef_s); return *SignalHandler::singletonRef_s; } 109 void doCatch( const std::string & appName, const std::string & filename ) {} 110 void dontCatch() {} 111 void registerCallback( SignalCallback cb, void * someData ) {} 110 112 111 113 private: 112 static SignalHandler * singletonRef;114 static SignalHandler* singletonRef_s; 113 115 }; 114 116 } - Property svn:mergeinfo changed
-
code/trunk/src/util/String.cc
r2171 r2662 84 84 { 85 85 size_t pos1 = 0; 86 int pos2 = str.size() - 1;86 int pos2 = (int)(str.size() - 1); 87 87 for (; pos1 < str.size() && (str[pos1] == ' ' || str[pos1] == '\t' || str[pos1] == '\n'); pos1++); 88 88 for (; pos2 > 0 && (str[pos2] == ' ' || str[pos2] == '\t' || str[pos2] == '\n'); pos2--); -
code/trunk/src/util/mbool.h
r2171 r2662 36 36 struct _UtilExport mbool 37 37 { 38 // friend Synchronisable::registerVariable<>() 38 39 public: 39 40 inline mbool(bool value = false) … … 67 68 inline bool operator!() const 68 69 { return (!this->value_.bool_); } 70 71 inline unsigned char& getMemory(){ return value_.memory_; } 69 72 70 73 private: -
code/trunk/visual_studio/vc8/audio.vsprops
- Property svn:mergeinfo changed
-
code/trunk/visual_studio/vc8/base.vsprops
- Property svn:mergeinfo changed
r2261 r2662 8 8 <Tool 9 9 Name="VCCLCompilerTool" 10 AdditionalIncludeDirectories=""$(RootDir) ";"$(RootDir)src";"$(RootDir)src\orxonox";"$(RootDir)src\ceguilua-0.6.1";"$(LibDir)ogre-1.4.9\include";"$(LibDir)boost-1.35.0\include";"$(LibDir)cegui-0.6.1\include";"$(LibDir)enet-1.2\include";"$(LibDir)libogg-1.1.3\include";"$(LibDir)libvorbis-1.2.0\include";"$(LibDir)openal-1.1\include";"$(LibDir)freealut-1.1.0\include";"$(LibDir)tcl-8.5.2\include";"$(LibDir)zlib-1.2.3\include""10 AdditionalIncludeDirectories=""$(RootDir)src";"$(RootDir)src\ceguilua-0.6.1";"$(RootDir)src\bullet";"$(LibDir)ogre-1.4.9\include";"$(LibDir)boost-1.35.0\include";"$(LibDir)cegui-0.6.1\include";"$(LibDir)enet-1.2\include";"$(LibDir)libogg-1.1.3\include";"$(LibDir)libvorbis-1.2.0\include";"$(LibDir)openal-1.1\include";"$(LibDir)freealut-1.1.0\include";"$(LibDir)tcl-8.5.2\include";"$(LibDir)zlib-1.2.3\include"" 11 11 PreprocessorDefinitions="WIN32;__WIN32__;_WIN32;_WINDOWS;BOOST_ALL_DYN_LINK;OIS_DYNAMIC_LIB;ZLIB_WINAPI" 12 12 WarningLevel="3" -
code/trunk/visual_studio/vc8/ceguilua.vsprops
- Property svn:mergeinfo changed
-
code/trunk/visual_studio/vc8/core.vcproj
r2087 r2662 101 101 <Tool 102 102 Name="VCCLCompilerTool" 103 AdditionalOptions="/MP2" 103 104 /> 104 105 <Tool … … 153 154 </File> 154 155 <File 156 RelativePath="..\..\src\core\CommandLine.cc" 157 > 158 </File> 159 <File 155 160 RelativePath="..\..\src\core\ConfigFileManager.cc" 156 161 > … … 169 174 </File> 170 175 <File 176 RelativePath="..\..\src\core\Executor.cc" 177 > 178 </File> 179 <File 171 180 RelativePath="..\..\src\core\GameState.cc" 172 181 > … … 181 190 </File> 182 191 <File 183 RelativePath="..\..\src\core\OrxonoxClass.cc"184 >185 </File>186 <File187 192 RelativePath="..\..\src\core\RootGameState.cc" 188 >189 </File>190 <File191 RelativePath="..\..\src\core\Template.cc"192 >193 </File>194 <File195 RelativePath="..\..\src\core\XMLNameListener.cc"196 193 > 197 194 </File> … … 231 228 </Filter> 232 229 <Filter 233 Name="command "230 Name="commands" 234 231 > 235 232 <File … … 246 243 </File> 247 244 <File 248 RelativePath="..\..\src\core\CommandLine.cc"249 >250 </File>251 <File252 245 RelativePath="..\..\src\core\ConsoleCommand.cc" 253 246 > … … 257 250 > 258 251 </File> 259 <File260 RelativePath="..\..\src\core\Executor.cc"261 >262 </File>263 252 </Filter> 264 253 <Filter … … 266 255 > 267 256 <File 257 RelativePath="..\..\src\core\BaseObject.cc" 258 > 259 </File> 260 <File 268 261 RelativePath="..\..\src\core\Factory.cc" 269 262 > … … 281 274 > 282 275 </File> 283 </Filter>284 <Filter285 Name="level"286 >287 <File288 RelativePath="..\..\src\core\BaseObject.cc"289 >290 </File>276 <File 277 RelativePath="..\..\src\core\OrxonoxClass.cc" 278 > 279 </File> 280 </Filter> 281 <Filter 282 Name="loading" 283 > 291 284 <File 292 285 RelativePath="..\..\src\core\ClassTreeMask.cc" … … 303 296 <File 304 297 RelativePath="..\..\src\core\NamespaceNode.cc" 298 > 299 </File> 300 <File 301 RelativePath="..\..\src\core\Template.cc" 302 > 303 </File> 304 <File 305 RelativePath="..\..\src\core\XMLNameListener.cc" 305 306 > 306 307 </File> … … 389 390 </File> 390 391 <File 392 RelativePath="..\..\src\core\CommandLine.h" 393 > 394 </File> 395 <File 391 396 RelativePath="..\..\src\core\ConfigFileManager.h" 392 397 > … … 417 422 </File> 418 423 <File 424 RelativePath="..\..\src\core\Executor.h" 425 > 426 </File> 427 <File 428 RelativePath="..\..\src\core\Functor.h" 429 > 430 </File> 431 <File 419 432 RelativePath="..\..\src\core\GameState.h" 420 433 > … … 429 442 </File> 430 443 <File 431 RelativePath="..\..\src\core\OrxonoxClass.h"432 >433 </File>434 <File435 444 RelativePath="..\..\src\core\RootGameState.h" 436 445 > … … 440 449 > 441 450 </File> 442 <File443 RelativePath="..\..\src\core\Template.h"444 >445 </File>446 <File447 RelativePath="..\..\src\core\XMLIncludes.h"448 >449 </File>450 <File451 RelativePath="..\..\src\core\XMLNameListener.h"452 >453 </File>454 451 <Filter 455 452 Name="input" … … 509 506 </Filter> 510 507 <Filter 511 Name="command "508 Name="commands" 512 509 > 513 510 <File … … 532 529 </File> 533 530 <File 534 RelativePath="..\..\src\core\CommandLine.h"535 >536 </File>537 <File538 531 RelativePath="..\..\src\core\ConsoleCommand.h" 539 532 > … … 543 536 > 544 537 </File> 545 <File546 RelativePath="..\..\src\core\Executor.h"547 >548 </File>549 <File550 RelativePath="..\..\src\core\Functor.h"551 >552 </File>553 538 </Filter> 554 539 <Filter … … 576 561 > 577 562 <File 563 RelativePath="..\..\src\core\BaseObject.h" 564 > 565 </File> 566 <File 578 567 RelativePath="..\..\src\core\ClassFactory.h" 579 568 > … … 611 600 > 612 601 </File> 613 </Filter>614 <Filter615 Name="level"616 >617 <File618 RelativePath="..\..\src\core\BaseObject.h"619 >620 </File>602 <File 603 RelativePath="..\..\src\core\OrxonoxClass.h" 604 > 605 </File> 606 </Filter> 607 <Filter 608 Name="loading" 609 > 621 610 <File 622 611 RelativePath="..\..\src\core\ClassTreeMask.h" … … 636 625 </File> 637 626 <File 627 RelativePath="..\..\src\core\Template.h" 628 > 629 </File> 630 <File 638 631 RelativePath="..\..\src\core\XMLFile.h" 632 > 633 </File> 634 <File 635 RelativePath="..\..\src\core\XMLIncludes.h" 636 > 637 </File> 638 <File 639 RelativePath="..\..\src\core\XMLNameListener.h" 639 640 > 640 641 </File> -
code/trunk/visual_studio/vc8/core.vsprops
- Property svn:mergeinfo changed
r2261 r2662 8 8 <Tool 9 9 Name="VCCLCompilerTool" 10 AdditionalOptions="/MP2"11 10 PreprocessorDefinitions="CORE_SHARED_BUILD;LUA_BUILD_AS_DLL" 12 11 /> -
code/trunk/visual_studio/vc8/cpptcl.vsprops
- Property svn:mergeinfo changed
-
code/trunk/visual_studio/vc8/debug.vsprops
- Property svn:mergeinfo changed
r2261 r2662 13 13 BasicRuntimeChecks="3" 14 14 RuntimeLibrary="3" 15 DebugInformationFormat=" 3"15 DebugInformationFormat="4" 16 16 /> 17 17 <Tool -
code/trunk/visual_studio/vc8/lua.vsprops
- Property svn:mergeinfo changed
-
code/trunk/visual_studio/vc8/network.vcproj
r2087 r2662 101 101 <Tool 102 102 Name="VCCLCompilerTool" 103 AdditionalOptions="/MP2" 103 104 /> 104 105 <Tool … … 197 198 </File> 198 199 <File 199 RelativePath="..\..\src\network\ Synchronisable.cc"200 RelativePath="..\..\src\network\TrafficControl.cc" 200 201 > 201 202 </File> … … 229 230 <File 230 231 RelativePath="..\..\src\network\packet\Welcome.cc" 232 > 233 </File> 234 </Filter> 235 <Filter 236 Name="synchronisable" 237 > 238 <File 239 RelativePath="..\..\src\network\synchronisable\NetworkCallbackManager.cc" 240 > 241 </File> 242 <File 243 RelativePath="..\..\src\network\synchronisable\Synchronisable.cc" 244 > 245 </File> 246 <File 247 RelativePath="..\..\src\network\synchronisable\SynchronisableSpecialisations.cc" 248 > 249 </File> 250 <File 251 RelativePath="..\..\src\network\synchronisable\SynchronisableVariable.cc" 231 252 > 232 253 </File> … … 279 300 </File> 280 301 <File 281 RelativePath="..\..\src\network\NetworkCallback.h"282 >283 </File>284 <File285 302 RelativePath="..\..\src\network\NetworkPrereqs.h" 286 303 > … … 295 312 </File> 296 313 <File 297 RelativePath="..\..\src\network\ Synchronisable.h"314 RelativePath="..\..\src\network\TrafficControl.h" 298 315 > 299 316 </File> … … 327 344 <File 328 345 RelativePath="..\..\src\network\packet\Welcome.h" 346 > 347 </File> 348 </Filter> 349 <Filter 350 Name="synchronisable" 351 > 352 <File 353 RelativePath="..\..\src\network\synchronisable\NetworkCallback.h" 354 > 355 </File> 356 <File 357 RelativePath="..\..\src\network\synchronisable\NetworkCallbackManager.h" 358 > 359 </File> 360 <File 361 RelativePath="..\..\src\network\synchronisable\Synchronisable.h" 362 > 363 </File> 364 <File 365 RelativePath="..\..\src\network\synchronisable\SynchronisableVariable.h" 329 366 > 330 367 </File> -
code/trunk/visual_studio/vc8/network.vsprops
- Property svn:mergeinfo changed
r2261 r2662 8 8 <Tool 9 9 Name="VCCLCompilerTool" 10 AdditionalOptions="/MP2"11 10 PreprocessorDefinitions="NETWORK_SHARED_BUILD" 12 11 /> -
code/trunk/visual_studio/vc8/ois.vsprops
r2087 r2662 8 8 <Tool 9 9 Name="VCCLCompilerTool" 10 AdditionalOptions="/MP2"11 10 AdditionalIncludeDirectories="$(RootDir)src\ois" 12 11 PreprocessorDefinitions="OIS_NONCLIENT_BUILD;OIS_DYNAMIC_LIB" -
code/trunk/visual_studio/vc8/orxonox.vcproj
r2171 r2662 102 102 <Tool 103 103 Name="VCCLCompilerTool" 104 AdditionalOptions="/MP2" 104 105 /> 105 106 <Tool … … 167 168 </File> 168 169 <File 170 RelativePath="..\..\src\orxonox\PawnManager.cc" 171 > 172 </File> 173 <File 169 174 RelativePath="..\..\src\orxonox\PlayerManager.cc" 170 175 > … … 210 215 </File> 211 216 <File 217 RelativePath="..\..\src\orxonox\objects\GlobalShader.cc" 218 > 219 </File> 220 <File 212 221 RelativePath="..\..\src\orxonox\objects\Level.cc" 213 222 > … … 247 256 RelativePath="..\..\src\orxonox\objects\worldentities\Backlight.cc" 248 257 > 249 <FileConfiguration250 Name="Debug|Win32"251 ExcludedFromBuild="true"252 >253 <Tool254 Name="VCCLCompilerTool"255 />256 </FileConfiguration>257 <FileConfiguration258 Name="Release|Win32"259 ExcludedFromBuild="true"260 >261 <Tool262 Name="VCCLCompilerTool"263 />264 </FileConfiguration>265 258 </File> 266 259 <File … … 285 278 </File> 286 279 <File 280 RelativePath="..\..\src\orxonox\objects\worldentities\ExplosionChunk.cc" 281 > 282 </File> 283 <File 284 RelativePath="..\..\src\orxonox\objects\worldentities\FadingBillboard.cc" 285 > 286 </File> 287 <File 287 288 RelativePath="..\..\src\orxonox\objects\worldentities\Light.cc" 288 289 > 289 290 </File> 290 291 <File 292 RelativePath="..\..\src\orxonox\objects\worldentities\MobileEntity.cc" 293 > 294 </File> 295 <File 291 296 RelativePath="..\..\src\orxonox\objects\worldentities\Model.cc" 292 297 > … … 305 310 </File> 306 311 <File 307 RelativePath="..\..\src\orxonox\objects\worldentities\P ositionableEntity.cc"312 RelativePath="..\..\src\orxonox\objects\worldentities\Planet.cc" 308 313 > 309 314 </File> 310 315 <File 311 316 RelativePath="..\..\src\orxonox\objects\worldentities\SpawnPoint.cc" 317 > 318 </File> 319 <File 320 RelativePath="..\..\src\orxonox\objects\worldentities\StaticEntity.cc" 312 321 > 313 322 </File> … … 344 353 </File> 345 354 <File 355 RelativePath="..\..\src\orxonox\objects\worldentities\triggers\PlayerTrigger.cc" 356 > 357 </File> 358 <File 346 359 RelativePath="..\..\src\orxonox\objects\worldentities\triggers\Trigger.cc" 347 360 > … … 361 374 > 362 375 <File 376 RelativePath="..\..\src\orxonox\objects\infos\Bot.cc" 377 > 378 </File> 379 <File 380 RelativePath="..\..\src\orxonox\objects\infos\GametypeInfo.cc" 381 > 382 </File> 383 <File 363 384 RelativePath="..\..\src\orxonox\objects\infos\HumanPlayer.cc" 364 385 > … … 377 398 > 378 399 <File 400 RelativePath="..\..\src\orxonox\objects\controllers\AIController.cc" 401 > 402 </File> 403 <File 404 RelativePath="..\..\src\orxonox\objects\controllers\ArtificialController.cc" 405 > 406 </File> 407 <File 379 408 RelativePath="..\..\src\orxonox\objects\controllers\Controller.cc" 380 409 > … … 384 413 > 385 414 </File> 415 <File 416 RelativePath="..\..\src\orxonox\objects\controllers\ScriptController.cc" 417 > 418 </File> 386 419 </Filter> 387 420 <Filter … … 394 427 <File 395 428 RelativePath="..\..\src\orxonox\objects\weaponSystem\Weapon.cc" 429 > 430 </File> 431 <File 432 RelativePath="..\..\src\orxonox\objects\weaponSystem\WeaponPack.cc" 396 433 > 397 434 </File> … … 413 450 <File 414 451 RelativePath="..\..\src\orxonox\objects\weaponSystem\munitions\LaserGunMunition.cc" 452 > 453 </File> 454 </Filter> 455 <Filter 456 Name="weapons" 457 > 458 <File 459 RelativePath="..\..\src\orxonox\objects\weaponSystem\weapons\Fusion.cc" 460 > 461 </File> 462 <File 463 RelativePath="..\..\src\orxonox\objects\weaponSystem\weapons\LaserGun.cc" 464 > 465 </File> 466 <File 467 RelativePath="..\..\src\orxonox\objects\weaponSystem\weapons\Missile.cc" 415 468 > 416 469 <FileConfiguration … … 433 486 </Filter> 434 487 <Filter 435 Name="weapons" 436 > 437 <File 438 RelativePath="..\..\src\orxonox\objects\weaponSystem\weapons\LaserGun.cc" 439 > 440 <FileConfiguration 441 Name="Debug|Win32" 442 ExcludedFromBuild="true" 443 > 444 <Tool 445 Name="VCCLCompilerTool" 446 /> 447 </FileConfiguration> 448 <FileConfiguration 449 Name="Release|Win32" 450 ExcludedFromBuild="true" 451 > 452 <Tool 453 Name="VCCLCompilerTool" 454 /> 455 </FileConfiguration> 456 </File> 457 <File 458 RelativePath="..\..\src\orxonox\objects\weaponSystem\weapons\Missile.cc" 459 > 460 <FileConfiguration 461 Name="Debug|Win32" 462 ExcludedFromBuild="true" 463 > 464 <Tool 465 Name="VCCLCompilerTool" 466 /> 467 </FileConfiguration> 468 <FileConfiguration 469 Name="Release|Win32" 470 ExcludedFromBuild="true" 471 > 472 <Tool 473 Name="VCCLCompilerTool" 474 /> 475 </FileConfiguration> 488 Name="projectiles" 489 > 490 <File 491 RelativePath="..\..\src\orxonox\objects\weaponSystem\projectiles\BillboardProjectile.cc" 492 > 493 </File> 494 <File 495 RelativePath="..\..\src\orxonox\objects\weaponSystem\projectiles\ParticleProjectile.cc" 496 > 497 </File> 498 <File 499 RelativePath="..\..\src\orxonox\objects\weaponSystem\projectiles\Projectile.cc" 500 > 476 501 </File> 477 502 </Filter> 478 <Filter 479 Name="projectiles" 480 > 481 <File 482 RelativePath="..\..\src\orxonox\objects\weaponSystem\projectiles\BillboardProjectile.cc" 483 > 484 <FileConfiguration 485 Name="Debug|Win32" 486 ExcludedFromBuild="true" 487 > 488 <Tool 489 Name="VCCLCompilerTool" 490 /> 491 </FileConfiguration> 492 <FileConfiguration 493 Name="Release|Win32" 494 ExcludedFromBuild="true" 495 > 496 <Tool 497 Name="VCCLCompilerTool" 498 /> 499 </FileConfiguration> 500 </File> 501 <File 502 RelativePath="..\..\src\orxonox\objects\weaponSystem\projectiles\ParticleProjectile.cc" 503 > 504 <FileConfiguration 505 Name="Debug|Win32" 506 ExcludedFromBuild="true" 507 > 508 <Tool 509 Name="VCCLCompilerTool" 510 /> 511 </FileConfiguration> 512 <FileConfiguration 513 Name="Release|Win32" 514 ExcludedFromBuild="true" 515 > 516 <Tool 517 Name="VCCLCompilerTool" 518 /> 519 </FileConfiguration> 520 </File> 521 <File 522 RelativePath="..\..\src\orxonox\objects\weaponSystem\projectiles\Projectile.cc" 523 > 524 <FileConfiguration 525 Name="Debug|Win32" 526 ExcludedFromBuild="true" 527 > 528 <Tool 529 Name="VCCLCompilerTool" 530 /> 531 </FileConfiguration> 532 <FileConfiguration 533 Name="Release|Win32" 534 ExcludedFromBuild="true" 535 > 536 <Tool 537 Name="VCCLCompilerTool" 538 /> 539 </FileConfiguration> 540 </File> 541 </Filter> 503 </Filter> 504 <Filter 505 Name="collisionShapes" 506 > 507 <File 508 RelativePath="..\..\src\orxonox\objects\collisionshapes\BoxCollisionShape.cc" 509 > 510 </File> 511 <File 512 RelativePath="..\..\src\orxonox\objects\collisionshapes\CollisionShape.cc" 513 > 514 </File> 515 <File 516 RelativePath="..\..\src\orxonox\objects\collisionshapes\CompoundCollisionShape.cc" 517 > 518 </File> 519 <File 520 RelativePath="..\..\src\orxonox\objects\collisionshapes\ConeCollisionShape.cc" 521 > 522 </File> 523 <File 524 RelativePath="..\..\src\orxonox\objects\collisionshapes\PlaneCollisionShape.cc" 525 > 526 </File> 527 <File 528 RelativePath="..\..\src\orxonox\objects\collisionshapes\SphereCollisionShape.cc" 529 > 530 </File> 531 <File 532 RelativePath="..\..\src\orxonox\objects\collisionshapes\WorldEntityCollisionShape.cc" 533 > 534 </File> 535 </Filter> 536 <Filter 537 Name="items" 538 > 539 <File 540 RelativePath="..\..\src\orxonox\objects\items\Engine.cc" 541 > 542 </File> 543 <File 544 RelativePath="..\..\src\orxonox\objects\items\Item.cc" 545 > 546 </File> 547 <File 548 RelativePath="..\..\src\orxonox\objects\items\MultiStateEngine.cc" 549 > 550 </File> 542 551 </Filter> 543 552 <Filter … … 589 598 </File> 590 599 <File 600 RelativePath="..\..\src\orxonox\objects\quest\QuestEffectBeacon.cc" 601 > 602 </File> 603 <File 591 604 RelativePath="..\..\src\orxonox\objects\quest\QuestHint.cc" 592 605 > … … 597 610 </File> 598 611 <File 612 RelativePath="..\..\src\orxonox\objects\quest\QuestListener.cc" 613 > 614 </File> 615 <File 599 616 RelativePath="..\..\src\orxonox\objects\quest\QuestManager.cc" 600 617 > … … 602 619 <File 603 620 RelativePath="..\..\src\orxonox\objects\quest\Rewardable.cc" 621 > 622 </File> 623 </Filter> 624 <Filter 625 Name="pickup" 626 > 627 <File 628 RelativePath="..\..\src\orxonox\objects\pickup\BaseItem.cc" 629 > 630 </File> 631 <File 632 RelativePath="..\..\src\orxonox\objects\pickup\PickupSpawner.cc" 633 > 634 </File> 635 <File 636 RelativePath="..\..\src\orxonox\objects\pickup\ShipEquipment.cc" 637 > 638 </File> 639 <File 640 RelativePath="..\..\src\orxonox\objects\pickup\Turbo.cc" 604 641 > 605 642 </File> … … 619 656 <File 620 657 RelativePath="..\..\src\orxonox\tools\ParticleInterface.cc" 658 > 659 </File> 660 <File 661 RelativePath="..\..\src\orxonox\tools\Shader.cc" 621 662 > 622 663 </File> … … 715 756 </File> 716 757 <File 758 RelativePath="..\..\src\orxonox\overlays\hud\GametypeStatus.cc" 759 > 760 </File> 761 <File 717 762 RelativePath="..\..\src\orxonox\overlays\hud\HUDBar.cc" 718 763 > 719 764 </File> 720 765 <File 766 RelativePath="..\..\src\orxonox\overlays\hud\HUDHealthBar.cc" 767 > 768 </File> 769 <File 721 770 RelativePath="..\..\src\orxonox\overlays\hud\HUDNavigation.cc" 722 771 > … … 740 789 <File 741 790 RelativePath="..\..\src\orxonox\overlays\debug\DebugRTRText.cc" 791 > 792 </File> 793 </Filter> 794 <Filter 795 Name="stats" 796 > 797 <File 798 RelativePath="..\..\src\orxonox\overlays\stats\CreateLines.cc" 799 > 800 </File> 801 <File 802 RelativePath="..\..\src\orxonox\overlays\stats\Scoreboard.cc" 803 > 804 </File> 805 <File 806 RelativePath="..\..\src\orxonox\overlays\stats\Stats.cc" 807 > 808 </File> 809 <File 810 RelativePath="..\..\src\orxonox\overlays\stats\StatsTest.cc" 811 > 812 </File> 813 </Filter> 814 <Filter 815 Name="notifications" 816 > 817 <File 818 RelativePath="..\..\src\orxonox\overlays\notifications\Notification.cc" 819 > 820 </File> 821 <File 822 RelativePath="..\..\src\orxonox\overlays\notifications\NotificationManager.cc" 823 > 824 </File> 825 <File 826 RelativePath="..\..\src\orxonox\overlays\notifications\NotificationQueue.cc" 742 827 > 743 828 </File> … … 831 916 </File> 832 917 <File 918 RelativePath="..\..\src\orxonox\PawnManager.h" 919 > 920 </File> 921 <File 833 922 RelativePath="..\..\src\orxonox\PlayerManager.h" 834 923 > … … 854 943 </File> 855 944 <File 945 RelativePath="..\..\src\orxonox\objects\GlobalShader.h" 946 > 947 </File> 948 <File 856 949 RelativePath="..\..\src\orxonox\objects\Level.h" 857 950 > … … 913 1006 </File> 914 1007 <File 1008 RelativePath="..\..\src\orxonox\objects\worldentities\ExplosionChunk.h" 1009 > 1010 </File> 1011 <File 1012 RelativePath="..\..\src\orxonox\objects\worldentities\FadingBillboard.h" 1013 > 1014 </File> 1015 <File 915 1016 RelativePath="..\..\src\orxonox\objects\worldentities\Light.h" 916 1017 > 917 1018 </File> 918 1019 <File 1020 RelativePath="..\..\src\orxonox\objects\worldentities\MobileEntity.h" 1021 > 1022 </File> 1023 <File 919 1024 RelativePath="..\..\src\orxonox\objects\worldentities\Model.h" 920 1025 > … … 933 1038 </File> 934 1039 <File 935 RelativePath="..\..\src\orxonox\objects\worldentities\P ositionableEntity.h"1040 RelativePath="..\..\src\orxonox\objects\worldentities\Planet.h" 936 1041 > 937 1042 </File> 938 1043 <File 939 1044 RelativePath="..\..\src\orxonox\objects\worldentities\SpawnPoint.h" 1045 > 1046 </File> 1047 <File 1048 RelativePath="..\..\src\orxonox\objects\worldentities\StaticEntity.h" 940 1049 > 941 1050 </File> … … 972 1081 </File> 973 1082 <File 1083 RelativePath="..\..\src\orxonox\objects\worldentities\triggers\PlayerTrigger.h" 1084 > 1085 </File> 1086 <File 974 1087 RelativePath="..\..\src\orxonox\objects\worldentities\triggers\Trigger.h" 975 1088 > … … 989 1102 > 990 1103 <File 1104 RelativePath="..\..\src\orxonox\objects\infos\Bot.h" 1105 > 1106 </File> 1107 <File 1108 RelativePath="..\..\src\orxonox\objects\infos\GametypeInfo.h" 1109 > 1110 </File> 1111 <File 1112 RelativePath="..\..\src\orxonox\objects\infos\HumanPlayer.h" 1113 > 1114 </File> 1115 <File 991 1116 RelativePath="..\..\src\orxonox\objects\infos\Info.h" 992 1117 > … … 1001 1126 > 1002 1127 <File 1128 RelativePath="..\..\src\orxonox\objects\controllers\AIController.h" 1129 > 1130 </File> 1131 <File 1132 RelativePath="..\..\src\orxonox\objects\controllers\ArtificialController.h" 1133 > 1134 </File> 1135 <File 1003 1136 RelativePath="..\..\src\orxonox\objects\controllers\Controller.h" 1004 1137 > … … 1008 1141 > 1009 1142 </File> 1143 <File 1144 RelativePath="..\..\src\orxonox\objects\controllers\ScriptController.h" 1145 > 1146 </File> 1010 1147 </Filter> 1011 1148 <Filter … … 1057 1194 </File> 1058 1195 <File 1196 RelativePath="..\..\src\orxonox\objects\quest\QuestEffectBeacon.h" 1197 > 1198 </File> 1199 <File 1059 1200 RelativePath="..\..\src\orxonox\objects\quest\QuestHint.h" 1060 1201 > … … 1062 1203 <File 1063 1204 RelativePath="..\..\src\orxonox\objects\quest\QuestItem.h" 1205 > 1206 </File> 1207 <File 1208 RelativePath="..\..\src\orxonox\objects\quest\QuestListener.h" 1064 1209 > 1065 1210 </File> … … 1099 1244 Name="weapons" 1100 1245 > 1246 <File 1247 RelativePath="..\..\src\orxonox\objects\weaponSystem\weapons\Fusion.h" 1248 > 1249 </File> 1101 1250 <File 1102 1251 RelativePath="..\..\src\orxonox\objects\weaponSystem\weapons\LaserGun.h" … … 1133 1282 </Filter> 1134 1283 </Filter> 1284 <Filter 1285 Name="collisionShapes" 1286 > 1287 <File 1288 RelativePath="..\..\src\orxonox\objects\collisionshapes\BoxCollisionShape.h" 1289 > 1290 </File> 1291 <File 1292 RelativePath="..\..\src\orxonox\objects\collisionshapes\CollisionShape.h" 1293 > 1294 </File> 1295 <File 1296 RelativePath="..\..\src\orxonox\objects\collisionshapes\CompoundCollisionShape.h" 1297 > 1298 </File> 1299 <File 1300 RelativePath="..\..\src\orxonox\objects\collisionshapes\ConeCollisionShape.h" 1301 > 1302 </File> 1303 <File 1304 RelativePath="..\..\src\orxonox\objects\collisionshapes\PlaneCollisionShape.h" 1305 > 1306 </File> 1307 <File 1308 RelativePath="..\..\src\orxonox\objects\collisionshapes\SphereCollisionShape.h" 1309 > 1310 </File> 1311 <File 1312 RelativePath="..\..\src\orxonox\objects\collisionshapes\WorldEntityCollisionShape.h" 1313 > 1314 </File> 1315 </Filter> 1316 <Filter 1317 Name="items" 1318 > 1319 <File 1320 RelativePath="..\..\src\orxonox\objects\items\Engine.h" 1321 > 1322 </File> 1323 <File 1324 RelativePath="..\..\src\orxonox\objects\items\Item.h" 1325 > 1326 </File> 1327 <File 1328 RelativePath="..\..\src\orxonox\objects\items\MultiStateEngine.h" 1329 > 1330 </File> 1331 </Filter> 1332 <Filter 1333 Name="pickup" 1334 > 1335 <File 1336 RelativePath="..\..\src\orxonox\objects\pickup\BaseItem.h" 1337 > 1338 </File> 1339 <File 1340 RelativePath="..\..\src\orxonox\objects\pickup\PickupSpawner.h" 1341 > 1342 </File> 1343 <File 1344 RelativePath="..\..\src\orxonox\objects\pickup\ShipEquipment.h" 1345 > 1346 </File> 1347 <File 1348 RelativePath="..\..\src\orxonox\objects\pickup\ShipEquipmentClasses.h" 1349 > 1350 </File> 1351 <File 1352 RelativePath="..\..\src\orxonox\objects\pickup\ShipItem.h" 1353 > 1354 </File> 1355 <File 1356 RelativePath="..\..\src\orxonox\objects\pickup\Turbo.h" 1357 > 1358 </File> 1359 <File 1360 RelativePath="..\..\src\orxonox\objects\pickup\Usable.h" 1361 > 1362 </File> 1363 </Filter> 1135 1364 </Filter> 1136 1365 <Filter … … 1142 1371 </File> 1143 1372 <File 1373 RelativePath="..\..\src\orxonox\tools\BulletConversions.h" 1374 > 1375 </File> 1376 <File 1144 1377 RelativePath="..\..\src\orxonox\tools\Mesh.h" 1145 1378 > … … 1147 1380 <File 1148 1381 RelativePath="..\..\src\orxonox\tools\ParticleInterface.h" 1382 > 1383 </File> 1384 <File 1385 RelativePath="..\..\src\orxonox\tools\Shader.h" 1149 1386 > 1150 1387 </File> … … 1193 1430 </File> 1194 1431 <File 1432 RelativePath="..\..\src\orxonox\overlays\hud\GametypeStatus.h" 1433 > 1434 </File> 1435 <File 1195 1436 RelativePath="..\..\src\orxonox\overlays\hud\HUDBar.h" 1196 1437 > 1197 1438 </File> 1198 1439 <File 1440 RelativePath="..\..\src\orxonox\overlays\hud\HUDHealthBar.h" 1441 > 1442 </File> 1443 <File 1199 1444 RelativePath="..\..\src\orxonox\overlays\hud\HUDNavigation.h" 1200 1445 > … … 1226 1471 <File 1227 1472 RelativePath="..\..\src\orxonox\overlays\debug\DebugRTRText.h" 1473 > 1474 </File> 1475 </Filter> 1476 <Filter 1477 Name="stats" 1478 > 1479 <File 1480 RelativePath="..\..\src\orxonox\overlays\stats\CreateLines.h" 1481 > 1482 </File> 1483 <File 1484 RelativePath="..\..\src\orxonox\overlays\stats\Scoreboard.h" 1485 > 1486 </File> 1487 <File 1488 RelativePath="..\..\src\orxonox\overlays\stats\Stats.h" 1489 > 1490 </File> 1491 <File 1492 RelativePath="..\..\src\orxonox\overlays\stats\StatsTest.h" 1493 > 1494 </File> 1495 </Filter> 1496 <Filter 1497 Name="notifications" 1498 > 1499 <File 1500 RelativePath="..\..\src\orxonox\overlays\notifications\Notification.h" 1501 > 1502 </File> 1503 <File 1504 RelativePath="..\..\src\orxonox\overlays\notifications\NotificationManager.h" 1505 > 1506 </File> 1507 <File 1508 RelativePath="..\..\src\orxonox\overlays\notifications\NotificationQueue.h" 1228 1509 > 1229 1510 </File> -
code/trunk/visual_studio/vc8/orxonox.vsprops
- Property svn:mergeinfo changed
r2261 r2662 8 8 <Tool 9 9 Name="VCCLCompilerTool" 10 AdditionalOptions="/MP2 /Zm200" 10 AdditionalOptions="/Zm200" 11 AdditionalIncludeDirectories="$(RootDir)src\orxonox" 11 12 PreprocessorDefinitions="ORXONOX_NO_EXPORTS;ORXONOX_ENABLE_PCH;LUA_BUILD_AS_DLL" 12 13 UsePrecompiledHeader="2" -
code/trunk/visual_studio/vc8/orxonox_vc8.sln
- Property svn:mergeinfo changed
r2261 r2662 8 8 EndProjectSection 9 9 ProjectSection(ProjectDependencies) = postProject 10 {4BBBB49F-3203-4BB4-AAE3-48BCA96FCB4F} = {4BBBB49F-3203-4BB4-AAE3-48BCA96FCB4F} 10 {35575B59-E1AE-40E8-89C4-2862B5B09B68} = {35575B59-E1AE-40E8-89C4-2862B5B09B68} 11 {63B3E57A-4382-42F3-85EC-E869CFCCA88F} = {63B3E57A-4382-42F3-85EC-E869CFCCA88F} 12 {2240ECD7-2F48-4431-8E1B-25466A384CCC} = {2240ECD7-2F48-4431-8E1B-25466A384CCC} 11 13 {F101C2F0-1CB9-4A57-827B-6C399A99B28F} = {F101C2F0-1CB9-4A57-827B-6C399A99B28F} 12 14 {271715F3-5B90-4110-A552-70C788084A86} = {271715F3-5B90-4110-A552-70C788084A86} 13 {2240ECD7-2F48-4431-8E1B-25466A384CCC} = {2240ECD7-2F48-4431-8E1B-25466A384CCC} 14 {35575B59-E1AE-40E8-89C4-2862B5B09B68} = {35575B59-E1AE-40E8-89C4-2862B5B09B68} 15 {4733BD1A-E04C-458D-8BFB-5010250EA497} = {4733BD1A-E04C-458D-8BFB-5010250EA497} 16 {63B3E57A-4382-42F3-85EC-E869CFCCA88F} = {63B3E57A-4382-42F3-85EC-E869CFCCA88F} 15 {C8659D22-3CB7-41C9-A1BC-B40DB70A31A5} = {C8659D22-3CB7-41C9-A1BC-B40DB70A31A5} 16 {41481057-47FD-4BEF-853B-7EF5F975F05E} = {41481057-47FD-4BEF-853B-7EF5F975F05E} 17 {BA753941-F455-43A2-925C-7F3E02F6A995} = {BA753941-F455-43A2-925C-7F3E02F6A995} 18 {4BBBB49F-3203-4BB4-AAE3-48BCA96FCB4F} = {4BBBB49F-3203-4BB4-AAE3-48BCA96FCB4F} 19 {71FC0211-5EB5-4637-BE8A-A48EC3CC27D0} = {71FC0211-5EB5-4637-BE8A-A48EC3CC27D0} 17 20 {35E36A06-0A5C-4A0D-9AB6-5A05EAA87626} = {35E36A06-0A5C-4A0D-9AB6-5A05EAA87626} 21 EndProjectSection 22 EndProject 23 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cpptcl", "cpptcl.vcproj", "{53C56131-E2AA-4A27-B460-7AC05D61A0E6}" 24 ProjectSection(WebsiteProperties) = preProject 25 Debug.AspNetCompiler.Debug = "True" 26 Release.AspNetCompiler.Debug = "False" 27 EndProjectSection 28 EndProject 29 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyxml", "tinyxml.vcproj", "{F101C2F0-1CB9-4A57-827B-6C399A99B28F}" 30 ProjectSection(WebsiteProperties) = preProject 31 Debug.AspNetCompiler.Debug = "True" 32 Release.AspNetCompiler.Debug = "False" 33 EndProjectSection 34 EndProject 35 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tolua", "tolua.vcproj", "{35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}" 36 ProjectSection(WebsiteProperties) = preProject 37 Debug.AspNetCompiler.Debug = "True" 38 Release.AspNetCompiler.Debug = "False" 39 EndProjectSection 40 ProjectSection(ProjectDependencies) = postProject 41 {63B3E57A-4382-42F3-85EC-E869CFCCA88F} = {63B3E57A-4382-42F3-85EC-E869CFCCA88F} 42 EndProjectSection 43 EndProject 44 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "toluagen_orxonox", "toluagen_orxonox.vcproj", "{71FC0211-5EB5-4637-BE8A-A48EC3CC27D0}" 45 ProjectSection(WebsiteProperties) = preProject 46 Debug.AspNetCompiler.Debug = "True" 47 Release.AspNetCompiler.Debug = "False" 48 EndProjectSection 49 ProjectSection(ProjectDependencies) = postProject 50 {A0724246-CB7C-420B-BCF0-68EF205AFE34} = {A0724246-CB7C-420B-BCF0-68EF205AFE34} 51 {C6692661-9160-49E6-B109-A155F9485402} = {C6692661-9160-49E6-B109-A155F9485402} 52 {8F5B7ED0-D380-4B4F-A744-3A568718176C} = {8F5B7ED0-D380-4B4F-A744-3A568718176C} 53 EndProjectSection 54 EndProject 55 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "toluagen", "toluagen.vcproj", "{A0724246-CB7C-420B-BCF0-68EF205AFE34}" 56 ProjectSection(WebsiteProperties) = preProject 57 Debug.AspNetCompiler.Debug = "True" 58 Release.AspNetCompiler.Debug = "False" 59 EndProjectSection 60 ProjectSection(ProjectDependencies) = postProject 61 {C6692661-9160-49E6-B109-A155F9485402} = {C6692661-9160-49E6-B109-A155F9485402} 62 {8F5B7ED0-D380-4B4F-A744-3A568718176C} = {8F5B7ED0-D380-4B4F-A744-3A568718176C} 63 EndProjectSection 64 EndProject 65 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "util", "util.vcproj", "{2240ECD7-2F48-4431-8E1B-25466A384CCC}" 66 ProjectSection(WebsiteProperties) = preProject 67 Debug.AspNetCompiler.Debug = "True" 68 Release.AspNetCompiler.Debug = "False" 69 EndProjectSection 70 EndProject 71 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "core", "core.vcproj", "{271715F3-5B90-4110-A552-70C788084A86}" 72 ProjectSection(WebsiteProperties) = preProject 73 Debug.AspNetCompiler.Debug = "True" 74 Release.AspNetCompiler.Debug = "False" 75 EndProjectSection 76 ProjectSection(ProjectDependencies) = postProject 18 77 {71FC0211-5EB5-4637-BE8A-A48EC3CC27D0} = {71FC0211-5EB5-4637-BE8A-A48EC3CC27D0} 19 EndProjectSection 20 EndProject 21 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cpptcl", "cpptcl.vcproj", "{53C56131-E2AA-4A27-B460-7AC05D61A0E6}" 22 ProjectSection(WebsiteProperties) = preProject 23 Debug.AspNetCompiler.Debug = "True" 24 Release.AspNetCompiler.Debug = "False" 25 EndProjectSection 26 EndProject 27 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyxml", "tinyxml.vcproj", "{F101C2F0-1CB9-4A57-827B-6C399A99B28F}" 28 ProjectSection(WebsiteProperties) = preProject 29 Debug.AspNetCompiler.Debug = "True" 30 Release.AspNetCompiler.Debug = "False" 31 EndProjectSection 32 EndProject 33 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tolua", "tolua.vcproj", "{35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}" 34 ProjectSection(WebsiteProperties) = preProject 35 Debug.AspNetCompiler.Debug = "True" 36 Release.AspNetCompiler.Debug = "False" 37 EndProjectSection 38 ProjectSection(ProjectDependencies) = postProject 39 {63B3E57A-4382-42F3-85EC-E869CFCCA88F} = {63B3E57A-4382-42F3-85EC-E869CFCCA88F} 40 EndProjectSection 41 EndProject 42 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "toluagen_orxonox", "toluagen_orxonox.vcproj", "{71FC0211-5EB5-4637-BE8A-A48EC3CC27D0}" 43 ProjectSection(WebsiteProperties) = preProject 44 Debug.AspNetCompiler.Debug = "True" 45 Release.AspNetCompiler.Debug = "False" 46 EndProjectSection 47 ProjectSection(ProjectDependencies) = postProject 48 {8F5B7ED0-D380-4B4F-A744-3A568718176C} = {8F5B7ED0-D380-4B4F-A744-3A568718176C} 49 {C6692661-9160-49E6-B109-A155F9485402} = {C6692661-9160-49E6-B109-A155F9485402} 50 {A0724246-CB7C-420B-BCF0-68EF205AFE34} = {A0724246-CB7C-420B-BCF0-68EF205AFE34} 51 EndProjectSection 52 EndProject 53 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "toluagen", "toluagen.vcproj", "{A0724246-CB7C-420B-BCF0-68EF205AFE34}" 54 ProjectSection(WebsiteProperties) = preProject 55 Debug.AspNetCompiler.Debug = "True" 56 Release.AspNetCompiler.Debug = "False" 57 EndProjectSection 58 ProjectSection(ProjectDependencies) = postProject 59 {8F5B7ED0-D380-4B4F-A744-3A568718176C} = {8F5B7ED0-D380-4B4F-A744-3A568718176C} 60 {C6692661-9160-49E6-B109-A155F9485402} = {C6692661-9160-49E6-B109-A155F9485402} 61 EndProjectSection 62 EndProject 63 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "util", "util.vcproj", "{2240ECD7-2F48-4431-8E1B-25466A384CCC}" 64 ProjectSection(WebsiteProperties) = preProject 65 Debug.AspNetCompiler.Debug = "True" 66 Release.AspNetCompiler.Debug = "False" 67 EndProjectSection 68 EndProject 69 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "core", "core.vcproj", "{271715F3-5B90-4110-A552-70C788084A86}" 70 ProjectSection(WebsiteProperties) = preProject 71 Debug.AspNetCompiler.Debug = "True" 72 Release.AspNetCompiler.Debug = "False" 73 EndProjectSection 74 ProjectSection(ProjectDependencies) = postProject 78 {63B3E57A-4382-42F3-85EC-E869CFCCA88F} = {63B3E57A-4382-42F3-85EC-E869CFCCA88F} 79 {35E36A06-0A5C-4A0D-9AB6-5A05EAA87626} = {35E36A06-0A5C-4A0D-9AB6-5A05EAA87626} 80 {53C56131-E2AA-4A27-B460-7AC05D61A0E6} = {53C56131-E2AA-4A27-B460-7AC05D61A0E6} 81 {2240ECD7-2F48-4431-8E1B-25466A384CCC} = {2240ECD7-2F48-4431-8E1B-25466A384CCC} 82 {F101C2F0-1CB9-4A57-827B-6C399A99B28F} = {F101C2F0-1CB9-4A57-827B-6C399A99B28F} 75 83 {EA969DF2-70AF-46E6-BBE2-E03112E04CB8} = {EA969DF2-70AF-46E6-BBE2-E03112E04CB8} 76 {F101C2F0-1CB9-4A57-827B-6C399A99B28F} = {F101C2F0-1CB9-4A57-827B-6C399A99B28F} 77 {2240ECD7-2F48-4431-8E1B-25466A384CCC} = {2240ECD7-2F48-4431-8E1B-25466A384CCC} 78 {53C56131-E2AA-4A27-B460-7AC05D61A0E6} = {53C56131-E2AA-4A27-B460-7AC05D61A0E6} 84 EndProjectSection 85 EndProject 86 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "audio", "audio.vcproj", "{4733BD1A-E04C-458D-8BFB-5010250EA497}" 87 ProjectSection(WebsiteProperties) = preProject 88 Debug.AspNetCompiler.Debug = "True" 89 Release.AspNetCompiler.Debug = "False" 90 EndProjectSection 91 ProjectSection(ProjectDependencies) = postProject 92 {2240ECD7-2F48-4431-8E1B-25466A384CCC} = {2240ECD7-2F48-4431-8E1B-25466A384CCC} 93 {271715F3-5B90-4110-A552-70C788084A86} = {271715F3-5B90-4110-A552-70C788084A86} 94 EndProjectSection 95 EndProject 96 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "network", "network.vcproj", "{35575B59-E1AE-40E8-89C4-2862B5B09B68}" 97 ProjectSection(WebsiteProperties) = preProject 98 Debug.AspNetCompiler.Debug = "True" 99 Release.AspNetCompiler.Debug = "False" 100 EndProjectSection 101 ProjectSection(ProjectDependencies) = postProject 102 {2240ECD7-2F48-4431-8E1B-25466A384CCC} = {2240ECD7-2F48-4431-8E1B-25466A384CCC} 103 {271715F3-5B90-4110-A552-70C788084A86} = {271715F3-5B90-4110-A552-70C788084A86} 104 EndProjectSection 105 EndProject 106 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lua", "lua.vcproj", "{63B3E57A-4382-42F3-85EC-E869CFCCA88F}" 107 ProjectSection(WebsiteProperties) = preProject 108 Debug.AspNetCompiler.Debug = "True" 109 Release.AspNetCompiler.Debug = "False" 110 EndProjectSection 111 EndProject 112 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ceguilua", "ceguilua.vcproj", "{4BBBB49F-3203-4BB4-AAE3-48BCA96FCB4F}" 113 ProjectSection(WebsiteProperties) = preProject 114 Debug.AspNetCompiler.Debug = "True" 115 Release.AspNetCompiler.Debug = "False" 116 EndProjectSection 117 ProjectSection(ProjectDependencies) = postProject 118 {63B3E57A-4382-42F3-85EC-E869CFCCA88F} = {63B3E57A-4382-42F3-85EC-E869CFCCA88F} 79 119 {35E36A06-0A5C-4A0D-9AB6-5A05EAA87626} = {35E36A06-0A5C-4A0D-9AB6-5A05EAA87626} 80 {63B3E57A-4382-42F3-85EC-E869CFCCA88F} = {63B3E57A-4382-42F3-85EC-E869CFCCA88F}81 {71FC0211-5EB5-4637-BE8A-A48EC3CC27D0} = {71FC0211-5EB5-4637-BE8A-A48EC3CC27D0}82 EndProjectSection83 EndProject84 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "audio", "audio.vcproj", "{4733BD1A-E04C-458D-8BFB-5010250EA497}"85 ProjectSection(WebsiteProperties) = preProject86 Debug.AspNetCompiler.Debug = "True"87 Release.AspNetCompiler.Debug = "False"88 EndProjectSection89 ProjectSection(ProjectDependencies) = postProject90 {271715F3-5B90-4110-A552-70C788084A86} = {271715F3-5B90-4110-A552-70C788084A86}91 {2240ECD7-2F48-4431-8E1B-25466A384CCC} = {2240ECD7-2F48-4431-8E1B-25466A384CCC}92 EndProjectSection93 EndProject94 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "network", "network.vcproj", "{35575B59-E1AE-40E8-89C4-2862B5B09B68}"95 ProjectSection(WebsiteProperties) = preProject96 Debug.AspNetCompiler.Debug = "True"97 Release.AspNetCompiler.Debug = "False"98 EndProjectSection99 ProjectSection(ProjectDependencies) = postProject100 {271715F3-5B90-4110-A552-70C788084A86} = {271715F3-5B90-4110-A552-70C788084A86}101 {2240ECD7-2F48-4431-8E1B-25466A384CCC} = {2240ECD7-2F48-4431-8E1B-25466A384CCC}102 EndProjectSection103 EndProject104 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lua", "lua.vcproj", "{63B3E57A-4382-42F3-85EC-E869CFCCA88F}"105 ProjectSection(WebsiteProperties) = preProject106 Debug.AspNetCompiler.Debug = "True"107 Release.AspNetCompiler.Debug = "False"108 EndProjectSection109 EndProject110 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ceguilua", "ceguilua.vcproj", "{4BBBB49F-3203-4BB4-AAE3-48BCA96FCB4F}"111 ProjectSection(WebsiteProperties) = preProject112 Debug.AspNetCompiler.Debug = "True"113 Release.AspNetCompiler.Debug = "False"114 EndProjectSection115 ProjectSection(ProjectDependencies) = postProject116 {35E36A06-0A5C-4A0D-9AB6-5A05EAA87626} = {35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}117 {63B3E57A-4382-42F3-85EC-E869CFCCA88F} = {63B3E57A-4382-42F3-85EC-E869CFCCA88F}118 120 EndProjectSection 119 121 EndProject … … 137 139 EndProject 138 140 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lua_static", "lua_static.vcproj", "{8F5B7ED0-D380-4B4F-A744-3A568718176C}" 141 ProjectSection(WebsiteProperties) = preProject 142 Debug.AspNetCompiler.Debug = "True" 143 Release.AspNetCompiler.Debug = "False" 144 EndProjectSection 145 EndProject 146 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bullet_collision", "bullet_collision.vcproj", "{BA753941-F455-43A2-925C-7F3E02F6A995}" 147 ProjectSection(WebsiteProperties) = preProject 148 Debug.AspNetCompiler.Debug = "True" 149 Release.AspNetCompiler.Debug = "False" 150 EndProjectSection 151 EndProject 152 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bullet_dynamics", "bullet_dynamics.vcproj", "{41481057-47FD-4BEF-853B-7EF5F975F05E}" 153 ProjectSection(WebsiteProperties) = preProject 154 Debug.AspNetCompiler.Debug = "True" 155 Release.AspNetCompiler.Debug = "False" 156 EndProjectSection 157 EndProject 158 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bullet_linearmath", "bullet_linearmath.vcproj", "{C8659D22-3CB7-41C9-A1BC-B40DB70A31A5}" 139 159 ProjectSection(WebsiteProperties) = preProject 140 160 Debug.AspNetCompiler.Debug = "True" … … 148 168 EndGlobalSection 149 169 GlobalSection(ProjectConfigurationPlatforms) = postSolution 170 {0B6C5CFD-F91B-432A-80A3-2610F61E060B}.Debug|Win32.ActiveCfg = Debug|Win32 171 {0B6C5CFD-F91B-432A-80A3-2610F61E060B}.Debug|Win32.Build.0 = Debug|Win32 172 {0B6C5CFD-F91B-432A-80A3-2610F61E060B}.Release|Win32.ActiveCfg = Release|Win32 173 {0B6C5CFD-F91B-432A-80A3-2610F61E060B}.Release|Win32.Build.0 = Release|Win32 150 174 {53C56131-E2AA-4A27-B460-7AC05D61A0E6}.Debug|Win32.ActiveCfg = Debug|Win32 151 175 {53C56131-E2AA-4A27-B460-7AC05D61A0E6}.Debug|Win32.Build.0 = Debug|Win32 … … 177 201 {271715F3-5B90-4110-A552-70C788084A86}.Release|Win32.Build.0 = Release|Win32 178 202 {4733BD1A-E04C-458D-8BFB-5010250EA497}.Debug|Win32.ActiveCfg = Debug|Win32 179 {4733BD1A-E04C-458D-8BFB-5010250EA497}.Debug|Win32.Build.0 = Debug|Win32180 203 {4733BD1A-E04C-458D-8BFB-5010250EA497}.Release|Win32.ActiveCfg = Release|Win32 181 {4733BD1A-E04C-458D-8BFB-5010250EA497}.Release|Win32.Build.0 = Release|Win32182 204 {35575B59-E1AE-40E8-89C4-2862B5B09B68}.Debug|Win32.ActiveCfg = Debug|Win32 183 205 {35575B59-E1AE-40E8-89C4-2862B5B09B68}.Debug|Win32.Build.0 = Debug|Win32 184 206 {35575B59-E1AE-40E8-89C4-2862B5B09B68}.Release|Win32.ActiveCfg = Release|Win32 185 207 {35575B59-E1AE-40E8-89C4-2862B5B09B68}.Release|Win32.Build.0 = Release|Win32 186 {0B6C5CFD-F91B-432A-80A3-2610F61E060B}.Debug|Win32.ActiveCfg = Debug|Win32187 {0B6C5CFD-F91B-432A-80A3-2610F61E060B}.Debug|Win32.Build.0 = Debug|Win32188 {0B6C5CFD-F91B-432A-80A3-2610F61E060B}.Release|Win32.ActiveCfg = Release|Win32189 {0B6C5CFD-F91B-432A-80A3-2610F61E060B}.Release|Win32.Build.0 = Release|Win32190 208 {63B3E57A-4382-42F3-85EC-E869CFCCA88F}.Debug|Win32.ActiveCfg = Debug|Win32 191 209 {63B3E57A-4382-42F3-85EC-E869CFCCA88F}.Debug|Win32.Build.0 = Debug|Win32 … … 208 226 {8F5B7ED0-D380-4B4F-A744-3A568718176C}.Release|Win32.ActiveCfg = Release|Win32 209 227 {8F5B7ED0-D380-4B4F-A744-3A568718176C}.Release|Win32.Build.0 = Release|Win32 228 {BA753941-F455-43A2-925C-7F3E02F6A995}.Debug|Win32.ActiveCfg = Debug|Win32 229 {BA753941-F455-43A2-925C-7F3E02F6A995}.Debug|Win32.Build.0 = Debug|Win32 230 {BA753941-F455-43A2-925C-7F3E02F6A995}.Release|Win32.ActiveCfg = Release|Win32 231 {BA753941-F455-43A2-925C-7F3E02F6A995}.Release|Win32.Build.0 = Release|Win32 232 {41481057-47FD-4BEF-853B-7EF5F975F05E}.Debug|Win32.ActiveCfg = Debug|Win32 233 {41481057-47FD-4BEF-853B-7EF5F975F05E}.Debug|Win32.Build.0 = Debug|Win32 234 {41481057-47FD-4BEF-853B-7EF5F975F05E}.Release|Win32.ActiveCfg = Release|Win32 235 {41481057-47FD-4BEF-853B-7EF5F975F05E}.Release|Win32.Build.0 = Release|Win32 236 {C8659D22-3CB7-41C9-A1BC-B40DB70A31A5}.Debug|Win32.ActiveCfg = Debug|Win32 237 {C8659D22-3CB7-41C9-A1BC-B40DB70A31A5}.Debug|Win32.Build.0 = Debug|Win32 238 {C8659D22-3CB7-41C9-A1BC-B40DB70A31A5}.Release|Win32.ActiveCfg = Release|Win32 239 {C8659D22-3CB7-41C9-A1BC-B40DB70A31A5}.Release|Win32.Build.0 = Release|Win32 210 240 EndGlobalSection 211 241 GlobalSection(SolutionProperties) = preSolution … … 223 253 {C6692661-9160-49E6-B109-A155F9485402} = {B9D56701-B4DB-43F8-9920-241CA418C1CE} 224 254 {8F5B7ED0-D380-4B4F-A744-3A568718176C} = {B9D56701-B4DB-43F8-9920-241CA418C1CE} 255 {BA753941-F455-43A2-925C-7F3E02F6A995} = {B9D56701-B4DB-43F8-9920-241CA418C1CE} 256 {41481057-47FD-4BEF-853B-7EF5F975F05E} = {B9D56701-B4DB-43F8-9920-241CA418C1CE} 257 {C8659D22-3CB7-41C9-A1BC-B40DB70A31A5} = {B9D56701-B4DB-43F8-9920-241CA418C1CE} 225 258 EndGlobalSection 226 259 EndGlobal -
code/trunk/visual_studio/vc8/release.vsprops
- Property svn:mergeinfo changed
-
code/trunk/visual_studio/vc8/tinyxml.vcproj
- Property svn:mergeinfo changed
-
code/trunk/visual_studio/vc8/tinyxml.vsprops
- Property svn:mergeinfo changed
-
code/trunk/visual_studio/vc8/tolua.vsprops
- Property svn:mergeinfo changed
-
code/trunk/visual_studio/vc8/toluagen.vcproj
- Property svn:mergeinfo changed
-
code/trunk/visual_studio/vc8/toluagen.vsprops
- Property svn:mergeinfo changed
-
code/trunk/visual_studio/vc8/toluagen_orxonox.vcproj
- Property svn:mergeinfo changed
-
code/trunk/visual_studio/vc8/toluagen_orxonox.vsprops
- Property svn:mergeinfo changed
-
code/trunk/visual_studio/vc8/util.vcproj
r2171 r2662 247 247 </File> 248 248 <File 249 RelativePath="..\..\src\util\OrxEnum.h" 250 > 251 </File> 252 <File 249 253 RelativePath="..\..\src\util\OrxonoxPlatform.h" 250 254 > -
code/trunk/visual_studio/vc8/util.vsprops
- Property svn:mergeinfo changed
r2261 r2662 8 8 <Tool 9 9 Name="VCCLCompilerTool" 10 AdditionalOptions="/MP2"11 10 PreprocessorDefinitions="UTIL_SHARED_BUILD" 12 11 />
Note: See TracChangeset
for help on using the changeset viewer.