TDME2  1.9.200
EnvironmentMapping.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <memory>
4 #include <string>
5 
6 #include <tdme/tdme.h>
7 #include <tdme/engine/fwd-tdme.h>
9 #include <tdme/engine/Color4.h>
13 #include <tdme/engine/Entity.h>
14 #include <tdme/engine/Transform.h>
15 #include <tdme/math/Matrix4x4.h>
16 #include <tdme/math/Quaternion.h>
17 #include <tdme/math/Vector3.h>
18 
19 using std::make_unique;
20 using std::string;
21 using std::unique_ptr;
22 
34 
35 /**
36  * Environment mapping entity
37  * @author Andreas Drewke
38  */
40 {
41 
42 private:
43  friend class Engine;
44 
45  Engine* engine { nullptr };
46  bool frustumCulling { true };
48  unique_ptr<EnvironmentMappingRenderer> environmentMappingRenderer;
49  bool enabled { true };
52  Color4 effectColorMul { 1.0f, 1.0f, 1.0f, 1.0f };
53  Color4 effectColorAdd { 0.0f, 0.0f, 0.0f, 0.0f };
54  string id;
55  int width;
56  int height;
58  int64_t timeRenderUpdateFrequency { 100LL };
59 
62 
63  // overridden methods
64  inline void setParentTransform(const Transform& parentTransform) override {
65  this->parentTransform = parentTransform;
66  auto entityTransform = parentTransform * (*this);
67  entityTransformMatrix = entityTransform.getTransformMatrix();
68  }
69 
70  /**
71  * Render environment map
72  */
73  inline void render() {
77  }
78 
79 public:
80  // forbid class copy
82 
83  /**
84  * Public constructor
85  * @param id id
86  * @param width width
87  * @param height height
88  * @param boundingBox bounding box
89  */
90  EnvironmentMapping(const string& id, int width, int height, BoundingBox boundingBox);
91 
92  // overridden methods
93  inline EntityType getEntityType() override {
95  }
96 
97  void setEngine(Engine* engine) override;
98 
99  inline void setRenderer(Renderer* renderer) override {
100  }
101 
102  inline void initialize() override;
103  inline void dispose() override;
104 
105  inline bool isEnabled() override {
106  return enabled;
107  }
108 
109  void setEnabled(bool enabled) override;
110  inline bool isFrustumCulling() override {
111  return frustumCulling;
112  }
113  void setFrustumCulling(bool frustumCulling) override;
114  void update() override;
115 
116  inline BoundingBox* getBoundingBox() override {
117  return &boundingBox;
118  }
119 
120  inline BoundingBox* getWorldBoundingBox() override {
121  return &worldBoundingBox;
122  }
123 
124  inline const Color4& getEffectColorAdd() const override {
125  return effectColorAdd;
126  }
127 
128  inline void setEffectColorAdd(const Color4& effectColorAdd) override {
129  }
130 
131  inline const Color4& getEffectColorMul() const override {
132  return effectColorMul;
133  }
134 
135  inline void setEffectColorMul(const Color4& effectColorMul) override {
136  }
137 
138  inline const string& getId() override {
139  return id;
140  }
141 
142  inline bool isContributesShadows() override {
143  return false;
144  }
145 
146  inline void setContributesShadows(bool contributesShadows) override {
147  }
148 
149  inline bool isReceivesShadows() override {
150  return false;
151  }
152 
153  inline void setReceivesShadows(bool receivesShadows) override {
154  }
155 
156  inline bool isPickable() override {
157  return false;
158  }
159 
160  inline void setPickable(bool pickable) override {
161  }
162 
163  inline const Vector3& getTranslation() const override {
164  return Transform::getTranslation();
165  }
166 
167  inline void setTranslation(const Vector3& translation) override {
169  }
170 
171  inline const Vector3& getScale() const override {
172  return Transform::getScale();
173  }
174 
175  inline void setScale(const Vector3& scale) override {
177  }
178 
179  inline const int getRotationCount() const override {
181  }
182 
183  inline Rotation& getRotation(const int idx) override {
184  return Transform::getRotation(idx);
185  }
186 
187  inline void addRotation(const Vector3& axis, const float angle) override {
188  Transform::addRotation(axis, angle);
189  }
190 
191  inline void removeRotation(const int idx) override {
193  }
194 
195  inline const Vector3& getRotationAxis(const int idx) const override {
196  return Transform::getRotationAxis(idx);
197  }
198 
199  inline void setRotationAxis(const int idx, const Vector3& axis) override {
200  Transform::setRotationAxis(idx, axis);
201  }
202 
203  inline const float getRotationAngle(const int idx) const override {
204  return Transform::getRotationAngle(idx);
205  }
206 
207  inline void setRotationAngle(const int idx, const float angle) override {
208  Transform::setRotationAngle(idx, angle);
209  }
210 
211  inline const Quaternion& getRotationsQuaternion() const override {
213  }
214 
215  inline const Matrix4x4& getTransformMatrix() const override {
216  return entityTransformMatrix;
217  }
218 
219  inline const Transform& getParentTransform() const override {
220  return parentTransform;
221  }
222 
223  inline const Transform& getTransform() const override {
224  return *this;
225  }
226 
227  void setTransform(const Transform& transform) override;
228 
229  inline RenderPass getRenderPass() const override {
230  return renderPass;
231  }
232 
233  inline void setRenderPass(RenderPass renderPass) override {
234  }
235 
236  /**
237  * @return width
238  */
239  inline int32_t getWidth() {
240  return width;
241  }
242 
243  /**
244  * @return height
245  */
246  inline int32_t getHeight() {
247  return height;
248  }
249 
250  /**
251  * @return render pass mask
252  */
253  inline int32_t getRenderPassMask() {
254  return renderPassMask;
255  }
256 
257  /**
258  * Set up render pass mask
259  * @param renderPassMask render pass mask
260  */
261  inline void setRenderPassMask(int32_t renderPassMask) {
262  this->renderPassMask = renderPassMask;
263  if (environmentMappingRenderer != nullptr) environmentMappingRenderer->setRenderPassMask(renderPassMask);
264  }
265 
266  /**
267  * @return render update time frequency in milliseconds
268  */
269  inline int64_t getTimeRenderUpdateFrequency() {
271  }
272 
273  /**
274  * Set up render update time frequency
275  * @param frequency frequency in milliseconds
276  */
277  inline void setTimeRenderUpdateFrequency(int64_t frequency) {
278  this->timeRenderUpdateFrequency = frequency;
279  if (environmentMappingRenderer != nullptr) environmentMappingRenderer->setTimeRenderUpdateFrequency(frequency);
280  }
281 
282  /**
283  * @return cube map texture id
284  */
285  inline int32_t getCubeMapTextureId() {
286  if (environmentMappingRenderer == nullptr) return 0;
287  return environmentMappingRenderer->getCubeMapTextureId();
288  }
289 
290 };
Color 4 definition class.
Definition: Color4.h:18
Engine main class.
Definition: Engine.h:131
Engine entity.
Definition: Entity.h:30
static constexpr int RENDERPASS_ALL
Definition: Entity.h:84
@ ENTITYTYPE_ENVIRONMENTMAPPING
Definition: Entity.h:90
Environment mapping entity.
BoundingBox * getBoundingBox() override
const Vector3 & getTranslation() const override
const Transform & getTransform() const override
RenderPass getRenderPass() const override
void dispose() override
Dispose this entity.
void setTranslation(const Vector3 &translation) override
Set translation.
void removeRotation(const int idx) override
Remove rotation.
Rotation & getRotation(const int idx) override
Get rotation at given index.
EnvironmentMapping(const string &id, int width, int height, BoundingBox boundingBox)
Public constructor.
const int getRotationCount() const override
const Vector3 & getRotationAxis(const int idx) const override
void initialize() override
Initiates this entity.
void setRenderPass(RenderPass renderPass) override
Set render pass.
void setReceivesShadows(bool receivesShadows) override
Enable/disable receives shadows.
void addRotation(const Vector3 &axis, const float angle) override
Add rotation.
void update() override
Update transform.
void setRenderPassMask(int32_t renderPassMask)
Set up render pass mask.
void setPickable(bool pickable) override
Set this entity pickable.
void setEffectColorMul(const Color4 &effectColorMul) override
Set effect color that will be multiplied with fragment color.
void setTransform(const Transform &transform) override
Set transform.
void render()
Render environment map.
const Quaternion & getRotationsQuaternion() const override
void setScale(const Vector3 &scale) override
Set scale.
const Vector3 & getScale() const override
const float getRotationAngle(const int idx) const override
BoundingBox * getWorldBoundingBox() override
const Color4 & getEffectColorMul() const override
The effect color will be multiplied with fragment color.
void setFrustumCulling(bool frustumCulling) override
Set frustum culling.
void setTimeRenderUpdateFrequency(int64_t frequency)
Set up render update time frequency.
void setEngine(Engine *engine) override
Set up engine.
void setEnabled(bool enabled) override
Enable/disable rendering.
const Transform & getParentTransform() const override
const Matrix4x4 & getTransformMatrix() const override
const string & getId() override
unique_ptr< EnvironmentMappingRenderer > environmentMappingRenderer
EntityType getEntityType() override
void setContributesShadows(bool contributesShadows) override
Enable/disable contributes shadows.
void setRotationAxis(const int idx, const Vector3 &axis) override
Set rotation axis.
void setEffectColorAdd(const Color4 &effectColorAdd) override
Set effect color that will be added to fragment color.
const Color4 & getEffectColorAdd() const override
The effect color will be added to fragment color.
void setParentTransform(const Transform &parentTransform) override
Set parent transform.
void setRenderer(Renderer *renderer) override
Set up renderer.
void setRotationAngle(const int idx, const float angle) override
Rotation representation.
Definition: Rotation.h:18
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
Representation of a 3D model.
Definition: Model.h:35
Axis aligned bounding box used for frustum, this is not directly connectable with physics engine.
Definition: BoundingBox.h:26
Matrix4x4 class representing matrix4x4 mathematical structure and operations for 3d space.
Definition: Matrix4x4.h:23
void getTranslation(Vector3 &translation) const
Get translation.
Definition: Matrix4x4.h:433
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