[670] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
[1056] | 3 | * > www.orxonox.net < |
---|
[670] | 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 | |
---|
[786] | 29 | #include "OrxonoxStableHeaders.h" |
---|
[1039] | 30 | #include "Model.h" |
---|
[784] | 31 | |
---|
[1209] | 32 | #include "tinyxml/tinyxml.h" |
---|
[1032] | 33 | #include "core/CoreIncludes.h" |
---|
| 34 | #include "GraphicsEngine.h" |
---|
[871] | 35 | #include "core/XMLPort.h" |
---|
[576] | 36 | |
---|
| 37 | namespace orxonox |
---|
| 38 | { |
---|
| 39 | CreateFactory(Model); |
---|
| 40 | |
---|
| 41 | Model::Model() |
---|
| 42 | { |
---|
| 43 | RegisterObject(Model); |
---|
[1021] | 44 | registerAllVariables(); |
---|
[576] | 45 | } |
---|
| 46 | |
---|
| 47 | Model::~Model() |
---|
| 48 | { |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | void Model::loadParams(TiXmlElement* xmlElem) |
---|
| 52 | { |
---|
[583] | 53 | WorldEntity::loadParams(xmlElem); |
---|
[576] | 54 | |
---|
[622] | 55 | if (xmlElem->Attribute("mesh")) |
---|
| 56 | { |
---|
[630] | 57 | meshSrc_ = xmlElem->Attribute("mesh"); |
---|
[586] | 58 | } |
---|
[631] | 59 | create(); |
---|
[630] | 60 | } |
---|
[646] | 61 | |
---|
[871] | 62 | /** |
---|
| 63 | @brief XML loading and saving. |
---|
[1021] | 64 | @p |
---|
| 65 | aram xmlelement The XML-element |
---|
[871] | 66 | @param loading Loading (true) or saving (false) |
---|
| 67 | @return The XML-element |
---|
| 68 | */ |
---|
[1052] | 69 | void Model::XMLPort(Element& xmlelement, XMLPort::Mode mode) |
---|
[871] | 70 | { |
---|
[1052] | 71 | WorldEntity::XMLPort(xmlelement, mode); |
---|
[871] | 72 | |
---|
[1052] | 73 | XMLPortParamLoadOnly(Model, "mesh", setMesh, xmlelement, mode); |
---|
[871] | 74 | |
---|
| 75 | create(); |
---|
| 76 | } |
---|
| 77 | |
---|
| 78 | void Model::setMesh(const std::string& meshname) |
---|
| 79 | { |
---|
| 80 | this->meshSrc_ = meshname; |
---|
| 81 | } |
---|
| 82 | |
---|
[630] | 83 | bool Model::create(){ |
---|
[1021] | 84 | WorldEntity::create(); |
---|
[1052] | 85 | if ((this->meshSrc_ != "") && (this->meshSrc_.size() > 0)) |
---|
| 86 | { |
---|
[631] | 87 | this->mesh_.setMesh(meshSrc_); |
---|
| 88 | this->attachObject(this->mesh_.getEntity()); |
---|
| 89 | COUT(4) << "Loader: Created model" << std::endl; |
---|
| 90 | } |
---|
[630] | 91 | return true; |
---|
[576] | 92 | } |
---|
[646] | 93 | |
---|
[630] | 94 | void Model::registerAllVariables(){ |
---|
[1021] | 95 | WorldEntity::registerAllVariables(); |
---|
| 96 | registerVar(&meshSrc_, meshSrc_.length() + 1, network::STRING); |
---|
[630] | 97 | } |
---|
[576] | 98 | } |
---|