Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/FICN/src/orxonox/GraphicsEngine.cc @ 715

Last change on this file since 715 was 715, checked in by rgrieder, 16 years ago
  • the master has spoken…
  • misc/String.h is not anymore..
File size: 3.6 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#if defined(_DEBUG) && defined(WIN32)
67    std::string plugin_filename = "plugins_d.cfg";
68#else
69    std::string plugin_filename = "plugins.cfg";
70#endif
71    root_ = new Root(plugin_filename);
72  }
73
74  /**
75   * @return scene manager
76   */
77  SceneManager* GraphicsEngine::getSceneManager()
78  {
79    if(!scene_)
80    {
81      scene_ = root_->createSceneManager(ST_GENERIC, "Default SceneManager");
82      COUT(3) << "Info: Created SceneMan: " << scene_ << std::endl;
83    }
84    return scene_;
85  }
86
87  bool GraphicsEngine::load()
88  {
89    loadRessourceLocations(this->dataPath_);
90    if (!root_->restoreConfig() && !root_->showConfigDialog())
91      return false;
92    return true;
93  }
94
95  void GraphicsEngine::startRender()
96  {
97    root_->initialise(true, "OrxonoxV2");
98    TextureManager::getSingleton().setDefaultNumMipmaps(5);
99    ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
100  }
101
102  void GraphicsEngine::loadRessourceLocations(std::string dataPath)
103  {
104    //TODO: Specify layout of data file and maybe use xml-loader
105    //TODO: Work with ressource groups (should be generated by a special loader)
106    // Load resource paths from data file using configfile ressource type
107    ConfigFile cf;
108    cf.load(dataPath + "resources.cfg");
109
110    // Go through all sections & settings in the file
111    ConfigFile::SectionIterator seci = cf.getSectionIterator();
112
113    std::string secName, typeName, archName;
114    while (seci.hasMoreElements())
115    {
116      secName = seci.peekNextKey();
117      ConfigFile::SettingsMultiMap *settings = seci.getNext();
118      ConfigFile::SettingsMultiMap::iterator i;
119      for (i = settings->begin(); i != settings->end(); ++i)
120      {
121        typeName = i->first; // for instance "FileSystem" or "Zip"
122        archName = i->second; // name (and location) of archive
123
124        ResourceGroupManager::getSingleton().addResourceLocation(
125                                           std::string(dataPath + archName),
126                                           typeName, secName);
127      }
128    }
129  }
130
131
132}
Note: See TracBrowser for help on using the repository browser.