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 00020 00021 #ifndef _NAVIGATOR_TOOL_HPP_ 00022 #define _NAVIGATOR_TOOL_HPP_ 00023 00024 #include <trackball.hpp> 00025 #include <v3.hpp> 00026 00027 #include <vector> 00028 00029 namespace cpe 00030 { 00031 00043 class navigator_tool 00044 { 00045 public: 00046 00047 // ********************************************* // 00048 // ********************************************* // 00049 // CONSTRUCTORS 00050 // ********************************************* // 00051 // ********************************************* // 00052 00054 navigator_tool(); 00055 00056 00057 // ********************************************* // 00058 // ********************************************* // 00059 // Screen parameters 00060 // ********************************************* // 00061 // ********************************************* // 00062 00064 unsigned int& screen_size_x(); 00066 const unsigned int& screen_size_x() const; 00067 00069 unsigned int& screen_size_y(); 00071 const unsigned int& screen_size_y() const; 00072 00073 00074 // ********************************************* // 00075 // ********************************************* // 00076 // Camera manipulation 00077 // ********************************************* // 00078 // ********************************************* // 00079 00081 double& dist_cam(); 00083 const double& dist_cam() const; 00084 00086 void go_forward(const double& dL); 00088 void go_right (const double& dL); 00090 void go_up (const double& dL); 00091 00092 00094 void trackball_rotate(const int& x,const int&y); 00096 void trackball_zoom(const int& y); 00097 00098 00099 // ********************************************* // 00100 // ********************************************* // 00101 // Mouse record 00102 // ********************************************* // 00103 // ********************************************* // 00104 00106 int& x_previous(); 00108 const int& x_previous() const; 00109 00111 int& y_previous(); 00113 const int& y_previous() const; 00114 00116 bool& left_button(); 00118 const bool& left_button() const; 00119 00121 bool& right_button(); 00123 const bool& right_button() const; 00124 00125 00126 00127 00128 // ********************************************* // 00129 // ********************************************* // 00130 // Projection parameters 00131 // ********************************************* // 00132 // ********************************************* // 00133 00146 std::vector<double> projection_param() const; 00147 00148 00149 // ********************************************* // 00150 // ********************************************* // 00151 // Camera orientation 00152 // ********************************************* // 00153 // ********************************************* // 00154 00156 matrix3 camera_orientation() const; 00158 v3 camera_translation() const; 00159 00161 v3 camera_position() const; 00162 00163 00164 // ********************************************* // 00165 // ********************************************* // 00166 // FPS 00167 // ********************************************* // 00168 // ********************************************* // 00169 00171 void increase_frame_number(); 00172 00174 const unsigned int& time() const; 00176 unsigned int& time(); 00177 00179 double update_fps(); 00181 double delta_time(); 00182 00184 double fps(); 00185 00186 // ********************************************* // 00187 // ********************************************* // 00188 // Picking 00189 // ********************************************* // 00190 // ********************************************* // 00194 std::pair<v3,v3> ray_world_space_cam1(const int& x_screen,const int& y_screen) const; 00195 00196 00197 private: 00198 00199 00200 // ********************************************* // 00201 // ********************************************* // 00202 // Internal Camera Parameters 00203 // ********************************************* // 00204 // ********************************************* // 00205 00207 trackball track; 00209 v3 tr; 00211 double dist; 00212 00214 double fov; 00216 double znear; 00218 double zfar; 00219 00220 // ********************************************* // 00221 // ********************************************* // 00222 // Window and mouse parameters 00223 // ********************************************* // 00224 // ********************************************* // 00225 00227 unsigned int x_size; 00229 unsigned int y_size; 00230 00232 int mouse_x_previous; 00234 int mouse_y_previous; 00235 00236 00238 bool is_left_button; 00240 bool is_right_button; 00241 00242 // ********************************************* // 00243 // ********************************************* // 00244 // Time parameter 00245 // ********************************************* // 00246 // ********************************************* // 00247 00249 double current_fps; 00251 unsigned int current_time; 00253 unsigned int old_time; 00255 unsigned int frame; 00256 00257 }; 00258 } 00259 00260 #endif