Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/objects/Model.cc @ 1062

Last change on this file since 1062 was 1056, checked in by landauf, 17 years ago

don't panic, no codechanges!
added a link to www.orxonox.net

File size: 2.6 KB
Line 
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 "OrxonoxStableHeaders.h"
30#include "Model.h"
31
32#include "util/tinyxml/tinyxml.h"
33#include "util/Tokenizer.h"
34#include "util/String2Number.h"
35#include "core/CoreIncludes.h"
36#include "GraphicsEngine.h"
37#include "core/XMLPort.h"
38
39namespace orxonox
40{
41    CreateFactory(Model);
42
43    Model::Model()
44    {
45        RegisterObject(Model);
46        registerAllVariables();
47    }
48
49    Model::~Model()
50    {
51    }
52
53    void Model::loadParams(TiXmlElement* xmlElem)
54    {
55        WorldEntity::loadParams(xmlElem);
56
57        if (xmlElem->Attribute("mesh"))
58        {
59            meshSrc_ = xmlElem->Attribute("mesh");
60        }
61        create();
62    }
63
64    /**
65        @brief XML loading and saving.
66    @p
67    aram xmlelement The XML-element
68        @param loading Loading (true) or saving (false)
69        @return The XML-element
70    */
71    void Model::XMLPort(Element& xmlelement, XMLPort::Mode mode)
72    {
73        WorldEntity::XMLPort(xmlelement, mode);
74
75        XMLPortParamLoadOnly(Model, "mesh", setMesh, xmlelement, mode);
76
77        create();
78    }
79
80    void Model::setMesh(const std::string& meshname)
81    {
82        this->meshSrc_ = meshname;
83    }
84
85    bool Model::create(){
86      WorldEntity::create();
87      if ((this->meshSrc_ != "") && (this->meshSrc_.size() > 0))
88      {
89        this->mesh_.setMesh(meshSrc_);
90        this->attachObject(this->mesh_.getEntity());
91        COUT(4) << "Loader: Created model" << std::endl;
92      }
93      return true;
94    }
95
96    void Model::registerAllVariables(){
97      WorldEntity::registerAllVariables();
98      registerVar(&meshSrc_, meshSrc_.length() + 1, network::STRING);
99    }
100}
Note: See TracBrowser for help on using the repository browser.