Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/ogre/src/orxonox/objects/Model.cc @ 1260

Last change on this file since 1260 was 1260, checked in by rgrieder, 16 years ago
  • moved variable initialisation of class hierarchy members into initialiser list
  • added windowClosed (Ogre::WindowEventUtilities::WindowEventListener) event to GraphicsEngine
File size: 2.3 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 "tinyxml/tinyxml.h"
33#include "core/CoreIncludes.h"
34#include "GraphicsEngine.h"
35#include "core/XMLPort.h"
36
37namespace orxonox
38{
39    CreateFactory(Model);
40
41    Model::Model()
42    {
43        RegisterObject(Model);
44        registerAllVariables();
45    }
46
47    Model::~Model()
48    {
49    }
50
51    /**
52        @brief XML loading and saving.
53    @p
54    aram xmlelement The XML-element
55        @param loading Loading (true) or saving (false)
56        @return The XML-element
57    */
58    void Model::XMLPort(Element& xmlelement, XMLPort::Mode mode)
59    {
60        WorldEntity::XMLPort(xmlelement, mode);
61
62        XMLPortParamLoadOnly(Model, "mesh", setMesh, xmlelement, mode);
63
64        create();
65    }
66
67    void Model::setMesh(const std::string& meshname)
68    {
69        this->meshSrc_ = meshname;
70    }
71
72    bool Model::create(){
73      WorldEntity::create();
74      if ((this->meshSrc_ != "") && (this->meshSrc_.size() > 0))
75      {
76        this->mesh_.setMesh(meshSrc_);
77        this->attachObject(this->mesh_.getEntity());
78        COUT(4) << "Loader: Created model" << std::endl;
79      }
80      return true;
81    }
82
83    void Model::registerAllVariables(){
84      WorldEntity::registerAllVariables();
85      registerVar(&meshSrc_, meshSrc_.length() + 1, network::STRING);
86    }
87}
Note: See TracBrowser for help on using the repository browser.