MC_navigator_tool.hpp

Go to the documentation of this file.
00001 /*
00002 **    Mesh Converter
00003 **    Copyright (C) 2008  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 #ifndef _MC_NAVIGATOR_TOOL_HPP_
00021 #define _MC_NAVIGATOR_TOOL_HPP_
00022 
00023 #include <MC_v3d.hpp>
00024 #include <MC_trackball.hpp>
00025 
00026 
00027 namespace mesh_conv
00028 {
00029 
00031     class MC_navigator_tool
00032     {
00033 
00034         public:
00035 
00036         MC_navigator_tool();
00037 
00038         //*********************************************//
00039         //ORIENTATION
00040         //*********************************************//
00041 
00042         // orientation of camera 1
00043         MC_trackball trackball_cam1;
00044         // translation of the camera 1
00045         MC_v3d tr_cam1;
00046         // distance to camera 1
00047         double dist_cam1;
00048 
00049 
00050         // orientation of light 1
00051         MC_trackball trackball_light1;
00052         // translation of the light 1
00053         MC_v3d tr_light1;
00054         // distance to light 1
00055         double dist_light1;
00056 
00057         // Matrix light1
00058         MC_matrix current_light1() const;
00059         //  get the matrix parameters for light1
00061         MC_v3d_vector axis_light1() const;
00062 
00063 
00064         // Matrix camera1
00065         MC_matrix current_cam1() const;
00066         //  get the matrix parameters
00068         MC_v3d_vector axis_cam1() const;
00069 
00070         // move camera trackball (forward=q*(0,0,1))
00071         void go_forward_trackball_cam1(const double& d_L);
00072         // move camera trackball (right=q*(-1,0,0))
00073         void go_right_trackball_cam1(const double& d_L);
00074         // move camera trackball (up=q*(0,-1,0))
00075         void go_up_trackball_cam1(const double& d_L);
00076 
00077         // save cam1
00078         std::ostream& write_cam1(std::ostream& stream) const;
00079         // save cam1 to file
00080         const MC_navigator_tool& write_cam1_file(std::string& filename) const;
00081         //load cam1
00082         MC_navigator_tool& read_cam1(std::istream& param);
00083         //load cam1 file
00084         MC_navigator_tool& read_cam1_file(const std::string& filename);
00085 
00086         // save light1
00087         std::ostream& write_light1(std::ostream& stream) const;
00088         // save light1 to file
00089         const MC_navigator_tool& write_light1_file(std::string& filename) const;
00090         //load light1
00091         MC_navigator_tool& read_light1(std::istream& param);
00092         //load light1 file
00093         MC_navigator_tool& read_light1_file(const std::string& filename);
00094 
00095 
00096         //*********************************************//
00097         //TIME
00098         //*********************************************//
00099 
00101         double delta_time() {return current_time-old_time;}
00103         double update_fps();
00105         int increase_frame_number() {++frame;return frame;}
00106         unsigned int current_time,old_time,frame;
00107         double current_fps;
00108 
00109         //*********************************************//
00110         //Mouse record
00111         //*********************************************//
00112 
00113         int x_previous,y_previous;
00114 
00115         //*********************************************//
00116         //Screen Size
00117         //*********************************************//
00118 
00119         int x_screen_size_1,y_screen_size_1;
00120 
00121         //*********************************************//
00122         //Projection matrix
00123         //*********************************************//
00124 
00125         double fov,znear,zfar;
00126 
00127         // left/top/znear/zfar/aspect
00128         /* for use: glFrustum(left, -left, top, -top, znear, zfar);
00129            with
00130              double aspect=static_cast<double>(navigator.x_screen_size_1)/static_cast<double>(navigator.y_screen_size_1);
00131              double fov=45.0*PI/180.0;
00132              double near=0.1;
00133              double top=tan(fov*0.5)*near;
00134              double bottom=-top;
00135              double left=aspect*bottom;
00136              double right=-left;
00137            */
00138         MC_double_vector projection_param() const;
00139 
00140         /* glFrustum camera
00141           http://www.opengl.org/sdk/docs/man/xhtml/glFrustum.xml
00142           */
00143         MC_matrix projection_matrix() const;
00144 
00145         //*********************************************//
00146         //Screen tool record
00147         //*********************************************//
00148 
00149         double size_pointer;
00150 
00151 
00152         //*********************************************//
00153         //Picking ray
00154         //*********************************************//
00155 
00159         MC_v3d_vector ray_world_space_cam1(const int& x_screen,const int& y_screen) const;
00160 
00161         //*********************************************//
00162         //mouse
00163         //*********************************************//
00164         bool left_button;
00165         bool right_button;
00166 
00167         private:
00168     };
00169 }
00170 
00171 #endif

Generated on Fri Sep 25 13:31:35 2009 by  doxygen 1.5.8