![]() |
Vis 2 Demo
1.0
Technical illustration type real-time rendering of geometry
|
This class loads a scene from a scene description file and the _resource folder of the application. More...
Public Member Functions | |
LoaderScene (const std::string &_scene_path, const unsigned int _screen_w, const unsigned int _screen_h) | |
Constructor. More... | |
~LoaderScene () | |
Destructor. More... | |
int | loadScene () |
This function calls the parsers and prepares the scene for rendering. More... | |
void | updateScene (glm::mat4 &_modelMatrix) |
This function updates the scene. More... | |
void | drawScene (bool _mouse_right_click, float _mouse_x, float _mouse_y, bool _b_with_pp, bool _b_debug_mode, unsigned int _debug_pass) |
This function draws the objects in the scene. More... | |
glm::vec3 | getBackgrColor () const |
A getter for the background color. More... | |
glm::vec3 | getSelectedColor () |
A getter for the color picked by the mouse of the user in the caller component. More... | |
glm::mat4 | getProjectionMatrix () |
A getter for the projection matrix. More... | |
glm::vec2 | getZoomLimits () const |
A getter for the zoom limits according to viewer position and near and far planes of the projection matrix. More... | |
Private Member Functions | |
LoaderScene (const LoaderScene &) | |
Hidden copy-constructor. More... | |
void | parseShaders (std::FILE *_f) |
Function for parsing the shader descriptions. More... | |
void | string2Shader (const std::string &_shader_type, const std::string &_vertex_shader_path, const std::string &_geometry_shader_path, const std::string &_fragment_shader_path) |
Function for creating and loading shaders according to description. More... | |
void | parseEnvironment (std::FILE *_f) |
Function for parsing the descriptions of the environment variables (viewpoint, lights, etc.). More... | |
glm::vec3 | string2Vec3 (const std::string &_line) |
Function for parsing float vectors from strings. More... | |
float | string2Float (const std::string &_line) |
Function for parsing floats from strings. More... | |
void | parseGeometry (std::FILE *_f) |
Function for parsing the geometry descriptions. More... | |
void | string2Geometry (const unsigned int _type, const std::string &_object_name, const std::string &_geometry_path, const std::string &_diff_texture_path, const std::string &_scale, const std::string &_object_color) |
Function for creating and loading the geometric objects. More... | |
void | parseNeighbors (std::FILE *_f) |
Function for parsing the descriptions of the neighborhood relationships btw. the geometric objects in the scene. More... | |
void | string2Neighbors (const std::string &_name, const std::string &_neighbors) |
Function for parsing a neighborhood relationship. More... | |
glm::vec3 | name2Color (const std::string &_obj_name) |
Function for translating an objects name to its color. More... | |
void | setupDrawing () |
Function for initializing matrices, FBOs, etc. in preparation for draw calls. More... | |
bool | setupEDF () |
Function for setup of the EDGE DETECTION and FILTERING task. More... | |
bool | shaderEDFLoaded () const |
Function for checking if setup of the EDGE DETECTION and FILTERING task is possible. More... | |
bool | setupSMF () |
Function for setup of the SELECTION MASKING and FILTERING task. More... | |
bool | shaderSMFLoaded () const |
Function for checking if setup of the SELECTION MASKING and FILTERING task is possible. More... | |
bool | setupDPS () |
Function for setup of the DEPTH PEELING of the SHELL task. More... | |
bool | shaderDPSLoaded () const |
Function for checking if setup of the DEPTH PEELING of the SHELL and the BLENDING task is possible. More... | |
bool | setupDPSB () |
Function for setup of the BLENDING of the result of DEPTH PEELING task. More... | |
bool | shaderDPSBLoaded () const |
Function for checking if setup of the BLENDING of the result of DEPTH PEELING task is possible. More... | |
glm::vec3 | getSelectedColorId (glm::vec3 &_color_in, float _tolerance) |
Function finds the color among the contens objects that is closest to the input. More... | |
Private Attributes | |
const unsigned int | screen_width |
the viewport width is needed for the FBOs and postprocessing More... | |
const unsigned int | screen_height |
the viewport height is needed for the FBOs and postprocessing More... | |
std::string | scene_path |
the path to the file containing the scene description More... | |
glm::vec4 | light_pos_0 |
is the position of the 1. light source as a result of updates from the caller More... | |
glm::vec4 | light_pos_1 |
is the position of the 2. light source as a result of updates from the caller More... | |
glm::vec3 | selected_col |
is the color on which the user has clicked in the caller component More... | |
glm::mat4 | modelMatrix |
is the model matrix resulting from the user actions in the caller component More... | |
glm::vec3 | backgr_col |
is the viewport background color More... | |
glm::vec4 | view_pos |
is the position of the camera / viewer More... | |
glm::vec4 | view_pos_lookAt |
is the camera target More... | |
glm::mat4 | projectionMatrix |
is the projection matrix calculated using the two parameters above More... | |
glm::vec4 | light_pos_0_init |
is the initial position of the 1. light source More... | |
glm::vec4 | light_pos_1_init |
is the initial position of the 2. light source More... | |
glm::vec3 | light_col_0 |
is the color of the 1.light souce More... | |
glm::vec3 | light_col_1 |
is the color of the 2.light souce More... | |
glm::vec3 | col_edges |
is the color of the edges produced by the edge-finding shaders More... | |
bool | shader_loaded [VIS2_MAX_NR_SHADER_TYPES] |
is a binary flag array, signifying which shaders were loaded More... | |
vis2::Shader * | shaders [VIS2_MAX_NR_SHADER_TYPES] |
is an array of shader programs More... | |
vis2::ShaderController * | shader_ctrls [VIS2_MAX_NR_SHADER_TYPES] |
const glm::mat4 | mM_obj |
is the initial model matrix for all OBJ geometry (correction of y-z swap) More... | |
unsigned int | counter_shell_obj |
is the number of objects COMPRISING the shell More... | |
bool | shells_loaded [VIS2_SCENE_MAX_NR_SHELL_OBJ] |
is a binary flag array, signifying which SHELL slots are occupied More... | |
glm::mat4 | shells_mM [VIS2_SCENE_MAX_NR_SHELL_OBJ] |
is the array of the model matrices of each shell More... | |
vis2::LoaderOBJ * | loaders_shell [VIS2_SCENE_MAX_NR_SHELL_OBJ] |
is an array containing the geometry loaders for the SHELLS More... | |
vis2::Texture * | textures_shell [VIS2_SCENE_MAX_NR_SHELL_OBJ] |
is an array containing the diffuse textures for the SHELLS More... | |
vis2::ModelMultiTextured * | shells [VIS2_SCENE_MAX_NR_SHELL_OBJ] |
contains the SHELLS More... | |
unsigned int | counter_content_obj |
is the number of objects INSIDE the shell More... | |
bool | contents_loaded [VIS2_SCENE_MAX_NR_CONTENT_OBJ] |
is a binary flag array, signifying which CONTENTS slots are occupied More... | |
glm::mat4 | contents_mM [VIS2_SCENE_MAX_NR_CONTENT_OBJ] |
is the array of the model matrices of each content object More... | |
vis2::LoaderOBJ * | loaders_content [VIS2_SCENE_MAX_NR_CONTENT_OBJ] |
is an array containing the geometry loaders for the CONTENTS More... | |
vis2::Texture * | textures_content [VIS2_SCENE_MAX_NR_CONTENT_OBJ] |
is an array containing the diffuse textures for the CONTENTS More... | |
vis2::ModelMultiTextured * | contents [VIS2_SCENE_MAX_NR_CONTENT_OBJ] |
contains the CONTENTS More... | |
vis2::NeighborhoodRecord * | neighb_rec_Ptr |
holds the neighborhood relationships btw. the objects above More... | |
unsigned int | counter_separator_obj |
is the number of objects separating the contents inside the INSIDE the shell More... | |
bool | separators_loaded [VIS2_SCENE_MAX_NR_SEPARATOR_OBJ] |
is a binary flag array, signifying which SEPARATOR slots are occupied More... | |
glm::mat4 | separators_mM [VIS2_SCENE_MAX_NR_SEPARATOR_OBJ] |
is the array of the model matrices of each separator object More... | |
vis2::LoaderOBJ * | loaders_separator [VIS2_SCENE_MAX_NR_SEPARATOR_OBJ] |
is an array containing the geometry loaders for the SEPARATORS More... | |
vis2::Texture * | textures_separator [VIS2_SCENE_MAX_NR_SEPARATOR_OBJ] |
is an array containing the diffuse textures for the SEPARATORS More... | |
vis2::ModelMultiTextured * | separators [VIS2_SCENE_MAX_NR_SEPARATOR_OBJ] |
contains the SEPARATORS More... | |
bool | FBOs_ready |
saves the status of all FBOs and shader controllers needed for rendering More... | |
glm::mat4 | orthoMatrix |
is the orthogonal matrix for drawing the texture quads More... | |
vis2::FramebufferObject * | fbo_0 |
is the FBO for selecting objects More... | |
vis2::FramebufferObject * | fbos_EDF [VIS2_SCENE_NR_FBOS_EDF] |
contains FBOs for the EDGE DETECTION and FILTERING task More... | |
vis2::QuadTextured * | quads_EDF [VIS2_SCENE_NR_FBOS_EDF] |
quad for the EDGE DETECTION and FILTERING task More... | |
vis2::FramebufferObject * | fbos_SMF [VIS2_SCENE_NR_FBOS_SMF] |
contains FBOs for the SELECTION MASKING and FILTERING task More... | |
vis2::QuadTextured * | quads_SMF [VIS2_SCENE_NR_QUADS_SMF] |
quad for the SELECTION MASKING and FILTERING task More... | |
vis2::FramebufferObject * | fbos_DPS [VIS2_SCENE_NR_FBOS_DPS] |
contains FBOs for the DEPTH PEELING of the SHELL task More... | |
vis2::FramebufferObject * | fbos_DPSB [VIS2_SCENE_NR_FBOS_DPSB] |
contains FBOs for the BLENDING of the result of DEPTH PEELING task More... | |
vis2::QuadTextured * | quad_DPSB_Ptr |
quad for the BLENDING of the result of DEPTH PEELING task More... | |
vis2::QuadTextured * | quad_final_Ptr |
for the final blending of all components More... | |
vis2::QuadTextured * | quad_debug_Ptr |
quad for debugging texture output More... | |
This class loads a scene from a scene description file and the _resource folder of the application.
This class uses the scene file description in folder "_resources/Levels/" to load objects with
geometry in folder "_resources/Models/..." and textures in folder "_resources/Textures".
The scene description file also includes shader program definitions referncing the folder "_resources/Shader"
as well as definitions of environment variables (i.e. light sources, background color etc.) and
object neighborhood relationships.
Definition at line 48 of file LoaderScene.h.
LoaderScene::LoaderScene | ( | const std::string & | _scene_path, |
const unsigned int | _screen_w, | ||
const unsigned int | _screen_h | ||
) |
Constructor.
Checks if the file extension of the scene description file is TXT and initiates all loading flags to false.
If the file extension is not valid the application terminates.
[in] | _scene_path | is the path to the scene description file. |
[in] | _screen_w | is the viewport width, |
[in] | _screen_h | is the viewport height. |
Definition at line 8 of file LoaderScene.cpp.
LoaderScene::~LoaderScene | ( | ) |
Destructor.
Deletes all shader and shader controller objects, all drawable objects, the neighboring service,
and the Frame Buffer Objects and quads for post-processing effects.
Definition at line 51 of file LoaderScene.cpp.
|
private |
Hidden copy-constructor.
void LoaderScene::drawScene | ( | bool | _mouse_right_click, |
float | _mouse_x, | ||
float | _mouse_y, | ||
bool | _b_with_pp, | ||
bool | _b_debug_mode, | ||
unsigned int | _debug_pass | ||
) |
This function draws the objects in the scene.
Definition at line 278 of file LoaderScene.cpp.
|
inline |
A getter for the background color.
Definition at line 94 of file LoaderScene.h.
|
inline |
A getter for the projection matrix.
Definition at line 100 of file LoaderScene.h.
|
inline |
A getter for the color picked by the mouse of the user in the caller component.
Definition at line 97 of file LoaderScene.h.
|
private |
Function finds the color among the contens objects that is closest to the input.
[in] | _color_in | is the given color (selected by the user), |
[in] | _tolerance | is the margin of possible error, |
Definition at line 1197 of file LoaderScene.cpp.
|
inline |
A getter for the zoom limits according to viewer position and near and far planes of the projection matrix.
Definition at line 103 of file LoaderScene.h.
int LoaderScene::loadScene | ( | ) |
This function calls the parsers and prepares the scene for rendering.
The parsing order is: shader, shader controller, environment, geometry, neighborhood.
Definition at line 139 of file LoaderScene.cpp.
|
private |
Function for translating an objects name to its color.
[in] | _obj_name | is the name of the object, |
Definition at line 974 of file LoaderScene.cpp.
|
private |
Function for parsing the descriptions of the environment variables (viewpoint, lights, etc.).
[in] | _f | is the scene description file opened for reading |
Definition at line 620 of file LoaderScene.cpp.
|
private |
Function for parsing the geometry descriptions.
[in] | _f | is the scene description file opened for reading |
Definition at line 727 of file LoaderScene.cpp.
|
private |
Function for parsing the descriptions of the neighborhood relationships btw. the geometric objects in the scene.
[in] | _f | is the scene description file opened for reading |
Definition at line 905 of file LoaderScene.cpp.
|
private |
Function for parsing the shader descriptions.
[in] | _f | is the scene description file opened for reading |
Definition at line 553 of file LoaderScene.cpp.
|
private |
Function for setup of the DEPTH PEELING of the SHELL task.
Definition at line 1158 of file LoaderScene.cpp.
|
private |
Function for setup of the BLENDING of the result of DEPTH PEELING task.
Definition at line 1175 of file LoaderScene.cpp.
|
private |
Function for initializing matrices, FBOs, etc. in preparation for draw calls.
If the setup of the FBOs fails, no post-processing effects are drawn.
Definition at line 1032 of file LoaderScene.cpp.
|
private |
Function for setup of the EDGE DETECTION and FILTERING task.
Definition at line 1106 of file LoaderScene.cpp.
|
private |
Function for setup of the SELECTION MASKING and FILTERING task.
Definition at line 1133 of file LoaderScene.cpp.
|
inlineprivate |
Function for checking if setup of the BLENDING of the result of DEPTH PEELING task is possible.
Definition at line 244 of file LoaderScene.h.
|
inlineprivate |
Function for checking if setup of the DEPTH PEELING of the SHELL and the BLENDING task is possible.
Definition at line 233 of file LoaderScene.h.
|
inlineprivate |
Function for checking if setup of the EDGE DETECTION and FILTERING task is possible.
Definition at line 209 of file LoaderScene.h.
|
inlineprivate |
Function for checking if setup of the SELECTION MASKING and FILTERING task is possible.
Definition at line 221 of file LoaderScene.h.
|
private |
Function for parsing floats from strings.
[in] | is the string to be parsed, |
Definition at line 708 of file LoaderScene.cpp.
|
private |
Function for creating and loading the geometric objects.
[in] | _type | is the type of the shader (see definitions in ShaderController), |
[in] | _object_name | is the object name, |
[in] | _geometry_path | contains the path to the OBJ file, |
[in] | _diff_texture_path | contains the path to the texture file, |
[in] | _scale | contains uniform scale of the object, |
[in] | _object_color | contains the color of the object for post-processing effects. |
Definition at line 800 of file LoaderScene.cpp.
|
private |
Function for parsing a neighborhood relationship.
[in] | _name | is the object name, |
[in] | _neighbors | is a string containing the names of all its neighbor. |
Definition at line 934 of file LoaderScene.cpp.
|
private |
Function for creating and loading shaders according to description.
[in] | _shader_type | contains the type of the shader, |
[in] | _vertex_shader_path | contains the path to the vertex shader file, |
[in] | _geometry_shader_path | contains the path to the geometry shader file, |
[in] | _fragment_shader_path | contains the path to the fragment shader file. |
Definition at line 587 of file LoaderScene.cpp.
|
private |
Function for parsing float vectors from strings.
[in] | is the string to be parsed, |
Definition at line 683 of file LoaderScene.cpp.
void LoaderScene::updateScene | ( | glm::mat4 & | _modelMatrix | ) |
This function updates the scene.
[in] | _modelMatrix | is the new model matrix resulting from the user actions in the caller component |
Definition at line 248 of file LoaderScene.cpp.
|
private |
is the viewport background color
Definition at line 280 of file LoaderScene.h.
|
private |
is the color of the edges produced by the edge-finding shaders
Definition at line 293 of file LoaderScene.h.
|
private |
contains the CONTENTS
Definition at line 318 of file LoaderScene.h.
|
private |
is a binary flag array, signifying which CONTENTS slots are occupied
Definition at line 314 of file LoaderScene.h.
|
private |
is the array of the model matrices of each content object
Definition at line 315 of file LoaderScene.h.
|
private |
is the number of objects INSIDE the shell
Definition at line 313 of file LoaderScene.h.
|
private |
is the number of objects separating the contents inside the INSIDE the shell
Definition at line 322 of file LoaderScene.h.
|
private |
is the number of objects COMPRISING the shell
Definition at line 306 of file LoaderScene.h.
|
private |
is the FBO for selecting objects
Definition at line 339 of file LoaderScene.h.
|
private |
contains FBOs for the DEPTH PEELING of the SHELL task
Definition at line 347 of file LoaderScene.h.
|
private |
contains FBOs for the BLENDING of the result of DEPTH PEELING task
Definition at line 349 of file LoaderScene.h.
|
private |
contains FBOs for the EDGE DETECTION and FILTERING task
Definition at line 341 of file LoaderScene.h.
|
private |
saves the status of all FBOs and shader controllers needed for rendering
Definition at line 336 of file LoaderScene.h.
|
private |
contains FBOs for the SELECTION MASKING and FILTERING task
Definition at line 344 of file LoaderScene.h.
|
private |
is the color of the 1.light souce
Definition at line 290 of file LoaderScene.h.
|
private |
is the color of the 2.light souce
Definition at line 291 of file LoaderScene.h.
|
private |
is the position of the 1. light source as a result of updates from the caller
Definition at line 268 of file LoaderScene.h.
|
private |
is the initial position of the 1. light source
Definition at line 287 of file LoaderScene.h.
|
private |
is the position of the 2. light source as a result of updates from the caller
Definition at line 269 of file LoaderScene.h.
|
private |
is the initial position of the 2. light source
Definition at line 288 of file LoaderScene.h.
|
private |
is an array containing the geometry loaders for the CONTENTS
Definition at line 316 of file LoaderScene.h.
|
private |
is an array containing the geometry loaders for the SEPARATORS
Definition at line 325 of file LoaderScene.h.
|
private |
is an array containing the geometry loaders for the SHELLS
Definition at line 309 of file LoaderScene.h.
|
private |
is the initial model matrix for all OBJ geometry (correction of y-z swap)
Definition at line 304 of file LoaderScene.h.
|
private |
is the model matrix resulting from the user actions in the caller component
Definition at line 273 of file LoaderScene.h.
|
private |
holds the neighborhood relationships btw. the objects above
Definition at line 320 of file LoaderScene.h.
|
private |
is the orthogonal matrix for drawing the texture quads
Definition at line 337 of file LoaderScene.h.
|
private |
is the projection matrix calculated using the two parameters above
Definition at line 285 of file LoaderScene.h.
|
private |
quad for debugging texture output
Definition at line 354 of file LoaderScene.h.
|
private |
quad for the BLENDING of the result of DEPTH PEELING task
Definition at line 350 of file LoaderScene.h.
|
private |
for the final blending of all components
Definition at line 352 of file LoaderScene.h.
|
private |
quad for the EDGE DETECTION and FILTERING task
Definition at line 342 of file LoaderScene.h.
|
private |
quad for the SELECTION MASKING and FILTERING task
Definition at line 345 of file LoaderScene.h.
|
private |
the path to the file containing the scene description
Definition at line 266 of file LoaderScene.h.
|
private |
the viewport height is needed for the FBOs and postprocessing
Definition at line 265 of file LoaderScene.h.
|
private |
the viewport width is needed for the FBOs and postprocessing
Definition at line 264 of file LoaderScene.h.
|
private |
is the color on which the user has clicked in the caller component
Definition at line 271 of file LoaderScene.h.
|
private |
contains the SEPARATORS
Definition at line 327 of file LoaderScene.h.
|
private |
is a binary flag array, signifying which SEPARATOR slots are occupied
Definition at line 323 of file LoaderScene.h.
|
private |
is the array of the model matrices of each separator object
Definition at line 324 of file LoaderScene.h.
|
private |
is an array of shader controllers for communication with the shaders
Definition at line 299 of file LoaderScene.h.
|
private |
is a binary flag array, signifying which shaders were loaded
Definition at line 297 of file LoaderScene.h.
|
private |
is an array of shader programs
Definition at line 298 of file LoaderScene.h.
|
private |
contains the SHELLS
Definition at line 311 of file LoaderScene.h.
|
private |
is a binary flag array, signifying which SHELL slots are occupied
Definition at line 307 of file LoaderScene.h.
|
private |
is the array of the model matrices of each shell
Definition at line 308 of file LoaderScene.h.
|
private |
is an array containing the diffuse textures for the CONTENTS
Definition at line 317 of file LoaderScene.h.
|
private |
is an array containing the diffuse textures for the SEPARATORS
Definition at line 326 of file LoaderScene.h.
|
private |
is an array containing the diffuse textures for the SHELLS
Definition at line 310 of file LoaderScene.h.
|
private |
is the position of the camera / viewer
Definition at line 282 of file LoaderScene.h.
|
private |
is the camera target
Definition at line 283 of file LoaderScene.h.