Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 543 was 473, checked in by bknecht, 17 years ago

should work again, sorry

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