TDME2  1.9.200
ShadowMapping.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <memory>
4 #include <vector>
5 
6 #include <tdme/tdme.h>
7 #include <tdme/engine/fwd-tdme.h>
11 #include <tdme/math/fwd-tdme.h>
12 #include <tdme/math/Matrix4x4.h>
14 
15 using std::vector;
16 using std::unique_ptr;
17 
25 
26 /**
27  * Shadow mapping module
28  * @author Andreas Drewke
29  */
31 {
32  friend class tdme::engine::Engine;
33  friend class ShadowMap;
34 
35 private:
37 
38  Renderer* renderer { nullptr };
40 
43 
44  Engine* engine { nullptr };
45 
46  vector<unique_ptr<ShadowMap>> shadowMaps;
48 
50 
51 public:
52  // forbid class copy
54 
55  /**
56  * Constructor
57  * @param engine engine
58  * @param renderer renderer
59  * @param entityRenderer entityRenderer
60  */
62 
63  /**
64  * Destructor
65  */
67 
68  /**
69  * @return engine
70  */
71  inline Engine* getEngine() {
72  return engine;
73  }
74 
75  /**
76  * Reshape shadow maps
77  * @param width width
78  * @param height height
79  */
80  void reshape(int32_t width, int32_t height);
81 
82  /**
83  * Get shadow map
84  * @param idx index
85  * @return shadow map
86  */
87  inline ShadowMap* getShadowMap(int idx) {
88  return shadowMaps[idx].get();
89  }
90 
91  /**
92  * Create shadow maps
93  */
94  void createShadowMaps();
95 
96  /**
97  * Render shadow maps to world
98  * @param visibleObjects visible objects
99  */
100  void renderShadowMaps(const vector<Object*>& visibleObjects);
101 
102  /**
103  * Dispose shadow maps
104  */
105  void dispose();
106 
107  /**
108  * Start object transform
109  * @param contextIdx context index
110  * @param transformMatrix transform matrix
111  */
112  void startObjectTransform(int contextIdx, Matrix4x4& transformMatrix);
113 
114  /**
115  * End object transform
116  */
117  void endObjectTransform();
118 
119  /**
120  * Update matrices
121  * @param contextIdx context index
122  */
123  void updateMatrices(int contextIdx);
124 
125  /**
126  * Update texture matrix
127  * @param contextIdx context index
128  */
129  void updateTextureMatrix(int contextIdx);
130 
131  /**
132  * Update material
133  * @param contextIdx context index
134  */
135  void updateMaterial(int contextIdx);
136 
137  /**
138  * Set shader
139  * @param contextIdx context index
140  * @param id shader id
141  */
142  void setShader(int contextIdx, const string& id);
143 
144  /**
145  * Update light
146  * @param lightId light id
147  */
148  void updateLight(int contextIdx, int32_t lightId);
149 
150  /**
151  * Update shader parameters
152  * @param context
153  */
154  void updateShaderParameters(int contextIdx);
155 
156  /**
157  * Bind texture
158  * @param textureId texture id
159  */
160  void bindTexture(int contextIdx, int32_t textureId);
161 
162  /**
163  * Update depth bias mvp matrix with given matrix
164  * @param contextIdx context index
165  * @param depthBiasMVPMatrix depth bias MVP matrix
166  */
168 
169  /**
170  * Update depth bias mvp matrix / upload only
171  * @param contextIdx context index
172  */
173  void updateDepthBiasMVPMatrix(int contextIdx);
174 
175 };
Engine main class.
Definition: Engine.h:131
void updateDepthBiasMVPMatrix(int contextIdx, Matrix4x4 &depthBiasMVPMatrix)
Update depth bias mvp matrix with given matrix.
void reshape(int32_t width, int32_t height)
Reshape shadow maps.
void updateLight(int contextIdx, int32_t lightId)
Update light.
void updateMatrices(int contextIdx)
Update matrices.
ShadowMap * getShadowMap(int idx)
Get shadow map.
Definition: ShadowMapping.h:87
void setShader(int contextIdx, const string &id)
Set shader.
ShadowMapping(Engine *engine, Renderer *renderer, EntityRenderer *entityRenderer)
Constructor.
void updateTextureMatrix(int contextIdx)
Update texture matrix.
void updateShaderParameters(int contextIdx)
Update shader parameters.
vector< unique_ptr< ShadowMap > > shadowMaps
Definition: ShadowMapping.h:46
void startObjectTransform(int contextIdx, Matrix4x4 &transformMatrix)
Start object transform.
void updateMaterial(int contextIdx)
Update material.
void renderShadowMaps(const vector< Object * > &visibleObjects)
Render shadow maps to world.
void bindTexture(int contextIdx, int32_t textureId)
Bind texture.
Matrix4x4 class representing matrix4x4 mathematical structure and operations for 3d space.
Definition: Matrix4x4.h:23
Vector3 class representing vector3 mathematical structure and operations with x, y,...
Definition: Vector3.h:20
Vector4 class representing vector4 mathematical structure and operations with x, y,...
Definition: Vector4.h:22
#define FORBID_CLASS_COPY(CLASS)
Definition: tdme.h:6