scene.hpp
Go to the documentation of this file.
1 /*
2 ** TP CPE Lyon
3 ** Copyright (C) 2013 Damien Rohmer
4 **
5 ** This program is free software: you can redistribute it and/or modify
6 ** it under the terms of the GNU General Public License as published by
7 ** the Free Software Foundation, either version 3 of the License, or
8 ** (at your option) any later version.
9 **
10 ** This program is distributed in the hope that it will be useful,
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ** GNU General Public License for more details.
14 **
15 ** You should have received a copy of the GNU General Public License
16 ** along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 
20 
21 
22 #ifndef SCENE_HPP_
23 #define SCENE_HPP_
24 
25 #include <vec3.hpp>
26 #include <mesh.hpp>
27 #include <grid.hpp>
29 #include <picking_data.hpp>
30 #include <gui_interface.hpp>
31 
32 #include <vector>
33 
34 class glwidget;
35 
36 class scene
37 {
38  private:
39 
43  std::vector<cpe::surface_param_drawable> surf;
44 
45  public:
46 
47  // ********************************************* //
48  // ********************************************* //
49  // CONSTRUCTORS
50  // ********************************************* //
51  // ********************************************* //
52 
54  scene();
55 
56 
57  // ********************************************* //
58  // ********************************************* //
59  // Scene construction and drawing
60  // ********************************************* //
61  // ********************************************* //
62 
64  void load_model();
66  void draw_scene();
67 
68  // ********************************************* //
69  // ********************************************* //
70  // Spline manager
71  // ********************************************* //
72  // ********************************************* //
73 
75  void build_spline_surface(const unsigned int& N_samples);
77  void fill_patch(const unsigned int& index_surface,const cpe::patch4& p,const unsigned int& N_samples);
79  void compute_curve_spline();
80 
82  void update_high_res();
84  void update_low_res();
85 
86 
87 
88  // ********************************************* //
89  // ********************************************* //
90  // Grid manager
91  // ********************************************* //
92  // ********************************************* //
93 
95  void picking_grid(const cpe::vec3& center_ray,const cpe::vec3& direction_ray);
97  void translate_picking(const cpe::vec3 t);
98 
100  void add_u_back_line();
102  void add_v_back_line();
104  void add_u_front_line();
106  void add_v_front_line();
107 
109  void erase_u_back_line();
111  void erase_v_back_line();
113  void erase_u_front_line();
115  void erase_v_front_line();
116 
118  void duplicate_boundary();
119 
121  void load_grid();
123  void save_grid() const;
124 
125 
126  // ********************************************* //
127  // ********************************************* //
128  // Gui Helpers
129  // ********************************************* //
130  // ********************************************* //
131 
132 
134  void set_glwidget(glwidget *p_widget);
135 
138 
139 
140 
141  private:
142 
144  std::vector<cpe::vec3> color_table;
145 
147  std::vector<std::vector<cpe::vec3> > curve_spline;
148 
152  std::vector<cpe::vec3> sphere_normal;
154  void preload_sphere();
155 
158 
160  std::string filename_grid;
161 
163  unsigned int N_sample_high_res;
165  unsigned int N_sample_low_res;
166 
167 
170 
172  unsigned int counter_update;
173 
174 
176  void init_gui_visibility();
178  void init_color_table();
179 
180 };
181 
182 #endif