Changeset 1132
- Timestamp:
- Apr 22, 2008, 4:25:54 PM (17 years ago)
- Location:
- code/branches/network2
- Files:
-
- 4 deleted
- 15 edited
- 16 copied
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network2/CMakeLists.txt
r1103 r1132 32 32 33 33 #set binary output directories 34 SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_ BINARY_DIR}/bin)35 SET(LIBRARY_OUTPUT_PATH ${PROJECT_ BINARY_DIR}/bin/lib)34 SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin) 35 SET(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin/lib) 36 36 37 37 # global compiler/linker flags. force -O2! … … 43 43 SET(CMAKE_MODULE_LINKER_FLAGS " --no-undefined") 44 44 45 #Create verbose makefile output when compiling 46 SET(CMAKE_VERBOSE_MAKEFILE TRUE) 45 #use 'cmake -D make_verb:1 path' to get verbose make output when compiling 46 IF (MAKE_VERB) 47 SET(CMAKE_VERBOSE_MAKEFILE TRUE) 48 ENDIF (MAKE_VERB) 47 49 48 50 … … 79 81 ${ENet_INCLUDE_DIR} 80 82 ${Boost_INCLUDE_DIRS} 81 ${OPENAL_INCLUDE_DIR} ${ALUT_INCLUDE_DIR} ${VORBIS_INCLUDE_DIR} ${OGG_INCLUDE_DIR} 83 ${OPENAL_INCLUDE_DIR} 84 ${ALUT_INCLUDE_DIR} 85 ${VORBIS_INCLUDE_DIR} 86 ${OGG_INCLUDE_DIR} 82 87 ${Lua_INCLUDE_DIR} 83 88 ) 84 85 86 ################ Source files ###################87 88 #At first, build lua89 MESSAGE(STATUS "\n******************* Building tolua... ******************\n\n")90 EXECUTE_PROCESS(COMMAND ./tolua-build)91 MESSAGE(STATUS "\n\n******************* Building tolua done ****************\n")92 93 #generate lua bind source files94 EXECUTE_PROCESS(COMMAND bin/./tolua-exec-script)95 89 96 90 #add main source dir -
code/branches/network2/cmake/FindLua.cmake
r1076 r1132 1 # Find Lua includes and library1 # Find Lua header and library files 2 2 # 3 # This module defines4 # Lua_INCLUDE_DIR 5 # Lua_LIBRARIES , the libraries to link against to use Lua.6 # Lua_ LIB_DIR, the location of the libraries7 # Lua_ FOUND, If false, do not try to use Lua3 # When called, this script tries to define: 4 # Lua_INCLUDE_DIR Header files directory 5 # Lua_LIBRARIES library files (or file when using lua 5.1) 6 # Lua_FOUND defined (true) if lua was found 7 # Lua_VERSION either 5.1 or 5.0 or undefined 8 8 # 9 # Copyright © 2007, Matt Williams 10 # 11 # Redistribution and use is allowed according to the terms of the BSD license. 9 # authors: Benjamin Knecht, Reto Grieder 12 10 13 MESSAGE(STATUS "lua libs in cache: ${Lua_LIBRARIES}")14 11 IF (Lua_LIBRARIES AND Lua_INCLUDE_DIR) 15 SET(Lua_FIND_QUIETLY TRUE) # Already in cache, be silent 12 13 # Already in cache, be silent 14 SET(Lua_FOUND TRUE) 15 SET(Lua_FIND_QUIETLY TRUE) 16 MESSAGE(STATUS "Lua was found.") 17 18 ELSE (Lua_LIBRARIES AND Lua_INCLUDE_DIR) 19 20 FIND_PATH(Lua_INCLUDE_DIR_51 lua.h 21 /usr/include/lua5.1 22 /usr/local/include/lua5.1 23 ../libs/lua-5.1.3/src) 24 25 FIND_PATH(Lua_INCLUDE_DIR_50 lua.h 26 /usr/include/lua50 27 /usr/local/include/lua50 28 /usr/pack/lua-5.0.3-sd/include) 29 30 FIND_LIBRARY(Lua_LIBRARY_51 NAMES lua5.1 lua PATHS 31 /usr/lib 32 /usr/local/lib 33 ../libs/lua-5.1.3/lib) 34 35 FIND_LIBRARY(Lua_LIBRARY_1_50 NAMES lua50 lua PATHS 36 /usr/pack/lua-5.0.3-sd/i686-debian-linux3.1/lib #tardis 37 /usr/lib 38 /usr/local/lib) 39 40 FIND_LIBRARY(Lua_LIBRARY_2_50 NAMES lualib50 lualib PATHS 41 /usr/pack/lua-5.0.3-sd/i686-debian-linux3.1/lib #tardis 42 /usr/lib 43 /usr/local/lib) 44 45 46 IF (Lua_INCLUDE_DIR_51 AND Lua_LIBRARY_51) 47 48 # Found newer lua 5.1 libs 49 SET(Lua_FOUND TRUE) 50 SET(Lua_VERSION 5.1 CACHE STRING "") 51 SET(Lua_INCLUDE_DIR ${Lua_INCLUDE_DIR_51} CACHE PATH "") 52 SET(Lua_LIBRARIES ${Lua_LIBRARY_51} CACHE FILEPATH "") 53 54 ELSEIF(Lua_INCLUDE_DIR_50 AND Lua_LIBRARY_1_50 AND Lua_LIBRARY_2_50) 55 56 # Found older lua 5.0 libs 57 SET(Lua_FOUND TRUE) 58 SET(Lua_VERSION 5.0 CACHE STRING "") 59 SET(Lua_INCLUDE_DIR ${Lua_INCLUDE_DIR_50} CACHE PATH "") 60 SET(Lua_LIBRARIES ${Lua_LIBRARY_1_50} ${Lua_LIBRARY_2_50} CACHE FILEPATH "") 61 62 ENDIF (Lua_INCLUDE_DIR_51 AND Lua_LIBRARY_51) 63 64 65 IF (Lua_FOUND) 66 MESSAGE(STATUS "Found Lua: ${Lua_LIBRARIES}") 67 ELSE (Lua_FOUND) 68 IF (Lua_FIND_REQUIRED) 69 MESSAGE(FATAL_ERROR "Could not find Lua") 70 ENDIF (Lua_FIND_REQUIRED) 71 ENDIF (Lua_FOUND) 72 16 73 ENDIF (Lua_LIBRARIES AND Lua_INCLUDE_DIR) 17 74 18 FIND_PATH(Lua_INCLUDE_DIR lua.h19 /usr/include/lua5.120 /usr/local/include/lua5.121 ../libs/lua-5.1.3/src)22 23 FIND_LIBRARY(Lua_LIBRARIES lua5.124 /usr/lib25 /usr/local/lib26 ../libs/lua-5.1.3/lib)27 28 IF (NOT Lua_INCLUDE_DIR)29 FIND_PATH(Lua_INCLUDE_DIR lua.h30 /usr/include/lua5031 /usr/local/include/lua5032 /usr/pack/lua-5.0.3-sd/include)33 ENDIF (NOT Lua_INCLUDE_DIR)34 35 IF (NOT Lua_LIBRARIES)36 FIND_LIBRARY(Lua_LIBRARIES lua5037 /usr/lib38 /usr/local/lib)39 40 FIND_LIBRARY(Lua_LIBRARY lualib5041 /usr/lib42 /usr/local/lib)43 44 #SET(Lua_LIBRARIES ${Lua_LIBRARIES} ${Lua_LIBRARY})45 ENDIF (NOT Lua_LIBRARIES)46 47 #especially for tardis48 IF (NOT Lua_LIBRARIES)49 FIND_LIBRARY(Lua_LIBRARIES lua50 /usr/pack/lua-5.0.3-sd/i686-debian-linux3.1/lib)51 52 FIND_LIBRARY(Lua_LIBRARY lualib53 /usr/pack/lua-5.0.3-sd/i686-debian-linux3.1/lib)54 55 #SET(Lua_LIBRARIES ${Lua_LIBRARIES} ${Lua_LIBRARY})56 ENDIF (NOT Lua_LIBRARIES)57 58 IF (Lua_INCLUDE_DIR AND Lua_LIBRARIES)59 SET(Lua_FOUND TRUE)60 ENDIF (Lua_INCLUDE_DIR AND Lua_LIBRARIES)61 62 IF (Lua_FOUND)63 MESSAGE(STATUS "Found Lua: ${Lua_LIBRARIES}")64 MESSAGE(STATUS "Found Lua: ${Lua_LIBRARY}")65 ELSE (Lua_FOUND)66 IF (Lua_FIND_REQUIRED)67 MESSAGE(FATAL_ERROR "Could not find Lua")68 ENDIF (Lua_FIND_REQUIRED)69 ENDIF (Lua_FOUND) -
code/branches/network2/src/CMakeLists.txt
r1076 r1132 1 1 INCLUDE_DIRECTORIES(.) 2 2 INCLUDE_DIRECTORIES(orxonox) 3 INCLUDE_DIRECTORIES( util/tolua)3 INCLUDE_DIRECTORIES(tolua) 4 4 5 ADD_SUBDIRECTORY(tolua) 5 6 ADD_SUBDIRECTORY(util) 6 7 ADD_SUBDIRECTORY(core) -
code/branches/network2/src/core/CMakeLists.txt
r1084 r1132 1 #get the created files 2 AUX_SOURCE_DIRECTORY(tolua TOLUA_BIND_FILES) 3 4 SET( CORE_SRC_FILES 1 SET(CORE_SRC_FILES 5 2 OrxonoxClass.cc 6 3 BaseObject.cc … … 29 26 Tickable.cc 30 27 Script.cc 31 ${TOLUA_BIND_FILES}32 28 ) 33 29 34 ADD_LIBRARY( 30 ADD_LIBRARY(core SHARED ${CORE_SRC_FILES}) 35 31 36 TARGET_LINK_LIBRARIES( 32 TARGET_LINK_LIBRARIES(core 37 33 util 34 tolualib 38 35 ${Lua_LIBRARIES} 39 ${Lua_LIBRARY}40 36 ${OIS_LIBRARIES} 41 37 ) -
code/branches/network2/src/core/ConfigFileManager.h
r1064 r1132 63 63 { 64 64 public: 65 virtual ~ConfigFileEntry() {}; 65 66 virtual void setValue(const std::string& value) = 0; 66 67 virtual std::string getValue() const = 0; -
code/branches/network2/src/core/Loader.cc
r1085 r1132 115 115 Script::init(Script::getLuaState()); 116 116 Script::run();*/ 117 //Script* lua = Script::getInstance();118 //lua->loadFile(level->getFile(), true);119 //lua->run();117 Script* lua = Script::getInstance(); 118 lua->loadFile(level->getFile(), true); 119 lua->run(); 120 120 121 121 try … … 124 124 COUT(3) << "Mask: " << Loader::currentMask_s << std::endl; 125 125 126 ticpp::Document xmlfile(level->getFile());127 xmlfile.LoadFile();126 //ticpp::Document xmlfile(level->getFile()); 127 //xmlfile.LoadFile(); 128 128 //ticpp::Element myelement(*Script::getFileString()); 129 //ticpp::Document xmlfile;130 xmlfile.ToDocument();131 //xmlfile.Parse(lua->getLuaOutput(), true);129 ticpp::Document xmlfile; 130 //xmlfile.ToDocument(); 131 xmlfile.Parse(lua->getLuaOutput(), true); 132 132 133 133 ticpp::Element rootElement; -
code/branches/network2/src/core/Script.cc
r1076 r1132 39 39 } 40 40 41 #include "tolua ++.h"41 #include "tolua/tolua++.h" 42 42 #include "tolua/tolua_bind.h" 43 43 … … 102 102 } 103 103 104 #if LUA_VERSION_NUM != 501 105 const char * Script::lua_Chunkreader(lua_State *L, void *data, size_t *size) 106 { 107 LoadS* ls = ((LoadS*)data); 108 if (ls->size == 0) return NULL; 109 *size = ls->size; 110 ls->size = 0; 111 return ls->s; 112 } 113 #endif 104 114 void Script::run() 105 115 { … … 110 120 error = luaL_loadstring(luaState_, init.c_str()); 111 121 #else 112 error = lua_load(luaState_, &orxonox::Script::lua_Chunkreader, (void*)init.c_str(), "init"); 122 LoadS ls; 123 ls.s = init.c_str(); 124 ls.size = init.size(); 125 error = lua_load(luaState_, &orxonox::Script::lua_Chunkreader, &ls, init.c_str()); 113 126 #endif 114 127 if (error == 0) -
code/branches/network2/src/core/Script.h
r1056 r1132 50 50 class _CoreExport Script // tolua_export 51 51 { // tolua_export 52 struct LoadS { 53 const char *s; 54 size_t size; 55 }; 56 52 57 public: 53 58 inline static Script* getInstance() { if (!Script::singletonRef) Script::singletonRef = new Script(); return Script::singletonRef; } // tolua_export … … 61 66 62 67 #if LUA_VERSION_NUM != 501 63 inline static const char * lua_Chunkreader(lua_State *L, void *data, size_t *size) { return NULL;};68 static const char * lua_Chunkreader(lua_State *L, void *data, size_t *size); 64 69 #endif 65 70 -
code/branches/network2/src/orxonox/GraphicsEngine.cc
r1090 r1132 100 100 Ogre::LogManager::getSingleton().getDefaultLog()->removeListener(this); 101 101 Ogre::LogManager::getSingleton().destroyLog(Ogre::LogManager::getSingleton().getDefaultLog()); 102 delete Ogre::LogManager::getSingletonPtr();102 Ogre::LogManager::getSingletonPtr()->~LogManager(); 103 103 } 104 104 COUT(4) << "*** GraphicsEngine: Destroying objects done" << std::endl; -
code/branches/network2/src/orxonox/Orxonox.cc
r1105 r1132 1 1 /* 2 2 * ORXONOX - the hottest 3D action shooter ever to exist 3 * > www.orxonox.net < 3 4 * 4 5 * … … 27 28 28 29 /** 29 @file Orxonox.cc30 @file 30 31 @brief Orxonox Main Class 31 32 */ … … 33 34 // Precompiled Headers 34 35 #include "OrxonoxStableHeaders.h" 36 #include "Orxonox.h" 37 38 //****** STD ******* 39 //#include <iostream> 40 //#include <exception> 41 #include <deque> 35 42 36 43 //****** OGRE ****** … … 39 46 #include <OgreOverlay.h> 40 47 #include <OgreOverlayManager.h> 48 #include <OgreRoot.h> 41 49 #include <OgreTimer.h> 42 50 #include <OgreWindowEventUtilities.h> 43 51 44 //****** STD *******45 //#include <iostream>46 //#include <exception>47 #include <deque>48 49 52 //***** ORXONOX **** 50 // misc53 // util 51 54 //#include "util/Sleep.h" 52 53 // audio 54 #include "audio/AudioManager.h" 55 56 // network 57 #include "network/Server.h" 58 #include "network/Client.h" 59 network::Client *client_g; 60 network::Server *server_g; 61 62 // objects 63 #include "core/ArgReader.h" 55 #include "util/ArgReader.h" 56 #include "util/ExprParser.h" 57 58 // core 59 #include "core/ConfigFileManager.h" 60 #include "core/ConsoleCommand.h" 64 61 #include "core/Debug.h" 65 62 #include "core/Factory.h" 66 63 #include "core/Loader.h" 67 64 #include "core/Tickable.h" 65 #include "core/InputBuffer.h" 66 #include "core/InputManager.h" 67 68 // audio 69 #include "audio/AudioManager.h" 70 71 // network 72 #include "network/Server.h" 73 #include "network/Client.h" 74 75 // objects and tools 76 #include "tools/Timer.h" 68 77 #include "hud/HUD.h" 69 #include "tools/Timer.h" 70 #include "objects/weapon/BulletManager.h" 71 72 #include "InputHandler.h" 73 74 #include "Orxonox.h" 78 79 // FIXME: is this really file scope? 80 // globals for the server or client 81 network::Client *client_g; 82 network::Server *server_g; 75 83 76 84 namespace orxonox 77 85 { 86 ConsoleCommand(Orxonox, exit, AccessLevel::None, true); 87 ConsoleCommand(Orxonox, slomo, AccessLevel::Offline, true).setDefaultValue(0, 1.0); 88 ConsoleCommand(Orxonox, setTimeFactor, AccessLevel::Offline, false).setDefaultValue(0, 1.0); 89 90 class Testconsole : public InputBufferListener 91 { 92 public: 93 Testconsole(InputBuffer* ib) : ib_(ib) {} 94 void listen() const 95 { 96 std::cout << "> " << this->ib_->get() << std::endl; 97 } 98 void execute() const 99 { 100 std::cout << ">> " << this->ib_->get() << std::endl; 101 if (!CommandExecutor::execute(this->ib_->get())) 102 std::cout << "Error" << std::endl; 103 this->ib_->clear(); 104 } 105 void hintandcomplete() const 106 { 107 std::cout << CommandExecutor::hint(this->ib_->get()) << std::endl; 108 this->ib_->set(CommandExecutor::complete(this->ib_->get())); 109 } 110 void clear() const 111 { 112 this->ib_->clear(); 113 } 114 void removeLast() const 115 { 116 this->ib_->removeLast(); 117 } 118 void exit() const 119 { 120 CommandExecutor::execute("setInputMode 2"); 121 } 122 123 private: 124 InputBuffer* ib_; 125 }; 126 127 class Calculator 128 { 129 public: 130 static void calculate(const std::string& calculation) 131 { 132 ExprParser expr(calculation); 133 if (expr.getSuccess()) 134 { 135 if (expr.getResult() == 42.0) 136 std::cout << "Greetings from the restaurant at the end of the universe." << std::endl; 137 // FIXME: insert modifier to display in full precision 138 std::cout << "Result is: " << expr.getResult() << std::endl; 139 if (expr.getRemains() != "") 140 std::cout << "Warning: Expression could not be parsed to the end! Remains: '" 141 << expr.getRemains() << "'" << std::endl; 142 } 143 else 144 std::cout << "Cannot calculate expression: Parse error" << std::endl; 145 } 146 }; 147 ConsoleCommandShortcut(Calculator, calculate, AccessLevel::None); 148 78 149 /** 79 150 @brief Reference to the only instance of the class. … … 86 157 Orxonox::Orxonox() 87 158 { 88 this->ogre_ = new GraphicsEngine();159 this->ogre_ = &GraphicsEngine::getSingleton(); 89 160 this->timer_ = 0; 90 161 this->dataPath_ = ""; 91 162 this->auMan_ = 0; 92 163 this->inputHandler_ = 0; 93 //this->root_ = 0;94 164 // turn on frame smoothing by setting a value different from 0 95 165 this->frameSmoothingTime_ = 0.0f; 96 166 this->bAbort_ = false; 167 this->timefactor_ = 1.0f; 97 168 } 98 169 … … 103 174 { 104 175 // keep in mind: the order of deletion is very important! 105 if (this->bulletMgr_)106 delete this->bulletMgr_;107 176 if (this->orxonoxHUD_) 108 177 delete this->orxonoxHUD_; 109 178 Loader::close(); 110 Input Handler::destroy();179 InputManager::getSingleton().destroy(); 111 180 if (this->auMan_) 112 181 delete this->auMan_; 113 182 if (this->timer_) 114 183 delete this->timer_; 115 if (this->ogre_) 116 delete this->ogre_; 184 GraphicsEngine::getSingleton().destroy(); 117 185 118 186 if (client_g) … … 123 191 124 192 /** 125 * error kills orxonox 126 */ 127 void Orxonox::abortImmediate(/* some error code */) 128 { 129 //TODO: destroy and destruct everything and print nice error msg 193 @brief Immediately deletes the orxonox object. 194 Never use if you can help it while rendering! 195 */ 196 void Orxonox::abortImmediateForce() 197 { 198 COUT(1) << "*** Orxonox Error: Orxonox object was unexpectedly destroyed." << std::endl; 130 199 delete this; 131 200 } … … 136 205 void Orxonox::abortRequest() 137 206 { 207 COUT(3) << "*** Orxonox: Abort requested." << std::endl; 138 208 bAbort_ = true; 139 209 } … … 147 217 singletonRef_s = new Orxonox(); 148 218 return singletonRef_s; 149 //static Orxonox theOnlyInstance;150 //return &theOnlyInstance;151 219 } 152 220 … … 154 222 @brief Destroys the Orxonox singleton. 155 223 */ 156 void Orxonox::destroy ()224 void Orxonox::destroySingleton() 157 225 { 158 226 if (singletonRef_s) … … 174 242 std::string mode; 175 243 176 ArgReader ar = ArgReader(argc, argv);244 ArgReader ar(argc, argv); 177 245 ar.checkArgument("mode", mode, false); 178 246 ar.checkArgument("data", this->dataPath_, false); 179 247 ar.checkArgument("ip", serverIp_, false); 180 if(ar.errorHandling()) abortImmediate ();248 if(ar.errorHandling()) abortImmediateForce(); 181 249 if(mode == std::string("client")) 182 250 { … … 197 265 { 198 266 COUT(2) << "initialising server" << std::endl; 199 267 200 268 ogre_->setConfigPath(path); 201 269 ogre_->setup(); 202 270 //root_ = ogre_->getRoot(); 203 if(!ogre_->load(this->dataPath_)) abortImmediate (/* unable to load */);204 271 if(!ogre_->load(this->dataPath_)) abortImmediateForce(/* unable to load */); 272 205 273 server_g = new network::Server(); 206 274 } … … 209 277 { 210 278 COUT(2) << "initialising client" << std::endl;\ 211 279 212 280 ogre_->setConfigPath(path); 213 281 ogre_->setup(); … … 216 284 else 217 285 client_g = new network::Client(serverIp_, NETWORK_PORT); 218 if(!ogre_->load(this->dataPath_)) abortImmediate (/* unable to load */);219 } 220 286 if(!ogre_->load(this->dataPath_)) abortImmediateForce(/* unable to load */); 287 } 288 221 289 void Orxonox::standaloneInit(std::string path) 222 290 { 223 291 COUT(2) << "initialising standalone mode" << std::endl; 224 292 225 293 ogre_->setConfigPath(path); 226 294 ogre_->setup(); 227 //root_ = ogre_->getRoot(); 228 if(!ogre_->load(this->dataPath_)) abortImmediate(/* unable to load */); 229 } 230 295 if(!ogre_->load(this->dataPath_)) abortImmediateForce(/* unable to load */); 296 } 297 231 298 /** 232 299 * start modules … … 245 312 } 246 313 } 247 314 248 315 void Orxonox::clientStart(){ 249 316 ogre_->initialise(); 317 ConfigFileManager::getSingleton()->setFile(CFT_Settings, "orxonox.ini"); 250 318 Factory::createClassHierarchy(); 251 252 319 320 253 321 auMan_ = new audio::AudioManager(); 254 322 255 bulletMgr_ = new BulletManager();256 257 323 Ogre::Overlay* hudOverlay = Ogre::OverlayManager::getSingleton().getByName("Orxonox/HUD1.2"); 258 orxonoxHUD_ = new HUD(); 259 orxonoxHUD_->setEnergyValue(20); 260 orxonoxHUD_->setEnergyDistr(20,20,60); 324 HUD* orxonoxHud; 325 orxonoxHud = new HUD(); 326 orxonoxHud->setEnergyValue(20); 327 orxonoxHud->setEnergyDistr(20,20,60); 261 328 hudOverlay->show(); 262 263 if( !client_g->establishConnection() ) 264 COUT(1) <<"CLIENT COULD NOT ESTABLISH CONNECTION" << std::endl; 329 330 client_g->establishConnection(); 265 331 client_g->tick(0); 266 267 332 333 268 334 //setupInputSystem(); 269 335 270 336 startRenderLoop(); 271 337 } 272 338 273 339 void Orxonox::serverStart(){ 274 340 //TODO: start modules 275 341 ogre_->initialise(); 276 342 //TODO: run engine 343 ConfigFileManager::getSingleton()->setFile(CFT_Settings, "orxonox.ini"); 277 344 Factory::createClassHierarchy(); 278 345 createScene(); 279 346 setupInputSystem(); 280 347 281 348 server_g->open(); 282 349 283 350 startRenderLoop(); 284 351 } 285 352 286 353 void Orxonox::standaloneStart(){ 287 354 //TODO: start modules 288 355 ogre_->initialise(); 289 356 //TODO: run engine 357 ConfigFileManager::getSingleton()->setFile(CFT_Settings, "orxonox.ini"); 290 358 Factory::createClassHierarchy(); 291 359 createScene(); 292 360 setupInputSystem(); 293 361 294 362 startRenderLoop(); 295 363 } … … 299 367 // Init audio 300 368 auMan_ = new audio::AudioManager(); 301 302 bulletMgr_ = new BulletManager();303 369 304 370 // load this file from config … … 327 393 void Orxonox::setupInputSystem() 328 394 { 329 inputHandler_ = InputHandler::getSingleton();395 inputHandler_ = &InputManager::getSingleton(); 330 396 if (!inputHandler_->initialise(ogre_->getWindowHandle(), 331 397 ogre_->getWindowWidth(), ogre_->getWindowHeight())) 332 abortImmediate(); 398 abortImmediateForce(); 399 inputHandler_->setInputMode(IM_INGAME); 333 400 } 334 401 … … 343 410 About the loop: The design is almost exactly like the one in ogre, so that 344 411 if any part of ogre registers a framelisteners, it will still behave 345 correctly. Furthermore I have taken over the time smoothing feature from346 ogre. If turned on (see orxonox constructor), it will calculate the dt_n by347 means of the recent most dt_n-1, dt_n-2, etc.412 correctly. Furthermore the time smoothing feature from ogre has been 413 implemented too. If turned on (see orxonox constructor), it will calculate 414 the dt_n by means of the recent most dt_n-1, dt_n-2, etc. 348 415 */ 349 416 void Orxonox::startRenderLoop() 350 417 { 418 InputBuffer* ib = new InputBuffer(); 419 InputManager::getSingleton().feedInputBuffer(ib); 420 Testconsole* console = new Testconsole(ib); 421 ib->registerListener(console, &Testconsole::listen, true); 422 ib->registerListener(console, &Testconsole::execute, '\r', false); 423 ib->registerListener(console, &Testconsole::execute, '\n', false); 424 ib->registerListener(console, &Testconsole::hintandcomplete, '\t', true); 425 ib->registerListener(console, &Testconsole::clear, '§', true); 426 ib->registerListener(console, &Testconsole::removeLast, '\b', true); 427 ib->registerListener(console, &Testconsole::exit, (char)0x1B, true); 428 429 // first check whether ogre root object has been created 430 if (Ogre::Root::getSingletonPtr() == 0) 431 { 432 COUT(2) << "*** Orxonox Error: Could not start rendering. No Ogre root object found" << std::endl; 433 return; 434 } 435 Ogre::Root& ogreRoot = Ogre::Root::getSingleton(); 436 437 438 // Contains the times of recently fired events 439 // eventTimes[4] is the list for the times required for the fps counter 440 std::deque<unsigned long> eventTimes[4]; 441 // Clear event times 442 for (int i = 0; i < 4; ++i) 443 eventTimes[i].clear(); 444 // fill the fps time list with zeros 445 for (int i = 0; i < 20; i++) 446 eventTimes[3].push_back(0); 447 351 448 // use the ogre timer class to measure time. 352 449 if (!timer_) … … 354 451 timer_->reset(); 355 452 356 // Contains the times of recently fired events357 std::deque<unsigned long> eventTimes[3];358 // Clear event times359 for (int i = 0; i < 3; ++i)360 eventTimes[i].clear();361 362 453 while (!bAbort_) 363 454 { 364 455 // Pump messages in all registered RenderWindows 456 // This calls the WindowEventListener objects. 365 457 Ogre::WindowEventUtilities::messagePump(); 366 458 367 459 // get current time 368 460 unsigned long now = timer_->getMilliseconds(); 461 eventTimes[3].push_back(now); 462 eventTimes[3].erase(eventTimes[3].begin()); 369 463 370 464 // create an event to pass to the frameStarted method in ogre … … 374 468 375 469 // show the current time in the HUD 376 //orxonoxHUD_->setTime((int)now, 0); 470 orxonoxHUD_->setTime((int)now, 0); 471 if (eventTimes[3].back() - eventTimes[3].front() != 0) 472 orxonoxHUD_->setRocket1((int)(20000.0f/(eventTimes[3].back() - eventTimes[3].front()))); 377 473 378 474 // Iterate through all Tickables and call their tick(dt) function 379 for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; )380 (it++)->tick((float)evt.timeSinceLastFrame);475 for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it) 476 it->tick((float)evt.timeSinceLastFrame * this->timefactor_); 381 477 382 478 // don't forget to call _fireFrameStarted in ogre to make sure 383 479 // everything goes smoothly 384 ogre_->frameStarted(evt); 385 480 ogreRoot._fireFrameStarted(evt); 481 482 // server still renders at the moment 386 483 //if (mode_ != SERVER) 387 ogre_->renderOneFrame(); // only render in non-server mode484 ogreRoot._updateAllRenderTargets(); // only render in non-server mode 388 485 389 486 // get current time … … 395 492 396 493 // again, just to be sure ogre works fine 397 ogre _->frameEnded(evt);494 ogreRoot._fireFrameEnded(evt); 398 495 } 399 496 } … … 408 505 { 409 506 // Calculate the average time passed between events of the given type 410 // during the last mFrameSmoothingTimeseconds.507 // during the last frameSmoothingTime_ seconds. 411 508 412 509 times.push_back(now); … … 415 512 return 0; 416 513 417 // Times up to mFrameSmoothingTime seconds old should be kept 418 unsigned long discardThreshold = 419 static_cast<unsigned long>(frameSmoothingTime_ * 1000.0f); 514 // Times up to frameSmoothingTime_ seconds old should be kept 515 unsigned long discardThreshold = (unsigned long)(frameSmoothingTime_ * 1000.0f); 420 516 421 517 // Find the oldest time to keep 422 std::deque<unsigned long>::iterator it = times.begin(), 423 end = times.end()-2; // We need at least two times 518 std::deque<unsigned long>::iterator it = times.begin(); 519 // We need at least two times 520 std::deque<unsigned long>::iterator end = times.end() - 2; 521 424 522 while(it != end) 425 523 { … … 433 531 times.erase(times.begin(), it); 434 532 435 return (float)(times.back() - times.front()) / ((times.size() -1) * 1000);533 return (float)(times.back() - times.front()) / ((times.size() - 1) * 1000); 436 534 } 437 535 -
code/branches/network2/src/util/CMakeLists.txt
r1085 r1132 1 1 AUX_SOURCE_DIRECTORY(tinyxml TINYXML_SRC_FILES) 2 2 3 SET 3 SET(UTIL_SRC_FILES 4 4 ArgReader.cc 5 5 Math.cc … … 7 7 Clipboard.cc 8 8 SubString.cc 9 ExprParser.cc 9 10 MultiTypePrimitive.cc 10 11 MultiTypeString.cc 11 12 MultiTypeMath.cc 12 tolua/tolua_event.c13 tolua/tolua_is.c14 tolua/tolua_map.c15 tolua/tolua_push.c16 tolua/tolua_to.c17 13 ${TINYXML_SRC_FILES} 18 14 ) 19 15 20 ADD_LIBRARY( util SHARED ${UTIL_SRC_FILES})16 ADD_LIBRARY(util SHARED ${UTIL_SRC_FILES}) 21 17 22 18 IF(TESTING_ENABLED) … … 24 20 ENDIF(TESTING_ENABLED) 25 21 26 TARGET_LINK_LIBRARIES( 22 TARGET_LINK_LIBRARIES(util 27 23 ${OGRE_LIBRARIES} 28 ${Lua_LIBRARIES}29 ${Lua_LIBRARY}30 24 ) 31 25 -
code/branches/network2/src/util/String.cc
r1064 r1132 274 274 if (str.size() == 0) 275 275 return str; 276 else if (str.size() == 1) 277 { 278 //TODO: decide whether we need the commented code 279 /*if (str[0] != '\\') 280 return ""; 281 else*/ 282 return str; 283 } 276 284 277 285 std::string output = ""; -
code/branches/network2/visual_studio/vc8/core.vcproj
r1084 r1132 252 252 > 253 253 </File> 254 <Filter255 Name="tolua"256 >257 <File258 RelativePath="..\..\src\core\tolua\tolua_bind.cc"259 >260 <FileConfiguration261 Name="Debug|Win32"262 >263 <Tool264 Name="VCCLCompilerTool"265 />266 </FileConfiguration>267 </File>268 </Filter>269 254 </Filter> 270 255 <Filter … … 425 410 > 426 411 </File> 427 <Filter428 Name="tolua"429 >430 <File431 RelativePath="..\..\src\core\tolua\tolua_bind.h"432 >433 </File>434 </Filter>435 412 </Filter> 436 413 </Files> -
code/branches/network2/visual_studio/vc8/tolua++.vcproj
r1089 r1132 131 131 > 132 132 <File 133 RelativePath="..\..\src\ util\tolua\tolua_event.c"133 RelativePath="..\..\src\tolua\tolua_bind.cc" 134 134 > 135 135 </File> 136 136 <File 137 RelativePath="..\..\src\ util\tolua\tolua_is.c"137 RelativePath="..\..\src\tolua\tolua_event.c" 138 138 > 139 139 </File> 140 140 <File 141 RelativePath="..\..\src\ util\tolua\tolua_map.c"141 RelativePath="..\..\src\tolua\tolua_is.c" 142 142 > 143 143 </File> 144 144 <File 145 RelativePath="..\..\src\ util\tolua\tolua_push.c"145 RelativePath="..\..\src\tolua\tolua_map.c" 146 146 > 147 147 </File> 148 148 <File 149 RelativePath="..\..\src\util\tolua\tolua_to.c" 149 RelativePath="..\..\src\tolua\tolua_push.c" 150 > 151 </File> 152 <File 153 RelativePath="..\..\src\tolua\tolua_to.c" 150 154 > 151 155 </File> … … 157 161 > 158 162 <File 159 RelativePath="..\..\src\ util\tolua\tolua++.h"163 RelativePath="..\..\src\tolua\tolua++.h" 160 164 > 161 165 </File> 162 166 <File 163 RelativePath="..\..\src\util\tolua\tolua_event.h" 167 RelativePath="..\..\src\tolua\tolua_bind.h" 168 > 169 </File> 170 <File 171 RelativePath="..\..\src\tolua\tolua_event.h" 164 172 > 165 173 </File> -
code/branches/network2/visual_studio/vc8/util.vcproj
r1064 r1132 157 157 </File> 158 158 <File 159 RelativePath="..\..\src\util\ExprParser.cc" 160 > 161 </File> 162 <File 159 163 RelativePath="..\..\src\util\Math.cc" 160 164 > … … 199 203 </File> 200 204 <File 205 RelativePath="..\..\src\util\ExprParser.h" 206 > 207 </File> 208 <File 201 209 RelativePath="..\..\src\util\Math.h" 202 210 >
Note: See TracChangeset
for help on using the changeset viewer.