Changeset 1243 for code/branches/ogre/src/orxonox/GraphicsEngine.cc
- Timestamp:
- May 7, 2008, 12:11:25 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/ogre/src/orxonox/GraphicsEngine.cc
r1220 r1243 44 44 #include "core/ConfigValueIncludes.h" 45 45 #include "core/Debug.h" 46 #include "core/TclBind.h"47 46 48 47 … … 65 64 { 66 65 RegisterObject(GraphicsEngine); 67 //this->bOverwritePath_ = false;68 this->setConfigValues();69 66 // set to standard values 70 67 this->configPath_ = ""; … … 72 69 this->scene_ = 0; 73 70 this->renderWindow_ = 0; 71 this->setConfigValues(); 74 72 COUT(4) << "*** GraphicsEngine: Constructed" << std::endl; 75 73 } … … 113 111 SetConfigValue(ogreLogLevelNormal_ , 4).description("Corresponding orxonox debug level for ogre Normal"); 114 112 SetConfigValue(ogreLogLevelCritical_, 2).description("Corresponding orxonox debug level for ogre Critical"); 115 116 TclBind::getInstance().setDataPath(this->dataPath_);117 113 } 118 114 … … 120 116 @brief Creates the Ogre Root object and sets up the ogre log. 121 117 */ 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 124 128 //TODO: Check if file exists (maybe not here) 125 /*#ifndef OGRE_STATIC_LIB126 root_ = new Ogre::Root(configPath_ + "plugins.cfg", configPath_ + "ogre.cfg",127 configPath_ + "Ogre.log");128 #else129 root_ = new Ogre::Root(NULL, configPath_ + "ogre.cfg", configPath_ + "Ogre.log");130 #endif*/131 129 #if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC && defined(_DEBUG) 132 130 std::string plugin_filename = "plugins_d.cfg"; … … 158 156 root_ = new Ogre::Root(plugin_filename); 159 157 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 183 162 return true; 184 163 } 185 164 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() 196 166 { 197 167 //TODO: Specify layout of data file and maybe use xml-loader … … 199 169 // Load resource paths from data file using configfile ressource type 200 170 Ogre::ConfigFile cf; 201 cf.load(dataPath + "resources.cfg");171 cf.load(dataPath_ + "resources.cfg"); 202 172 203 173 // Go through all sections & settings in the file … … 216 186 217 187 Ogre::ResourceGroupManager::getSingleton().addResourceLocation( 218 std::string(dataPath + archName),188 std::string(dataPath_ + archName), 219 189 typeName, secName); 220 190 } 221 191 } 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; 222 223 } 223 224 … … 291 292 } 292 293 OutputHandler::getOutStream().setOutputLevel(orxonoxLevel) 293 << " ***Ogre: " << message << std::endl;294 << "Ogre: " << message << std::endl; 294 295 } 295 296
Note: See TracChangeset
for help on using the changeset viewer.