00001 /* 00002 ** TP 4ETI CPE Lyon 00003 ** Copyright (C) 2012 Damien Rohmer 00004 ** 00005 ** This program is free software: you can redistribute it and/or modify 00006 ** it under the terms of the GNU General Public License as published by 00007 ** the Free Software Foundation, either version 3 of the License, or 00008 ** (at your option) any later version. 00009 ** 00010 ** This program is distributed in the hope that it will be useful, 00011 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 ** GNU General Public License for more details. 00014 ** 00015 ** You should have received a copy of the GNU General Public License 00016 ** along with this program. If not, see <http://www.gnu.org/licenses/>. 00017 */ 00018 00019 00023 #ifndef _SCENE_HPP_ 00024 #define _SCENE_HPP_ 00025 00026 #include <v3.hpp> 00027 #include <mesh.hpp> 00028 #include <grid.hpp> 00029 #include <surface_param_drawable.hpp> 00030 #include <picking_data.hpp> 00031 #include <gui_interface.hpp> 00032 00033 #include <vector> 00034 00035 class glwidget; 00036 00037 class scene 00038 { 00039 private: 00040 00042 cpe::grid g0; 00044 cpe::surface_param_drawable surf; 00045 00046 public: 00047 00048 // ********************************************* // 00049 // ********************************************* // 00050 // CONSTRUCTORS 00051 // ********************************************* // 00052 // ********************************************* // 00053 00055 scene(); 00056 00057 00058 // ********************************************* // 00059 // ********************************************* // 00060 // Scene construction and drawing 00061 // ********************************************* // 00062 // ********************************************* // 00063 00065 void load_model(); 00067 void draw_scene(); 00068 00069 // ********************************************* // 00070 // ********************************************* // 00071 // Spline manager 00072 // ********************************************* // 00073 // ********************************************* // 00074 00076 void build_spline_surface(const unsigned int& N_samples); 00078 void fill_patch(const unsigned int& index_surface,const cpe::patch4& p,const unsigned int& N_samples); 00080 void compute_curve_spline(); 00081 00083 void update_high_res(); 00085 void update_low_res(); 00086 00087 00088 00089 // ********************************************* // 00090 // ********************************************* // 00091 // Grid manager 00092 // ********************************************* // 00093 // ********************************************* // 00094 00096 void picking_grid(const cpe::v3& center_ray,const cpe::v3& direction_ray); 00098 void translate_picking(const cpe::v3 t); 00099 00101 void add_u_back_line(); 00103 void add_v_back_line(); 00105 void add_u_front_line(); 00107 void add_v_front_line(); 00108 00110 void erase_u_back_line(); 00112 void erase_v_back_line(); 00114 void erase_u_front_line(); 00116 void erase_v_front_line(); 00117 00119 void duplicate_boundary(); 00120 00121 00122 00123 // ********************************************* // 00124 // ********************************************* // 00125 // Gui Helpers 00126 // ********************************************* // 00127 // ********************************************* // 00128 00129 00131 void set_glwidget(glwidget *p_widget); 00132 00134 cpe::gui_interface& gui_visible_interface(); 00135 00136 00137 00138 private: 00139 00141 std::vector<cpe::v3> color_table; 00142 00144 std::vector<std::vector<cpe::v3> > curve_spline; 00145 00147 cpe::mesh sphere; 00149 std::vector<cpe::v3> sphere_normal; 00151 void preload_sphere(); 00152 00154 cpe::picking_data pick; 00155 00157 unsigned int N_sample_high_res; 00159 unsigned int N_sample_low_res; 00160 00161 00163 cpe::gui_interface gui_visible; 00164 00166 unsigned int counter_update; 00167 00168 00170 void init_gui_visibility(); 00172 void init_color_table(); 00173 00174 }; 00175 00176 #endif