10 screen_width(_screen_w), screen_height(_screen_h), backgr_col(glm::vec3(1.0f, 1.0f, 1.0f)),
11 view_pos(glm::vec4(0.0f, 0.0f, -1.0f, 1.0f)), view_pos_lookAt(glm::vec4(0.0f, 0.0f, 0.0f, 1.0f)),
12 light_pos_0_init(glm::vec4(-10.0f, 10.0f, -10.0f, 1.0f)), light_col_0(glm::vec3(1.0f, 1.0f, 1.0f)),
13 light_pos_1_init(glm::vec4( 10.0f, -10.0f, 10.0f, 1.0f)), light_col_1(glm::vec3(1.0f, 1.0f, 1.0f)),
14 col_edges(glm::vec3(0.0f, 0.0f, 0.0f)),
15 mM_obj(glm::rotate(glm::mat4(1.0f), -90.0f, glm::vec3(1.0f, 0.0f, 0.0f))),
16 counter_shell_obj(0), counter_content_obj(0), counter_separator_obj(0),
20 if (_scene_path.size() > 4 && !_scene_path.substr(_scene_path.size()-4).compare(
".txt")) {
45 std::cout <<
"The valid file extension for a scene file is \"txt\"!" << std::endl;
142 std::cout <<
"Loading Scene File from ...\"" <<
scene_path <<
"\"." << std::endl;
151 std::cout <<
"Failed to open file \"" <<
scene_path <<
"\" !" << std::endl;
168 std::cout <<
"Failed to open file \"" <<
scene_path <<
"\" !" << std::endl;
211 std::cout <<
"Failed to open file \"" <<
scene_path <<
"\" !" << std::endl;
225 std::cout <<
"Failed to open file \"" <<
scene_path <<
"\" !" << std::endl;
279 bool _b_with_pp,
bool _b_debug_mode,
unsigned int _debug_pass)
281 unsigned int counter_neighb_sel = 0;
286 glDisable(GL_CULL_FACE);
295 if (_mouse_right_click)
297 GLfloat selectedCol[4];
299 selected_col = glm::vec3(selectedCol[0], selectedCol[1], selectedCol[2]);
302 glEnable(GL_CULL_FACE);
351 counter_neighb_sel++;
352 if (counter_neighb_sel == 1)
386 glDisable(GL_CULL_FACE);
433 glEnable(GL_CULL_FACE);
444 unsigned int counter_selected_obj = 0;
450 if (tmp_col.r == selected_col_id.r && tmp_col.g == selected_col_id.g && tmp_col.b == selected_col_id.b)
452 counter_selected_obj++;
454 if (counter_selected_obj == 1)
463 if (counter_selected_obj > 0)
470 if (tmp_col.r == selected_col_id.r && tmp_col.g == selected_col_id.g && tmp_col.b == selected_col_id.b)
478 if (counter_selected_obj > 0)
518 if (
FBOs_ready && _b_with_pp && _b_debug_mode)
556 std::ifstream file_stream(_f);
557 std::string file_line;
558 while (!file_stream.eof())
560 std::getline(file_stream, file_line);
568 if (!file_line.substr(0,7).compare(
"#shader"))
570 std::string shader_type;
571 std::string vertex_shader_path;
572 std::string geometry_shader_path;
573 std::string fragment_shader_path;
575 std::getline(file_stream, shader_type);
576 std::getline(file_stream, vertex_shader_path);
577 std::getline(file_stream, geometry_shader_path);
578 std::getline(file_stream, fragment_shader_path);
580 string2Shader(shader_type, vertex_shader_path, geometry_shader_path, fragment_shader_path);
588 const std::string & _vertex_shader_path,
589 const std::string & _geometry_shader_path,
590 const std::string & _fragment_shader_path)
592 if (_shader_type.empty() ||
593 _vertex_shader_path.empty() || _vertex_shader_path.size() < 5 ||
594 _geometry_shader_path.empty() || _geometry_shader_path.size() < 4 ||
595 _fragment_shader_path.empty() || _fragment_shader_path.size() < 5)
600 std::stringstream type_ss(_shader_type);
601 if ((type_ss>>type).fail())
610 std::cout <<
"SHADER TYPE " << type <<
" loaded." << std::endl;
622 unsigned int counter_lights = 0;
625 std::ifstream file_stream(_f);
626 std::string file_line;
627 while (!file_stream.eof())
629 std::getline(file_stream, file_line);
630 if (!file_line.substr(0,13).compare(
"#backgr_color"))
632 std::string str_color;
633 std::getline(file_stream, str_color);
636 else if (!file_line.substr(0,11).compare(
"#viewer_pos"))
639 std::getline(file_stream, str_pos);
641 this->
view_pos = glm::vec4(pos_inhomog.x, pos_inhomog.y, pos_inhomog.z, 1.0f);
643 else if (!file_line.substr(0,15).compare(
"#viewer_look_at"))
645 std::string str_look_at;
646 std::getline(file_stream, str_look_at);
647 glm::vec3 look_at_inhomog =
string2Vec3(str_look_at);
648 this->
view_pos_lookAt = glm::vec4(look_at_inhomog.x, look_at_inhomog.y, look_at_inhomog.z, 1.0f);
650 else if (!file_line.substr(0,6).compare(
"#light"))
653 if (counter_lights > 1)
658 std::getline(file_stream, str_pos);
659 std::getline(file_stream, str_col);
660 if (counter_lights == 0)
662 glm::vec3 light_0_pos_inhomog =
string2Vec3(str_pos);
663 this->
light_pos_0_init = glm::vec4(light_0_pos_inhomog.x, light_0_pos_inhomog.y, light_0_pos_inhomog.z, 1.0f);
668 glm::vec3 light_1_pos_inhomog =
string2Vec3(str_pos);
669 this->
light_pos_1_init = glm::vec4(light_1_pos_inhomog.x, light_1_pos_inhomog.y, light_1_pos_inhomog.z, 1.0f);
674 else if (!file_line.substr(0,11).compare(
"#edge_color"))
676 std::string str_color;
677 std::getline(file_stream, str_color);
686 glm::vec3 values = glm::vec3(0.0f, 0.0f, 0.0f);
689 std::stringstream line_ss(_line);
692 std::string str_item;
693 unsigned int counter = 0;
694 while(std::getline(line_ss,str_item,
' ') && counter < 3)
697 std::stringstream item_ss(str_item);
698 if (!(item_ss>>num).fail())
700 values[counter] = num;
713 std::stringstream line_ss(_line);
714 if (!(line_ss>>num).fail())
730 std::ifstream file_stream(_f);
731 std::string file_line;
732 while (!file_stream.eof())
734 std::getline(file_stream, file_line);
743 if (!file_line.substr(0,6).compare(
"#shell"))
745 std::string object_name;
746 std::string geometry_path;
747 std::string diff_texture_path;
749 std::string object_color;
751 std::getline(file_stream, object_name);
752 std::getline(file_stream, geometry_path);
753 std::getline(file_stream, diff_texture_path);
754 std::getline(file_stream, scale);
755 std::getline(file_stream, object_color);
759 else if (!file_line.substr(0,8).compare(
"#content"))
761 std::string object_name;
762 std::string geometry_path;
763 std::string diff_texture_path;
765 std::string object_color;
767 std::getline(file_stream, object_name);
768 std::getline(file_stream, geometry_path);
769 std::getline(file_stream, diff_texture_path);
770 std::getline(file_stream, scale);
771 std::getline(file_stream, object_color);
775 else if (!file_line.substr(0,10).compare(
"#separator"))
777 std::string object_name;
778 std::string geometry_path;
779 std::string diff_texture_path;
781 std::string object_color;
783 std::getline(file_stream, object_name);
784 std::getline(file_stream, geometry_path);
785 std::getline(file_stream, diff_texture_path);
786 std::getline(file_stream, scale);
787 std::getline(file_stream, object_color);
801 const std::string & _object_name,
802 const std::string & _geometry_path,
803 const std::string & _diff_texture_path,
804 const std::string & _scale,
805 const std::string & _object_color)
812 if (_object_name.empty() ||
813 _geometry_path.empty() || _geometry_path.size() < 5 ||
814 _diff_texture_path.empty() || _diff_texture_path.size() < 5 ||
815 _scale.empty() || _object_color.empty())
819 char* obj_name_copy =
new char[_object_name.size()+1];
820 sprintf_s(obj_name_copy, _object_name.size()+1,
"%s", _object_name.c_str());
824 const glm::vec3 obj_color =
string2Vec3(_object_color);
871 counter_content_obj++;
894 counter_separator_obj++;
908 std::ifstream file_stream(_f);
909 std::string file_line;
910 while (!file_stream.eof())
912 std::getline(file_stream, file_line);
918 if (!file_line.substr(0,10).compare(
"#neighbors"))
920 std::string object_name;
921 std::string neighbors_list;
923 std::getline(file_stream, object_name);
924 std::getline(file_stream, neighbors_list);
930 std::cout <<
"\nNEIGHTBORS:" << std::endl;
936 if (_name.empty() || _neighbors.empty() || (!_neighbors.compare(
"NONE")))
942 if (obj_col.r == this->backgr_col.r && obj_col.g == this->backgr_col.g && obj_col.b == this->backgr_col.b)
949 std::stringstream neighbors_ss(_neighbors);
952 std::string str_neighb;
953 while(std::getline(neighbors_ss,str_neighb,
' '))
955 glm::vec3 neighb_col =
name2Color(str_neighb);
957 if ((neighb_col.r == this->backgr_col.r && neighb_col.g == this->backgr_col.g && neighb_col.b == this->backgr_col.b) ||
958 (obj_col.r == neighb_col.r && obj_col.g == neighb_col.g && obj_col.b == neighb_col.b))
978 if (_obj_name.empty())
981 bool obj_name_found =
false;
986 if (!_obj_name.compare(tmp_name))
989 obj_name_found =
true;
999 if (!_obj_name.compare(tmp_name))
1002 obj_name_found =
true;
1008 if (!obj_name_found)
1013 if (!_obj_name.compare(tmp_name))
1016 obj_name_found =
true;
1045 this->
orthoMatrix = glm::ortho(0.0f, 1.0f, 1.0f, 0.0f, -1.0f, 1.0f);
1065 std::cout <<
"Edge Detection and Filtering setup failed! No post-processing effects." << std::endl;
1073 std::cout <<
"Selection Masking and Filtering setup failed! No post-processing effects." << std::endl;
1081 std::cout <<
"Depth Peeling of Shell setup failed! No post-processing effects." << std::endl;
1089 std::cout <<
"Blending of the Depth Peeling setup failed! No post-processing effects." << std::endl;
1208 found = (abs(tmp_col.r - _color_in.r) < _tolerance) &&
1209 (abs(tmp_col.g - _color_in.g) < _tolerance) &&
1210 (abs(tmp_col.b - _color_in.b) < _tolerance);
1213 found_col = tmp_col;