Vis 2 Demo  1.0
Technical illustration type real-time rendering of geometry
 All Classes Namespaces Files Functions Variables Typedefs Macros
LoaderScene.h
Go to the documentation of this file.
1 #ifndef __LOADER_SCENE_H__
2 #define __LOADER_SCENE_H__
3 
4 #include <cstdio>
5 #include <vector>
6 #include <iostream>
7 #include <string>
8 #include <vector>
9 #include <glew.h>
10 #include <glm/glm.hpp>
11 
13 #include "geometry/QuadTextured.h"
16 
17 #include "visualisation/Shader.h"
19 #include "visualisation/Texture.h"
21 
22 #define VIS2_SCENE_MAX_NR_LIGHTS 2
23 #define VIS2_SCENE_MAX_NR_SHELL_OBJ 10
24 #define VIS2_SCENE_MAX_NR_CONTENT_OBJ 16
25 #define VIS2_SCENE_MAX_NR_SEPARATOR_OBJ 10
26 
27 #define VIS2_SCENE_NR_FBOS_EDF 4
28 #define VIS2_SCENE_MAX_NR_MASKED_NEIGHB 4
29 #define VIS2_SCENE_NR_FBOS_SMF VIS2_SCENE_MAX_NR_MASKED_NEIGHB + 3
30 #define VIS2_SCENE_NR_QUADS_SMF 3
31 #define VIS2_SCENE_NR_FBOS_DPS 3
32 #define VIS2_SCENE_NR_FBOS_DPSB 2
33 
34 #define VIS2_SCENE_OBJECT_TYPE_SHELL 0
35 #define VIS2_SCENE_OBJECT_TYPE_CONTENT 1
36 #define VIS2_SCENE_OBJECT_TYPE_SEPARATOR 2
37 
38 namespace vis2
39 {
41 
49  {
50  public:
51 
53 
59  LoaderScene( const std::string & _scene_path,
60  const unsigned int _screen_w,
61  const unsigned int _screen_h);
63 
67  ~LoaderScene();
68 
70 
73  int loadScene();
74 
76 
79  void updateScene(glm::mat4 & _modelMatrix);
80 
82  /* The user input (right-click w. mouse) is used to calculate transparency.
83  \param[in] _mouse_right_click : if \b true the user performed a right-click at normalized screen coordinates
84  \param[in] _mouse_x and
85  \param[in] _mouse_y,
86  \param[in] _b_with_pp : if \b true draws scene with post-processing, otherwise - without,
87  \param[in] _b_debug_mode : if \b true shows a small quad with the result of render-pass nr
88  \param[in] _debug_pass as a diffuse texture.
89  */
90  void drawScene( bool _mouse_right_click, float _mouse_x, float _mouse_y,
91  bool _b_with_pp, bool _b_debug_mode, unsigned int _debug_pass);
92 
94  inline glm::vec3 getBackgrColor() const { return this->backgr_col; }
95 
97  inline glm::vec3 getSelectedColor() { return this->selected_col; }
98 
100  inline glm::mat4 getProjectionMatrix() { return this->projectionMatrix; }
101 
103  inline glm::vec2 getZoomLimits() const { return glm::vec2(0.1f - view_pos.z * 0.5f , - view_pos.z * 2.5f - 20.0f); }
104 
105  private:
106 
108  LoaderScene( const LoaderScene&);
109 
111  // ----------------- functions for SHADER parsing -------------------- //
113 
115 
116  void parseShaders(std::FILE* _f);
117 
119 
125  void string2Shader( const std::string & _shader_type,
126  const std::string & _vertex_shader_path,
127  const std::string & _geometry_shader_path,
128  const std::string & _fragment_shader_path);
129 
131  // --------- functions for parsing of ENVIRONMENT PARAMETERS --------- //
133 
135 
136  void parseEnvironment( std::FILE* _f);
137 
139 
143  glm::vec3 string2Vec3(const std::string & _line);
144 
146 
150  float string2Float(const std::string & _line);
151 
153  // ------------------ functions for GEOMETRY parsing ----------------- //
155 
157 
158  void parseGeometry( std::FILE* _f);
159 
161 
169  void string2Geometry( const unsigned int _type,
170  const std::string & _object_name,
171  const std::string & _geometry_path,
172  const std::string & _diff_texture_path,
173  const std::string & _scale,
174  const std::string & _object_color);
175 
176 
178 
179  void parseNeighbors( std::FILE* _f);
180 
182 
186  void string2Neighbors( const std::string & _name, const std::string & _neighbors);
187 
189 
194  glm::vec3 name2Color( const std::string & _obj_name);
195 
197  // ---------------- functions for FBO and PP setup ------------------- //
199 
201 
202  void setupDrawing();
203 
205 
206  bool setupEDF();
208 
209  inline bool shaderEDFLoaded() const
210  {
213  return result;
214  }
215 
217 
218  bool setupSMF();
220 
221  inline bool shaderSMFLoaded() const
222  {
223  bool result = shader_loaded[VIS2_SHADER_TYPE_MASK];
225  return result;
226  }
227 
229 
230  bool setupDPS();
232 
233  inline bool shaderDPSLoaded() const
234  {
236  return result;
237  }
238 
240 
241  bool setupDPSB();
243 
244  inline bool shaderDPSBLoaded() const
245  {
247  return result;
248  }
249 
251 
256  glm::vec3 getSelectedColorId(glm::vec3 & _color_in, float _tolerance);
257 
258  // %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% //
259 
261  // ------------------- paramaters from CALLER ------------------------ //
263 
264  const unsigned int screen_width;
265  const unsigned int screen_height;
266  std::string scene_path;
267 
268  glm::vec4 light_pos_0;
269  glm::vec4 light_pos_1;
270 
271  glm::vec3 selected_col;
272 
273  glm::mat4 modelMatrix;
274 
276  // ----------------- paramaters from SCENE FILE ---------------------- //
278 
279  // ---------------------- scene environment -------------------------- //
280  glm::vec3 backgr_col;
281 
282  glm::vec4 view_pos;
283  glm::vec4 view_pos_lookAt;
284 
285  glm::mat4 projectionMatrix;
286 
287  glm::vec4 light_pos_0_init;
288  glm::vec4 light_pos_1_init;
289 
290  glm::vec3 light_col_0;
291  glm::vec3 light_col_1;
292 
293  glm::vec3 col_edges;
294 
295  // -------------- shader programs and controllers -------------- //
296 
300 
301 
302  // --------------- geometry objects in the scene ---------------- //
303 
304  const glm::mat4 mM_obj;
305 
306  unsigned int counter_shell_obj;
312 
313  unsigned int counter_content_obj;
319 
321 
322  unsigned int counter_separator_obj;
328 
330  // --------- paramaters and objects for POST-PROCESSING -------------- //
332 
333  // ------------- Frame Buffer Objects and Textures ------------------ //
335 
336  bool FBOs_ready;
337  glm::mat4 orthoMatrix;
338 
340 
343 
346 
348 
351 
353 
355 
356  };
357 }
358 
359 
360 #endif