Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/FICN/src/orxonox/graphicsEngine.cc @ 576

Last change on this file since 576 was 560, checked in by landauf, 17 years ago
  • changed output from std::cout to COUT(level)
  • added SoftDebugLevel config-variable (its a hack, but it works fine)
File size: 3.5 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *
4 *
5 *   License notice:
6 *
7 *   This program is free software; you can redistribute it and/or
8 *   modify it under the terms of the GNU General Public License
9 *   as published by the Free Software Foundation; either version 2
10 *   of the License, or (at your option) any later version.
11 *
12 *   This program is distributed in the hope that it will be useful,
13 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 *   GNU General Public License for more details.
16 *
17 *   You should have received a copy of the GNU General Public License
18 *   along with this program; if not, write to the Free Software
19 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 *
21 *   Author:
22 *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007
23 *   Co-authors:
24 *      ...
25 *
26 */
27 /**
28    @file orxonox.cc
29    @brief Orxonox class
30  */
31
32#include "graphicsEngine.h"
33
34#include <OgreRoot.h>
35#include <OgreConfigFile.h>
36#include <OgreTextureManager.h>
37#include "core/Debug.h"
38
39
40namespace orxonox {
41
42  using namespace Ogre;
43
44  GraphicsEngine::GraphicsEngine()
45  {
46    // set to standard values
47    this->configPath_ = "";
48    this->dataPath_ = "";
49    scene_ = NULL;
50  }
51
52
53  GraphicsEngine::~GraphicsEngine()
54  {
55  }
56
57  void GraphicsEngine::setup()
58  {
59    //TODO: Check if file exists (maybe not here)
60/*#ifndef OGRE_STATIC_LIB
61    root_ = new Root(configPath_ + "plugins.cfg", configPath_ + "ogre.cfg",
62                     configPath_ + "Ogre.log");
63#else
64    root_ = new Root(NULL, configPath_ + "ogre.cfg", configPath_ + "Ogre.log");
65#endif*/
66    root_ = new Root();
67  }
68
69  /**
70   * @return scene manager
71   */
72  SceneManager* GraphicsEngine::getSceneManager()
73  {
74    if(!scene_)
75    {
76      scene_ = root_->createSceneManager(ST_GENERIC, "Default SceneManager");
77      COUT(3) << "Info: Created SceneMan: " << scene_ << std::endl;
78    }
79    return scene_;
80  }
81
82  bool GraphicsEngine::load()
83  {
84    loadRessourceLocations(this->dataPath_);
85    if (!root_->restoreConfig() && !root_->showConfigDialog())
86      return false;
87    return true;
88  }
89
90  void GraphicsEngine::startRender()
91  {
92    root_->initialise(true, "OrxonoxV2");
93    TextureManager::getSingleton().setDefaultNumMipmaps(5);
94    ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
95  }
96
97  void GraphicsEngine::loadRessourceLocations(std::string dataPath)
98  {
99    //TODO: Specify layout of data file and maybe use xml-loader
100    //TODO: Work with ressource groups (should be generated by a special loader)
101    // Load resource paths from data file using configfile ressource type
102    ConfigFile cf;
103    cf.load(dataPath + "resources.cfg");
104
105    // Go through all sections & settings in the file
106    ConfigFile::SectionIterator seci = cf.getSectionIterator();
107
108    String secName, typeName, archName;
109    while (seci.hasMoreElements())
110    {
111      secName = seci.peekNextKey();
112      ConfigFile::SettingsMultiMap *settings = seci.getNext();
113      ConfigFile::SettingsMultiMap::iterator i;
114      for (i = settings->begin(); i != settings->end(); ++i)
115      {
116        typeName = i->first; // for instance "FileSystem" or "Zip"
117        archName = i->second; // name (and location) of archive
118
119        ResourceGroupManager::getSingleton().addResourceLocation(
120                                           String(dataPath + archName),
121                                           typeName, secName);
122      }
123    }
124  }
125
126
127}
Note: See TracBrowser for help on using the repository browser.