Changeset 926 for code/branches/network/src/orxonox/Orxonox.cc
- Timestamp:
- Mar 26, 2008, 1:44:51 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/src/orxonox/Orxonox.cc
r923 r926 35 35 36 36 //****** OGRE ****** 37 #include <OgreException.h>37 //#include <OgreException.h> 38 38 #include <OgreFrameListener.h> 39 39 #include <OgreRoot.h> 40 #include <OgreRenderWindow.h>41 #include <OgreTextureManager.h>42 #include <OgreResourceGroupManager.h>43 #include <OgreConfigFile.h>44 40 #include <OgreOverlay.h> 45 41 #include <OgreOverlayManager.h> … … 47 43 #include <OgreWindowEventUtilities.h> 48 44 49 //****** OIS *******50 #include <OIS/OIS.h>51 52 45 //****** STD ******* 53 #include <iostream> 54 #include <exception> 46 //#include <iostream> 47 //#include <exception> 48 #include <deque> 55 49 56 50 //***** ORXONOX **** 57 51 //misc 58 #include "util/Sleep.h"52 //#include "util/Sleep.h" 59 53 60 54 // audio … … 68 62 69 63 // objects 70 #include "tools/Timer.h"71 64 #include "core/ArgReader.h" 72 65 #include "core/Debug.h" … … 75 68 #include "core/Tickable.h" 76 69 #include "hud/HUD.h" 70 #include "tools/Timer.h" 77 71 #include "objects/weapon/BulletManager.h" 78 72 … … 83 77 namespace orxonox 84 78 { 85 /// init static singleton reference of Orxonox86 Orxonox* Orxonox::singletonRef_ = NULL;87 88 79 /** 89 80 * create a new instance of Orxonox … … 94 85 this->dataPath_ = ""; 95 86 this->auMan_ = 0; 96 this->singletonRef_ = 0;97 //this->keyboard_ = 0;98 //this->mouse_ = 0;99 //this->inputManager_ = 0;100 87 this->inputHandler_ = 0; 101 this->frameListener_ = 0;102 88 this->root_ = 0; 103 // turn frame smoothing onby setting a value different from 089 // turn on frame smoothing by setting a value different from 0 104 90 this->frameSmoothingTime_ = 0.0f; 105 91 this->bAbort_ = false; … … 126 112 //TODO: give config file to Ogre 127 113 std::string mode; 128 129 114 130 115 ArgReader ar = ArgReader(argc, argv); 131 116 ar.checkArgument("mode", mode, false); … … 197 182 Factory::createClassHierarchy(); 198 183 createScene(); 199 setupScene();200 184 setupInputSystem(); 201 185 … … 211 195 Factory::createClassHierarchy(); 212 196 createScene(); 213 setupScene();214 197 setupInputSystem(); 215 198 … … 222 205 Orxonox* Orxonox::getSingleton() 223 206 { 224 if (!singletonRef_) 225 singletonRef_ = new Orxonox(); 226 return singletonRef_; 207 static Orxonox theOnlyInstance; 208 return &theOnlyInstance; 227 209 } 228 210 … … 252 234 ogre_->setup(); 253 235 root_ = ogre_->getRoot(); 254 if(!ogre_->load( )) die(/* unable to load */);236 if(!ogre_->load(this->dataPath_)) die(/* unable to load */); 255 237 256 238 server_g = new network::Server(); … … 267 249 else 268 250 client_g = new network::Client(serverIp_, NETWORK_PORT); 269 if(!ogre_->load( )) die(/* unable to load */);251 if(!ogre_->load(this->dataPath_)) die(/* unable to load */); 270 252 } 271 253 … … 277 259 ogre_->setup(); 278 260 root_ = ogre_->getRoot(); 279 if(!ogre_->load()) die(/* unable to load */); 280 } 281 282 void Orxonox::defineResources() 283 { 284 std::string secName, typeName, archName; 285 Ogre::ConfigFile cf; 286 #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE 287 cf.load(macBundlePath() + "/Contents/Resources/resources.cfg"); 288 #else 289 cf.load(dataPath_ + "resources.cfg"); 290 #endif 291 292 Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator(); 293 while (seci.hasMoreElements()) 294 { 295 secName = seci.peekNextKey(); 296 Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext(); 297 Ogre::ConfigFile::SettingsMultiMap::iterator i; 298 for (i = settings->begin(); i != settings->end(); ++i) 299 { 300 typeName = i->first; 301 archName = i->second; 302 #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE 303 Ogre::ResourceGroupManager::getSingleton().addResourceLocation( std::string(macBundlePath() + "/" + archName), typeName, secName); 304 #else 305 Ogre::ResourceGroupManager::getSingleton().addResourceLocation( archName, typeName, secName); 306 #endif 307 } 308 } 309 } 310 311 void Orxonox::setupRenderSystem() 312 { 313 if (!root_->restoreConfig() && !root_->showConfigDialog()) 314 throw Ogre::Exception(52, "User canceled the config dialog!", "OrxApplication::setupRenderSystem()"); 315 } 316 317 void Orxonox::createRenderWindow() 318 { 319 root_->initialise(true, "OrxonoxV2"); 320 } 321 322 void Orxonox::initializeResourceGroups() 323 { 324 Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5); 325 Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups(); 261 if(!ogre_->load(this->dataPath_)) die(/* unable to load */); 326 262 } 327 263 328 264 void Orxonox::createScene(void) 329 265 { 330 // Init audio266 // Init audio 331 267 auMan_ = new audio::AudioManager(); 332 268 … … 334 270 335 271 // load this file from config 336 // loader_ = new loader::LevelLoader("sample.oxw");337 // loader_->loadLevel();338 272 Level* startlevel = new Level("levels/sample.oxw"); 339 273 Loader::open(startlevel); 340 274 341 275 Ogre::Overlay* hudOverlay = Ogre::OverlayManager::getSingleton().getByName("Orxonox/HUD1.2"); 342 //HUD* orxonoxHud;343 276 orxonoxHUD_ = new HUD(); 344 277 orxonoxHUD_->setEnergyValue(20); … … 350 283 auMan_->ambientAdd("a2"); 351 284 auMan_->ambientAdd("a3"); 352 285 //auMan->ambientAdd("ambient1"); 353 286 auMan_->ambientStart();*/ 354 }355 356 357 void Orxonox::setupScene()358 {359 // SceneManager *mgr = ogre_->getSceneManager();360 361 362 // SceneNode* node = (SceneNode*)mgr->getRootSceneNode()->getChild("OgreHeadNode");363 // SceneNode *node = mgr->getRootSceneNode()->createChildSceneNode("OgreHeadNode", Vector3(0,0,0));364 365 366 /*367 particle::ParticleInterface *e = new particle::ParticleInterface(mgr,"engine","Orxonox/strahl");368 e->particleSystem_->setParameter("local_space","true");369 e->setPositionOfEmitter(0, Vector3(0,-10,0));370 e->setDirection(Vector3(0,0,-1));371 e->addToSceneNode(node);372 */373 287 } 374 288
Note: See TracChangeset
for help on using the changeset viewer.