Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 7, 2008, 12:11:25 AM (17 years ago)
Author:
rgrieder
Message:
  • rearranged function calls in Orxonox.cc has yet to be looked at clearly, commented and COUTed
  • works so far, but using 3 little hacks… in hacky classes
File:
1 edited

Legend:

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

    r1220 r1243  
    4444#include "core/ConfigValueIncludes.h"
    4545#include "core/Debug.h"
    46 #include "core/TclBind.h"
    4746
    4847
     
    6564  {
    6665    RegisterObject(GraphicsEngine);
    67     //this->bOverwritePath_ = false;
    68     this->setConfigValues();
    6966    // set to standard values
    7067    this->configPath_ = "";
     
    7269    this->scene_ = 0;
    7370    this->renderWindow_ = 0;
     71    this->setConfigValues();
    7472    COUT(4) << "*** GraphicsEngine: Constructed" << std::endl;
    7573  }
     
    113111    SetConfigValue(ogreLogLevelNormal_  , 4).description("Corresponding orxonox debug level for ogre Normal");
    114112    SetConfigValue(ogreLogLevelCritical_, 2).description("Corresponding orxonox debug level for ogre Critical");
    115 
    116     TclBind::getInstance().setDataPath(this->dataPath_);
    117113  }
    118114
     
    120116    @brief Creates the Ogre Root object and sets up the ogre log.
    121117  */
    122   void GraphicsEngine::setup()
    123   {
     118  bool GraphicsEngine::setup(std::string& dataPath)
     119  {
     120    // temporary overwrite of dataPath, change ini file for permanent change
     121    if (dataPath != "")
     122      dataPath_ = dataPath;
     123    if (dataPath_ == "")
     124      return false;
     125    if (dataPath_[dataPath_.size() - 1] != '/')
     126      dataPath_ += "/";
     127
    124128    //TODO: Check if file exists (maybe not here)
    125 /*#ifndef OGRE_STATIC_LIB
    126     root_ = new Ogre::Root(configPath_ + "plugins.cfg", configPath_ + "ogre.cfg",
    127                      configPath_ + "Ogre.log");
    128 #else
    129     root_ = new Ogre::Root(NULL, configPath_ + "ogre.cfg", configPath_ + "Ogre.log");
    130 #endif*/
    131129#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC && defined(_DEBUG)
    132130    std::string plugin_filename = "plugins_d.cfg";
     
    158156    root_ = new Ogre::Root(plugin_filename);
    159157    COUT(4) << "*** GraphicsEngine: Creating Ogre Root done" << std::endl;
    160   }
    161 
    162   /**
    163    * @return scene manager
    164    */
    165   Ogre::SceneManager* GraphicsEngine::getSceneManager()
    166   {
    167     if(!scene_)
    168     {
    169       scene_ = root_->createSceneManager(Ogre::ST_GENERIC, "Default SceneManager");
    170       COUT(3) << "Info: Created SceneMan: " << scene_ << std::endl;
    171     }
    172     return scene_;
    173   }
    174 
    175   bool GraphicsEngine::load(std::string dataPath)
    176   {
    177     // temporary overwrite of dataPath, change ini file for permanent change
    178     if( dataPath != "" )
    179       dataPath_ = dataPath + "/";
    180     loadRessourceLocations(this->dataPath_);
    181     if (!root_->restoreConfig() && !root_->showConfigDialog())
    182       return false;
     158
     159    // specify where Ogre has to look for resources. This call doesn't parse anything yet!
     160    declareRessourceLocations();
     161
    183162    return true;
    184163  }
    185164
    186   void GraphicsEngine::initialise()
    187   {
    188     this->renderWindow_ = root_->initialise(true, "OrxonoxV2");
    189     Ogre::WindowEventUtilities::addWindowEventListener(this->renderWindow_, this);
    190     Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
    191     //TODO: Do NOT load all the groups, why are we doing that? And do we really do that? initialise != load...
    192     Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
    193   }
    194 
    195   void GraphicsEngine::loadRessourceLocations(std::string dataPath)
     165  void GraphicsEngine::declareRessourceLocations()
    196166  {
    197167    //TODO: Specify layout of data file and maybe use xml-loader
     
    199169    // Load resource paths from data file using configfile ressource type
    200170    Ogre::ConfigFile cf;
    201     cf.load(dataPath + "resources.cfg");
     171    cf.load(dataPath_ + "resources.cfg");
    202172
    203173    // Go through all sections & settings in the file
     
    216186
    217187        Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
    218                                            std::string(dataPath + archName),
     188                                           std::string(dataPath_ + archName),
    219189                                           typeName, secName);
    220190      }
    221191    }
     192  }
     193
     194  bool GraphicsEngine::loadRenderer()
     195  {
     196    if (!root_->restoreConfig() && !root_->showConfigDialog())
     197      return false;
     198
     199    this->renderWindow_ = root_->initialise(true, "OrxonoxV2");
     200    if (!root_->isInitialised())
     201      return false;
     202    Ogre::WindowEventUtilities::addWindowEventListener(this->renderWindow_, this);
     203    Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
     204    return true;
     205  }
     206
     207  void GraphicsEngine::initialiseResources()
     208  {
     209    //TODO: Do NOT load all the groups, why are we doing that? And do we really do that? initialise != load...
     210    Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
     211  }
     212
     213  /**
     214   * @brief Creates the SceneManager
     215   */
     216  bool GraphicsEngine::createNewScene()
     217  {
     218    if (scene_)
     219      return false;
     220    scene_ = root_->createSceneManager(Ogre::ST_GENERIC, "Default SceneManager");
     221    COUT(3) << "Info: Created SceneManager: " << scene_ << std::endl;
     222    return true;
    222223  }
    223224
     
    291292    }
    292293    OutputHandler::getOutStream().setOutputLevel(orxonoxLevel)
    293         << "*** Ogre: " << message << std::endl;
     294        << "Ogre: " << message << std::endl;
    294295  }
    295296
Note: See TracChangeset for help on using the changeset viewer.