Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/releases/0.1.0/src/orxonox/GraphicsEngine.cc @ 1488

Last change on this file since 1488 was 790, checked in by nicolasc, 17 years ago

merged FICN back into trunk
awaiting release.

File size: 3.7 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 "OrxonoxStableHeaders.h"
33
34#include <OgreRoot.h>
35#include <OgreConfigFile.h>
36#include <OgreTextureManager.h>
37
38#include "core/Debug.h"
39#include "GraphicsEngine.h"
40
41
42namespace orxonox {
43
44  using namespace Ogre;
45
46  GraphicsEngine::GraphicsEngine()
47  {
48    // set to standard values
49    this->configPath_ = "";
50    this->dataPath_ = "";
51    scene_ = NULL;
52  }
53
54
55  GraphicsEngine::~GraphicsEngine()
56  {
57  }
58
59  void GraphicsEngine::setup()
60  {
61    //TODO: Check if file exists (maybe not here)
62/*#ifndef OGRE_STATIC_LIB
63    root_ = new Root(configPath_ + "plugins.cfg", configPath_ + "ogre.cfg",
64                     configPath_ + "Ogre.log");
65#else
66    root_ = new Root(NULL, configPath_ + "ogre.cfg", configPath_ + "Ogre.log");
67#endif*/
68#if defined(_DEBUG) && defined(WIN32)
69    std::string plugin_filename = "plugins_d.cfg";
70#else
71    std::string plugin_filename = "plugins.cfg";
72#endif
73    root_ = new Root(plugin_filename);
74  }
75
76  /**
77   * @return scene manager
78   */
79  SceneManager* GraphicsEngine::getSceneManager()
80  {
81    if(!scene_)
82    {
83      scene_ = root_->createSceneManager(ST_GENERIC, "Default SceneManager");
84      COUT(3) << "Info: Created SceneMan: " << scene_ << std::endl;
85    }
86    return scene_;
87  }
88
89  bool GraphicsEngine::load()
90  {
91    loadRessourceLocations(this->dataPath_);
92    if (!root_->restoreConfig() && !root_->showConfigDialog())
93      return false;
94    return true;
95  }
96
97  void GraphicsEngine::startRender()
98  {
99    root_->initialise(true, "OrxonoxV2");
100    TextureManager::getSingleton().setDefaultNumMipmaps(5);
101    ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
102  }
103
104  void GraphicsEngine::loadRessourceLocations(std::string dataPath)
105  {
106    //TODO: Specify layout of data file and maybe use xml-loader
107    //TODO: Work with ressource groups (should be generated by a special loader)
108    // Load resource paths from data file using configfile ressource type
109    ConfigFile cf;
110    cf.load(dataPath + "resources.cfg");
111
112    // Go through all sections & settings in the file
113    ConfigFile::SectionIterator seci = cf.getSectionIterator();
114
115    std::string secName, typeName, archName;
116    while (seci.hasMoreElements())
117    {
118      secName = seci.peekNextKey();
119      ConfigFile::SettingsMultiMap *settings = seci.getNext();
120      ConfigFile::SettingsMultiMap::iterator i;
121      for (i = settings->begin(); i != settings->end(); ++i)
122      {
123        typeName = i->first; // for instance "FileSystem" or "Zip"
124        archName = i->second; // name (and location) of archive
125
126        ResourceGroupManager::getSingleton().addResourceLocation(
127                                           std::string(dataPath + archName),
128                                           typeName, secName);
129      }
130    }
131  }
132
133
134}
Note: See TracBrowser for help on using the repository browser.