Changeset 1052 for code/trunk/src/orxonox/Orxonox.cc
- Timestamp:
- Apr 14, 2008, 3:42:49 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/Orxonox.cc
r1039 r1052 55 55 56 56 // core 57 #include "core/ConsoleCommand.h" 57 58 #include "core/Debug.h" 58 59 #include "core/Factory.h" 59 60 #include "core/Loader.h" 60 61 #include "core/Tickable.h" 62 #include "core/InputBuffer.h" 61 63 #include "core/InputManager.h" 62 64 … … 80 82 namespace orxonox 81 83 { 84 ConsoleCommand(Orxonox, exit, AccessLevel::None, true); 85 ConsoleCommand(Orxonox, slomo, AccessLevel::Offline, true).setDefaultValue(0, 1.0); 86 ConsoleCommand(Orxonox, setTimeFactor, AccessLevel::Offline, false).setDefaultValue(0, 1.0); 87 88 class Testconsole : public InputBufferListener 89 { 90 public: 91 Testconsole(InputBuffer* ib) : ib_(ib) {} 92 void listen() const 93 { 94 std::cout << "> " << this->ib_->get() << std::endl; 95 } 96 void execute() const 97 { 98 std::cout << ">> " << this->ib_->get() << std::endl; 99 if (!CommandExecutor::execute(this->ib_->get())) 100 std::cout << "Error" << std::endl; 101 this->ib_->clear(); 102 } 103 void hintandcomplete() const 104 { 105 std::cout << CommandExecutor::hint(this->ib_->get()) << std::endl; 106 this->ib_->set(CommandExecutor::complete(this->ib_->get())); 107 } 108 void clear() const 109 { 110 this->ib_->clear(); 111 } 112 void removeLast() const 113 { 114 this->ib_->removeLast(); 115 } 116 117 private: 118 InputBuffer* ib_; 119 }; 120 82 121 /** 83 122 @brief Reference to the only instance of the class. … … 198 237 { 199 238 COUT(2) << "initialising server" << std::endl; 200 239 201 240 ogre_->setConfigPath(path); 202 241 ogre_->setup(); 203 242 //root_ = ogre_->getRoot(); 204 243 if(!ogre_->load(this->dataPath_)) abortImmediate(/* unable to load */); 205 244 206 245 server_g = new network::Server(); 207 246 } … … 210 249 { 211 250 COUT(2) << "initialising client" << std::endl;\ 212 251 213 252 ogre_->setConfigPath(path); 214 253 ogre_->setup(); … … 219 258 if(!ogre_->load(this->dataPath_)) abortImmediate(/* unable to load */); 220 259 } 221 260 222 261 void Orxonox::standaloneInit(std::string path) 223 262 { 224 263 COUT(2) << "initialising standalone mode" << std::endl; 225 264 226 265 ogre_->setConfigPath(path); 227 266 ogre_->setup(); … … 229 268 if(!ogre_->load(this->dataPath_)) abortImmediate(/* unable to load */); 230 269 } 231 270 232 271 /** 233 272 * start modules … … 246 285 } 247 286 } 248 287 249 288 void Orxonox::clientStart(){ 250 289 ogre_->initialise(); 251 290 Factory::createClassHierarchy(); 252 253 291 292 254 293 auMan_ = new audio::AudioManager(); 255 294 256 295 //bulletMgr_ = new BulletManager(); 257 296 258 297 Ogre::Overlay* hudOverlay = Ogre::OverlayManager::getSingleton().getByName("Orxonox/HUD1.2"); 259 298 HUD* orxonoxHud; … … 262 301 orxonoxHud->setEnergyDistr(20,20,60); 263 302 hudOverlay->show(); 264 303 265 304 client_g->establishConnection(); 266 305 client_g->tick(0); 267 268 306 307 269 308 //setupInputSystem(); 270 309 271 310 startRenderLoop(); 272 311 } 273 312 274 313 void Orxonox::serverStart(){ 275 314 //TODO: start modules … … 279 318 createScene(); 280 319 setupInputSystem(); 281 320 282 321 server_g->open(); 283 322 284 323 startRenderLoop(); 285 324 } 286 325 287 326 void Orxonox::standaloneStart(){ 288 327 //TODO: start modules … … 292 331 createScene(); 293 332 setupInputSystem(); 294 333 295 334 startRenderLoop(); 296 335 } … … 351 390 void Orxonox::startRenderLoop() 352 391 { 392 InputBuffer* ib = new InputBuffer(); 393 Testconsole* console = new Testconsole(ib); 394 ib->registerListener(console, &Testconsole::listen, true); 395 ib->registerListener(console, &Testconsole::execute, '\r', false); 396 ib->registerListener(console, &Testconsole::hintandcomplete, '\t', true); 397 ib->registerListener(console, &Testconsole::clear, '§', true); 398 ib->registerListener(console, &Testconsole::removeLast, '\b', true); 399 353 400 // first check whether ogre root object has been created 354 401 if (Ogre::Root::getSingletonPtr() == 0) … … 395 442 // Iterate through all Tickables and call their tick(dt) function 396 443 for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ) 397 (it++)->tick((float)evt.timeSinceLastFrame );444 (it++)->tick((float)evt.timeSinceLastFrame * this->timefactor_); 398 445 399 446 // don't forget to call _fireFrameStarted in ogre to make sure
Note: See TracChangeset
for help on using the changeset viewer.