[2072] | 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 | * Fabian 'x3n' Landau |
---|
| 24 | * Co-authors: |
---|
| 25 | * ... |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | #include "Billboard.h" |
---|
| 30 | |
---|
[2662] | 31 | #include <OgreBillboardSet.h> |
---|
| 32 | |
---|
[2072] | 33 | #include "core/CoreIncludes.h" |
---|
| 34 | #include "core/XMLPort.h" |
---|
[2896] | 35 | #include "core/GameMode.h" |
---|
[2072] | 36 | #include "objects/Scene.h" |
---|
| 37 | |
---|
| 38 | namespace orxonox |
---|
| 39 | { |
---|
| 40 | CreateFactory(Billboard); |
---|
| 41 | |
---|
[2662] | 42 | Billboard::Billboard(BaseObject* creator) : StaticEntity(creator) |
---|
[2072] | 43 | { |
---|
| 44 | RegisterObject(Billboard); |
---|
| 45 | |
---|
[2662] | 46 | this->material_ = ""; |
---|
| 47 | this->colour_ = ColourValue::White; |
---|
[3053] | 48 | // this->rotation_ = 0; |
---|
[2662] | 49 | |
---|
[2072] | 50 | this->registerVariables(); |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | Billboard::~Billboard() |
---|
| 54 | { |
---|
| 55 | if (this->isInitialized()) |
---|
| 56 | { |
---|
| 57 | if (this->isInitialized() && this->billboard_.getBillboardSet()) |
---|
[2662] | 58 | this->detachOgreObject(this->billboard_.getBillboardSet()); |
---|
[2072] | 59 | } |
---|
| 60 | } |
---|
| 61 | |
---|
| 62 | void Billboard::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
---|
| 63 | { |
---|
| 64 | SUPER(Billboard, XMLPort, xmlelement, mode); |
---|
| 65 | |
---|
| 66 | XMLPortParam(Billboard, "material", setMaterial, getMaterial, xmlelement, mode); |
---|
| 67 | XMLPortParam(Billboard, "colour", setColour, getColour, xmlelement, mode).defaultValues(ColourValue::White); |
---|
[3053] | 68 | // XMLPortParam(Billboard, "rotation", setRotation, getRotation, xmlelement, mode).defaultValues(0); |
---|
[2072] | 69 | } |
---|
| 70 | |
---|
| 71 | void Billboard::registerVariables() |
---|
| 72 | { |
---|
[2662] | 73 | registerVariable(this->material_, variableDirection::toclient, new NetworkCallback<Billboard>(this, &Billboard::changedMaterial)); |
---|
| 74 | registerVariable(this->colour_, variableDirection::toclient, new NetworkCallback<Billboard>(this, &Billboard::changedColour)); |
---|
[3053] | 75 | // registerVariable(this->rotation_, variableDirection::toclient, new NetworkCallback<Billboard>(this, &Billboard::changedRotation)); |
---|
[2072] | 76 | } |
---|
| 77 | |
---|
| 78 | void Billboard::changedMaterial() |
---|
| 79 | { |
---|
[2662] | 80 | if (this->material_ == "") |
---|
| 81 | return; |
---|
| 82 | |
---|
[2072] | 83 | if (!this->billboard_.getBillboardSet()) |
---|
| 84 | { |
---|
[2896] | 85 | if (this->getScene() && GameMode::showsGraphics()) |
---|
[2072] | 86 | { |
---|
| 87 | this->billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->material_, this->colour_, 1); |
---|
[2171] | 88 | if (this->billboard_.getBillboardSet()) |
---|
[2662] | 89 | this->attachOgreObject(this->billboard_.getBillboardSet()); |
---|
[2072] | 90 | this->billboard_.setVisible(this->isVisible()); |
---|
[3053] | 91 | // this->changedRotation(); |
---|
[2072] | 92 | } |
---|
| 93 | } |
---|
| 94 | else |
---|
| 95 | this->billboard_.setMaterial(this->material_); |
---|
| 96 | } |
---|
| 97 | |
---|
| 98 | void Billboard::changedColour() |
---|
| 99 | { |
---|
| 100 | if (!this->billboard_.getBillboardSet()) |
---|
| 101 | { |
---|
[2662] | 102 | /* |
---|
[2896] | 103 | if (this->getScene() && GameMode::showsGraphics() && (this->material_ != "")) |
---|
[2072] | 104 | { |
---|
| 105 | this->billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->material_, this->colour_, 1); |
---|
[2171] | 106 | if (this->billboard_.getBillboardSet()) |
---|
[2662] | 107 | this->attachOgreObject(this->billboard_.getBillboardSet()); |
---|
[2072] | 108 | this->billboard_.setVisible(this->isVisible()); |
---|
| 109 | } |
---|
[2662] | 110 | */ |
---|
[2072] | 111 | } |
---|
| 112 | else |
---|
| 113 | this->billboard_.setColour(this->colour_); |
---|
| 114 | } |
---|
[3053] | 115 | |
---|
| 116 | /* |
---|
| 117 | void Billboard::changedRotation() |
---|
| 118 | { |
---|
| 119 | if (this->billboard_.getBillboardSet()) |
---|
| 120 | this->billboard_.getBillboardSet()->setRotation(this->rotation_); |
---|
| 121 | } |
---|
| 122 | */ |
---|
[2072] | 123 | |
---|
| 124 | void Billboard::changedVisibility() |
---|
| 125 | { |
---|
| 126 | SUPER(Billboard, changedVisibility); |
---|
| 127 | |
---|
| 128 | this->billboard_.setVisible(this->isVisible()); |
---|
| 129 | } |
---|
| 130 | } |
---|