Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/objects/Ambient.cc @ 1163

Last change on this file since 1163 was 1064, checked in by rgrieder, 17 years ago
  • replaced all String2Number with ConvertValue
  • replaced all tokenize with SubString
  • dealt with warnings under msvc
  • removed some warnings by placing casts
  • bugfix in audio: local variable pushed into member variable std::vector
  • updated StableHeaders.h
File size: 2.8 KB
RevLine 
[513]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
[1056]3 *                    > www.orxonox.net <
[513]4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      ...
24 *   Co-authors:
25 *      ...
26 *
27 */
28
[786]29#include "OrxonoxStableHeaders.h"
[1039]30#include "Ambient.h"
[784]31
[708]32#include <vector>
[715]33#include <string>
[708]34
[507]35#include <OgreSceneManager.h>
36
[742]37#include "util/tinyxml/tinyxml.h"
[1064]38#include "util/SubString.h"
39#include "util/Convert.h"
[742]40#include "util/Math.h"
[1032]41#include "core/Debug.h"
42#include "core/CoreIncludes.h"
43#include "GraphicsEngine.h"
[871]44#include "core/XMLPort.h"
[1052]45#include "core/ConsoleCommand.h"
[507]46
47namespace orxonox
48{
[1052]49    ConsoleCommand(Ambient, setAmbientLightTest, AccessLevel::Offline, false).setDefaultValues(ColourValue(1, 1, 1, 1));
50
[507]51    CreateFactory(Ambient);
52
[1052]53    Ambient* Ambient::instance_s;
54
[507]55    Ambient::Ambient()
56    {
57        RegisterObject(Ambient);
[1052]58        Ambient::instance_s = this;
[507]59    }
60
61    Ambient::~Ambient()
62    {
63    }
64
65    void Ambient::loadParams(TiXmlElement* xmlElem)
66    {
67        if (xmlElem->Attribute("colourvalue"))
68        {
[1064]69        SubString colourvalues(xmlElem->Attribute("colourvalue"), ',');
[513]70
[507]71                float r, g, b;
[1064]72        convertValue<std::string, float>(&r, colourvalues[0]);
73        convertValue<std::string, float>(&g, colourvalues[1]);
74        convertValue<std::string, float>(&b, colourvalues[2]);
[513]75
[871]76                this->setAmbientLight(ColourValue(r, g, b));
[513]77
[560]78                COUT(4) << "Loader: Set ambient light: "<<r<<" " << g << " " << b  << std::endl << std::endl;
[513]79        }
[507]80   }
[871]81
82   void Ambient::setAmbientLight(const ColourValue& colour)
83   {
[1032]84        GraphicsEngine::getSingleton().getSceneManager()->setAmbientLight(colour);
[871]85   }
86
87    /**
88        @brief XML loading and saving.
89        @param xmlelement The XML-element
90        @param loading Loading (true) or saving (false)
91        @return The XML-element
92    */
[1052]93    void Ambient::XMLPort(Element& xmlelement, XMLPort::Mode mode)
[871]94    {
[1052]95        BaseObject::XMLPort(xmlelement, mode);
[871]96
[1052]97        XMLPortParamLoadOnly(Ambient, "colourvalue", setAmbientLight, xmlelement, mode);
[871]98    }
[507]99}
Note: See TracBrowser for help on using the repository browser.