TDME2  1.9.200
Decal.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 
5 #include <tdme/tdme.h>
6 #include <tdme/engine/fwd-tdme.h>
7 #include <tdme/engine/Color4.h>
11 #include <tdme/engine/Entity.h>
12 #include <tdme/engine/Transform.h>
13 #include <tdme/math/Matrix4x4.h>
14 #include <tdme/math/Quaternion.h>
15 #include <tdme/math/Vector3.h>
16 
17 using std::string;
18 
30 
31 /**
32  * Decal entity to be used with engine class
33  * @author Andreas Drewke
34  */
35 class tdme::engine::Decal final: public DecalInternal, public Entity
36 {
37 
38 private:
39  friend class Engine;
40 
41  Engine* engine { nullptr };
42  bool frustumCulling { true };
44 
45  // overridden methods
46  inline void setParentTransform(const Transform& parentTransform) override {
47  DecalInternal::setParentTransform(parentTransform);
48  }
49 
50 public:
51  // forbid class copy
53 
54  /**
55  * Public constructor
56  * @param id id
57  * @param obb oriented bounding box
58  * @param texture texture
59  * @param textureHorizonalSprites texture horizonal sprites
60  * @param textureVerticalSprites texture vertical sprites
61  * @param fps frames per seconds
62  */
63  Decal(const string& id, OrientedBoundingBox* obb, Texture* texture = nullptr, int32_t textureHorizontalSprites = 1, int32_t textureVerticalSprites = 1, float fps = 10.0f);
64 
65  // overridden methods
66  inline EntityType getEntityType() override {
67  return ENTITYTYPE_DECAL;
68  }
69 
70  void setEngine(Engine* engine) override;
71 
72  inline void setRenderer(Renderer* renderer) override {
73  DecalInternal::setRenderer(renderer);
74  }
75 
76  inline void initialize() override {
77  DecalInternal::initialize();
78  }
79 
80  inline void dispose() override {
81  DecalInternal::dispose();
82  }
83 
84  inline bool isEnabled() override {
85  return DecalInternal::isEnabled();
86  }
87 
88  void setEnabled(bool enabled) override;
89  inline bool isFrustumCulling() override {
90  return frustumCulling;
91  }
92  void setFrustumCulling(bool frustumCulling) override;
93  void update() override;
94 
95  inline BoundingBox* getBoundingBox() override {
96  return DecalInternal::getBoundingBox();
97  }
98 
99  inline BoundingBox* getWorldBoundingBox() override {
100  return DecalInternal::getWorldBoundingBox();
101  }
102 
103  inline const Color4& getEffectColorAdd() const override {
104  return DecalInternal::getEffectColorAdd();
105  }
106 
107  inline void setEffectColorAdd(const Color4& effectColorAdd) override {
108  return DecalInternal::setEffectColorAdd(effectColorAdd);
109  }
110 
111  inline const Color4& getEffectColorMul() const override {
112  return DecalInternal::getEffectColorMul();
113  }
114 
115  inline void setEffectColorMul(const Color4& effectColorMul) override {
116  return DecalInternal::setEffectColorMul(effectColorMul);
117  }
118 
119  inline const string& getId() override {
120  return DecalInternal::getId();
121  }
122 
123  inline bool isContributesShadows() override {
124  return DecalInternal::isContributesShadows();
125  }
126 
127  inline void setContributesShadows(bool contributesShadows) override {
128  DecalInternal::setContributesShadows(contributesShadows);
129  }
130 
131  inline bool isReceivesShadows() override {
132  return DecalInternal::isReceivesShadows();
133  }
134 
135  inline void setReceivesShadows(bool receivesShadows) override {
136  DecalInternal::setReceivesShadows(receivesShadows);
137  }
138 
139  inline bool isPickable() override {
140  return DecalInternal::isPickable();
141  }
142 
143  inline void setPickable(bool pickable) override {
144  DecalInternal::setPickable(pickable);
145  }
146 
147  inline const Vector3& getTranslation() const override {
148  return Transform::getTranslation();
149  }
150 
151  inline void setTranslation(const Vector3& translation) override {
153  }
154 
155  inline const Vector3& getScale() const override {
156  return Transform::getScale();
157  }
158 
159  inline void setScale(const Vector3& scale) override {
161  }
162 
163  inline const int getRotationCount() const override {
165  }
166 
167  inline Rotation& getRotation(const int idx) override {
168  return Transform::getRotation(idx);
169  }
170 
171  inline void addRotation(const Vector3& axis, const float angle) override {
172  Transform::addRotation(axis, angle);
173  }
174 
175  inline void removeRotation(const int idx) override {
177  }
178 
179  inline const Vector3& getRotationAxis(const int idx) const override {
180  return Transform::getRotationAxis(idx);
181  }
182 
183  inline void setRotationAxis(const int idx, const Vector3& axis) override {
184  Transform::setRotationAxis(idx, axis);
185  }
186 
187  inline const float getRotationAngle(const int idx) const override {
188  return Transform::getRotationAngle(idx);
189  }
190 
191  inline void setRotationAngle(const int idx, const float angle) override {
192  Transform::setRotationAngle(idx, angle);
193  }
194 
195  inline const Quaternion& getRotationsQuaternion() const override {
197  }
198 
199  inline const Matrix4x4& getTransformMatrix() const override {
200  return entityTransformMatrix;
201  }
202 
203  inline const Transform& getParentTransform() const override {
204  return parentTransform;
205  }
206 
207  inline const Transform& getTransform() const override {
208  return *this;
209  }
210 
211  void setTransform(const Transform& transform) override;
212 
213  inline RenderPass getRenderPass() const override {
214  return renderPass;
215  }
216 
217  inline void setRenderPass(RenderPass renderPass) override {
218  this->renderPass = renderPass;
219  }
220 
221  /**
222  * @return decal texture
223  */
225  return DecalInternal::getDecalTexture();
226  }
227 
228  /**
229  * @return world to decal space matrix
230  */
232  return DecalInternal::getWorldToDecalSpaceMatrix();
233  }
234 
235 };
Color 4 definition class.
Definition: Color4.h:18
Decal entity to be used with engine class.
Definition: Decal.h:36
BoundingBox * getBoundingBox() override
Definition: Decal.h:95
const Vector3 & getTranslation() const override
Definition: Decal.h:147
Engine * engine
Definition: Decal.h:41
const Transform & getTransform() const override
Definition: Decal.h:207
RenderPass getRenderPass() const override
Definition: Decal.h:213
void dispose() override
Dispose this entity.
Definition: Decal.h:80
void setTranslation(const Vector3 &translation) override
Set translation.
Definition: Decal.h:151
void removeRotation(const int idx) override
Remove rotation.
Definition: Decal.h:175
Rotation & getRotation(const int idx) override
Get rotation at given index.
Definition: Decal.h:167
RenderPass renderPass
Definition: Decal.h:43
const int getRotationCount() const override
Definition: Decal.h:163
const Vector3 & getRotationAxis(const int idx) const override
Definition: Decal.h:179
Decal(const string &id, OrientedBoundingBox *obb, Texture *texture=nullptr, int32_t textureHorizontalSprites=1, int32_t textureVerticalSprites=1, float fps=10.0f)
Public constructor.
Definition: Decal.cpp:19
void initialize() override
Initiates this entity.
Definition: Decal.h:76
bool isReceivesShadows() override
Definition: Decal.h:131
void setRenderPass(RenderPass renderPass) override
Set render pass.
Definition: Decal.h:217
void setReceivesShadows(bool receivesShadows) override
Enable/disable receives shadows.
Definition: Decal.h:135
const Matrix4x4 & getWorldToDecalSpaceMatrix()
Definition: Decal.h:231
void addRotation(const Vector3 &axis, const float angle) override
Add rotation.
Definition: Decal.h:171
void update() override
Update transform.
Definition: Decal.cpp:37
void setPickable(bool pickable) override
Set this entity pickable.
Definition: Decal.h:143
void setEffectColorMul(const Color4 &effectColorMul) override
Set effect color that will be multiplied with fragment color.
Definition: Decal.h:115
bool isPickable() override
Definition: Decal.h:139
void setTransform(const Transform &transform) override
Set transform.
Definition: Decal.cpp:31
Texture * getDecalTexture()
Definition: Decal.h:224
const Quaternion & getRotationsQuaternion() const override
Definition: Decal.h:195
void setScale(const Vector3 &scale) override
Set scale.
Definition: Decal.h:159
bool isContributesShadows() override
Definition: Decal.h:123
const Vector3 & getScale() const override
Definition: Decal.h:155
const float getRotationAngle(const int idx) const override
Definition: Decal.h:187
BoundingBox * getWorldBoundingBox() override
Definition: Decal.h:99
bool frustumCulling
Definition: Decal.h:42
const Color4 & getEffectColorMul() const override
The effect color will be multiplied with fragment color.
Definition: Decal.h:111
void setFrustumCulling(bool frustumCulling) override
Set frustum culling.
Definition: Decal.cpp:64
void setEngine(Engine *engine) override
Set up engine.
Definition: Decal.cpp:24
void setEnabled(bool enabled) override
Enable/disable rendering.
Definition: Decal.cpp:43
const Transform & getParentTransform() const override
Definition: Decal.h:203
const Matrix4x4 & getTransformMatrix() const override
Definition: Decal.h:199
const string & getId() override
Definition: Decal.h:119
EntityType getEntityType() override
Definition: Decal.h:66
void setContributesShadows(bool contributesShadows) override
Enable/disable contributes shadows.
Definition: Decal.h:127
void setRotationAxis(const int idx, const Vector3 &axis) override
Set rotation axis.
Definition: Decal.h:183
bool isFrustumCulling() override
Definition: Decal.h:89
bool isEnabled() override
Definition: Decal.h:84
void setEffectColorAdd(const Color4 &effectColorAdd) override
Set effect color that will be added to fragment color.
Definition: Decal.h:107
const Color4 & getEffectColorAdd() const override
The effect color will be added to fragment color.
Definition: Decal.h:103
void setParentTransform(const Transform &parentTransform) override
Set parent transform.
Definition: Decal.h:46
void setRenderer(Renderer *renderer) override
Set up renderer.
Definition: Decal.h:72
void setRotationAngle(const int idx, const float angle) override
Definition: Decal.h:191
Engine main class.
Definition: Engine.h:131
Engine entity.
Definition: Entity.h:30
Rotation representation.
Definition: Rotation.h:18
Texture entity.
Definition: Texture.h:24
Transform which contain scale, rotations and translation.
Definition: Transform.h:29
void setRotationAngle(const int idx, const float angle)
Definition: Transform.h:155
void setRotationAxis(const int idx, const Vector3 &axis)
Set rotation axis.
Definition: Transform.h:138
void setTranslation(const Vector3 &translation)
Set translation.
Definition: Transform.h:64
void removeRotation(const int idx)
Remove rotation.
Definition: Transform.h:121
const Vector3 & getScale() const
Definition: Transform.h:71
Rotation & getRotation(const int idx)
Get rotation at given index.
Definition: Transform.h:95
void setScale(const Vector3 &scale)
Set scale.
Definition: Transform.h:79
const int getRotationCount() const
Definition: Transform.h:86
const Vector3 & getRotationAxis(const int idx) const
Definition: Transform.h:129
const Quaternion & getRotationsQuaternion() const
Definition: Transform.h:162
const Vector3 & getTranslation() const
Definition: Transform.h:56
void addRotation(const Vector3 &axis, const float angle)
Add rotation.
Definition: Transform.h:113
const float getRotationAngle(const int idx) const
Definition: Transform.h:146
Axis aligned bounding box used for frustum, this is not directly connectable with physics engine.
Definition: BoundingBox.h:26
Oriented bounding box physics primitive.
Matrix4x4 class representing matrix4x4 mathematical structure and operations for 3d space.
Definition: Matrix4x4.h:23
Quaternion class representing quaternion mathematical structure and operations with x,...
Definition: Quaternion.h:24
Vector3 class representing vector3 mathematical structure and operations with x, y,...
Definition: Vector3.h:20
#define FORBID_CLASS_COPY(CLASS)
Definition: tdme.h:6