Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/core3/src/orxonox/objects/Model.cc @ 1768

Last change on this file since 1768 was 1736, checked in by landauf, 16 years ago

Super.h:

  • removed some commented lines
  • removed testfunction
  • Property svn:eol-style set to native
File size: 2.7 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
37#include <OgreEntity.h>
38#include <OgreMesh.h>
39#include <OgreHardwareVertexBuffer.h>
40#include <OgreMeshManager.h>
41
42
43namespace orxonox
44{
45    CreateFactory(Model);
46
47    Model::Model()
48    {
49        RegisterObject(Model);
50        registerAllVariables();
51    }
52
53    Model::~Model()
54    {
55        if (this->isInitialized() && (this->meshSrc_ != "") && (this->meshSrc_.size() > 0))
56            this->detachObject(this->mesh_.getEntity());
57    }
58
59    /**
60        @brief XML loading and saving.
61    @p
62    aram xmlelement The XML-element
63        @param loading Loading (true) or saving (false)
64        @return The XML-element
65    */
66    void Model::XMLPort(Element& xmlelement, XMLPort::Mode mode)
67    {
68        SUPER(Model, XMLPort, xmlelement, mode);
69
70        XMLPortParam(Model, "mesh", setMesh, getMesh, xmlelement, mode);
71
72        Model::create();
73    }
74
75    bool Model::create(){
76      if(!WorldEntity::create())
77        return false;
78      if ((this->meshSrc_ != "") && (this->meshSrc_.size() > 0))
79      {
80        this->mesh_.setMesh(meshSrc_);
81        this->attachObject(this->mesh_.getEntity());
82
83        COUT(4) << "Loader (Model.cc): Created model" << std::endl;
84      }
85      return true;
86    }
87
88    void Model::registerAllVariables(){
89//       WorldEntity::registerAllVariables();
90      COUT(5) << "Model.cc:registering new meshsrc with size: " << meshSrc_.length()+1 << " this: " << this << std::endl;
91      registerVar(&meshSrc_, meshSrc_.length() + 1, network::STRING);
92    }
93
94    void Model::changedVisibility()
95    {
96        SUPER(Model, changedVisibility);
97        this->mesh_.setVisible(this->isVisible());
98    }
99}
Note: See TracBrowser for help on using the repository browser.