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