Orxonox  0.0.5 Codename: Arcturus
Model.h
Go to the documentation of this file.
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 
34 #ifndef _Model_H__
35 #define _Model_H__
36 
37 #include "OrxonoxPrereqs.h"
38 
39 #include <string>
40 #include "tools/Mesh.h"
41 #include "RenderQueueListener.h"
43 
44 namespace orxonox
45 {
47  {
55  public:
56  Model(Context* context);
57  virtual ~Model();
58 
59  void setConfigValues();
60 
61  virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
62 
63  virtual void changedVisibility() override;
64 
65  inline const Mesh& getMesh() const
66  { return this->mesh_; }
67 
68  inline void setMeshSource(const std::string& meshname)
69  { this->meshSrc_ = meshname; this->changedMesh(); }
70  inline const std::string& getMeshSource() const
71  { return this->meshSrc_; }
72 
73  inline void setRenderQueueGroup(const std::string& renderQueueGroup)
74  { this->renderQueueGroup_ = getRenderQueueGroupID(renderQueueGroup); this->changedRenderQueueGroup(); }
75  inline const int getRenderQueueGroup() const
76  { return this->renderQueueGroup_; }
77 
78  inline void setCastShadows(bool bCastShadows)
79  { this->bCastShadows_ = bCastShadows; this->changedShadows(); }
80  inline bool getCastShadows() const
81  { return this->bCastShadows_; }
82 
83  inline void setMaterial(const std::string& materialname)
84  { this->materialName_ = materialname; this->changedMaterial(); }
85  inline const std::string& getMaterial() const
86  { return this->materialName_; }
87 
88  void setSubMaterial(const std::string& name, const int index);
89 
90  protected:
91  inline Mesh& getMesh()
92  { return this->mesh_; }
93 
94  inline void setLodEnabled(bool bLodEnabled)
95  { this->bLodEnabled_ = bLodEnabled; }
96 
97  private:
107  const unsigned int getRenderQueueGroupID(const std::string& renderQueueGroup) const;
108 
109  void registerVariables();
110  void changedMesh();
111  void changedRenderQueueGroup();
112  void changedMaterial();
113  void changedShadows();
114 
115  //LoD
116  void enableLod();
117 
118  template <class T>
119  void addLodDistanceToList(T& list, float distance);
120 
121  inline void setLodLevel(float lodLevel)
122  { this->lodLevel_ = lodLevel; }
123  inline float getLodLevel() const
124  { return this->lodLevel_; }
125  float getBiggestScale(Vector3 scale3d);
126 
130  unsigned int renderQueueGroup_;
132 
133  //LoD
135  float lodLevel_;
137  unsigned int numLodLevels_;
139 
140  };
141 }
142 
143 #endif /* _Model_H__ */
const Mesh & getMesh() const
Definition: Model.h:65
The StaticEntity is the simplest derivative of the orxonox::WorldEntity class.
Definition: StaticEntity.h:50
float lodReductionRate_
How fast should be switched to lower LoDs.
Definition: Model.h:138
void setLodEnabled(bool bLodEnabled)
Definition: Model.h:94
void setCastShadows(bool bCastShadows)
Definition: Model.h:78
void setMeshSource(const std::string &meshname)
Definition: Model.h:68
::std::string string
Definition: gtest-port.h:756
std::string meshSrc_
This string stores the path where the mesh is stored.
Definition: Model.h:127
bool getCastShadows() const
Definition: Model.h:80
bool bLodEnabled_
Is LoD to be used on this model?
Definition: Model.h:136
Definition of the RenderQueueListener class.
const int getRenderQueueGroup() const
Definition: Model.h:75
void setRenderQueueGroup(const std::string &renderQueueGroup)
Definition: Model.h:73
xmlelement
Definition: Super.h:519
bool bCastShadows_
This value determines whether a Model is casting a shadow or not, turn it off to save performance...
Definition: Model.h:129
Mesh & getMesh()
Definition: Model.h:91
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
Mode
Definition: CorePrereqs.h:102
Shared library macros, enums, constants and forward declarations for the orxonox library ...
Definition: InputPrereqs.h:78
Definition: Context.h:45
void setLodLevel(float lodLevel)
Definition: Model.h:121
#define _OrxonoxExport
Definition: OrxonoxPrereqs.h:60
float getLodLevel() const
Definition: Model.h:123
Mesh mesh_
This is the mesh object linked to this Object, it stores the data from the mesh file in a usable form...
Definition: Model.h:128
void setMaterial(const std::string &materialname)
Definition: Model.h:83
std::string materialName_
This string stores the name of the material to be applied to the mesh/model.
Definition: Model.h:131
Definition: Mesh.h:37
const std::string & getMeshSource() const
Definition: Model.h:70
Definition: Model.h:46
unsigned int renderQueueGroup_
This variable stores which render queue group this object is assigned to.
Definition: Model.h:130
float lodLevel_
Standard LoD Level.
Definition: Model.h:135
unsigned int numLodLevels_
How many LoD does this model feature.
Definition: Model.h:137
bool bGlobalEnableLod_
Has LoD been turned on in the graphics configuration?
Definition: Model.h:134
const std::string & getMaterial() const
Definition: Model.h:85