[2072] | 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 | |
---|
[11080] | 29 | /** |
---|
| 30 | @file Model.h |
---|
| 31 | @brief Definition of Model Class |
---|
| 32 | */ |
---|
| 33 | |
---|
[2072] | 34 | #ifndef _Model_H__ |
---|
| 35 | #define _Model_H__ |
---|
| 36 | |
---|
| 37 | #include "OrxonoxPrereqs.h" |
---|
[3196] | 38 | |
---|
| 39 | #include <string> |
---|
| 40 | #include "tools/Mesh.h" |
---|
[11080] | 41 | #include "RenderQueueListener.h" |
---|
[5737] | 42 | #include "worldentities/StaticEntity.h" |
---|
[2072] | 43 | |
---|
| 44 | namespace orxonox |
---|
| 45 | { |
---|
[2662] | 46 | class _OrxonoxExport Model : public StaticEntity |
---|
[2072] | 47 | { |
---|
[11080] | 48 | /** |
---|
| 49 | @brief |
---|
| 50 | The class Model stores a Mesh and some additional properties, so you can easily render any Model and apply different effects to it. |
---|
| 51 | |
---|
| 52 | You can assign any Material to any Mesh to completely change the way it looks, to further add versatility you can also assign the Model |
---|
| 53 | to a render queue group, to enable proper rendering of fancy effect like glowing edges around objects with alpha blending. |
---|
| 54 | */ |
---|
[2072] | 55 | public: |
---|
[9667] | 56 | Model(Context* context); |
---|
[2072] | 57 | virtual ~Model(); |
---|
| 58 | |
---|
[7166] | 59 | void setConfigValues(); |
---|
| 60 | |
---|
[11071] | 61 | virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; |
---|
[2072] | 62 | |
---|
[11071] | 63 | virtual void changedVisibility() override; |
---|
[2072] | 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 | |
---|
[11080] | 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 | |
---|
[2072] | 78 | inline void setCastShadows(bool bCastShadows) |
---|
| 79 | { this->bCastShadows_ = bCastShadows; this->changedShadows(); } |
---|
| 80 | inline bool getCastShadows() const |
---|
| 81 | { return this->bCastShadows_; } |
---|
| 82 | |
---|
[11080] | 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 | |
---|
[11783] | 88 | void setSubMaterial(const std::string& name, const int index); |
---|
| 89 | |
---|
[7163] | 90 | protected: |
---|
[11080] | 91 | /** |
---|
| 92 | @brief |
---|
| 93 | This function turns a string from XML Port into a usable ID for the rendering system |
---|
| 94 | It defaults to the main queue if the group isn't recognized. |
---|
| 95 | |
---|
| 96 | @param renderQueueGroup |
---|
| 97 | This is a string representing the render queue group. Accepted values: |
---|
| 98 | main, stencil glow, stencil object |
---|
| 99 | */ |
---|
| 100 | const unsigned int getRenderQueueGroupID(const std::string& renderQueueGroup) const; |
---|
| 101 | |
---|
[7163] | 102 | void registerVariables(); |
---|
[2072] | 103 | void changedMesh(); |
---|
[11080] | 104 | void changedRenderQueueGroup(); |
---|
| 105 | void changedMaterial(); |
---|
[2072] | 106 | void changedShadows(); |
---|
| 107 | |
---|
[7163] | 108 | //LoD |
---|
[7166] | 109 | void enableLod(); |
---|
| 110 | |
---|
[7163] | 111 | inline void setLodLevel(float lodLevel) |
---|
| 112 | { this->lodLevel_ = lodLevel; } |
---|
| 113 | inline float getLodLevel() const |
---|
| 114 | { return this->lodLevel_; } |
---|
| 115 | float getBiggestScale(Vector3 scale3d); |
---|
| 116 | |
---|
[11080] | 117 | std::string meshSrc_; //!< This string stores the path where the mesh is stored |
---|
| 118 | Mesh mesh_; //!< This is the mesh object linked to this Object, it stores the data from the mesh file in a usable format for the Ogre engine |
---|
| 119 | bool bCastShadows_; //!< This value determines whether a Model is casting a shadow or not, turn it off to save performance, when not needed |
---|
| 120 | unsigned int renderQueueGroup_; //!< This variable stores which render queue group this object is assigned to |
---|
| 121 | std::string materialName_; //!< This string stores the name of the material to be applied to the mesh/model |
---|
[7163] | 122 | |
---|
| 123 | //LoD |
---|
[11080] | 124 | bool bGlobalEnableLod_; //!< Has LoD been turned on in the graphics configuration? |
---|
| 125 | float lodLevel_; //!< Standard LoD Level |
---|
| 126 | bool bLodEnabled_; //!< Is LoD to be used on this model? |
---|
| 127 | unsigned int numLodLevels_; //!< How many LoD does this model feature |
---|
| 128 | float lodReductionRate_; //!< How fast should be switched to lower LoDs |
---|
[7163] | 129 | |
---|
[2072] | 130 | }; |
---|
| 131 | } |
---|
| 132 | |
---|
[2662] | 133 | #endif /* _Model_H__ */ |
---|