[1505] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
| 3 | * > www.orxonox.net < |
---|
| 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 | |
---|
| 29 | #include "OrxonoxStableHeaders.h" |
---|
| 30 | #include "Ambient.h" |
---|
| 31 | |
---|
| 32 | #include <vector> |
---|
| 33 | #include <string> |
---|
| 34 | |
---|
| 35 | #include <OgreSceneManager.h> |
---|
| 36 | |
---|
| 37 | #include "tinyxml/tinyxml.h" |
---|
| 38 | #include "util/SubString.h" |
---|
| 39 | #include "util/Convert.h" |
---|
| 40 | #include "util/Math.h" |
---|
[1747] | 41 | #include "util/Debug.h" |
---|
[1505] | 42 | #include "core/CoreIncludes.h" |
---|
| 43 | #include "core/XMLPort.h" |
---|
| 44 | #include "core/ConsoleCommand.h" |
---|
[1755] | 45 | #include "Settings.h" |
---|
[1747] | 46 | #include "GraphicsEngine.h" |
---|
[1505] | 47 | |
---|
| 48 | namespace orxonox |
---|
| 49 | { |
---|
[1747] | 50 | SetConsoleCommandAlias(Ambient, setAmbientLightTest, "setAmbientLight", false).defaultValues(ColourValue(1, 1, 1, 1)).accessLevel(AccessLevel::Offline); |
---|
[1505] | 51 | |
---|
| 52 | CreateFactory(Ambient); |
---|
| 53 | |
---|
| 54 | Ambient* Ambient::instance_s; |
---|
| 55 | |
---|
| 56 | Ambient::Ambient() |
---|
| 57 | { |
---|
| 58 | RegisterObject(Ambient); |
---|
| 59 | Ambient::instance_s = this; |
---|
| 60 | registerAllVariables(); |
---|
| 61 | } |
---|
| 62 | |
---|
| 63 | Ambient::~Ambient() |
---|
| 64 | { |
---|
| 65 | } |
---|
| 66 | |
---|
[1747] | 67 | bool Ambient::create() |
---|
| 68 | { |
---|
[1755] | 69 | if (Settings::showsGraphics()) |
---|
| 70 | GraphicsEngine::getInstance().getLevelSceneManager()->setAmbientLight(ambientLight_); |
---|
[1747] | 71 | return Synchronisable::create(); |
---|
[1505] | 72 | } |
---|
[1747] | 73 | |
---|
| 74 | void Ambient::registerAllVariables() |
---|
| 75 | { |
---|
| 76 | registerVar(&ambientLight_, sizeof(ColourValue), network::DATA); |
---|
[1505] | 77 | } |
---|
[1625] | 78 | |
---|
| 79 | void Ambient::setAmbientLight(const ColourValue& colour) |
---|
[1505] | 80 | { |
---|
[1755] | 81 | if (Settings::showsGraphics()) |
---|
| 82 | GraphicsEngine::getInstance().getLevelSceneManager()->setAmbientLight(colour); |
---|
| 83 | ambientLight_ = colour; |
---|
[1625] | 84 | } |
---|
[1505] | 85 | |
---|
| 86 | /** |
---|
[1755] | 87 | @brief |
---|
| 88 | XML loading and saving. |
---|
| 89 | @param |
---|
| 90 | xmlelement The XML-element |
---|
| 91 | @param |
---|
| 92 | loading Loading (true) or saving (false) |
---|
| 93 | @return |
---|
| 94 | The XML-element |
---|
[1505] | 95 | */ |
---|
| 96 | void Ambient::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
---|
| 97 | { |
---|
[1747] | 98 | SUPER(Ambient, XMLPort, xmlelement, mode); |
---|
[1505] | 99 | |
---|
[1747] | 100 | XMLPortParam(Ambient, "colourvalue", setAmbientLight, getAmbienetLight, xmlelement, mode); |
---|
[1505] | 101 | create(); |
---|
| 102 | } |
---|
| 103 | } |
---|