Changeset 1493 for code/branches/network/src/orxonox/Orxonox.cc
- Timestamp:
- May 31, 2008, 10:35:56 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/src/orxonox/Orxonox.cc
r1491 r1493 187 187 mode_ = SERVER; 188 188 else if (mode == "dedicated") 189 mode_ = DEDICATED;189 mode_ = DEDICATED; 190 190 else 191 191 { … … 217 217 bool Orxonox::start() 218 218 { 219 //if (mode_ == DEDICATED) 220 // do something else 221 //else 222 223 if (!ogre_->loadRenderer()) // creates the render window 224 return false; 225 226 // Calls the InputManager which sets up the input devices. 227 // The render window width and height are used to set up the mouse movement. 228 if (!InputManager::initialise(ogre_->getWindowHandle(), 229 ogre_->getWindowWidth(), ogre_->getWindowHeight(), true, true, true)) 230 return false; 231 232 // TODO: Spread this so that this call only initialises things needed for the GUI 233 if (!ogre_->initialiseResources()) 234 return false; 235 236 // TOOD: load the GUI here 237 // set InputManager to GUI mode 238 InputManager::setInputState(InputManager::IS_GUI); 239 // TODO: run GUI here 240 241 // The following lines depend very much on the GUI output, so they're probably misplaced here.. 242 243 InputManager::setInputState(InputManager::IS_NONE); 244 245 if (!loadPlayground()) 246 return false; 219 if (mode_ == DEDICATED) 220 { 221 // do something else 222 } 223 else 224 { // not dedicated server 225 if (!ogre_->loadRenderer()) // creates the render window 226 return false; 227 228 // Calls the InputManager which sets up the input devices. 229 // The render window width and height are used to set up the mouse movement. 230 if (!InputManager::initialise(ogre_->getWindowHandle(), 231 ogre_->getWindowWidth(), ogre_->getWindowHeight(), true, true, true)) 232 return false; 233 234 // TODO: Spread this so that this call only initialises things needed for the GUI 235 if (!ogre_->initialiseResources()) 236 return false; 237 238 // TOOD: load the GUI here 239 // set InputManager to GUI mode 240 InputManager::setInputState(InputManager::IS_GUI); 241 // TODO: run GUI here 242 243 // The following lines depend very much on the GUI output, so they're probably misplaced here.. 244 245 InputManager::setInputState(InputManager::IS_NONE); 246 247 // create Ogre SceneManager 248 ogre_->createNewScene(); 249 250 if (!loadPlayground()) 251 return false; 252 } 247 253 248 254 switch (mode_) … … 256 262 return false; 257 263 break; 264 case DEDICATED: 265 if (!serverLoad()) 266 return false; 267 break; 258 268 default: 259 269 if (!standaloneLoad()) … … 272 282 bool Orxonox::loadPlayground() 273 283 { 274 ogre_->createNewScene(); 275 276 // Init audio 284 // Init audio 277 285 //auMan_ = new audio::AudioManager(); 278 286 //auMan_->ambientAdd("a1"); … … 346 354 Loader::open(startlevel); 347 355 348 349 Ogre::SceneManager* mSceneMgr = GraphicsEngine::getSingleton().getSceneManager();356 // HACK: shader stuff for presentation 357 /*Ogre::SceneManager* mSceneMgr = GraphicsEngine::getSingleton().getSceneManager(); 350 358 mSceneMgr->setAmbientLight(ColourValue(0.4,0.4,0.4)); 351 359 Ogre::Light* dirlight = mSceneMgr->createLight("Light1"); 352 360 353 354 355 356 dirlight->setSpecularColour(ColourValue(1.0, 1.0, 1.0));361 dirlight->setType(Ogre::Light::LT_DIRECTIONAL); 362 dirlight->setDirection(Vector3( 0, 1, 5 )); 363 dirlight->setDiffuseColour(ColourValue(0.6, 0.6, 0.4)); 364 dirlight->setSpecularColour(ColourValue(1.0, 1.0, 1.0));*/ 357 365 358 366 return true; … … 402 410 403 411 COUT(3) << "Orxonox: Starting the main loop." << std::endl; 404 while (!bAbort_) 405 { 406 // Pump messages in all registered RenderWindows 407 // This calls the WindowEventListener objects. 408 Ogre::WindowEventUtilities::messagePump(); 409 412 while (!bAbort_) 413 { 410 414 // get current time 411 415 unsigned long now = timer_->getMilliseconds(); … … 419 423 // show the current time in the HUD 420 424 // HUD::getSingleton().setTime(now); 421 if ( frameTime > 0.4f)425 if (mode_ != DEDICATED && frameTime > 0.4f) 422 426 { 423 427 HUD::getSingleton().setRenderTimeRatio(renderTime / frameTime); … … 435 439 // don't forget to call _fireFrameStarted in ogre to make sure 436 440 // everything goes smoothly 437 if(mode_!=DEDICATED) 438 ogreRoot._fireFrameStarted(evt); 441 ogreRoot._fireFrameStarted(evt); 439 442 440 443 // get current time … … 442 445 calculateEventTime(now, eventTimes[2]); 443 446 444 if(mode_!=DEDICATED) 445 ogreRoot._updateAllRenderTargets(); // only render in non-server mode 447 if (mode_ != DEDICATED) 448 { 449 // Pump messages in all registered RenderWindows 450 // This calls the WindowEventListener objects. 451 Ogre::WindowEventUtilities::messagePump(); 452 453 // render 454 ogreRoot._updateAllRenderTargets(); 455 } 446 456 447 457 // get current time … … 453 463 454 464 // again, just to be sure ogre works fine 455 if(mode_!=DEDICATED)456 ogreRoot._fireFrameEnded(evt);457 458 459 if (mode_ ==CLIENT)465 ogreRoot._fireFrameEnded(evt); 466 //msleep(200); 467 } 468 469 if (mode_ == CLIENT) 460 470 network::Client::getSingleton()->closeConnection(); 461 else if (mode_ ==SERVER)471 else if (mode_ == SERVER) 462 472 server_g->close(); 463 473
Note: See TracChangeset
for help on using the changeset viewer.