Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 1990 was 1907, checked in by scheusso, 16 years ago

merged network branch back to trunk

  • Property svn:eol-style set to native
File size: 3.0 KB
RevLine 
[1502]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
[1751]47    /**
[1907]48     * @brief Constructor
[1751]49     */
[1559]50    Model::Model()
[1502]51    {
52        RegisterObject(Model);
53        registerAllVariables();
54    }
55
[1907]56    /**
57     * @brief Destructor
58     */
[1502]59    Model::~Model()
60    {
[1559]61        if (this->isInitialized() && (this->meshSrc_ != "") && (this->meshSrc_.size() > 0))
[1552]62            this->detachObject(this->mesh_.getEntity());
[1502]63    }
64
65    /**
66        @brief XML loading and saving.
[1627]67        @param xmlelement The XML-element
[1502]68        @param loading Loading (true) or saving (false)
69        @return The XML-element
70    */
71    void Model::XMLPort(Element& xmlelement, XMLPort::Mode mode)
72    {
[1747]73        SUPER(Model, XMLPort, xmlelement, mode);
[1502]74
[1747]75        XMLPortParam(Model, "mesh", setMesh, getMesh, xmlelement, mode);
[1502]76
77        Model::create();
78    }
79
80    bool Model::create(){
81      if(!WorldEntity::create())
82        return false;
83      if ((this->meshSrc_ != "") && (this->meshSrc_.size() > 0))
84      {
85        this->mesh_.setMesh(meshSrc_);
86        this->attachObject(this->mesh_.getEntity());
87
88        COUT(4) << "Loader (Model.cc): Created model" << std::endl;
89      }
[1789]90      if(this->isExactlyA(Class(Model)))
[1907]91        setObjectFrequency(300); //sync all 10 seconds (this only applies to asteroids and other isExactlyA(Model)'s
[1502]92      return true;
93    }
94
95    void Model::registerAllVariables(){
96//       WorldEntity::registerAllVariables();
97      COUT(5) << "Model.cc:registering new meshsrc with size: " << meshSrc_.length()+1 << " this: " << this << std::endl;
98      registerVar(&meshSrc_, meshSrc_.length() + 1, network::STRING);
99    }
[1558]100
101    void Model::changedVisibility()
102    {
[1747]103        SUPER(Model, changedVisibility);
[1627]104        if (this->isInitialized())
105            this->mesh_.setVisible(this->isVisible());
[1558]106    }
[1502]107}
Note: See TracBrowser for help on using the repository browser.