Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 926


Ignore:
Timestamp:
Mar 26, 2008, 1:44:51 PM (16 years ago)
Author:
rgrieder
Message:
Location:
code/branches/network
Files:
2 deleted
4 edited

Legend:

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

    r919 r926  
    3737#include <OgreRenderWindow.h>
    3838
     39#include "core/CoreIncludes.h"
    3940#include "core/Debug.h"
    4041#include "GraphicsEngine.h"
     
    4748  GraphicsEngine::GraphicsEngine()
    4849  {
     50    RegisterObject(GraphicsEngine);
     51    //this->bOverwritePath_ = false;
     52    this->setConfigValues();
    4953    // set to standard values
    5054    this->configPath_ = "";
    51     this->dataPath_ = "";
    5255    this->root_ = 0;
    5356    this->scene_ = 0;
     
    5861  GraphicsEngine::~GraphicsEngine()
    5962  {
     63  }
     64
     65  void GraphicsEngine::setConfigValues()
     66  {
     67    SetConfigValue(dataPath_, dataPath_).description("relative path to media data");
     68
    6069  }
    6170
     
    9099  }
    91100
    92   bool GraphicsEngine::load()
     101  bool GraphicsEngine::load(std::string dataPath)
    93102  {
     103    // temporary overwrite of dataPath, change ini file for permanent change
     104    if( dataPath != "" )
     105      dataPath_ = dataPath;
    94106    loadRessourceLocations(this->dataPath_);
    95107    if (!root_->restoreConfig() && !root_->showConfigDialog())
     
    103115    this->renderWindow_ = root_->getAutoCreatedWindow();
    104116    TextureManager::getSingleton().setDefaultNumMipmaps(5);
     117    //TODO: Do NOT load all the groups, why are we doing that? And do we really do that? initialise != load...
    105118    ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
    106119  }
  • code/branches/network/src/orxonox/GraphicsEngine.h

    r919 r926  
    1414
    1515#include "OrxonoxPrereqs.h"
     16#include "core/BaseObject.h"
    1617
    1718
     
    2122   * graphics engine manager class
    2223 */
    23   class _OrxonoxExport GraphicsEngine {
     24  class _OrxonoxExport GraphicsEngine : public BaseObject
     25  {
    2426    public:
    2527      GraphicsEngine();
     
    2729      // find a better way for this
    2830      inline Ogre::Root* getRoot() { return root_; };
     31      void setConfigValues();
    2932      void setup();
    30       bool load();
     33      bool load(std::string path);
    3134      void loadRessourceLocations(std::string path);
    3235      Ogre::SceneManager* getSceneManager();
     
    4548      Ogre::SceneManager* scene_;       //!< scene manager of the game
    4649      Ogre::RenderWindow* renderWindow_;//!< the current render window
     50      //bool               bOverwritePath_; //!< overwrites path
    4751
    4852  };
  • 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
  • code/branches/network/src/orxonox/Orxonox.h

    r922 r926  
    99
    1010#include <string>
    11 #include <deque>
    1211
    1312#include <OgrePrerequisites.h>
    14 #include <OIS/OISPrereqs.h>
     13//#include <OIS/OISPrereqs.h>
    1514
    1615#include "OrxonoxPrereqs.h"
     
    4342      inline GraphicsEngine* getOgrePointer()              { return ogre_; };
    4443      inline audio::AudioManager* getAudioManagerPointer() { return auMan_; };
    45       //inline OIS::Keyboard* getKeyboard()                  { return this->keyboard_; }
    46       //inline OIS::Mouse* getMouse()                        { return this->mouse_; }
    4744      inline BulletManager* getBulletMgr()                 { return this->bulletMgr_; }
    4845
     
    5855      void clientStart();
    5956      void standaloneStart();
    60       void defineResources();
    61       void setupRenderSystem();
    62       void createRenderWindow();
    63       void initializeResourceGroups();
     57
    6458      void createScene(void);
    65       void setupScene();
    6659      void setupInputSystem();
    6760      void startRenderLoop();
    68       void updateTimers(float);
    6961      float calculateEventTime(unsigned long, std::deque<unsigned long>&);
    7062
     
    7466      GraphicsEngine*       ogre_;          //!< our dearest graphics engine <3
    7567      std::string           dataPath_;      //!< path to data
    76 //      loader::LevelLoader*  loader_;        //!< level loader builds the scene
    7768      audio::AudioManager*  auMan_;         //!< audio manager
    7869      BulletManager*        bulletMgr_;     //!< Keeps track of the thrown bullets
    79       static Orxonox*       singletonRef_;
    8070      InputHandler*         inputHandler_;
    81       //OIS::Keyboard*        keyboard_;
    82       //OIS::Mouse*           mouse_;
    83       //OIS::InputManager*    inputManager_;
    84       OrxListener*          frameListener_;
    8571      Ogre::Root*           root_;
    8672      // TODO: make this a config-value by creating a config class for orxonox
     
    8874      // little hack to actually show something dynamic in the HUD
    8975      HUD*                  orxonoxHUD_;
    90       bool                  bAbort_;
     76      bool                  bAbort_;        //!< aborts the render loop if true
    9177
    9278      // this is used to identify the mode (server/client/...) we're in
Note: See TracChangeset for help on using the changeset viewer.