Changeset 2485 for code/branches/presentation
- Timestamp:
- Dec 16, 2008, 6:01:13 PM (16 years ago)
- Location:
- code/branches/presentation
- Files:
-
- 201 edited
- 32 copied
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation
-
code/branches/presentation/TODO
r2171 r2485 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/branches/presentation/bin/Plugins.cfg
r1763 r2485 10 10 Plugin=Plugin_BSPSceneManager 11 11 Plugin=Plugin_OctreeSceneManager 12 #Plugin=Plugin_CgProgramManager12 Plugin=Plugin_CgProgramManager 13 13 -
code/branches/presentation/bin/def_keybindings.ini
r2103 r2485 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= -
code/branches/presentation/bin/telnet_server.tcl
r1505 r2485 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/branches/presentation/src/core/BaseObject.cc
r2171 r2485 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->functorSetMainState_ = 0; 64 this->functorGetMainState_ = 0; 65 62 66 this->setCreator(creator); 63 67 if (this->creator_) … … 82 86 BaseObject::~BaseObject() 83 87 { 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); 88 if (this->isInitialized()) 89 { 90 for (std::list<BaseObject*>::const_iterator it = this->events_.begin(); it != this->events_.end(); ++it) 91 (*it)->unregisterEventListener(this); 92 93 for (std::map<BaseObject*, std::string>::const_iterator it = this->eventListeners_.begin(); it != this->eventListeners_.end(); ++it) 94 it->first->removeEvent(this); 95 96 if (this->functorSetMainState_) 97 delete this->functorSetMainState_; 98 if (this->functorGetMainState_) 99 delete this->functorGetMainState_; 100 } 89 101 } 90 102 … … 100 112 XMLPortParam(BaseObject, "visible", setVisible, isVisible, xmlelement, mode); 101 113 XMLPortParam(BaseObject, "active", setActive, isActive, xmlelement, mode); 114 XMLPortParam(BaseObject, "mainstate", setMainStateName, getMainStateName, xmlelement, mode); 102 115 103 116 XMLPortObjectTemplate(BaseObject, Template, "templates", addTemplate, getTemplate, xmlelement, mode, Template*); … … 109 122 std::list<std::string> eventnames; 110 123 111 if (mode == XMLPort::LoadObject )124 if (mode == XMLPort::LoadObject || mode == XMLPort::ExpandObject) 112 125 { 113 126 for (ticpp::Iterator<ticpp::Element> child = events->FirstChildElement(false); child != child.end(); child++) … … 279 292 SetEvent(BaseObject, "visibility", setVisible, event); 280 293 } 294 295 void BaseObject::setMainStateName(const std::string& name) 296 { 297 if (this->mainStateName_ != name) 298 { 299 this->mainStateName_ = name; 300 if (this->functorSetMainState_) 301 delete this->functorSetMainState_; 302 if (this->functorGetMainState_) 303 delete this->functorGetMainState_; 304 this->changedMainState(); 305 if (!this->functorSetMainState_) 306 COUT(2) << "Warning: \"" << name << "\" is not a valid MainState." << std::endl; 307 } 308 } 309 310 void BaseObject::setMainState(bool state) 311 { 312 if (this->functorSetMainState_) 313 (*this->functorSetMainState_)(state); 314 else 315 COUT(2) << "Warning: No MainState defined in object \"" << this->getName() << "\" (" << this->getIdentifier()->getName() << ")" << std::endl; 316 } 317 318 bool BaseObject::getMainState() const 319 { 320 if (this->functorGetMainState_) 321 { 322 (*this->functorGetMainState_)(); 323 return this->functorGetMainState_->getReturnvalue(); 324 } 325 else 326 { 327 COUT(2) << "Warning: No MainState defined in object \"" << this->getName() << "\" (" << this->getIdentifier()->getName() << ")" << std::endl; 328 return false; 329 } 330 } 331 332 void BaseObject::changedMainState() 333 { 334 SetMainState(BaseObject, "activity", setActive, isActive); 335 SetMainState(BaseObject, "visibility", setVisible, isVisible); 336 } 281 337 } -
code/branches/presentation/src/core/BaseObject.h
r2171 r2485 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> … … 100 107 virtual void changedVisibility() {} 101 108 109 void setMainState(bool state); 110 bool getMainState() const; 111 112 void setMainStateName(const std::string& name); 113 inline const std::string& getMainStateName() const { return this->mainStateName_; } 114 virtual void changedMainState(); 115 102 116 /** @brief Sets a pointer to the xml file that loaded this object. @param file The pointer to the XMLFile */ 103 117 inline void setFile(const XMLFile* file) { this->file_ = file; } … … 121 135 inline Scene* getScene() const { return this->scene_; } 122 136 123 inline void setGametype(Gametype* gametype) { this->oldGametype_ = this->gametype_; this->gametype_ = gametype; this->changedGametype(); } 137 inline void setGametype(Gametype* gametype) 138 { 139 if (gametype != this->gametype_) 140 { 141 this->oldGametype_ = this->gametype_; 142 this->gametype_ = gametype; 143 this->changedGametype(); 144 } 145 } 124 146 inline Gametype* getGametype() const { return this->gametype_; } 125 147 inline Gametype* getOldGametype() const { return this->oldGametype_; } 126 virtual inlinevoid changedGametype() {}148 virtual void changedGametype() {} 127 149 128 150 void fireEvent(); … … 153 175 std::string name_; //!< The name of the object 154 176 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 mbool bActive_; //!< True = the object is active 178 mbool bVisible_; //!< True = the object is visible 179 std::string mainStateName_; 180 Functor* functorSetMainState_; 181 Functor* functorGetMainState_; 157 182 158 183 private: … … 160 185 Template* getTemplate(unsigned int index) const; 161 186 162 bool bInitialized_; //!< True if the object was initialized (passed the object registration)163 const XMLFile* file_; //!< The XMLFile that loaded this object164 std::string loaderIndentation_; //!< Indentation of the debug output in the Loader165 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_;187 bool bInitialized_; //!< True if the object was initialized (passed the object registration) 188 const XMLFile* file_; //!< The XMLFile that loaded this object 189 std::string loaderIndentation_; //!< Indentation of the debug output in the Loader 190 Namespace* namespace_; 191 BaseObject* creator_; 192 Scene* scene_; 193 Gametype* gametype_; 194 Gametype* oldGametype_; 195 std::set<Template*> templates_; 196 std::map<BaseObject*, std::string> eventListeners_; 172 197 std::list<BaseObject*> events_; 173 198 std::map<std::string, EventContainer*> eventContainers_; … … 178 203 SUPER_FUNCTION(3, BaseObject, changedVisibility, false); 179 204 SUPER_FUNCTION(4, BaseObject, processEvent, false); 205 SUPER_FUNCTION(6, BaseObject, changedMainState, false); 206 SUPER_FUNCTION(9, BaseObject, changedName, false); 207 SUPER_FUNCTION(10, BaseObject, changedGametype, false); 180 208 } 181 209 -
code/branches/presentation/src/core/CommandExecutor.cc
r1784 r2485 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/branches/presentation/src/core/CommandExecutor.h
r1771 r2485 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/branches/presentation/src/core/CommandLine.cc
r2105 r2485 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/branches/presentation/src/core/CommandLine.h
r2103 r2485 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/branches/presentation/src/core/ConsoleCommand.h
r2087 r2485 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/branches/presentation/src/core/Core.cc
r2171 r2485 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/branches/presentation/src/core/Core.h
r2171 r2485 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/branches/presentation/src/core/CorePrereqs.h
r2087 r2485 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/branches/presentation/src/core/Functor.h
r2087 r2485 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/branches/presentation/src/core/Identifier.cc
r2371 r2485 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 } -
code/branches/presentation/src/core/Identifier.h
r2371 r2485 258 258 void initializeClassHierarchy(std::set<const Identifier*>* parents, bool bRootClass); 259 259 260 static void destroyAllIdentifiers(); 261 260 262 protected: 261 263 Identifier(); … … 300 302 } 301 303 304 static std::map<std::string, Identifier*>& getTypeIDIdentifierMap(); 305 302 306 void initialize(std::set<const Identifier*>* parents); 303 304 static void destroyAllIdentifiers();305 307 306 308 std::set<const Identifier*> parents_; //!< The parents of the class the Identifier belongs to -
code/branches/presentation/src/core/Language.cc
r2171 r2485 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 -
code/branches/presentation/src/core/Language.h
r2171 r2485 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/branches/presentation/src/core/Loader.cc
r2171 r2485 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/branches/presentation/src/core/LuaBind.cc
r2087 r2485 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/branches/presentation/src/core/LuaBind.h
r2087 r2485 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/branches/presentation/src/core/RootGameState.cc
r2459 r2485 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" … … 138 137 Clock clock; 139 138 140 // create the Core settings to configure the output level141 Core::getInstance();142 143 139 this->activate(); 144 140 -
code/branches/presentation/src/core/RootGameState.h
r2103 r2485 48 48 void gotoState(const std::string& name); 49 49 50 std::string 50 std::string stateRequest_; 51 51 }; 52 52 } -
code/branches/presentation/src/core/Shell.cc
r1792 r2485 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/branches/presentation/src/core/Super.h
r2171 r2485 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/branches/presentation/src/core/Template.cc
- Property svn:mergeinfo changed
/code/branches/objecthierarchy2/src/core/Template.cc (added) merged: 2173,2369
r2459 r2485 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/branches/presentation/src/core/Template.h
- Property svn:mergeinfo changed
/code/branches/objecthierarchy2/src/core/Template.h (added) merged: 2173
r2459 r2485 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/branches/presentation/src/core/XMLFile.h
- Property svn:mergeinfo changed
/code/trunk/src/core/XMLFile.h merged: 2-1912
- Property svn:mergeinfo changed
-
code/branches/presentation/src/core/XMLIncludes.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/core/XMLPort.h
r2459 r2485 43 43 #include "CorePrereqs.h" 44 44 45 #include <cassert> 45 46 #include "util/Debug.h" 46 47 #include "util/Exception.h" … … 369 370 } 370 371 372 ~XMLPortClassParamContainer() 373 { 374 assert(this->loadexecutor_); 375 delete this->loadexecutor_; 376 if (this->saveexecutor_) 377 delete this->saveexecutor_; 378 } 379 371 380 XMLPortParamContainer& port(BaseObject* owner, T* object, Element& xmlelement, XMLPort::Mode mode) 372 381 { … … 376 385 this->parseParams_.mode = mode; 377 386 378 if ( mode == XMLPort::LoadObject)387 if ((mode == XMLPort::LoadObject) || (mode == XMLPort::ExpandObject)) 379 388 { 380 389 try 381 390 { 382 391 std::string attribute = xmlelement.GetAttribute(this->paramname_); 383 if ((attribute.size() > 0) || ( this->loadexecutor_->allDefaultValuesSet()))392 if ((attribute.size() > 0) || ((mode != XMLPort::ExpandObject) && this->loadexecutor_->allDefaultValuesSet())) 384 393 { 385 394 COUT(5) << this->owner_->getLoaderIndentation() << "Loading parameter " << this->paramname_ << " in " << this->identifier_->getName() << " (objectname " << this->owner_->getName() << ")." << std::endl << this->owner_->getLoaderIndentation(); 386 if (this->loadexecutor_->parse(object, attribute, ",") )395 if (this->loadexecutor_->parse(object, attribute, ",") || (mode == XMLPort::ExpandObject)) 387 396 this->parseResult_ = PR_finished; 388 397 else 389 398 this->parseResult_ = PR_waiting_for_default_values; 390 399 } 400 else if (mode == XMLPort::ExpandObject) 401 this->parseResult_ = PR_finished; 391 402 else 392 403 this->parseResult_ = PR_waiting_for_default_values; … … 511 522 } 512 523 524 ~XMLPortClassObjectContainer() 525 { 526 assert(this->loadexecutor_); 527 delete this->loadexecutor_; 528 if (this->saveexecutor_) 529 delete this->saveexecutor_; 530 } 531 513 532 XMLPortObjectContainer& port(T* object, Element& xmlelement, XMLPort::Mode mode) 514 533 { 515 if ( mode == XMLPort::LoadObject)534 if ((mode == XMLPort::LoadObject) || (mode == XMLPort::ExpandObject)) 516 535 { 517 536 try -
code/branches/presentation/src/core/input/Button.cc
r2103 r2485 59 59 nCommands_[1]=0; 60 60 nCommands_[2]=0; 61 this->configContainer_ = 0; 61 62 clear(); 62 63 } … … 80 81 } 81 82 } 83 84 if (this->configContainer_) 85 delete this->configContainer_; 86 this->configContainer_ = 0; 82 87 } 83 88 -
code/branches/presentation/src/core/input/InputBuffer.cc
r1755 r2485 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/branches/presentation/src/core/input/InputBuffer.h
r1887 r2485 79 79 public: 80 80 InputBuffer(); 81 ~InputBuffer(); 81 82 InputBuffer(const std::string allowedChars); 82 83 -
code/branches/presentation/src/network/GamestateClient.cc
r2371 r2485 82 82 NetworkCallbackManager::callCallbacks(); 83 83 84 if (!processed) 85 return false; 84 if (!processed){ 85 sendAck(0); 86 return false; 87 } 86 88 //successfully loaded data from gamestate. now save gamestate for diff and delete the old gs 87 89 tempGamestate_=NULL; -
code/branches/presentation/src/network/GamestateManager.cc
r2382 r2485 51 51 #include "synchronisable/Synchronisable.h" 52 52 #include "synchronisable/NetworkCallbackManager.h" 53 #include "packet/Acknowledgement.h" 53 54 54 55 namespace orxonox … … 172 173 unsigned int curid = temp->getGamestateID(); 173 174 174 if(gamestateID == 0){175 if(gamestateID == ACKID_NACK){ 175 176 temp->setGamestateID(GAMESTATEID_INITIAL); 176 177 return true; -
code/branches/presentation/src/network/TrafficControl.cc
r2436 r2485 36 36 37 37 namespace orxonox { 38 39 static const unsigned int SCHED_PRIORITY_OFFSET = -1;38 39 static const unsigned int SCHED_PRIORITY_OFFSET = (unsigned int)-1; 40 40 41 41 objInfo::objInfo(uint32_t ID, uint32_t creatorID, int32_t curGsID, int32_t diffGsID, uint32_t size, unsigned int prioperm, unsigned int priosched) 42 { 43 objID = ID; objCreatorID = creatorID; objCurGS = curGsID; objDiffGS = diffGsID; objSize = size; objValuePerm = prioperm; objValueSched = priosched; 44 } 45 42 { 43 objID = ID; objCreatorID = creatorID; objCurGS = curGsID; objDiffGS = diffGsID; objSize = size; objValuePerm = prioperm; objValueSched = priosched; 44 } 45 46 46 objInfo::objInfo() 47 { 48 objID = OBJECTID_UNKNOWN; objCreatorID = OBJECTID_UNKNOWN; objCurGS = GAMESTATEID_INITIAL; objDiffGS = objCurGS; objSize = 0; objValuePerm = 0; objValueSched = 0; 49 } 50 51 52 47 { 48 objID = OBJECTID_UNKNOWN; objCreatorID = OBJECTID_UNKNOWN; objCurGS = GAMESTATEID_INITIAL; objDiffGS = objCurGS; objSize = 0; objValuePerm = 0; objValueSched = 0; 49 } 50 51 52 53 53 obj::obj() 54 { 55 objID = OBJECTID_UNKNOWN; objCreatorID = OBJECTID_UNKNOWN; objSize = 0; objDataOffset = 0; 54 { 55 objID = OBJECTID_UNKNOWN; objCreatorID = OBJECTID_UNKNOWN; objSize = 0; objDataOffset = 0; 56 56 } 57 57 obj::obj( uint32_t ID, uint32_t creatorID, uint32_t size, uint32_t offset ) … … 59 59 objID = ID; objCreatorID = creatorID; objSize = size; objDataOffset = offset; 60 60 } 61 61 62 62 /** 63 63 *Initializing protected members 64 64 */ 65 65 TrafficControl *TrafficControl::instance_=0; 66 66 67 67 /** 68 68 * @brief Constructor: assures that only one reference will be created and sets the pointer … … 75 75 this->setConfigValues(); 76 76 } 77 77 78 78 /** 79 79 * @brief Destructor: resets the instance pointer to 0 … … 93 93 SetConfigValue ( targetSize, 5000 ); 94 94 } 95 95 96 96 /** 97 97 * sort-algorithm for sorting the objectlist after priorities … … 102 102 assert(clientListPerm_[clientID].find(i.objID) != clientListPerm_[clientID].end()); // make sure the object i is in the client list 103 103 assert(clientListPerm_[clientID].find(j.objID) != clientListPerm_[clientID].end()); // make sure the object j is in the client list 104 104 105 105 int prio1 = clientListPerm_[clientID][i.objID].objValuePerm + clientListPerm_[clientID][i.objID].objValueSched; 106 106 int prio2 = clientListPerm_[clientID][j.objID].objValuePerm + clientListPerm_[clientID][j.objID].objValueSched; … … 118 118 } 119 119 120 120 121 121 122 122 void TrafficControl::processObjectList(unsigned int clientID, unsigned int gamestateID, std::list<obj> *list) … … 128 128 return; 129 129 } 130 130 131 131 TrafficControl *TrafficControl::getInstance() 132 132 { … … 134 134 return instance_; 135 135 } 136 136 137 137 void TrafficControl::ack(unsigned int clientID, unsigned int gamestateID) 138 138 { 139 139 std::list<obj>::iterator itvec; // iterator to iterate through the acked objects 140 140 141 141 //assertions to make sure the maps already exist 142 142 assert(clientListTemp_.find(clientID) != clientListTemp_.end() ); 143 143 assert(clientListPerm_.find(clientID) != clientListPerm_.end() ); 144 144 assert( clientListTemp_[clientID].find(gamestateID) != clientListTemp_[clientID].end() ); 145 145 146 146 for(itvec = clientListTemp_[clientID][gamestateID].begin(); itvec != clientListTemp_[clientID][gamestateID].end(); itvec++) 147 147 { … … 173 173 */ 174 174 void TrafficControl::insertinClientListPerm(unsigned int clientID, obj objinf) 175 { 175 { 176 176 std::map<unsigned int,std::map<unsigned int, objInfo> >::iterator itperm;//iterator clientListPerm over clientIDs 177 177 // itperm = (clientListPerm_).find(clientID); … … 182 182 // permObjPrio_.insert(objid, objinf.objValuePerm); 183 183 } 184 184 185 185 /** 186 186 * updateClientListTemp 187 187 * takes the shortened list which will be sent to the gsmanager and puts the *info into clientListTemp 188 */ 188 */ 189 189 void TrafficControl::updateClientListTemp(std::list<obj> *list) 190 190 { … … 225 225 void TrafficControl::evaluateList(unsigned int clientID, std::list<obj> *list) 226 226 { 227 227 228 228 //now the sorting 229 229 230 230 //compare listToProcess vs clientListPerm 231 231 //if listToProcess contains new Objects, add them to clientListPerm … … 248 248 } 249 249 //end compare listToProcess vs clientListPerm 250 250 251 251 if( bActive_ ) 252 252 { … … 254 254 // use boost bind here because we need to pass a memberfunction to stl sort 255 255 list->sort(boost::bind(&TrafficControl::prioritySort, this, clientID, _1, _2) ); 256 256 257 257 //now we check, that the creator of an object always exists on a client 258 258 std::list<obj>::iterator itcreator; 259 259 for(itvec = list->begin(); itvec != list->end(); itvec++) 260 { 260 { 261 261 fixCreatorDependencies(itvec, list, clientID); 262 262 } 263 263 //end of sorting 264 //now the cutting, work the same obj out in processobjectlist and copiedlist, compression rate muss noch festgelegt werden. 264 //now the cutting, work the same obj out in processobjectlist and copiedlist, compression rate muss noch festgelegt werden. 265 265 // printList(list, clientID); 266 266 cut(list, targetSize); 267 267 268 268 //now sort again after objDataOffset 269 269 list->sort(boost::bind(&TrafficControl::dataSort, this, _1, _2) ); … … 281 281 COUT(0) << "ObjectID: " << (*it).objID << " creatorID: " << (*it).objCreatorID << " Priority: " << clientListPerm_[clientID][(*it).objID].objValuePerm + clientListPerm_[clientID][(*it).objID].objValueSched << " size: " << (*it).objSize << endl; 282 282 } 283 283 284 284 void TrafficControl::fixCreatorDependencies(std::list<obj>::iterator it1, std::list<obj> *list, unsigned int clientID) 285 285 { … … 301 301 } 302 302 } 303 303 304 304 void TrafficControl::clientDisconnected(unsigned int clientID) 305 305 { -
code/branches/presentation/src/network/packet/Acknowledgement.h
r2171 r2485 32 32 #include "Packet.h" 33 33 34 const unsigned int ACKID_NACK = 0; 34 35 35 36 namespace orxonox { -
code/branches/presentation/src/network/packet/Gamestate.cc
r2476 r2485 31 31 #include "../synchronisable/Synchronisable.h" 32 32 #include "../TrafficControl.h" 33 #include "core/Core.h" 33 34 #include "core/CoreIncludes.h" 34 35 #include "core/Iterator.h" … … 151 152 if(!s) 152 153 { 153 Synchronisable::fabricate(mem, mode); 154 if (!Core::isMaster()) 155 Synchronisable::fabricate(mem, mode); 156 else 157 mem += objectheader->size; 154 158 // COUT(0) << "could not fabricate synchronisable: " << objectheader->objectID << " classid: " << objectheader->classID << " creator: " << objectheader->creatorID << endl; 155 159 // else … … 170 174 if (it->objectMode_ != 0x0) { 171 175 COUT(0) << "Found object with OBJECTID_UNKNOWN on the client with objectMode != 0x0!" << std::endl; 176 COUT(0) << "Possible reason for this error: Client created a synchronized object without the Server's approval." << std::endl; 172 177 assert(false); 173 178 } … … 384 389 //call TrafficControl 385 390 TrafficControl::getInstance()->processObjectList( clientID, HEADER->id, &dataMap_ ); 386 391 387 392 //copy in the zeros 388 393 for(it=dataMap_.begin(); it!=dataMap_.end();){ 389 394 // if((*it).objSize==0) 390 395 // continue; 396 // if(it->second->getSize(HEADER->id)==0) // merged from objecthierarchy2, doesn't work anymore; TODO: change this 397 // continue; // merged from objecthierarchy2, doesn't work anymore; TODO: change this 391 398 oldobjectheader = (synchronisableHeader*)origdata; 392 399 newobjectheader = (synchronisableHeader*)newdata; -
code/branches/presentation/src/network/packet/Packet.cc
r2171 r2485 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/branches/presentation/src/network/packet/Welcome.cc
r2483 r2485 43 43 #define _CLIENTID _PACKETID + sizeof(ENUM::Type) 44 44 #define _ENDIANTEST _CLIENTID + sizeof(uint32_t) 45 45 46 46 Welcome::Welcome( uint32_t clientID, uint32_t shipID ) 47 47 : Packet() … … 74 74 75 75 bool Welcome::process(){ 76 uint32_t shipID,clientID;76 uint32_t clientID; 77 77 clientID = *(uint32_t *)(data_ + _CLIENTID ); 78 78 assert(*(uint32_t *)(data_ + _ENDIANTEST ) == 0xFEDC4321); -
code/branches/presentation/src/network/synchronisable/Synchronisable.cc
r2482 r2485 119 119 if (it != objectMap_.end()) 120 120 objectMap_.erase(it); 121 121 122 122 //HACK HACK HACK HACK HACK HACK 123 123 // this hack ensures that childs of this object also get destroyed … … 166 166 167 167 Identifier* id = ClassByID(header->classID); 168 if (!id) 169 { 170 COUT(0) << "Assertion failed: id" << std::endl; 171 COUT(0) << "Possible reason for this error: Client received a synchronizable object whose class has no factory." << std::endl; 172 abort(); 173 } 168 174 assert(id); 169 175 BaseObject* creator = 0; … … 253 259 254 260 /* void Synchronisable::registerVariable(void *var, int size, variableType t, uint8_t mode, NetworkCallbackBase *cb){ 255 assert( mode== direction::toclient || mode==direction::toserver || mode==direction::serverMaster || mode==direction::clientMaster);261 assert( mode==variableDirection::toclient || mode==variableDirection::toserver || mode==variableDirection::serverMaster || mode==variableDirection::clientMaster); 256 262 // create temporary synch.Var struct 257 263 synchronisableVariable *temp = new synchronisableVariable; … … 261 267 temp->type = t; 262 268 temp->callback = cb; 263 if( ( mode & direction::bidirectional ) )269 if( ( mode & variableDirection::bidirectional ) ) 264 270 { 265 271 if(t!=STRING) … … 286 292 #endif 287 293 }*/ 288 294 289 295 290 296 /** … … 444 450 objectMode_=mode; 445 451 } 446 452 447 453 448 454 } -
code/branches/presentation/src/network/synchronisable/Synchronisable.h
r2459 r2485 61 61 }; 62 62 } 63 63 64 64 namespace priority{ 65 65 enum prio{ … … 100 100 static uint32_t popDeletedObject(){ uint32_t i = deletedObjects_.front(); deletedObjects_.pop(); return i; } 101 101 102 inline uint32_t getObjectID() {return objectID;}103 inline unsigned int getCreatorID() {return creatorID;}104 inline uint32_t getClassID() {return classID;}105 inline unsigned int getPriority() { return objectFrequency_;}102 inline uint32_t getObjectID() const {return objectID;} 103 inline unsigned int getCreatorID() const {return creatorID;} 104 inline uint32_t getClassID() const {return classID;} 105 inline unsigned int getPriority() const { return objectFrequency_;} 106 106 107 107 protected: … … 134 134 static std::queue<uint32_t> deletedObjects_; 135 135 }; 136 136 137 137 template <class T> void Synchronisable::registerVariable(T& variable, uint8_t mode, NetworkCallbackBase *cb, bool bidirectional) 138 138 { … … 158 158 // the variable has not been registered before 159 159 } 160 160 161 161 // ================= Specialisation declarations 162 162 template <> _NetworkExport void Synchronisable::registerVariable( const ColourValue& variable, uint8_t mode, NetworkCallbackBase* cb, bool bidirectional); -
code/branches/presentation/src/orxonox/CMakeLists.txt
r2459 r2485 4 4 LevelManager.cc 5 5 Main.cc 6 PawnManager.cc 6 7 PlayerManager.cc 7 8 Settings.cc -
code/branches/presentation/src/orxonox/CameraManager.cc
- Property svn:mergeinfo changed
/code/branches/objecthierarchy2/src/orxonox/CameraManager.cc (added) merged: 2369,2396 /code/trunk/src/orxonox/CameraManager.cc merged: 2-1912
r2459 r2485 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 } - Property svn:mergeinfo changed
-
code/branches/presentation/src/orxonox/CameraManager.h
- Property svn:mergeinfo changed
/code/branches/objecthierarchy2/src/orxonox/CameraManager.h (added) merged: 2369,2396 /code/trunk/src/orxonox/CameraManager.h merged: 2-1912
r2459 r2485 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; - Property svn:mergeinfo changed
-
code/branches/presentation/src/orxonox/GraphicsEngine.cc
r2087 r2485 77 77 singletonRef_s = this; 78 78 79 this->viewport_ = 0; 80 79 81 this->detailLevelParticle_ = 0; 80 82 -
code/branches/presentation/src/orxonox/GraphicsEngine.h
r2087 r2485 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/branches/presentation/src/orxonox/Main.cc
r2103 r2485 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/branches/presentation/src/orxonox/OrxonoxPrereqs.h
r2466 r2485 82 82 class CameraManager; 83 83 class LevelManager; 84 class PawnManager; 84 85 class PlayerManager; 85 86 … … 116 117 class Billboard; 117 118 class BlinkingBillboard; 119 class ExplosionChunk; 120 class FadingBillboard; 121 class GlobalShader; 118 122 class Light; 119 123 class Backlight; … … 128 132 class Pawn; 129 133 class SpaceShip; 134 135 class Item; 136 class Engine; 137 class MultiStateEngine; 138 class RotatingEngine; 130 139 131 140 class Trigger; … … 146 155 class Controller; 147 156 class HumanController; 157 class ArtificialController; 158 class AIController; 159 class ScriptController; 148 160 149 161 class Info; 150 162 class PlayerInfo; 151 163 class HumanPlayer; 164 class Bot; 165 class GametypeInfo; 152 166 153 167 class Gametype; … … 166 180 class Mesh; 167 181 class ParticleInterface; 182 class Shader; 168 183 template <class T> 169 184 class Timer; … … 177 192 class HUDRadar; 178 193 class HUDSpeedBar; 194 class HUDHealthBar; 179 195 class InGameConsole; 180 196 class Notification; … … 184 200 class OverlayGroup; 185 201 class OverlayText; 202 class GametypeStatus; 186 203 187 204 //gui -
code/branches/presentation/src/orxonox/PlayerManager.cc
r2171 r2485 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/branches/presentation/src/orxonox/PlayerManager.h
r2171 r2485 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/branches/presentation/src/orxonox/Settings.cc
r2087 r2485 83 83 } 84 84 85 LuaBind::getInstance() ->setIncludePath(this->dataPath_);85 LuaBind::getInstance().setIncludePath(this->dataPath_); 86 86 } 87 87 -
code/branches/presentation/src/orxonox/gamestates/GSGraphics.cc
r2171 r2485 31 31 32 32 #include <fstream> 33 #include <OgreCompositorManager.h> 33 34 #include <OgreConfigFile.h> 34 35 #include <OgreFrameListener.h> … … 164 165 FunctorMember<GSGraphics>* functor1 = createFunctor(&GSGraphics::printScreen); 165 166 functor1->setObject(this); 166 CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor1, "printScreen")); 167 ccPrintScreen_ = createConsoleCommand(functor1, "printScreen"); 168 CommandExecutor::addConsoleCommandShortcut(ccPrintScreen_); 167 169 } 168 170 … … 170 172 { 171 173 using namespace Ogre; 174 175 delete this->ccPrintScreen_; 172 176 173 177 // remove our WindowEventListener first to avoid bad calls after the window has been destroyed … … 184 188 Loader::unload(this->debugOverlay_); 185 189 delete this->debugOverlay_; 190 191 // unload all compositors 192 Ogre::CompositorManager::getSingleton().removeAll(); 186 193 187 194 // destroy render window … … 430 437 // create a full screen default viewport 431 438 this->viewport_ = this->renderWindow_->addViewport(0, 0); 439 440 if (this->graphicsEngine_) 441 this->graphicsEngine_->setViewport(this->viewport_); 432 442 } 433 443 -
code/branches/presentation/src/orxonox/gamestates/GSGraphics.h
r2103 r2485 112 112 unsigned int detailLevelParticle_; //!< Detail level of particle effects (0: off, 1: low, 2: normal, 3: high) 113 113 std::string defaultMasterKeybindings_; //!< Filename of default master keybindings. 114 115 // console commands 116 ConsoleCommand* ccPrintScreen_; 114 117 }; 115 118 } -
code/branches/presentation/src/orxonox/gamestates/GSLevel.cc
r2460 r2485 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 … … 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/branches/presentation/src/orxonox/gamestates/GSLevel.h
r2103 r2485 44 44 ~GSLevel(); 45 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 51 46 protected: 52 47 void enter(Ogre::Viewport* viewport); … … 56 51 void loadLevel(); 57 52 void unloadLevel(); 58 59 float timeFactor_; //!< A factor that sets the gamespeed. 1 is normal.60 53 61 54 // console commands … … 70 63 CameraManager* cameraManager_; 71 64 LevelManager* levelManager_; 65 PlayerManager* playerManager_; 72 66 73 67 //##### ConfigValues ##### … … 75 69 //! Filename of default keybindings. 76 70 std::string defaultKeybindings_; 71 72 // console commands 73 ConsoleCommand* ccKeybind_; 74 ConsoleCommand* ccTkeybind_; 77 75 78 76 private: -
code/branches/presentation/src/orxonox/gamestates/GSRoot.cc
r2459 r2485 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 … … 87 95 // creates the class hierarchy for all classes with factories 88 96 Factory::createClassHierarchy(); 97 98 // reset game speed to normal 99 timeFactor_ = 1.0f; 100 101 // Create the lua interface 102 this->luaBind_ = new LuaBind(); 89 103 90 104 // instantiate Settings class … … 114 128 setThreadAffinity((unsigned int)(limitToCPU - 1)); 115 129 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")); 130 { 131 // add console commands 132 FunctorMember<GSRoot>* functor = createFunctor(&GSRoot::exitGame); 133 functor->setObject(this); 134 this->ccExit_ = createConsoleCommand(functor, "exit"); 135 CommandExecutor::addConsoleCommandShortcut(this->ccExit_); 136 } 137 138 { 139 // add console commands 140 FunctorMember01<GameStateBase, const std::string&>* functor = createFunctor(&GameStateBase::requestState); 141 functor->setObject(this); 142 this->ccSelectGameState_ = createConsoleCommand(functor, "selectGameState"); 143 CommandExecutor::addConsoleCommandShortcut(this->ccSelectGameState_); 144 } 145 146 { 147 // time factor console command 148 FunctorMember<GSRoot>* functor = createFunctor(&GSRoot::setTimeFactor); 149 functor->setObject(this); 150 this->ccSetTimeFactor_ = createConsoleCommand(functor, "setTimeFactor"); 151 CommandExecutor::addConsoleCommandShortcut(this->ccSetTimeFactor_).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0); 152 } 153 154 { 155 // time factor console command 156 FunctorMember<GSRoot>* functor = createFunctor(&GSRoot::pause); 157 functor->setObject(this); 158 this->ccPause_ = createConsoleCommand(functor, "pause"); 159 CommandExecutor::addConsoleCommandShortcut(this->ccPause_).accessLevel(AccessLevel::Offline); 160 } 125 161 } 126 162 127 163 void GSRoot::leave() 128 164 { 129 // TODO: remove and destroy console commands 165 // destroy console commands 166 delete this->ccExit_; 167 delete this->ccSelectGameState_; 130 168 131 169 delete this->shell_; … … 133 171 delete this->tclBind_; 134 172 135 delete settings_; 136 173 delete this->settings_; 174 delete this->luaBind_; 175 176 if (this->ccSetTimeFactor_) 177 { 178 delete this->ccSetTimeFactor_; 179 this->ccSetTimeFactor_ = 0; 180 } 181 182 if (this->ccPause_) 183 { 184 delete this->ccPause_; 185 this->ccPause_ = 0; 186 } 137 187 } 138 188 … … 153 203 } 154 204 for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it) 155 it->tick(leveldt );205 it->tick(leveldt * this->timeFactor_); 156 206 /*** HACK *** HACK ***/ 157 207 … … 166 216 167 217 Copyright (c) 2000-2008 Torus Knot Software Ltd 168 218 169 219 OGRE is licensed under the LGPL. For more info, see OGRE license. 170 220 */ … … 173 223 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32 174 224 // Get the current process core mask 175 176 225 DWORD procMask; 226 DWORD sysMask; 177 227 # if _MSC_VER >= 1400 && defined (_M_X64) 178 228 GetProcessAffinityMask(GetCurrentProcess(), (PDWORD_PTR)&procMask, (PDWORD_PTR)&sysMask); 179 229 # else 180 230 GetProcessAffinityMask(GetCurrentProcess(), &procMask, &sysMask); 181 231 # endif 182 232 183 184 185 186 233 // If procMask is 0, consider there is only one core available 234 // (using 0 as procMask will cause an infinite loop below) 235 if (procMask == 0) 236 procMask = 1; 187 237 188 238 // if the core specified with limitToCPU is not available, take the lowest one … … 190 240 limitToCPU = 0; 191 241 192 242 // Find the lowest core that this process uses and limitToCPU suggests 193 243 DWORD threadMask = 1; 194 195 196 197 198 244 while ((threadMask & procMask) == 0 || (threadMask < (1u << limitToCPU))) 245 threadMask <<= 1; 246 247 // Set affinity to the first core 248 SetThreadAffinityMask(GetCurrentThread(), threadMask); 199 249 #endif 200 250 } 251 252 /** 253 @brief 254 Changes the speed of Orxonox 255 */ 256 void GSRoot::setTimeFactor(float factor) 257 { 258 if (Core::isMaster()) 259 { 260 if (!this->bPaused_) 261 { 262 TimeFactorListener::timefactor_s = factor; 263 264 for (ObjectList<TimeFactorListener>::iterator it = ObjectList<TimeFactorListener>::begin(); it != ObjectList<TimeFactorListener>::end(); ++it) 265 it->changedTimeFactor(factor, this->timeFactor_); 266 267 this->timeFactor_ = factor; 268 } 269 else 270 this->timeFactorPauseBackup_ = factor; 271 } 272 } 273 274 void GSRoot::pause() 275 { 276 if (Core::isMaster()) 277 { 278 if (!this->bPaused_) 279 { 280 this->timeFactorPauseBackup_ = this->timeFactor_; 281 this->setTimeFactor(0.0f); 282 this->bPaused_ = true; 283 } 284 else 285 { 286 this->bPaused_ = false; 287 this->setTimeFactor(this->timeFactorPauseBackup_); 288 } 289 } 290 } 291 292 //////////////////////// 293 // TimeFactorListener // 294 //////////////////////// 295 float TimeFactorListener::timefactor_s = 1.0f; 296 297 TimeFactorListener::TimeFactorListener() 298 { 299 RegisterRootObject(TimeFactorListener); 300 } 201 301 } -
code/branches/presentation/src/orxonox/gamestates/GSRoot.h
r1891 r2485 47 47 { requestState("root"); } 48 48 49 // this has to be public because proteced triggers a bug in msvc 50 // when taking the function address. 51 void setTimeFactor(float factor); 52 void pause(); 53 float getTimeFactor() { return this->timeFactor_; } 54 49 55 private: 50 56 void enter(); … … 55 61 void setThreadAffinity(unsigned int limitToCPU); 56 62 63 float timeFactor_; //!< A factor that sets the gamespeed. 1 is normal. 64 bool bPaused_; 65 float timeFactorPauseBackup_; 57 66 Settings* settings_; 58 67 TclBind* tclBind_; 59 68 TclThreadManager* tclThreadManager_; 60 69 Shell* shell_; 70 LuaBind* luaBind_; 71 72 // console commands 73 ConsoleCommand* ccExit_; 74 ConsoleCommand* ccSelectGameState_; 75 ConsoleCommand* ccSetTimeFactor_; 76 ConsoleCommand* ccPause_; 77 }; 78 79 class _OrxonoxExport TimeFactorListener : virtual public OrxonoxClass 80 { 81 friend class GSRoot; 82 83 public: 84 TimeFactorListener(); 85 virtual ~TimeFactorListener() {} 86 87 protected: 88 virtual void changedTimeFactor(float factor_new, float factor_old) {} 89 inline float getTimeFactor() const 90 { return TimeFactorListener::timefactor_s; } 91 92 private: 93 static float timefactor_s; 61 94 }; 62 95 } -
code/branches/presentation/src/orxonox/gui/GUIManager.cc
r2087 r2485 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/branches/presentation/src/orxonox/objects/CMakeLists.txt
r2459 r2485 3 3 EventDispatcher.cc 4 4 EventTarget.cc 5 GlobalShader.cc 5 6 Level.cc 6 7 Radar.cc … … 17 18 ADD_SOURCE_DIRECTORY(SRC_FILES gametypes) 18 19 ADD_SOURCE_DIRECTORY(SRC_FILES infos) 20 ADD_SOURCE_DIRECTORY(SRC_FILES items) 19 21 #ADD_SOURCE_DIRECTORY(SRC_FILES pickup) 20 22 ADD_SOURCE_DIRECTORY(SRC_FILES quest) -
code/branches/presentation/src/orxonox/objects/EventTarget.cc
r2087 r2485 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/branches/presentation/src/orxonox/objects/GlobalShader.cc
r2480 r2485 66 66 void GlobalShader::registerVariables() 67 67 { 68 REGISTERDATA (this->bVisible_, direction::toclient, new NetworkCallback<GlobalShader>(this, &GlobalShader::changedVisibility));69 REGISTERSTRING(const_cast<std::string&>(this->shader_.getCompositor()), direction::toclient, new NetworkCallback<Shader>(&this->shader_, &Shader::changedCompositor));68 registerVariable(this->bVisible_, variableDirection::toclient, new NetworkCallback<GlobalShader>(this, &GlobalShader::changedVisibility)); 69 registerVariable(const_cast<std::string&>(this->shader_.getCompositor()), variableDirection::toclient, new NetworkCallback<Shader>(&this->shader_, &Shader::changedCompositor)); 70 70 } 71 71 -
code/branches/presentation/src/orxonox/objects/GlobalShader.h
r2480 r2485 33 33 34 34 #include "core/BaseObject.h" 35 #include "network/ Synchronisable.h"35 #include "network/synchronisable/Synchronisable.h" 36 36 #include "tools/Shader.h" 37 37 -
code/branches/presentation/src/orxonox/objects/Level.cc
- Property svn:mergeinfo changed
/code/branches/objecthierarchy2/src/orxonox/objects/Level.cc (added) merged: 2173 /code/trunk/src/orxonox/objects/Level.cc merged: 2107-2169
r2459 r2485 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 } - Property svn:mergeinfo changed
-
code/branches/presentation/src/orxonox/objects/Level.h
- Property svn:mergeinfo changed
/code/trunk/src/orxonox/objects/Level.h merged: 2107-2169
- Property svn:mergeinfo changed
-
code/branches/presentation/src/orxonox/objects/Radar.cc
r2087 r2485 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/branches/presentation/src/orxonox/objects/RadarViewable.cc
r2087 r2485 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/branches/presentation/src/orxonox/objects/RadarViewable.h
r2087 r2485 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/branches/presentation/src/orxonox/objects/Scene.cc
r2468 r2485 34 34 #include <OgreSceneManagerEnumerator.h> 35 35 #include <OgreSceneNode.h> 36 #include <OgreLight.h>37 36 38 37 #include "BulletCollision/BroadphaseCollision/btAxisSweep3.h" … … 56 55 57 56 this->setScene(this); 58 this->bShadows_ = false;57 this->bShadows_ = true; 59 58 60 59 if (Core::showsGraphics()) … … 90 89 this->broadphase_ = 0; 91 90 92 // test test test93 if (Core::showsGraphics() && this->sceneManager_)94 {95 Ogre::Light* light;96 light = this->sceneManager_->createLight("Light-1");97 light->setType(Ogre::Light::LT_DIRECTIONAL);98 light->setDiffuseColour(ColourValue(1.0, 0.9, 0.6, 1.0));99 light->setSpecularColour(ColourValue(1.0, 0.9, 0.6, 1.0));100 light->setDirection(1, -0.3, 0.3);101 }102 // test test test103 104 91 this->registerVariables(); 105 92 } … … 145 132 registerVariable(this->gravity_, variableDirection::toclient, new NetworkCallback<Scene>(this, &Scene::networkcallback_gravity)); 146 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)); 147 135 } 148 136 … … 156 144 if (this->hasPhysics()) 157 145 { 158 CCOUT(2) << "Warning: Attempting to set the physical world range at run time. " 146 CCOUT(2) << "Warning: Attempting to set the physical world range at run time. " 159 147 << "This causes a complete physical reload which might take some time." << std::endl; 160 148 this->setPhysicalWorld(false); … … 175 163 if (this->hasPhysics()) 176 164 { 177 CCOUT(2) << "Warning: Attempting to set the physical world range at run time. " 165 CCOUT(2) << "Warning: Attempting to set the physical world range at run time. " 178 166 << "This causes a complete physical reload which might take some time." << std::endl; 179 167 this->setPhysicalWorld(false); -
code/branches/presentation/src/orxonox/objects/Scene.h
r2468 r2485 76 76 void networkcallback_applyAmbientLight() 77 77 { this->setAmbientLight(this->ambientLight_); } 78 void networkcallback_applyShadows() 79 { this->setShadow(this->bShadows_); } 78 80 79 81 Ogre::SceneManager* sceneManager_; -
code/branches/presentation/src/orxonox/objects/Script.cc
r2087 r2485 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/branches/presentation/src/orxonox/objects/controllers/CMakeLists.txt
r2131 r2485 2 2 Controller.cc 3 3 HumanController.cc 4 ArtificialController.cc 5 AIController.cc 6 ScriptController.cc 4 7 ) 5 8 -
code/branches/presentation/src/orxonox/objects/controllers/Controller.cc
r2087 r2485 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/branches/presentation/src/orxonox/objects/controllers/Controller.h
r2087 r2485 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/branches/presentation/src/orxonox/objects/controllers/HumanController.cc
r2087 r2485 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); 49 56 50 57 CreateUnloadableFactory(HumanController); … … 112 119 } 113 120 121 void HumanController::boost() 122 { 123 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 124 HumanController::localController_s->controllableEntity_->boost(); 125 } 126 114 127 void HumanController::greet() 115 128 { … … 129 142 HumanController::localController_s->controllableEntity_->switchCamera(); 130 143 } 144 145 void HumanController::mouseLook() 146 { 147 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 148 HumanController::localController_s->controllableEntity_->mouseLook(); 149 } 150 151 void HumanController::suicide() 152 { 153 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 154 { 155 Pawn* pawn = dynamic_cast<Pawn*>(HumanController::localController_s->controllableEntity_); 156 if (pawn) 157 pawn->kill(); 158 } 159 } 160 161 void HumanController::addBots(unsigned int amount) 162 { 163 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && HumanController::localController_s->controllableEntity_->getGametype()) 164 HumanController::localController_s->controllableEntity_->getGametype()->addBots(amount); 165 } 166 167 void HumanController::killBots(unsigned int amount) 168 { 169 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_ && HumanController::localController_s->controllableEntity_->getGametype()) 170 HumanController::localController_s->controllableEntity_->getGametype()->killBots(amount); 171 } 131 172 } -
code/branches/presentation/src/orxonox/objects/controllers/HumanController.h
r2087 r2485 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 62 static void suicide(); 63 64 static void addBots(unsigned int amount); 65 static void killBots(unsigned int amount = 0); 59 66 60 67 private: -
code/branches/presentation/src/orxonox/objects/gametypes/Gametype.cc
r2171 r2485 34 34 35 35 #include "core/CoreIncludes.h" 36 #include "core/ConfigValueIncludes.h" 36 37 #include "objects/infos/PlayerInfo.h" 38 #include "objects/infos/Bot.h" 37 39 #include "objects/worldentities/pawns/Spectator.h" 38 40 #include "objects/worldentities/SpawnPoint.h" 41 #include "objects/worldentities/Camera.h" 39 42 40 43 #include "network/Host.h" … … 44 47 CreateUnloadableFactory(Gametype); 45 48 46 Gametype::Gametype(BaseObject* creator) : BaseObject(creator) 49 Gametype::Gametype(BaseObject* creator) : BaseObject(creator), gtinfo_(creator) 47 50 { 48 51 RegisterObject(Gametype); 49 52 53 this->setGametype(this); 54 50 55 this->defaultControllableEntity_ = Class(Spectator); 51 56 52 this->bStarted_ = false;53 this->bEnded_ = false;54 57 this->bAutoStart_ = false; 55 58 this->bForceSpawn_ = false; 59 this->numberOfBots_ = 0; 56 60 57 61 this->initialStartCountdown_ = 3; 58 this->startCountdown_ = 0; 59 this->bStartCountdownRunning_ = false; 62 63 this->setConfigValues(); 64 65 this->addBots(this->numberOfBots_); 66 } 67 68 void Gametype::setConfigValues() 69 { 70 SetConfigValue(initialStartCountdown_, 3.0f); 71 SetConfigValue(bAutoStart_, false); 72 SetConfigValue(bForceSpawn_, false); 73 SetConfigValue(numberOfBots_, 0); 60 74 } 61 75 62 76 void Gametype::tick(float dt) 63 77 { 64 if (this->bStartCountdownRunning_ && !this->bStarted_) 65 this->startCountdown_ -= dt; 66 67 if (!this->bStarted_) 78 SUPER(Gametype, tick, dt); 79 80 if (this->gtinfo_.bStartCountdownRunning_ && !this->gtinfo_.bStarted_) 81 this->gtinfo_.startCountdown_ -= dt; 82 83 if (!this->gtinfo_.bStarted_) 68 84 this->checkStart(); 69 85 else … … 76 92 { 77 93 COUT(0) << "game started" << std::endl; 78 this-> bStarted_ = true;94 this->gtinfo_.bStarted_ = true; 79 95 80 96 this->spawnPlayersIfRequested(); … … 84 100 { 85 101 COUT(0) << "game ended" << std::endl; 86 this-> bEnded_ = true;102 this->gtinfo_.bEnded_ = true; 87 103 } 88 104 … … 140 156 void Gametype::pawnKilled(Pawn* victim, Pawn* killer) 141 157 { 158 if (victim && victim->getPlayer()) 159 { 160 std::map<PlayerInfo*, PlayerState::Enum>::iterator it = this->players_.find(victim->getPlayer()); 161 if (it != this->players_.end()) 162 { 163 it->second = PlayerState::Dead; 164 165 ControllableEntity* entity = this->defaultControllableEntity_.fabricate(victim->getCreator()); 166 if (victim->getCamera()) 167 { 168 entity->setPosition(victim->getCamera()->getWorldPosition()); 169 entity->setOrientation(victim->getCamera()->getWorldOrientation()); 170 } 171 else 172 { 173 entity->setPosition(victim->getWorldPosition()); 174 entity->setOrientation(victim->getWorldOrientation()); 175 } 176 it->first->startControl(entity); 177 } 178 else 179 COUT(2) << "Warning: Killed Pawn was not in the playerlist" << std::endl; 180 } 142 181 } 143 182 … … 150 189 if (this->spawnpoints_.size() > 0) 151 190 { 152 srand(time(0));153 rnd();154 155 191 unsigned int randomspawn = (unsigned int)rnd(this->spawnpoints_.size()); 156 192 unsigned int index = 0; … … 170 206 for (std::map<PlayerInfo*, PlayerState::Enum>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) 171 207 { 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; 208 if (!it->first->getControllableEntity()) 209 { 210 it->second = PlayerState::Dead; 211 212 if (!it->first->isReadyToSpawn() || !this->gtinfo_.bStarted_) 213 { 214 SpawnPoint* spawn = this->getBestSpawnPoint(it->first); 215 if (spawn) 216 { 217 // force spawn at spawnpoint with default pawn 218 ControllableEntity* entity = this->defaultControllableEntity_.fabricate(spawn); 219 spawn->spawn(entity); 220 it->first->startControl(entity); 221 it->second = PlayerState::Dead; 222 } 223 else 224 { 225 COUT(1) << "Error: No SpawnPoints in current Gametype" << std::endl; 226 abort(); 227 } 228 } 229 } 230 } 231 } 232 233 void Gametype::checkStart() 234 { 235 if (!this->gtinfo_.bStarted_) 236 { 237 if (this->gtinfo_.bStartCountdownRunning_) 238 { 239 if (this->gtinfo_.startCountdown_ <= 0) 240 { 241 this->gtinfo_.bStartCountdownRunning_ = false; 242 this->gtinfo_.startCountdown_ = 0; 243 this->start(); 244 } 245 } 246 else if (this->players_.size() > 0) 247 { 248 if (this->bAutoStart_) 249 { 250 this->start(); 182 251 } 183 252 else 184 253 { 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 254 bool allplayersready = true; 255 bool hashumanplayers = false; 214 256 for (std::map<PlayerInfo*, PlayerState::Enum>::iterator it = this->players_.begin(); it != this->players_.end(); ++it) 215 257 { 216 258 if (!it->first->isReadyToSpawn()) 217 259 allplayersready = false; 260 if (it->first->isHumanPlayer()) 261 hashumanplayers = true; 218 262 } 219 if (allplayersready )263 if (allplayersready && hashumanplayers) 220 264 { 221 this-> startCountdown_ = this->initialStartCountdown_;222 this-> bStartCountdownRunning_ = true;265 this->gtinfo_.startCountdown_ = this->initialStartCountdown_; 266 this->gtinfo_.bStartCountdownRunning_ = true; 223 267 } 224 268 } … … 256 300 } 257 301 } 302 303 void Gametype::addBots(unsigned int amount) 304 { 305 for (unsigned int i = 0; i < amount; ++i) 306 new Bot(this); 307 } 308 309 void Gametype::killBots(unsigned int amount) 310 { 311 unsigned int i = 0; 312 for (ObjectList<Bot>::iterator it = ObjectList<Bot>::begin(); (it != ObjectList<Bot>::end()) && ((amount == 0) || (i < amount)); ) 313 { 314 if (it->getGametype() == this) 315 { 316 delete (*(it++)); 317 ++i; 318 } 319 } 320 } 258 321 } -
code/branches/presentation/src/orxonox/objects/gametypes/Gametype.h
r2171 r2485 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 … … 60 61 virtual ~Gametype() {} 61 62 63 void setConfigValues(); 64 62 65 virtual void tick(float dt); 63 66 67 inline const GametypeInfo* getGametypeInfo() const 68 { return &this->gtinfo_; } 69 64 70 inline bool hasStarted() const 65 { return this-> bStarted_; }71 { return this->gtinfo_.bStarted_; } 66 72 inline bool hasEnded() const 67 { return this-> bEnded_; }73 { return this->gtinfo_.bEnded_; } 68 74 69 75 virtual void start(); … … 88 94 89 95 inline bool isStartCountdownRunning() const 90 { return this-> bStartCountdownRunning_; }96 { return this->gtinfo_.bStartCountdownRunning_; } 91 97 inline float getStartCountdown() const 92 { return this->startCountdown_; } 98 { return this->gtinfo_.startCountdown_; } 99 100 void addBots(unsigned int amount); 101 void killBots(unsigned int amount = 0); 93 102 94 103 private: … … 104 113 void spawnDeadPlayersIfRequested(); 105 114 106 bool bStarted_;107 bool bEnded_; 115 GametypeInfo gtinfo_; 116 108 117 bool bAutoStart_; 109 118 bool bForceSpawn_; 110 119 111 120 float initialStartCountdown_; 112 float startCountdown_; 113 bool bStartCountdownRunning_; 121 unsigned int numberOfBots_; 114 122 115 123 std::map<PlayerInfo*, PlayerState::Enum> players_; -
code/branches/presentation/src/orxonox/objects/infos/CMakeLists.txt
r2171 r2485 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/branches/presentation/src/orxonox/objects/infos/GametypeInfo.cc
r2480 r2485 54 54 void GametypeInfo::registerVariables() 55 55 { 56 REGISTERDATA(this->bStarted_, direction::toclient);57 REGISTERDATA(this->bEnded_, direction::toclient);58 REGISTERDATA(this->startCountdown_, direction::toclient);59 REGISTERDATA(this->bStartCountdownRunning_, direction::toclient);56 registerVariable(this->bStarted_, variableDirection::toclient); 57 registerVariable(this->bEnded_, variableDirection::toclient); 58 registerVariable(this->startCountdown_, variableDirection::toclient); 59 registerVariable(this->bStartCountdownRunning_, variableDirection::toclient); 60 60 } 61 61 } -
code/branches/presentation/src/orxonox/objects/infos/HumanPlayer.cc
r2371 r2485 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 … … 69 71 registerVariable(this->synchronize_nick_, variableDirection::toserver, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_changednick)); 70 72 71 registerVariable(this->clientID_, variableDirection::toclient, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_clientIDchanged));73 registerVariable(this->clientID_, variableDirection::toclient, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_clientIDchanged)); 72 74 registerVariable(this->server_initialized_, variableDirection::toclient, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_server_initialized)); 73 75 registerVariable(this->client_initialized_, variableDirection::toserver, new NetworkCallback<HumanPlayer>(this, &HumanPlayer::networkcallback_client_initialized)); … … 83 85 this->setName(this->nick_); 84 86 } 87 } 88 89 void HumanPlayer::configvaluecallback_changedHUDTemplate() 90 { 91 this->changedController(); 85 92 } 86 93 … … 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/branches/presentation/src/orxonox/objects/infos/HumanPlayer.h
r2171 r2485 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/branches/presentation/src/orxonox/objects/infos/PlayerInfo.cc
r2371 r2485 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 } … … 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/branches/presentation/src/orxonox/objects/infos/PlayerInfo.h
r2171 r2485 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/branches/presentation/src/orxonox/objects/items/Engine.cc
r2480 r2485 104 104 void Engine::registerVariables() 105 105 { 106 REGISTERDATA(this->shipID_, direction::toclient, new NetworkCallback<Engine>(this, &Engine::networkcallback_shipID));107 108 REGISTERDATA(this->speedFactor_, direction::toclient);109 REGISTERDATA(this->boostFactor_, direction::toclient);110 111 REGISTERDATA(this->maxSpeedFront_, direction::toclient);112 REGISTERDATA(this->maxSpeedBack_, direction::toclient);113 REGISTERDATA(this->maxSpeedLeftRight_, direction::toclient);114 REGISTERDATA(this->maxSpeedUpDown_, direction::toclient);115 116 REGISTERDATA(this->accelerationFront_, direction::toclient);117 REGISTERDATA(this->accelerationBrake_, direction::toclient);118 REGISTERDATA(this->accelerationBack_, direction::toclient);119 REGISTERDATA(this->accelerationLeftRight_, direction::toclient);120 REGISTERDATA(this->accelerationUpDown_, direction::toclient);106 registerVariable(this->shipID_, variableDirection::toclient, new NetworkCallback<Engine>(this, &Engine::networkcallback_shipID)); 107 108 registerVariable(this->speedFactor_, variableDirection::toclient); 109 registerVariable(this->boostFactor_, variableDirection::toclient); 110 111 registerVariable(this->maxSpeedFront_, variableDirection::toclient); 112 registerVariable(this->maxSpeedBack_, variableDirection::toclient); 113 registerVariable(this->maxSpeedLeftRight_, variableDirection::toclient); 114 registerVariable(this->maxSpeedUpDown_, variableDirection::toclient); 115 116 registerVariable(this->accelerationFront_, variableDirection::toclient); 117 registerVariable(this->accelerationBrake_, variableDirection::toclient); 118 registerVariable(this->accelerationBack_, variableDirection::toclient); 119 registerVariable(this->accelerationLeftRight_, variableDirection::toclient); 120 registerVariable(this->accelerationUpDown_, variableDirection::toclient); 121 121 } 122 122 -
code/branches/presentation/src/orxonox/objects/items/Item.h
r2480 r2485 33 33 34 34 #include "core/BaseObject.h" 35 #include "network/ Synchronisable.h"35 #include "network/synchronisable/Synchronisable.h" 36 36 37 37 namespace orxonox -
code/branches/presentation/src/orxonox/objects/items/MultiStateEngine.cc
r2480 r2485 83 83 void MultiStateEngine::registerVariables() 84 84 { 85 REGISTERDATA(this->state_, direction::toserver);85 registerVariable(this->state_, variableDirection::toserver); 86 86 } 87 87 … … 92 92 if (this->getShip()->hasLocalController()) 93 93 { 94 this->setObjectMode( direction::bidirectional);94 this->setObjectMode(objectDirection::bidirectional); 95 95 96 96 const Vector3& direction = this->getDirection(); -
code/branches/presentation/src/orxonox/objects/pickup/Usable.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/AddQuest.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/AddQuest.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/AddQuestHint.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/AddQuestHint.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/AddReward.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/AddReward.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/ChangeQuestStatus.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/ChangeQuestStatus.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/CompleteQuest.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/CompleteQuest.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/FailQuest.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/FailQuest.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/GlobalQuest.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/GlobalQuest.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/LocalQuest.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/LocalQuest.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/Quest.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/Quest.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/QuestDescription.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/QuestDescription.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/QuestEffect.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/QuestEffect.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/QuestHint.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/QuestHint.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/QuestItem.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/QuestItem.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/QuestManager.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/QuestManager.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/Rewardable.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/quest/Rewardable.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/weaponSystem/WeaponSystem.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/weaponSystem/WeaponSystem.h
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/orxonox/objects/worldentities/Backlight.cc
- Property svn:mergeinfo changed
r2459 r2485 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(const_cast<Ogre::SceneNode*>(this->getNode())); 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/branches/presentation/src/orxonox/objects/worldentities/Backlight.h
- Property svn:mergeinfo changed
/code/branches/objecthierarchy2/src/orxonox/objects/worldentities/Backlight.h (added) merged: 2182,2207,2212,2254,2406 /code/trunk/src/orxonox/objects/worldentities/Backlight.h merged: 2-1912
r2459 r2485 31 31 32 32 #include "OrxonoxPrereqs.h" 33 34 #include "StaticEntity.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 StaticEntity38 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 } - Property svn:mergeinfo changed
-
code/branches/presentation/src/orxonox/objects/worldentities/Billboard.cc
r2459 r2485 44 44 RegisterObject(Billboard); 45 45 46 this->material_ = ""; 47 this->colour_ = ColourValue::White; 48 46 49 this->registerVariables(); 47 50 } … … 52 55 { 53 56 if (this->isInitialized() && this->billboard_.getBillboardSet()) 54 this->detachOgreObject(this->billboard_.get Name());57 this->detachOgreObject(this->billboard_.getBillboardSet()); 55 58 } 56 59 } … … 72 75 void Billboard::changedMaterial() 73 76 { 77 if (this->material_ == "") 78 return; 79 74 80 if (!this->billboard_.getBillboardSet()) 75 81 { … … 90 96 if (!this->billboard_.getBillboardSet()) 91 97 { 92 if (this->getScene() && this->getScene()->getSceneManager()) 98 /* 99 if (this->getScene() && this->getScene()->getSceneManager() && (this->material_ != "")) 93 100 { 94 101 this->billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->material_, this->colour_, 1); … … 97 104 this->billboard_.setVisible(this->isVisible()); 98 105 } 106 */ 99 107 } 100 108 else -
code/branches/presentation/src/orxonox/objects/worldentities/Billboard.h
r2459 r2485 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/branches/presentation/src/orxonox/objects/worldentities/BlinkingBillboard.cc
r2171 r2485 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/branches/presentation/src/orxonox/objects/worldentities/CMakeLists.txt
r2459 r2485 5 5 MobileEntity.cc 6 6 ControllableEntity.cc 7 Model.cc 7 8 Backlight.cc 8 9 Billboard.cc 9 10 BlinkingBillboard.cc 11 ExplosionChunk.cc 12 FadingBillboard.cc 10 13 Light.cc 11 14 Camera.cc 12 15 CameraPosition.cc 13 SpawnPoint.cc16 Model.cc 14 17 ParticleEmitter.cc 15 18 ParticleSpawner.cc 16 19 Planet.cc 17 # Backlight.cc20 SpawnPoint.cc 18 21 ) 19 22 -
code/branches/presentation/src/orxonox/objects/worldentities/Camera.cc
- Property svn:mergeinfo changed
r2459 r2485 36 36 #include <OgreSceneManager.h> 37 37 #include <OgreSceneNode.h> 38 #include <OgreViewport.h>39 38 40 39 #include "util/Exception.h" … … 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->attachOgreObject(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->getNode()->getWorldPosition() - this->cameraNode_->getWorldPosition(); 112 this->cameraNode_->translate(coeff * offset); 113 114 this->cameraNode_->setOrientation(Quaternion::Slerp(coeff, this->cameraNode_->getWorldOrientation(), this->getWorldOrientation(), false)); 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/branches/presentation/src/orxonox/objects/worldentities/Camera.h
- Property svn:mergeinfo changed
/code/branches/objecthierarchy2/src/orxonox/objects/worldentities/Camera.h (added) merged: 2396,2478 /code/trunk/src/orxonox/objects/worldentities/Camera.h merged: 2-1912
r2459 r2485 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 } - Property svn:mergeinfo changed
-
code/branches/presentation/src/orxonox/objects/worldentities/CameraPosition.cc
r2459 r2485 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/branches/presentation/src/orxonox/objects/worldentities/CameraPosition.h
r2459 r2485 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/branches/presentation/src/orxonox/objects/worldentities/ControllableEntity.cc
r2474 r2485 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 … … 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; 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(); 58 72 59 73 this->server_position_ = Vector3::ZERO; … … 67 81 68 82 83 this->setConfigValues(); 69 84 this->setPriority( priority::very_high ); 70 85 this->registerVariables(); … … 75 90 if (this->isInitialized()) 76 91 { 77 if (this->bControlled_) 78 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); 79 99 80 100 if (this->hud_) … … 84 104 delete this->camera_; 85 105 86 if (this->getPlayer() && this->getPlayer()->getControllableEntity() == this) 87 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()); 88 111 } 89 112 } … … 99 122 } 100 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 101 144 void ControllableEntity::addCameraPosition(CameraPosition* position) 102 145 { 103 this->attach(position); 146 if (position->getAllowMouseLook()) 147 position->attachToNode(this->cameraPositionRootNode_); 148 else 149 this->attach(position); 104 150 this->cameraPositions_.push_back(position); 105 151 } … … 142 188 else 143 189 { 144 this-> attach(this->camera_);190 this->camera_->attachToNode(this->cameraPositionRootNode_); 145 191 } 146 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); 147 219 } 148 220 … … 157 229 this->player_ = player; 158 230 this->playerID_ = player->getObjectID(); 159 this->bControlled_ = (player->isLocalPlayer() && player->isHumanPlayer()); 160 if (this->bControlled_) 161 { 162 this->startLocalControl(); 231 this->bHasLocalController_ = player->isLocalPlayer(); 232 this->bHasHumanController_ = player->isHumanPlayer(); 233 234 if (this->bHasLocalController_ && this->bHasHumanController_) 235 { 236 this->startLocalHumanControl(); 163 237 164 238 if (!Core::isMaster()) 165 239 { 166 240 this->client_overwrite_ = this->server_overwrite_; 167 COUT(0) << "CE: bidirectional synchronization" << std::endl;168 241 this->setObjectMode(objectDirection::bidirectional); 169 242 } … … 173 246 void ControllableEntity::removePlayer() 174 247 { 175 if (this->b Controlled_)176 this->stopLocal Control();248 if (this->bHasLocalController_ && this->bHasHumanController_) 249 this->stopLocalHumanControl(); 177 250 178 251 this->player_ = 0; 179 252 this->playerID_ = OBJECTID_UNKNOWN; 180 this->bControlled_ = false; 253 this->bHasLocalController_ = false; 254 this->bHasHumanController_ = false; 181 255 this->setObjectMode(objectDirection::toclient); 182 256 … … 196 270 } 197 271 198 void ControllableEntity::startLocalControl() 199 { 200 // std::cout << this->getObjectID() << " ###### start local control" << std::endl; 201 this->camera_ = new Camera(this); 202 this->camera_->requestFocus(); 203 if (this->cameraPositionTemplate_ != "") 204 this->addTemplate(this->cameraPositionTemplate_); 205 if (this->cameraPositions_.size() > 0) 206 this->cameraPositions_.front()->attachCamera(this->camera_); 207 else 208 this->attach(this->camera_); 209 210 if (this->hudtemplate_ != "") 211 { 212 this->hud_ = new OverlayGroup(this); 213 this->hud_->addTemplate(this->hudtemplate_); 214 } 215 } 216 217 void ControllableEntity::stopLocalControl() 218 { 219 // std::cout << "###### stop local control" << std::endl; 220 this->camera_->detachFromParent(); 221 delete this->camera_; 222 this->camera_ = 0; 223 224 delete this->hud_; 225 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 } 226 322 } 227 323 … … 242 338 this->server_angular_velocity_ = this->getAngularVelocity(); 243 339 } 244 else if (this->b Controlled_)340 else if (this->bHasLocalController_) 245 341 { 246 342 this->client_position_ = this->getPosition(); … … 255 351 void ControllableEntity::registerVariables() 256 352 { 257 registerVariable(this->cameraPositionTemplate_, variableDirection::toclient); 353 registerVariable(this->cameraPositionTemplate_, variableDirection::toclient); 354 registerVariable(this->hudtemplate_, variableDirection::toclient); 258 355 259 356 registerVariable(this->server_position_, variableDirection::toclient, new NetworkCallback<ControllableEntity>(this, &ControllableEntity::processServerPosition)); … … 271 368 272 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)); 273 371 } 274 372 275 373 void ControllableEntity::processServerPosition() 276 374 { 277 if (!this->b Controlled_)375 if (!this->bHasLocalController_) 278 376 MobileEntity::setPosition(this->server_position_); 279 377 } … … 281 379 void ControllableEntity::processServerLinearVelocity() 282 380 { 283 if (!this->b Controlled_)381 if (!this->bHasLocalController_) 284 382 MobileEntity::setVelocity(this->server_linear_velocity_); 285 383 } … … 287 385 void ControllableEntity::processServerOrientation() 288 386 { 289 if (!this->b Controlled_)387 if (!this->bHasLocalController_) 290 388 MobileEntity::setOrientation(this->server_orientation_); 291 389 } … … 293 391 void ControllableEntity::processServerAngularVelocity() 294 392 { 295 if (!this->b Controlled_)393 if (!this->bHasLocalController_) 296 394 MobileEntity::setAngularVelocity(this->server_angular_velocity_); 297 395 } … … 299 397 void ControllableEntity::processOverwrite() 300 398 { 301 if (this->b Controlled_)399 if (this->bHasLocalController_) 302 400 { 303 401 this->setPosition(this->server_position_); … … 354 452 ++this->server_overwrite_; 355 453 } 356 else if (this->b Controlled_)454 else if (this->bHasLocalController_) 357 455 { 358 456 MobileEntity::setPosition(position); … … 369 467 ++this->server_overwrite_; 370 468 } 371 else if (this->b Controlled_)469 else if (this->bHasLocalController_) 372 470 { 373 471 MobileEntity::setOrientation(orientation); … … 384 482 ++this->server_overwrite_; 385 483 } 386 else if (this->b Controlled_)484 else if (this->bHasLocalController_) 387 485 { 388 486 MobileEntity::setVelocity(velocity); … … 399 497 ++this->server_overwrite_; 400 498 } 401 else if (this->b Controlled_)499 else if (this->bHasLocalController_) 402 500 { 403 501 MobileEntity::setAngularVelocity(velocity); … … 416 514 this->server_angular_velocity_ = this->getAngularVelocity(); 417 515 } 418 else if (this->b Controlled_)516 else if (this->bHasLocalController_) 419 517 { 420 518 this->client_position_ = this->getPosition(); -
code/branches/presentation/src/orxonox/objects/worldentities/ControllableEntity.h
r2459 r2485 45 45 virtual void tick(float dt); 46 46 void registerVariables(); 47 void setConfigValues(); 48 49 virtual void changedGametype(); 47 50 48 51 virtual void setPlayer(PlayerInfo* player); … … 60 63 virtual void moveUpDown(const Vector2& value) {} 61 64 62 virtual void rotateYaw(const Vector2& value) {} 63 virtual void rotatePitch(const Vector2& value) {} 64 virtual void rotateRoll(const Vector2& value) {} 65 virtual void rotateYaw(const Vector2& value); 66 virtual void rotatePitch(const Vector2& value); 67 virtual void rotateRoll(const Vector2& value); 68 69 inline void moveFrontBack(float value) 70 { this->moveFrontBack(Vector2(value, 0)); } 71 inline void moveRightLeft(float value) 72 { this->moveRightLeft(Vector2(value, 0)); } 73 inline void moveUpDown(float value) 74 { this->moveUpDown(Vector2(value, 0)); } 75 76 inline void rotateYaw(float value) 77 { this->rotateYaw(Vector2(value, 0)); } 78 inline void rotatePitch(float value) 79 { this->rotatePitch(Vector2(value, 0)); } 80 inline void rotateRoll(float value) 81 { this->rotateRoll(Vector2(value, 0)); } 65 82 66 83 virtual void fire() {} 67 84 virtual void altFire() {} 68 85 86 virtual void boost() {} 69 87 virtual void greet() {} 70 88 virtual void use() {} 71 89 virtual void switchCamera(); 90 virtual void mouseLook(); 72 91 73 92 inline const std::string& getHudTemplate() const … … 99 118 void setAngularVelocity(const Vector3& velocity); 100 119 120 inline bool hasLocalController() const 121 { return this->bHasLocalController_; } 122 inline bool hasHumanController() const 123 { return this->bHasHumanController_; } 124 125 inline const GametypeInfo* getGametypeInfo() const 126 { return this->gtinfo_; } 127 128 inline bool isInMouseLook() const 129 { return this->bMouseLook_; } 130 inline float getMouseLookSpeed() const 131 { return this->mouseLookSpeed_; } 132 101 133 protected: 102 virtual void startLocal Control();103 virtual void stopLocal Control();134 virtual void startLocalHumanControl(); 135 virtual void stopLocalHumanControl(); 104 136 105 137 inline void setHudTemplate(const std::string& name) 106 138 { this->hudtemplate_ = name; } 107 108 inline bool isLocallyControlled() const109 { return this->bControlled_; }110 139 111 140 private: … … 124 153 125 154 void networkcallback_changedplayerID(); 155 void networkcallback_changedgtinfoID(); 126 156 127 157 // Bullet btMotionState related … … 131 161 unsigned int client_overwrite_; 132 162 133 bool bControlled_; 163 bool bHasLocalController_; 164 bool bHasHumanController_; 165 bool bDestroyWhenPlayerLeft_; 166 134 167 Vector3 server_position_; 135 168 Vector3 client_position_; … … 143 176 PlayerInfo* player_; 144 177 unsigned int playerID_; 178 145 179 std::string hudtemplate_; 146 180 OverlayGroup* hud_; 181 147 182 Camera* camera_; 148 bool bDestroyWhenPlayerLeft_; 149 183 bool bMouseLook_; 184 float mouseLookSpeed_; 185 Ogre::SceneNode* cameraPositionRootNode_; 150 186 std::list<CameraPosition*> cameraPositions_; 151 187 std::string cameraPositionTemplate_; 188 189 const GametypeInfo* gtinfo_; 190 unsigned int gtinfoID_; 152 191 }; 153 192 } -
code/branches/presentation/src/orxonox/objects/worldentities/ExplosionChunk.cc
r2480 r2485 30 30 #include "ExplosionChunk.h" 31 31 32 #include <OgreParticleSystem.h> 33 32 34 #include "core/Core.h" 33 35 #include "core/CoreIncludes.h" … … 54 56 { 55 57 this->fire_ = new ParticleInterface(this->getScene()->getSceneManager(), "Orxonox/fire4", this->LOD_); 56 this-> fire_->addToSceneNode(this->getNode());58 this->attachOgreObject(this->fire_->getParticleSystem()); 57 59 this->smoke_ = new ParticleInterface(this->getScene()->getSceneManager(), "Orxonox/smoke7", this->LOD_); 58 this-> smoke_->addToSceneNode(this->getNode());60 this->attachOgreObject(this->smoke_->getParticleSystem()); 59 61 } 60 62 catch (...) … … 83 85 { 84 86 if (this->fire_) 87 { 88 this->detachOgreObject(this->fire_->getParticleSystem()); 85 89 delete this->fire_; 90 } 86 91 if (this->smoke_) 92 { 93 this->detachOgreObject(this->smoke_->getParticleSystem()); 87 94 delete this->smoke_; 95 } 88 96 } 89 97 } … … 91 99 void ExplosionChunk::registerVariables() 92 100 { 93 REGISTERDATA(this->LOD_, direction::toclient, new NetworkCallback<ExplosionChunk>(this, &ExplosionChunk::LODchanged));94 REGISTERDATA(this->bStop_, direction::toclient, new NetworkCallback<ExplosionChunk>(this, &ExplosionChunk::checkStop));101 registerVariable((int&)(this->LOD_), variableDirection::toclient, new NetworkCallback<ExplosionChunk>(this, &ExplosionChunk::LODchanged)); 102 registerVariable(this->bStop_, variableDirection::toclient, new NetworkCallback<ExplosionChunk>(this, &ExplosionChunk::checkStop)); 95 103 } 96 104 -
code/branches/presentation/src/orxonox/objects/worldentities/FadingBillboard.cc
r2480 r2485 66 66 void FadingBillboard::registerVariables() 67 67 { 68 REGISTERDATA(this->turnontime_, direction::toclient);69 REGISTERDATA(this->turnofftime_, direction::toclient);68 registerVariable(this->turnontime_, variableDirection::toclient); 69 registerVariable(this->turnofftime_, variableDirection::toclient); 70 70 } 71 71 -
code/branches/presentation/src/orxonox/objects/worldentities/Light.cc
r2459 r2485 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 … … 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->attachOgreObject(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 registerVariable((int &)this->type_, variableDirection::toclient, new NetworkCallback<Light>(this, &Light::changedType)); 82 registerVariable(this->light_->getDiffuseColour(), variableDirection::toclient); 83 registerVariable(this->light_->getSpecularColour(), variableDirection::toclient); 84 registerVariable(this->light_->getDirection(), variableDirection::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/branches/presentation/src/orxonox/objects/worldentities/Light.h
r2459 r2485 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/branches/presentation/src/orxonox/objects/worldentities/MobileEntity.cc
- Property svn:mergeinfo changed
/code/trunk/src/orxonox/objects/worldentities/MobileEntity.cc (added) merged: 2-2170
- Property svn:mergeinfo changed
-
code/branches/presentation/src/orxonox/objects/worldentities/MobileEntity.h
- Property svn:mergeinfo changed
/code/trunk/src/orxonox/objects/worldentities/MobileEntity.h (added) merged: 2-2170
- Property svn:mergeinfo changed
-
code/branches/presentation/src/orxonox/objects/worldentities/Model.cc
r2468 r2485 42 42 { 43 43 RegisterObject(Model); 44 45 this->bCastShadows_ = true; 44 46 45 47 this->registerVariables(); -
code/branches/presentation/src/orxonox/objects/worldentities/MovableEntity.cc
r2470 r2485 35 35 #include "core/Executor.h" 36 36 #include "core/Core.h" 37 #include "tools/Timer.h"38 37 39 38 namespace orxonox … … 81 80 void MovableEntity::clientConnected(unsigned int clientID) 82 81 { 83 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))); 84 83 } 85 84 -
code/branches/presentation/src/orxonox/objects/worldentities/MovableEntity.h
r2459 r2485 35 35 #include "MobileEntity.h" 36 36 #include "network/ClientConnectionListener.h" 37 #include "tools/Timer.h" 37 38 38 39 namespace orxonox … … 72 73 Vector3 overwrite_position_; 73 74 Quaternion overwrite_orientation_; 75 76 Timer<MovableEntity> resynchronizeTimer_; 74 77 Timer<MovableEntity>* continuousResynchroTimer_; 75 78 }; -
code/branches/presentation/src/orxonox/objects/worldentities/ParticleEmitter.cc
r2468 r2485 52 52 53 53 if (Core::showsGraphics() && (!this->getScene() || !this->getScene()->getSceneManager())) 54 ThrowException(AbortLoading, "Can't create Camera, no scene or no scene manager given.");54 ThrowException(AbortLoading, "Can't create ParticleEmitter, no scene or no scene manager given."); 55 55 56 56 this->particles_ = 0; … … 109 109 { 110 110 this->particles_ = new ParticleInterface(this->getScene()->getSceneManager(), this->source_, this->LOD_); 111 this->attachOgreObject( particles_->getParticleSystem());111 this->attachOgreObject(this->particles_->getParticleSystem()); 112 112 this->particles_->setVisible(this->isVisible()); 113 113 this->particles_->setEnabled(this->isActive()); -
code/branches/presentation/src/orxonox/objects/worldentities/ParticleSpawner.cc
- Property svn:mergeinfo changed
/code/trunk/src/orxonox/objects/worldentities/ParticleSpawner.cc merged: 2-1912
- Property svn:mergeinfo changed
-
code/branches/presentation/src/orxonox/objects/worldentities/ParticleSpawner.h
- Property svn:mergeinfo changed
/code/trunk/src/orxonox/objects/worldentities/ParticleSpawner.h merged: 2-1912
- Property svn:mergeinfo changed
-
code/branches/presentation/src/orxonox/objects/worldentities/WorldEntity.cc
r2481 r2485 95 95 { 96 96 this->node_->detachAllObjects(); 97 98 for (std::set<WorldEntity*>::const_iterator it = this->children_.begin(); it != this->children_.end(); ) 99 delete (*(it++)); 100 101 if (this->parent_) 102 this->detachFromParent(); 103 104 this->node_->removeAllChildren(); 105 97 106 if (this->getScene()->getSceneManager()) 98 107 this->getScene()->getSceneManager()->destroySceneNode(this->node_->getName()); … … 140 149 void WorldEntity::registerVariables() 141 150 { 151 registerVariable(this->mainStateName_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedMainState)); 152 142 153 registerVariable(this->bActive_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedActivity)); 143 154 registerVariable(this->bVisible_, variableDirection::toclient, new NetworkCallback<WorldEntity>(this, &WorldEntity::changedVisibility)); … … 212 223 } 213 224 225 void WorldEntity::attachNode(Ogre::SceneNode* node) 226 { 227 Ogre::Node* parent = node->getParent(); 228 if (parent) 229 parent->removeChild(node); 230 this->node_->addChild(node); 231 } 232 233 void WorldEntity::detachNode(Ogre::SceneNode* node) 234 { 235 this->node_->removeChild(node); 236 // this->getScene()->getRootSceneNode()->addChild(node); 237 } 238 239 void WorldEntity::attachToNode(Ogre::SceneNode* node) 240 { 241 Ogre::Node* parent = this->node_->getParent(); 242 if (parent) 243 parent->removeChild(this->node_); 244 node->addChild(this->node_); 245 } 246 247 void WorldEntity::detachFromNode(Ogre::SceneNode* node) 248 { 249 node->removeChild(this->node_); 250 // this->getScene()->getRootSceneNode()->addChild(this->node_); 251 } 252 214 253 void WorldEntity::attach(WorldEntity* object) 215 254 { … … 243 282 } 244 283 284 if (object == this) 285 { 286 COUT(2) << "Warning: Can't attach a WorldEntity to itself." << std::endl; 287 return; 288 } 289 245 290 if (object->getParent()) 246 291 object->detachFromParent(); 247 else 248 { 249 Ogre::Node* parent = object->node_->getParent(); 250 if (parent) 251 parent->removeChild(object->node_); 252 } 253 254 this->node_->addChild(object->node_); 292 293 this->attachNode(object->node_); 294 255 295 this->children_.insert(object); 256 296 object->parent_ = this; … … 275 315 } 276 316 277 this-> node_->removeChild(object->node_);317 this->detachNode(object->node_); 278 318 this->children_.erase(object); 279 319 object->parent_ = 0; 280 320 object->parentID_ = OBJECTID_UNKNOWN; 281 // this->getScene()->getRootSceneNode()->addChild(object->node_);282 321 283 322 // Note: It is possible that the object has physics but was disabled when attaching … … 466 505 467 506 this->node_->setScale(scale); 507 508 this->changedScale(); 509 } 510 511 const Vector3& WorldEntity::getWorldScale3D() const 512 { 513 return this->node_->_getDerivedScale(); 514 } 515 516 float WorldEntity::getWorldScale() const 517 { 518 Vector3 scale = this->getWorldScale3D(); 519 return (scale.x == scale.y && scale.x == scale.z) ? scale.x : 1; 468 520 } 469 521 -
code/branches/presentation/src/orxonox/objects/worldentities/WorldEntity.h
r2466 r2485 74 74 inline void translate(float x, float y, float z, TransformSpace::Space relativeTo = TransformSpace::Parent) 75 75 { this->translate(Vector3(x, y, z), relativeTo); } 76 77 virtual inline const Vector3& getVelocity() const 78 { return Vector3::ZERO; } 76 79 77 80 virtual void setOrientation(const Quaternion& orientation) = 0; … … 105 108 { this->setScale3D(Vector3(x, y, z)); } 106 109 const Vector3& getScale3D(void) const; 107 108 void setScale(float scale) 110 const Vector3& getWorldScale3D() const; 111 112 inline void setScale(float scale) 109 113 { this->setScale3D(scale, scale, scale); } 110 114 inline float getScale() const 111 115 { Vector3 scale = this->getScale3D(); return (scale.x == scale.y && scale.x == scale.z) ? scale.x : 1; } 116 float getWorldScale() const; 112 117 113 118 inline void scale3D(const Vector3& scale) … … 118 123 { this->scale3D(scale, scale, scale); } 119 124 125 virtual void changedScale() {} 126 120 127 void attach(WorldEntity* object); 121 128 void detach(WorldEntity* object); … … 134 141 inline WorldEntity* getParent() const 135 142 { return this->parent_; } 143 144 void attachNode(Ogre::SceneNode* node); 145 void detachNode(Ogre::SceneNode* node); 146 void attachToNode(Ogre::SceneNode* node); 147 void detachFromNode(Ogre::SceneNode* node); 136 148 137 149 void notifyChildPropsChanged(); … … 302 314 { return this->node_->getScale(); } 303 315 #endif 316 317 SUPER_FUNCTION(5, WorldEntity, changedScale, false); 304 318 } 305 319 -
code/branches/presentation/src/orxonox/objects/worldentities/pawns/Pawn.cc
r2371 r2485 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 39 #include "objects/weaponSystem/WeaponSystem.h" 40 #include "objects/worldentities/ParticleSpawner.h" 41 #include "objects/worldentities/ExplosionChunk.h" 38 42 39 43 namespace orxonox … … 45 49 RegisterObject(Pawn); 46 50 47 this->bAlive_ = false; 51 PawnManager::touch(); 52 53 this->bAlive_ = true; 48 54 49 55 this->health_ = 0; … … 53 59 this->lastHitOriginator_ = 0; 54 60 this->weaponSystem_ = 0; 61 62 this->spawnparticleduration_ = 3.0f; 55 63 56 64 /* … … 62 70 */ 63 71 72 this->setRadarObjectColour(ColourValue::Red); 73 this->setRadarObjectShape(RadarViewable::Dot); 74 64 75 this->registerVariables(); 65 76 } … … 67 78 Pawn::~Pawn() 68 79 { 80 if (this->isInitialized()) 81 { 82 for (ObjectList<PawnListener>::iterator it = ObjectList<PawnListener>::begin(); it != ObjectList<PawnListener>::end(); ++it) 83 it->destroyedPawn(this); 84 } 69 85 } 70 86 … … 73 89 SUPER(Pawn, XMLPort, xmlelement, mode); 74 90 75 XMLPortParam(Pawn, "health", setHealth, getHeal ht, xmlelement, mode).defaultValues(100);91 XMLPortParam(Pawn, "health", setHealth, getHealth, xmlelement, mode).defaultValues(100); 76 92 XMLPortParam(Pawn, "maxhealth", setMaxHealth, getMaxHealth, xmlelement, mode).defaultValues(200); 77 93 XMLPortParam(Pawn, "initialhealth", setInitialHealth, getInitialHealth, xmlelement, mode).defaultValues(100); 94 XMLPortParam(Pawn, "spawnparticlesource", setSpawnParticleSource, getSpawnParticleSource, xmlelement, mode); 95 XMLPortParam(Pawn, "spawnparticleduration", setSpawnParticleDuration, getSpawnParticleDuration, xmlelement, mode).defaultValues(3.0f); 96 XMLPortParam(Pawn, "explosionchunks", setExplosionChunks, getExplosionChunks, xmlelement, mode).defaultValues(7); 78 97 } 79 98 80 99 void Pawn::registerVariables() 81 100 { 82 registerVariable(this->bAlive_, variableDirection::toclient); 83 registerVariable(this->health_, variableDirection::toclient); 101 registerVariable(this->bAlive_, variableDirection::toclient); 102 registerVariable(this->health_, variableDirection::toclient); 103 registerVariable(this->initialHealth_, variableDirection::toclient); 84 104 } 85 105 … … 119 139 } 120 140 121 void Pawn::spawn ()141 void Pawn::spawneffect() 122 142 { 123 143 // play spawn effect 144 if (this->spawnparticlesource_ != "") 145 { 146 ParticleSpawner* effect = new ParticleSpawner(this->getCreator()); 147 effect->setPosition(this->getPosition()); 148 effect->setOrientation(this->getOrientation()); 149 effect->setDestroyAfterLife(true); 150 effect->setSource(this->spawnparticlesource_); 151 effect->setLifetime(this->spawnparticleduration_); 152 } 124 153 } 125 154 126 155 void Pawn::death() 127 156 { 157 // Set bAlive_ to false and wait for PawnManager to do the destruction 128 158 this->bAlive_ = false; 159 160 this->setDestroyWhenPlayerLeft(false); 161 129 162 if (this->getGametype()) 130 163 this->getGametype()->pawnKilled(this, this->lastHitOriginator_); 164 131 165 if (this->getPlayer()) 132 166 this->getPlayer()->stopControl(this); 133 167 134 delete this; 135 168 if (Core::isMaster()) 169 this->deatheffect(); 170 } 171 172 void Pawn::deatheffect() 173 { 136 174 // play death effect 175 { 176 ParticleSpawner* effect = new ParticleSpawner(this->getCreator()); 177 effect->setPosition(this->getPosition()); 178 effect->setOrientation(this->getOrientation()); 179 effect->setDestroyAfterLife(true); 180 effect->setSource("Orxonox/explosion2b"); 181 effect->setLifetime(4.0f); 182 } 183 { 184 ParticleSpawner* effect = new ParticleSpawner(this->getCreator()); 185 effect->setPosition(this->getPosition()); 186 effect->setOrientation(this->getOrientation()); 187 effect->setDestroyAfterLife(true); 188 effect->setSource("Orxonox/smoke6"); 189 effect->setLifetime(4.0f); 190 } 191 { 192 ParticleSpawner* effect = new ParticleSpawner(this->getCreator()); 193 effect->setPosition(this->getPosition()); 194 effect->setOrientation(this->getOrientation()); 195 effect->setDestroyAfterLife(true); 196 effect->setSource("Orxonox/sparks"); 197 effect->setLifetime(4.0f); 198 } 199 for (unsigned int i = 0; i < this->numexplosionchunks_; ++i) 200 { 201 ExplosionChunk* chunk = new ExplosionChunk(this->getCreator()); 202 chunk->setPosition(this->getPosition()); 203 204 } 137 205 } 138 206 … … 146 214 { 147 215 this->setHealth(this->initialHealth_); 148 this->spawn(); 216 if (Core::isMaster()) 217 this->spawneffect(); 218 } 219 220 /////////////////// 221 // Pawn Listener // 222 /////////////////// 223 PawnListener::PawnListener() 224 { 225 RegisterRootObject(PawnListener); 149 226 } 150 227 } -
code/branches/presentation/src/orxonox/objects/worldentities/pawns/Pawn.h
r2098 r2485 33 33 34 34 #include "objects/worldentities/ControllableEntity.h" 35 #include "objects/RadarViewable.h" 35 36 36 37 namespace orxonox 37 38 { 38 class _OrxonoxExport Pawn : public ControllableEntity 39 class _OrxonoxExport Pawn : public ControllableEntity, public RadarViewable 39 40 { 40 41 public: … … 54 55 inline void removeHealth(float health) 55 56 { this->setHealth(this->health_ - health); } 56 inline float getHeal ht() const57 inline float getHealth() const 57 58 { return this->health_; } 58 59 … … 78 79 virtual void postSpawn(); 79 80 81 inline const WorldEntity* getWorldEntity() const 82 { return (WorldEntity*)this; } 83 84 inline void setSpawnParticleSource(const std::string& source) 85 { this->spawnparticlesource_ = source; } 86 inline const std::string& getSpawnParticleSource() const 87 { return this->spawnparticlesource_; } 88 89 inline void setSpawnParticleDuration(float duration) 90 { this->spawnparticleduration_ = duration; } 91 inline float getSpawnParticleDuration() const 92 { return this->spawnparticleduration_; } 93 94 inline void setExplosionChunks(unsigned int chunks) 95 { this->numexplosionchunks_ = chunks; } 96 inline unsigned int getExplosionChunks() const 97 { return this->numexplosionchunks_; } 98 80 99 protected: 81 virtual void spawn();82 100 virtual void death(); 101 virtual void deatheffect(); 102 virtual void spawneffect(); 83 103 84 104 bool bAlive_; … … 91 111 92 112 WeaponSystem* weaponSystem_; 113 114 std::string spawnparticlesource_; 115 float spawnparticleduration_; 116 unsigned int numexplosionchunks_; 117 }; 118 119 class _OrxonoxExport PawnListener : public OrxonoxClass 120 { 121 friend class Pawn; 122 123 public: 124 PawnListener(); 125 virtual ~PawnListener() {} 126 127 protected: 128 virtual void destroyedPawn(Pawn* pawn) = 0; 93 129 }; 94 130 } -
code/branches/presentation/src/orxonox/objects/worldentities/pawns/SpaceShip.cc
r2475 r2485 36 36 #include "core/CoreIncludes.h" 37 37 #include "core/ConfigValueIncludes.h" 38 #include "core/Template.h" 38 39 #include "core/XMLPort.h" 40 #include "objects/items/Engine.h" 39 41 40 42 namespace orxonox … … 53 55 this->localLinearAcceleration_.setValue(0, 0, 0); 54 56 this->localAngularAcceleration_.setValue(0, 0, 0); 57 this->bBoost_ = false; 58 this->steering_ = Vector3::ZERO; 59 this->engine_ = 0; 60 55 61 56 62 this->bInvertYAxis_ = false; … … 70 76 SpaceShip::~SpaceShip() 71 77 { 78 if (this->isInitialized() && this->engine_) 79 delete this->engine_; 72 80 } 73 81 … … 76 84 SUPER(SpaceShip, XMLPort, xmlelement, mode); 77 85 86 XMLPortParam(SpaceShip, "engine", setEngineTemplate, getEngineTemplate, xmlelement, mode); 78 87 XMLPortParamVariable(SpaceShip, "primaryThrust", primaryThrust_, xmlelement, mode); 79 88 XMLPortParamVariable(SpaceShip, "auxilaryThrust", auxilaryThrust_, xmlelement, mode); … … 109 118 SUPER(SpaceShip, tick, dt); 110 119 111 if (this-> isLocallyControlled())120 if (this->hasLocalController()) 112 121 { 113 this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() * getMass() * this->auxilaryThrust_); 114 this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() * getMass() * this->auxilaryThrust_); 115 if (this->localLinearAcceleration_.z() > 0) 116 this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->auxilaryThrust_); 117 else 118 this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() * getMass() * this->primaryThrust_); 119 this->physicalBody_->applyCentralForce(physicalBody_->getWorldTransform().getBasis() * this->localLinearAcceleration_); 120 this->localLinearAcceleration_.setValue(0, 0, 0); 122 if (!this->isInMouseLook()) 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 } 121 133 122 134 this->localAngularAcceleration_ *= this->getLocalInertia() * this->rotationThrust_; … … 129 141 { 130 142 this->localLinearAcceleration_.setZ(this->localLinearAcceleration_.z() - value.x); 143 this->steering_.z = -value.x; 131 144 } 132 145 … … 134 147 { 135 148 this->localLinearAcceleration_.setX(this->localLinearAcceleration_.x() + value.x); 149 this->steering_.x = value.x; 136 150 } 137 151 … … 139 153 { 140 154 this->localLinearAcceleration_.setY(this->localLinearAcceleration_.y() + value.x); 155 this->steering_.y = value.x; 141 156 } 142 157 … … 144 159 { 145 160 this->localAngularAcceleration_.setY(this->localAngularAcceleration_.y() + value.x); 161 162 Pawn::rotateYaw(value); 146 163 } 147 164 … … 149 166 { 150 167 this->localAngularAcceleration_.setX(this->localAngularAcceleration_.x() + value.x); 168 169 Pawn::rotatePitch(value); 151 170 } 152 171 … … 154 173 { 155 174 this->localAngularAcceleration_.setZ(this->localAngularAcceleration_.z() + value.x); 175 176 Pawn::rotateRoll(value); 156 177 } 157 178 … … 159 180 { 160 181 } 182 183 void SpaceShip::boost() 184 { 185 this->bBoost_ = true; 186 } 187 188 void SpaceShip::loadEngineTemplate() 189 { 190 if (this->enginetemplate_ != "") 191 { 192 Template* temp = Template::getTemplate(this->enginetemplate_); 193 194 if (temp) 195 { 196 Identifier* identifier = temp->getBaseclassIdentifier(); 197 198 if (identifier) 199 { 200 BaseObject* object = identifier->fabricate(this); 201 this->engine_ = dynamic_cast<Engine*>(object); 202 203 if (this->engine_) 204 { 205 this->engine_->addTemplate(temp); 206 this->engine_->addToSpaceShip(this); 207 } 208 else 209 { 210 delete object; 211 } 212 } 213 } 214 } 215 } 216 217 void SpaceShip::setEngine(Engine* engine) 218 { 219 this->engine_ = engine; 220 if (engine && engine->getShip() != this) 221 engine->addToSpaceShip(this); 222 } 161 223 } -
code/branches/presentation/src/orxonox/objects/worldentities/pawns/SpaceShip.h
r2459 r2485 58 58 59 59 virtual void fire(); 60 virtual void boost(); 61 62 void setEngine(Engine* engine); 63 inline Engine* getEngine() const 64 { return this->engine_; } 65 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_; } 60 80 61 81 protected: 62 82 bool bInvertYAxis_; 63 83 84 bool bBoost_; 85 Vector3 steering_; 64 86 float primaryThrust_; 65 87 float auxilaryThrust_; … … 71 93 private: 72 94 virtual bool isCollisionTypeLegal(WorldEntity::CollisionType type) const; 95 96 private: 97 void loadEngineTemplate(); 98 99 std::string enginetemplate_; 100 Engine* engine_; 73 101 }; 74 102 } -
code/branches/presentation/src/orxonox/objects/worldentities/pawns/Spectator.cc
r2480 r2485 33 33 34 34 #include "core/CoreIncludes.h" 35 #include "core/ConfigValueIncludes.h" 35 36 #include "core/Core.h" 36 37 #include "objects/worldentities/Model.h" … … 51 52 RegisterObject(Spectator); 52 53 53 this->speed_ = 100; 54 this->rotationGain_ = 3; 54 this->speed_ = 200; 55 55 56 56 this->yaw_ = 0; … … 59 59 this->localVelocity_ = Vector3::ZERO; 60 60 this->setHudTemplate("spectatorhud"); 61 this-> hudmode_ = 0;61 this->greetingFlare_ = 0; 62 62 63 63 this->setDestroyWhenPlayerLeft(true); 64 64 65 if ( Core::showsGraphics())66 65 if (Core::showsGraphics()) 66 { 67 67 this->greetingFlare_ = new BillboardSet(); 68 68 this->greetingFlare_->setBillboardSet(this->getScene()->getSceneManager(), "Examples/Flare", ColourValue(1.0, 1.0, 0.8), Vector3(0, 20, 0), 1); … … 71 71 this->greetingFlare_->setVisible(false); 72 72 } 73 else 74 this->greetingFlare_ = 0; 73 75 74 this->bGreetingFlareVisible_ = false; 76 75 this->bGreeting_ = false; 77 76 77 this->setConfigValues(); 78 78 this->registerVariables(); 79 79 } … … 87 87 if (this->greetingFlare_->getBillboardSet()) 88 88 this->detachOgreObject(this->greetingFlare_->getBillboardSet()); 89 89 90 delete this->greetingFlare_; 90 91 } … … 92 93 } 93 94 95 void Spectator::setConfigValues() 96 { 97 SetConfigValue(speed_, 200.0f); 98 } 99 94 100 void Spectator::registerVariables() 95 101 { 96 102 registerVariable(this->bGreetingFlareVisible_, variableDirection::toclient, new NetworkCallback<Spectator>(this, &Spectator::changedFlareVisibility)); 97 103 registerVariable(this->bGreeting_, variableDirection::toserver, new NetworkCallback<Spectator>(this, &Spectator::changedGreeting)); 98 registerVariable(this->hudmode_, variableDirection::toclient);99 104 } 100 105 … … 107 112 void Spectator::changedFlareVisibility() 108 113 { 109 if ( this->greetingFlare_ ) 114 if ( this->greetingFlare_ ) 110 115 this->greetingFlare_->setVisible(this->bGreetingFlareVisible_); 111 116 } … … 113 118 void Spectator::tick(float dt) 114 119 { 115 this->updateHUD(); 116 117 if (this->isLocallyControlled()) 120 if (this->hasLocalController()) 118 121 { 119 122 float localSpeedSquared = this->localVelocity_.squaredLength(); … … 132 135 this->localVelocity_.z = 0; 133 136 134 this->yaw (Radian(this->yaw_ * this->rotationGain_)); 135 this->pitch(Radian(this->pitch_ * this->rotationGain_)); 136 this->roll (Radian(this->roll_ * this->rotationGain_)); 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 } 137 143 138 144 this->yaw_ = this->pitch_ = this->roll_ = 0; … … 146 152 ControllableEntity::setPlayer(player); 147 153 148 // this->setObjectMode(direction::toclient); 149 } 150 151 void Spectator::startLocalControl() 152 { 153 ControllableEntity::startLocalControl(); 154 // if (this->isLocallyControlled()) 155 // this->testmesh_->setVisible(false); 154 // this->setObjectMode(objectDirection::toclient); 155 } 156 157 void Spectator::startLocalHumanControl() 158 { 159 ControllableEntity::startLocalHumanControl(); 156 160 } 157 161 … … 174 178 { 175 179 this->yaw_ += value.y; 180 181 ControllableEntity::rotateYaw(value); 176 182 } 177 183 … … 179 185 { 180 186 this->pitch_ += value.y; 187 188 ControllableEntity::rotatePitch(value); 181 189 } 182 190 … … 184 192 { 185 193 this->roll_ += value.y; 194 195 ControllableEntity::rotateRoll(value); 186 196 } 187 197 … … 202 212 } 203 213 } 204 205 void Spectator::updateHUD()206 {207 // <hack>208 if (Core::isMaster())209 {210 if (this->getPlayer() && this->getGametype())211 {212 if (!this->getGametype()->hasStarted() && !this->getGametype()->isStartCountdownRunning())213 {214 if (!this->getPlayer()->isReadyToSpawn())215 this->hudmode_ = 0;216 else217 this->hudmode_ = 1;218 }219 else if (!this->getGametype()->hasEnded())220 {221 if (this->getGametype()->isStartCountdownRunning())222 this->hudmode_ = 2 + 10*(int)ceil(this->getGametype()->getStartCountdown());223 else224 this->hudmode_ = 3;225 }226 else227 this->hudmode_ = 4;228 }229 else230 return;231 }232 233 if (this->getHUD())234 {235 std::string text;236 int hudmode = this->hudmode_ % 10;237 238 switch (hudmode)239 {240 case 0:241 text = "Press [Fire] to start the match";242 break;243 case 1:244 text = "Waiting for other players";245 break;246 case 2:247 text = convertToString((this->hudmode_ - 2) / 10);248 break;249 case 3:250 text = "Press [Fire] to respawn";251 break;252 case 4:253 text = "Game has ended";254 break;255 default:;256 }257 258 std::map<std::string, OrxonoxOverlay*>::const_iterator it = this->getHUD()->getOverlays().begin();259 for (; it != this->getHUD()->getOverlays().end(); ++it)260 {261 if (it->second->isA(Class(OverlayText)) && it->second->getName() == "state")262 {263 OverlayText* overlay = dynamic_cast<OverlayText*>(it->second);264 if (overlay)265 overlay->setCaption(text);266 break;267 }268 }269 }270 // </hack>271 }272 214 } -
code/branches/presentation/src/orxonox/objects/worldentities/pawns/Spectator.h
r2459 r2485 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); … … 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 rotationGain_;72 71 73 72 float yaw_; … … 76 75 77 76 Vector3 localVelocity_; 78 79 int hudmode_;80 77 }; 81 78 } -
code/branches/presentation/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc
- Property svn:mergeinfo changed
/code/trunk/src/orxonox/objects/worldentities/triggers/DistanceTrigger.cc merged: 2-1912
- Property svn:mergeinfo changed
-
code/branches/presentation/src/orxonox/objects/worldentities/triggers/DistanceTrigger.h
- Property svn:mergeinfo changed
/code/trunk/src/orxonox/objects/worldentities/triggers/DistanceTrigger.h merged: 2-1912
- Property svn:mergeinfo changed
-
code/branches/presentation/src/orxonox/objects/worldentities/triggers/Trigger.cc
- Property svn:mergeinfo changed
/code/branches/objecthierarchy2/src/orxonox/objects/worldentities/triggers/Trigger.cc (added) merged: 2361 /code/trunk/src/orxonox/objects/worldentities/triggers/Trigger.cc merged: 2-1912
r2459 r2485 107 107 if (!this->BaseObject::isActive()) 108 108 return; 109 110 SUPER(Trigger, tick, dt); 109 111 110 112 bool newTriggered = this->isTriggered() ^ this->bInvertMode_; - Property svn:mergeinfo changed
-
code/branches/presentation/src/orxonox/objects/worldentities/triggers/Trigger.h
- Property svn:mergeinfo changed
/code/trunk/src/orxonox/objects/worldentities/triggers/Trigger.h merged: 2-1912
- Property svn:mergeinfo changed
-
code/branches/presentation/src/orxonox/overlays/OrxonoxOverlay.cc
r2171 r2485 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 … … 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/branches/presentation/src/orxonox/overlays/OrxonoxOverlay.h
r2087 r2485 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/branches/presentation/src/orxonox/overlays/OverlayGroup.cc
r2087 r2485 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/branches/presentation/src/orxonox/overlays/OverlayGroup.h
r2087 r2485 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 92 Vector2 scale_; //!< Current scale (independant of the elements). 89 93 Vector2 scroll_; //!< Current scrolling offset. 94 ControllableEntity* owner_; //!< The owner of this OverlayGroup 90 95 }; 91 96 } -
code/branches/presentation/src/orxonox/overlays/OverlayText.cc
r2087 r2485 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/branches/presentation/src/orxonox/overlays/OverlayText.h
r2087 r2485 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/branches/presentation/src/orxonox/overlays/debug/DebugFPSText.cc
r2087 r2485 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/branches/presentation/src/orxonox/overlays/debug/DebugRTRText.cc
r2087 r2485 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/branches/presentation/src/orxonox/overlays/hud/CMakeLists.txt
r2131 r2485 4 4 HUDRadar.cc 5 5 HUDSpeedBar.cc 6 HUDHealthBar.cc 6 7 ChatOverlay.cc 8 GametypeStatus.cc 7 9 ) 8 10 -
code/branches/presentation/src/orxonox/overlays/hud/HUDBar.cc
r2087 r2485 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/branches/presentation/src/orxonox/overlays/hud/HUDBar.h
r2087 r2485 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/branches/presentation/src/orxonox/overlays/hud/HUDNavigation.cc
r2087 r2485 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/branches/presentation/src/orxonox/overlays/hud/HUDRadar.cc
r2087 r2485 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/branches/presentation/src/orxonox/overlays/hud/HUDRadar.h
r2087 r2485 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/branches/presentation/src/orxonox/overlays/hud/HUDSpeedBar.cc
r2087 r2485 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/branches/presentation/src/orxonox/overlays/hud/HUDSpeedBar.h
r2087 r2485 45 45 46 46 virtual void tick(float dt); 47 virtual void changedOwner(); 48 49 private: 50 SpaceShip* owner_; 47 51 }; 48 52 } -
code/branches/presentation/src/orxonox/tools/CMakeLists.txt
r2131 r2485 3 3 Mesh.cc 4 4 ParticleInterface.cc 5 Shader.cc 5 6 TextureGenerator.cc 6 7 Timer.cc -
code/branches/presentation/src/orxonox/tools/ParticleInterface.cc
r2459 r2485 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); … … 62 62 this->bVisible_ = true; 63 63 this->bAllowedByLOD_ = true; 64 this->speedFactor_ = 1.0f; 64 65 65 66 if (Core::showsGraphics()) … … 68 69 { 69 70 this->particleSystem_ = this->scenemanager_->createParticleSystem("particles" + getConvertedValue<unsigned int, std::string>(ParticleInterface::counter_s++), templateName); 70 this->particleSystem_->setSpeedFactor(1.0f); 71 // this->particleSystem_->setSpeedFactor(Orxonox::getInstance().getTimeFactor()); 71 this->setSpeedFactor(1.0f); 72 72 } 73 73 catch (...) … … 200 200 void ParticleInterface::setSpeedFactor(float factor) 201 201 { 202 if (this->particleSystem_) 203 { 204 // this->particleSystem_->setSpeedFactor(Orxonox::getInstance().getTimeFactor() * factor); 205 this->particleSystem_->setSpeedFactor(1.0f * factor); 206 } 207 } 208 float ParticleInterface::getSpeedFactor() const 209 { 210 if (this->particleSystem_) 211 { 212 // return (this->particleSystem_->getSpeedFactor() / Orxonox::getInstance().getTimeFactor()); 213 return (this->particleSystem_->getSpeedFactor() / 1.0f); 214 } 215 else 216 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_); 217 210 } 218 211 -
code/branches/presentation/src/orxonox/tools/ParticleInterface.h
r2459 r2485 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: … … 66 67 unsigned int getNumAffectors() const; 67 68 68 float getSpeedFactor() const; 69 inline float getSpeedFactor() const 70 { return this->speedFactor_; } 69 71 void setSpeedFactor(float factor); 70 72 bool getKeepParticlesInLocalSpace() const; … … 87 89 { return ParticleInterface::currentParticleInterface_s; } 88 90 91 protected: 92 virtual void changedTimeFactor(float factor_new, float factor_old); 93 89 94 private: 90 95 void updateVisibility(); … … 98 103 bool bAllowedByLOD_; 99 104 unsigned int detaillevel_; //!< Detail level of this particle effect (0: off, 1: low, 2: normal, 3: high) 105 float speedFactor_; 100 106 Ogre::SceneManager* scenemanager_; 101 107 }; -
code/branches/presentation/src/orxonox/tools/Timer.cc
r2087 r2485 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/branches/presentation/src/orxonox/tools/Timer.h
r2171 r2485 63 63 #include "OrxonoxPrereqs.h" 64 64 #include "core/OrxonoxClass.h" 65 #include "gamestates/GSRoot.h" 65 66 66 67 namespace orxonox … … 72 73 73 74 //! TimerBase is the parent of the Timer class. 74 class _OrxonoxExport TimerBase : public OrxonoxClass75 class _OrxonoxExport TimerBase : public TimeFactorListener 75 76 { 76 77 public: -
code/branches/presentation/src/tolua/tolua-5.1.pkg
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/util
- Property svn:mergeinfo changed
/code/branches/objecthierarchy2/src/util (added) merged: 2257,2259,2343-2345,2361
- Property svn:mergeinfo changed
-
code/branches/presentation/src/util/Convert.h
r2171 r2485 460 460 else 461 461 *output = "false"; 462 return false;462 return true; 463 463 } 464 464 }; -
code/branches/presentation/src/util/Exception.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/src/util/Exception.h
- Property svn:mergeinfo changed
/code/branches/objecthierarchy2/src/util/Exception.h (added) merged: 2257,2259
- Property svn:mergeinfo changed
-
code/branches/presentation/src/util/OutputHandler.cc
r2171 r2485 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/branches/presentation/src/util/OutputHandler.h
r2171 r2485 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/branches/presentation/src/util/SignalHandler.cc
- Property svn:mergeinfo changed
/code/branches/objecthierarchy2/src/util/SignalHandler.cc (added) merged: 2344-2345 /code/trunk/src/util/SignalHandler.cc merged: 2-1912
r2459 r2485 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/branches/presentation/src/util/SignalHandler.h
- Property svn:mergeinfo changed
/code/branches/objecthierarchy2/src/util/SignalHandler.h (added) merged: 2344 /code/trunk/src/util/SignalHandler.h merged: 2-1912
r2459 r2485 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/branches/presentation/visual_studio/vc8/audio.vsprops
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/visual_studio/vc8/base.vsprops
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/visual_studio/vc8/ceguilua.vsprops
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/visual_studio/vc8/core.vsprops
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/visual_studio/vc8/cpptcl.vsprops
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/visual_studio/vc8/debug.vsprops
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/visual_studio/vc8/directories.vsprops
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/visual_studio/vc8/lua.vsprops
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/visual_studio/vc8/network.vsprops
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/visual_studio/vc8/orxonox.vcproj
r2459 r2485 167 167 </File> 168 168 <File 169 RelativePath="..\..\src\orxonox\PawnManager.cc" 170 > 171 </File> 172 <File 169 173 RelativePath="..\..\src\orxonox\PlayerManager.cc" 170 174 > … … 210 214 </File> 211 215 <File 216 RelativePath="..\..\src\orxonox\objects\GlobalShader.cc" 217 > 218 </File> 219 <File 212 220 RelativePath="..\..\src\orxonox\objects\Level.cc" 213 221 > … … 247 255 RelativePath="..\..\src\orxonox\objects\worldentities\Backlight.cc" 248 256 > 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 257 </File> 266 258 <File … … 282 274 <File 283 275 RelativePath="..\..\src\orxonox\objects\worldentities\ControllableEntity.cc" 276 > 277 </File> 278 <File 279 RelativePath="..\..\src\orxonox\objects\worldentities\ExplosionChunk.cc" 280 > 281 </File> 282 <File 283 RelativePath="..\..\src\orxonox\objects\worldentities\FadingBillboard.cc" 284 284 > 285 285 </File> … … 373 373 > 374 374 <File 375 RelativePath="..\..\src\orxonox\objects\infos\Bot.cc" 376 > 377 </File> 378 <File 379 RelativePath="..\..\src\orxonox\objects\infos\GametypeInfo.cc" 380 > 381 </File> 382 <File 375 383 RelativePath="..\..\src\orxonox\objects\infos\HumanPlayer.cc" 376 384 > … … 389 397 > 390 398 <File 399 RelativePath="..\..\src\orxonox\objects\controllers\AIController.cc" 400 > 401 </File> 402 <File 403 RelativePath="..\..\src\orxonox\objects\controllers\ArtificialController.cc" 404 > 405 </File> 406 <File 391 407 RelativePath="..\..\src\orxonox\objects\controllers\Controller.cc" 392 408 > … … 394 410 <File 395 411 RelativePath="..\..\src\orxonox\objects\controllers\HumanController.cc" 412 > 413 </File> 414 <File 415 RelativePath="..\..\src\orxonox\objects\controllers\ScriptController.cc" 396 416 > 397 417 </File> … … 645 665 </File> 646 666 </Filter> 667 <Filter 668 Name="items" 669 > 670 <File 671 RelativePath="..\..\src\orxonox\objects\items\Engine.cc" 672 > 673 </File> 674 <File 675 RelativePath="..\..\src\orxonox\objects\items\Item.cc" 676 > 677 </File> 678 <File 679 RelativePath="..\..\src\orxonox\objects\items\MultiStateEngine.cc" 680 > 681 </File> 682 </Filter> 647 683 </Filter> 648 684 <Filter … … 659 695 <File 660 696 RelativePath="..\..\src\orxonox\tools\ParticleInterface.cc" 697 > 698 </File> 699 <File 700 RelativePath="..\..\src\orxonox\tools\Shader.cc" 661 701 > 662 702 </File> … … 755 795 </File> 756 796 <File 797 RelativePath="..\..\src\orxonox\overlays\hud\GametypeStatus.cc" 798 > 799 </File> 800 <File 757 801 RelativePath="..\..\src\orxonox\overlays\hud\HUDBar.cc" 802 > 803 </File> 804 <File 805 RelativePath="..\..\src\orxonox\overlays\hud\HUDHealthBar.cc" 758 806 > 759 807 </File> … … 887 935 </File> 888 936 <File 937 RelativePath="..\..\src\orxonox\PawnManager.h" 938 > 939 </File> 940 <File 889 941 RelativePath="..\..\src\orxonox\PlayerManager.h" 890 942 > … … 910 962 </File> 911 963 <File 964 RelativePath="..\..\src\orxonox\objects\GlobalShader.h" 965 > 966 </File> 967 <File 912 968 RelativePath="..\..\src\orxonox\objects\Level.h" 913 969 > … … 966 1022 <File 967 1023 RelativePath="..\..\src\orxonox\objects\worldentities\ControllableEntity.h" 1024 > 1025 </File> 1026 <File 1027 RelativePath="..\..\src\orxonox\objects\worldentities\ExplosionChunk.h" 1028 > 1029 </File> 1030 <File 1031 RelativePath="..\..\src\orxonox\objects\worldentities\FadingBillboard.h" 968 1032 > 969 1033 </File> … … 1057 1121 > 1058 1122 <File 1123 RelativePath="..\..\src\orxonox\objects\infos\Bot.h" 1124 > 1125 </File> 1126 <File 1127 RelativePath="..\..\src\orxonox\objects\infos\GametypeInfo.h" 1128 > 1129 </File> 1130 <File 1131 RelativePath="..\..\src\orxonox\objects\infos\HumanPlayer.h" 1132 > 1133 </File> 1134 <File 1059 1135 RelativePath="..\..\src\orxonox\objects\infos\Info.h" 1060 1136 > … … 1069 1145 > 1070 1146 <File 1147 RelativePath="..\..\src\orxonox\objects\controllers\AIController.h" 1148 > 1149 </File> 1150 <File 1151 RelativePath="..\..\src\orxonox\objects\controllers\ArtificialController.h" 1152 > 1153 </File> 1154 <File 1071 1155 RelativePath="..\..\src\orxonox\objects\controllers\Controller.h" 1072 1156 > … … 1074 1158 <File 1075 1159 RelativePath="..\..\src\orxonox\objects\controllers\HumanController.h" 1160 > 1161 </File> 1162 <File 1163 RelativePath="..\..\src\orxonox\objects\controllers\ScriptController.h" 1076 1164 > 1077 1165 </File> … … 1229 1317 </File> 1230 1318 </Filter> 1319 <Filter 1320 Name="items" 1321 > 1322 <File 1323 RelativePath="..\..\src\orxonox\objects\items\Engine.h" 1324 > 1325 </File> 1326 <File 1327 RelativePath="..\..\src\orxonox\objects\items\Item.h" 1328 > 1329 </File> 1330 <File 1331 RelativePath="..\..\src\orxonox\objects\items\MultiStateEngine.h" 1332 > 1333 </File> 1334 </Filter> 1231 1335 </Filter> 1232 1336 <Filter … … 1250 1354 </File> 1251 1355 <File 1356 RelativePath="..\..\src\orxonox\tools\Shader.h" 1357 > 1358 </File> 1359 <File 1252 1360 RelativePath="..\..\src\orxonox\tools\TextureGenerator.h" 1253 1361 > … … 1293 1401 </File> 1294 1402 <File 1403 RelativePath="..\..\src\orxonox\overlays\hud\GametypeStatus.h" 1404 > 1405 </File> 1406 <File 1295 1407 RelativePath="..\..\src\orxonox\overlays\hud\HUDBar.h" 1408 > 1409 </File> 1410 <File 1411 RelativePath="..\..\src\orxonox\overlays\hud\HUDHealthBar.h" 1296 1412 > 1297 1413 </File> -
code/branches/presentation/visual_studio/vc8/orxonox.vsprops
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/visual_studio/vc8/orxonox_vc8.sln
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/visual_studio/vc8/release.vsprops
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/visual_studio/vc8/tinyxml.vcproj
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/visual_studio/vc8/tinyxml.vsprops
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/visual_studio/vc8/tolua.vsprops
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/visual_studio/vc8/toluagen.vcproj
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/visual_studio/vc8/toluagen.vsprops
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/visual_studio/vc8/toluagen_orxonox.vcproj
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/visual_studio/vc8/toluagen_orxonox.vsprops
- Property svn:mergeinfo changed (with no actual effect on merging)
-
code/branches/presentation/visual_studio/vc8/util.vsprops
- Property svn:mergeinfo changed (with no actual effect on merging)
Note: See TracChangeset
for help on using the changeset viewer.