Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Mar 26, 2008, 1:44:51 PM (16 years ago)
Author:
rgrieder
Message:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/network/src/orxonox/Orxonox.cc

    r923 r926  
    3535
    3636//****** OGRE ******
    37 #include <OgreException.h>
     37//#include <OgreException.h>
    3838#include <OgreFrameListener.h>
    3939#include <OgreRoot.h>
    40 #include <OgreRenderWindow.h>
    41 #include <OgreTextureManager.h>
    42 #include <OgreResourceGroupManager.h>
    43 #include <OgreConfigFile.h>
    4440#include <OgreOverlay.h>
    4541#include <OgreOverlayManager.h>
     
    4743#include <OgreWindowEventUtilities.h>
    4844
    49 //****** OIS *******
    50 #include <OIS/OIS.h>
    51 
    5245//****** STD *******
    53 #include <iostream>
    54 #include <exception>
     46//#include <iostream>
     47//#include <exception>
     48#include <deque>
    5549
    5650//***** ORXONOX ****
    5751//misc
    58 #include "util/Sleep.h"
     52//#include "util/Sleep.h"
    5953
    6054// audio
     
    6862
    6963// objects
    70 #include "tools/Timer.h"
    7164#include "core/ArgReader.h"
    7265#include "core/Debug.h"
     
    7568#include "core/Tickable.h"
    7669#include "hud/HUD.h"
     70#include "tools/Timer.h"
    7771#include "objects/weapon/BulletManager.h"
    7872
     
    8377namespace orxonox
    8478{
    85   /// init static singleton reference of Orxonox
    86   Orxonox* Orxonox::singletonRef_ = NULL;
    87 
    8879  /**
    8980   * create a new instance of Orxonox
     
    9485    this->dataPath_ = "";
    9586    this->auMan_ = 0;
    96     this->singletonRef_ = 0;
    97     //this->keyboard_ = 0;
    98     //this->mouse_ = 0;
    99     //this->inputManager_ = 0;
    10087    this->inputHandler_ = 0;
    101     this->frameListener_ = 0;
    10288    this->root_ = 0;
    103     // turn frame smoothing on by setting a value different from 0
     89    // turn on frame smoothing by setting a value different from 0
    10490    this->frameSmoothingTime_ = 0.0f;
    10591    this->bAbort_ = false;
     
    126112    //TODO: give config file to Ogre
    127113    std::string mode;
    128    
    129    
     114
    130115    ArgReader ar = ArgReader(argc, argv);
    131116    ar.checkArgument("mode", mode, false);
     
    197182    Factory::createClassHierarchy();
    198183    createScene();
    199     setupScene();
    200184    setupInputSystem();
    201185   
     
    211195    Factory::createClassHierarchy();
    212196    createScene();
    213     setupScene();
    214197    setupInputSystem();
    215198   
     
    222205  Orxonox* Orxonox::getSingleton()
    223206  {
    224     if (!singletonRef_)
    225       singletonRef_ = new Orxonox();
    226     return singletonRef_;
     207    static Orxonox theOnlyInstance;
     208    return &theOnlyInstance;
    227209  }
    228210
     
    252234    ogre_->setup();
    253235    root_ = ogre_->getRoot();
    254     if(!ogre_->load()) die(/* unable to load */);
     236    if(!ogre_->load(this->dataPath_)) die(/* unable to load */);
    255237   
    256238    server_g = new network::Server();
     
    267249    else
    268250      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 */);
    270252  }
    271253 
     
    277259    ogre_->setup();
    278260    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 */);
    326262  }
    327263
    328264  void Orxonox::createScene(void)
    329265  {
    330         // Init audio
     266          // Init audio
    331267    auMan_ = new audio::AudioManager();
    332268
     
    334270
    335271    // load this file from config
    336 //    loader_ = new loader::LevelLoader("sample.oxw");
    337 //    loader_->loadLevel();
    338272    Level* startlevel = new Level("levels/sample.oxw");
    339273    Loader::open(startlevel);
    340274
    341275    Ogre::Overlay* hudOverlay = Ogre::OverlayManager::getSingleton().getByName("Orxonox/HUD1.2");
    342     //HUD* orxonoxHud;
    343276    orxonoxHUD_ = new HUD();
    344277    orxonoxHUD_->setEnergyValue(20);
     
    350283    auMan_->ambientAdd("a2");
    351284    auMan_->ambientAdd("a3");
    352                                 //auMan->ambientAdd("ambient1");
     285    //auMan->ambientAdd("ambient1");
    353286    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 */
    373287  }
    374288
Note: See TracChangeset for help on using the changeset viewer.