Container class for the viewer, does not need to be weel written. More...
#include <MC_navigator_tool.hpp>

Public Member Functions | |
| MC_navigator_tool () | |
| MC_matrix | current_light1 () const |
| MC_v3d_vector | axis_light1 () const |
| MC_matrix | current_cam1 () const |
| MC_v3d_vector | axis_cam1 () const |
| void | go_forward_trackball_cam1 (const double &d_L) |
| void | go_right_trackball_cam1 (const double &d_L) |
| void | go_up_trackball_cam1 (const double &d_L) |
| std::ostream & | write_cam1 (std::ostream &stream) const |
| const MC_navigator_tool & | write_cam1_file (std::string &filename) const |
| MC_navigator_tool & | read_cam1 (std::istream ¶m) |
| MC_navigator_tool & | read_cam1_file (const std::string &filename) |
| std::ostream & | write_light1 (std::ostream &stream) const |
| const MC_navigator_tool & | write_light1_file (std::string &filename) const |
| MC_navigator_tool & | read_light1 (std::istream ¶m) |
| MC_navigator_tool & | read_light1_file (const std::string &filename) |
| double | delta_time () |
| return current_time-old_time; | |
| double | update_fps () |
| update the fps and return fps | |
| int | increase_frame_number () |
| increase the frame drawn and return the number | |
| MC_double_vector | projection_param () const |
| MC_matrix | projection_matrix () const |
| MC_v3d_vector | ray_world_space_cam1 (const int &x_screen, const int &y_screen) const |
| give the (x,y) coordinate in screen space and return the center and the ray pointed in world space | |
Public Attributes | |
| MC_trackball | trackball_cam1 |
| MC_v3d | tr_cam1 |
| double | dist_cam1 |
| MC_trackball | trackball_light1 |
| MC_v3d | tr_light1 |
| double | dist_light1 |
| unsigned int | current_time |
| unsigned int | old_time |
| unsigned int | frame |
| double | current_fps |
| int | x_previous |
| int | y_previous |
| int | x_screen_size_1 |
| int | y_screen_size_1 |
| double | fov |
| double | znear |
| double | zfar |
| double | size_pointer |
| bool | left_button |
| bool | right_button |
Container class for the viewer, does not need to be weel written.
Definition at line 31 of file MC_navigator_tool.hpp.
| mesh_conv::MC_navigator_tool::MC_navigator_tool | ( | ) |
Definition at line 11 of file MC_navigator_tool.cpp.
References current_fps, current_time, dist_cam1, fov, frame, old_time, PI, size_pointer, x_previous, x_screen_size_1, y_previous, y_screen_size_1, zfar, and znear.
00012 { 00013 #define PI 3.14159 00014 00015 dist_cam1=-3.0; 00016 current_time=0;old_time=0;frame=0;current_fps=0.0; 00017 x_previous=0;y_previous=0; 00018 x_screen_size_1=100;y_screen_size_1=100; 00019 size_pointer=0.1; 00020 00021 fov=45.0*PI/180.0; 00022 znear=0.01; 00023 zfar=150.0; 00024 }
| MC_v3d_vector mesh_conv::MC_navigator_tool::axis_cam1 | ( | ) | const |
Definition at line 47 of file MC_navigator_tool.cpp.
References current_cam1(), and mesh_conv::MC_matrix::to_matrix3().
Referenced by set_light(), and update_plane().
00048 { 00049 MC_matrix camera_1=current_cam1(); 00050 // MC_v3d eye_n(camera_1(0,2),camera_1(1,2),camera_1(2,2)); 00051 // MC_v3d eye_up(camera_1(0,1),camera_1(1,1),camera_1(2,1)); 00052 // MC_v3d eye_right(camera_1(0,0),camera_1(1,0),camera_1(2,0)); 00053 // 00054 MC_v3d eye_n(camera_1(2,0),camera_1(2,1),camera_1(2,2)); 00055 MC_v3d eye_up(camera_1(1,0),camera_1(1,1),camera_1(1,2)); 00056 MC_v3d eye_right(camera_1(0,0),camera_1(0,1),camera_1(0,2)); 00057 00058 00059 00060 MC_v3d local_p(camera_1(0,3),camera_1(1,3),camera_1(2,3)); 00061 00062 //local_p=camera_1.to_matrix3().first*(MC_v3d(0,0,-dist_cam1)); 00063 //local_p=camera_1.to_matrix3().first.inverted()*(-local_p); 00064 //local_p=-(MC_v3d(camera_1.to_matrix3().first*MC_v3d(0,0,dist_cam1))+tr_cam1); 00065 local_p=-MC_v3d((camera_1.to_matrix3().first).inverted()*(camera_1.to_matrix3().second)); 00066 00067 MC_v3d_vector parameters; 00068 parameters=parameters<<local_p<<eye_n<<eye_right<<eye_up; 00069 return parameters; 00070 }


| MC_v3d_vector mesh_conv::MC_navigator_tool::axis_light1 | ( | ) | const |
Definition at line 72 of file MC_navigator_tool.cpp.
References current_light1(), and mesh_conv::MC_matrix::to_matrix3().
00073 { 00074 MC_matrix light_1=current_light1(); 00075 00076 MC_v3d eye_n(light_1(2,0),light_1(2,1),light_1(2,2)); 00077 MC_v3d eye_up(light_1(1,0),light_1(1,1),light_1(1,2)); 00078 MC_v3d eye_right(light_1(0,0),light_1(0,1),light_1(0,2)); 00079 00080 MC_v3d local_p(light_1(0,3),light_1(1,3),light_1(2,3)); 00081 local_p=-MC_v3d((light_1.to_matrix3().first).inverted()*(light_1.to_matrix3().second)); 00082 00083 MC_v3d_vector parameters; 00084 parameters=parameters<<local_p<<eye_n<<eye_right<<eye_up; 00085 return parameters; 00086 }

| MC_matrix mesh_conv::MC_navigator_tool::current_cam1 | ( | ) | const |
Definition at line 25 of file MC_navigator_tool.cpp.
References mesh_conv::MC_matrix::add_translation(), mesh_conv::MC_quaternion::conjugated(), dist_cam1, mesh_conv::MC_matrix::identity(), mesh_conv::MC_quaternion::matrix(), mesh_conv::MC_trackball::quaternion(), mesh_conv::MC_matrix::to_matrix3(), mesh_conv::MC_matrix::to_matrix4(), tr_cam1, and trackball_cam1.
Referenced by axis_cam1(), ray_world_space_cam1(), and set_light().
00026 { 00027 MC_matrix camera_1=MC_matrix::identity(4); 00028 camera_1.add_translation(MC_v3d(0,0,dist_cam1)); 00029 camera_1=camera_1*trackball_cam1.quaternion().conjugated().matrix().to_matrix4(); 00030 00031 MC_v3d translate_after=camera_1.to_matrix3().first*tr_cam1; 00032 camera_1.add_translation(translate_after); 00033 00034 return camera_1; 00035 }


| MC_matrix mesh_conv::MC_navigator_tool::current_light1 | ( | ) | const |
Definition at line 36 of file MC_navigator_tool.cpp.
References mesh_conv::MC_matrix::add_translation(), mesh_conv::MC_quaternion::conjugated(), dist_light1, mesh_conv::MC_matrix::identity(), mesh_conv::MC_quaternion::matrix(), mesh_conv::MC_trackball::quaternion(), mesh_conv::MC_matrix::to_matrix3(), mesh_conv::MC_matrix::to_matrix4(), tr_light1, and trackball_light1.
Referenced by axis_light1().
00037 { 00038 MC_matrix light_1=MC_matrix::identity(4); 00039 light_1.add_translation(MC_v3d(0,0,dist_light1)); 00040 light_1=light_1*trackball_light1.quaternion().conjugated().matrix().to_matrix4(); 00041 00042 MC_v3d translate_after=light_1.to_matrix3().first*tr_light1; 00043 light_1.add_translation(translate_after); 00044 00045 return light_1; 00046 }


| double mesh_conv::MC_navigator_tool::delta_time | ( | ) | [inline] |
return current_time-old_time;
Definition at line 101 of file MC_navigator_tool.hpp.
References current_time, and old_time.
Referenced by display_callback().
00101 {return current_time-old_time;}

| void mesh_conv::MC_navigator_tool::go_forward_trackball_cam1 | ( | const double & | d_L | ) |
Definition at line 96 of file MC_navigator_tool.cpp.
References mesh_conv::MC_quaternion::conjugated(), mesh_conv::MC_trackball::quaternion(), tr_cam1, and trackball_cam1.
Referenced by keyboard_callback().
00097 { 00098 MC_v3d z(0,0,1); 00099 tr_cam1+=d_L*(trackball_cam1.quaternion().conjugated()*z); 00100 }


| void mesh_conv::MC_navigator_tool::go_right_trackball_cam1 | ( | const double & | d_L | ) |
Definition at line 101 of file MC_navigator_tool.cpp.
References mesh_conv::MC_quaternion::conjugated(), mesh_conv::MC_trackball::quaternion(), tr_cam1, and trackball_cam1.
Referenced by keyboard_callback().
00102 { 00103 MC_v3d z(-1,0,0); 00104 tr_cam1+=d_L*(trackball_cam1.quaternion().conjugated()*z); 00105 }


| void mesh_conv::MC_navigator_tool::go_up_trackball_cam1 | ( | const double & | d_L | ) |
Definition at line 106 of file MC_navigator_tool.cpp.
References mesh_conv::MC_quaternion::conjugated(), mesh_conv::MC_trackball::quaternion(), tr_cam1, and trackball_cam1.
Referenced by keyboard_callback().
00107 { 00108 MC_v3d z(0,1,0); 00109 tr_cam1+=d_L*(trackball_cam1.quaternion().conjugated()*z); 00110 }


| int mesh_conv::MC_navigator_tool::increase_frame_number | ( | ) | [inline] |
increase the frame drawn and return the number
Definition at line 105 of file MC_navigator_tool.hpp.
References frame.
Referenced by display_callback().

| MC_matrix mesh_conv::MC_navigator_tool::projection_matrix | ( | ) | const |
Definition at line 196 of file MC_navigator_tool.cpp.
References projection_param(), zfar, and znear.
00197 { 00198 MC_double_vector param=projection_param(); 00199 double left=param[0]; 00200 double right=-left; 00201 double top=param[1]; 00202 double bottom=-top; 00203 double znear=param[2]; 00204 double zfar=param[3]; 00205 MC_matrix p(4,4); 00206 00207 00208 p(0,0)=2*znear/(right-left); 00209 p(1,1)=2*znear/(top-bottom); 00210 00211 p(0,2)=(right+left)/(right-left); 00212 p(1,2)=(top+bottom)/(top-bottom); 00213 p(2,2)=-(zfar+znear)/(zfar-znear); 00214 p(3,2)=-1; 00215 00216 p(2,3)=-2*zfar*znear/(zfar-znear); 00217 00218 00219 00220 return p; 00221 }

| MC_double_vector mesh_conv::MC_navigator_tool::projection_param | ( | ) | const |
Definition at line 189 of file MC_navigator_tool.cpp.
References fov, x_screen_size_1, y_screen_size_1, zfar, and znear.
Referenced by display_callback(), projection_matrix(), and ray_world_space_cam1().
00190 { 00191 double aspect=static_cast<double>(x_screen_size_1)/static_cast<double>(y_screen_size_1); 00192 double top=tan(fov*0.5)*znear; 00193 double left=-aspect*top; 00194 return MC_double_vector(left,top,znear,zfar,aspect); 00195 }

| MC_v3d_vector mesh_conv::MC_navigator_tool::ray_world_space_cam1 | ( | const int & | x_screen, | |
| const int & | y_screen | |||
| ) | const |
give the (x,y) coordinate in screen space and return the center and the ray pointed in world space
Definition at line 223 of file MC_navigator_tool.cpp.
References current_cam1(), mesh_conv::MC_matrix::inverted(), mesh_conv::MC_v3d::normalized(), projection_param(), mesh_conv::MC_matrix::to_matrix3(), mesh_conv::MC_matrix::translation_part(), x_screen_size_1, y_screen_size_1, and znear.
00224 { 00225 //normalized screen coordinates 00226 MC_v3d local( 00227 (x_screen_size_1-2*x_screen)/double(x_screen_size_1) 00228 , 00229 (y_screen_size_1-2*y_screen)/double(y_screen_size_1),0); 00230 00231 //camera parameters 00232 MC_double_vector proj_param=projection_param(); 00233 double Lh=-proj_param[1]; 00234 double aspect=proj_param[4]; 00235 00236 //coordinate on the camera 00237 MC_v3d proj_ray(local[0]*Lh*aspect,local[1]*Lh,-znear); 00238 00239 // modelview 00240 MC_matrix mod=current_cam1(); 00241 MC_matrix mod_inv=mod.inverted(); 00242 00243 MC_v3d ray=mod_inv.to_matrix3().first*proj_ray; 00244 MC_v3d center=mod_inv.translation_part(); 00245 00246 return MC_v3d_vector(center,ray.normalized()); 00247 }

| MC_navigator_tool & mesh_conv::MC_navigator_tool::read_cam1 | ( | std::istream & | param | ) |
Definition at line 124 of file MC_navigator_tool.cpp.
References dist_cam1, mesh_conv::MC_trackball::quaternion(), tr_cam1, and trackball_cam1.
Referenced by read_cam1_file().
00125 { 00126 std::string buffer; 00127 00128 param>>buffer; //quat 00129 param>>trackball_cam1.quaternion(); 00130 00131 param>>buffer; //dist 00132 param>>dist_cam1; 00133 00134 param>>buffer; //tr 00135 param>>tr_cam1; 00136 00137 return *this; 00138 }


| MC_navigator_tool & mesh_conv::MC_navigator_tool::read_cam1_file | ( | const std::string & | filename | ) |
Definition at line 139 of file MC_navigator_tool.cpp.
References read_cam1().
Referenced by main().
00140 { 00141 std::ifstream fstream(filename.c_str()); 00142 if(!fstream.good()) 00143 {std::cout<<"MC_navigator_tool::read_cam1_file("<<filename<<") cannot open the file"<<std::endl;} 00144 read_cam1(fstream); 00145 fstream.close(); 00146 return *this; 00147 }


| MC_navigator_tool & mesh_conv::MC_navigator_tool::read_light1 | ( | std::istream & | param | ) |
Definition at line 161 of file MC_navigator_tool.cpp.
References dist_light1, mesh_conv::MC_trackball::quaternion(), tr_light1, and trackball_light1.
Referenced by read_light1_file().
00162 { 00163 std::string buffer; 00164 00165 param>>buffer; //quat 00166 param>>trackball_light1.quaternion(); 00167 00168 param>>buffer; //dist 00169 param>>dist_light1; 00170 00171 param>>buffer; //tr 00172 param>>tr_light1; 00173 00174 return *this; 00175 }


| MC_navigator_tool & mesh_conv::MC_navigator_tool::read_light1_file | ( | const std::string & | filename | ) |
Definition at line 176 of file MC_navigator_tool.cpp.
References read_light1().
00177 { 00178 std::ifstream fstream(filename.c_str()); 00179 if(!fstream.good()) 00180 {std::cout<<"MC_navigator_tool::read_light1_file("<<filename<<") cannot open the file"<<std::endl;} 00181 00182 read_light1(fstream); 00183 fstream.close(); 00184 return *this; 00185 }

| double mesh_conv::MC_navigator_tool::update_fps | ( | ) |
update the fps and return fps
Definition at line 88 of file MC_navigator_tool.cpp.
References current_fps, current_time, frame, and old_time.
Referenced by display_callback().
00089 { 00090 current_fps=double(frame*1000)/double(current_time-old_time); 00091 old_time=current_time; 00092 frame=0; 00093 return current_fps; 00094 }

| std::ostream & mesh_conv::MC_navigator_tool::write_cam1 | ( | std::ostream & | stream | ) | const |
Definition at line 112 of file MC_navigator_tool.cpp.
References dist_cam1, mesh_conv::MC_trackball::quaternion(), tr_cam1, and trackball_cam1.
Referenced by write_cam1_file().
00113 { 00114 stream<<"quat "<<trackball_cam1.quaternion()<<"\ndist "<<dist_cam1<<"\ntr "<<tr_cam1<<std::endl; 00115 return stream; 00116 }


| const MC_navigator_tool & mesh_conv::MC_navigator_tool::write_cam1_file | ( | std::string & | filename | ) | const |
Definition at line 117 of file MC_navigator_tool.cpp.
References write_cam1().
Referenced by keyboard_callback().
00118 { 00119 std::ofstream fstream(filename.c_str()); 00120 write_cam1(fstream); 00121 fstream.close(); 00122 return *this; 00123 }


| std::ostream & mesh_conv::MC_navigator_tool::write_light1 | ( | std::ostream & | stream | ) | const |
Definition at line 149 of file MC_navigator_tool.cpp.
References dist_light1, mesh_conv::MC_trackball::quaternion(), tr_light1, and trackball_light1.
Referenced by write_light1_file().
00150 { 00151 stream<<"quat "<<trackball_light1.quaternion()<<"\ndist "<<dist_light1<<"\ntr "<<tr_light1<<std::endl; 00152 return stream; 00153 }


| const MC_navigator_tool & mesh_conv::MC_navigator_tool::write_light1_file | ( | std::string & | filename | ) | const |
Definition at line 154 of file MC_navigator_tool.cpp.
References write_light1().
00155 { 00156 std::ofstream fstream(filename.c_str()); 00157 write_light1(fstream); 00158 fstream.close(); 00159 return *this; 00160 }

Definition at line 107 of file MC_navigator_tool.hpp.
Referenced by draw_fps(), MC_navigator_tool(), and update_fps().
| unsigned int mesh_conv::MC_navigator_tool::current_time |
Definition at line 106 of file MC_navigator_tool.hpp.
Referenced by delta_time(), display_callback(), evolve(), MC_navigator_tool(), and update_fps().
Definition at line 47 of file MC_navigator_tool.hpp.
Referenced by current_cam1(), display_callback(), draw_pointer(), keyboard_callback(), MC_navigator_tool(), motion_callback(), read_cam1(), and write_cam1().
Definition at line 55 of file MC_navigator_tool.hpp.
Referenced by current_light1(), read_light1(), and write_light1().
Definition at line 125 of file MC_navigator_tool.hpp.
Referenced by MC_navigator_tool(), and projection_param().
| unsigned int mesh_conv::MC_navigator_tool::frame |
Definition at line 106 of file MC_navigator_tool.hpp.
Referenced by increase_frame_number(), MC_navigator_tool(), and update_fps().
Definition at line 165 of file MC_navigator_tool.hpp.
Referenced by motion_callback(), and mouse_callback().
| unsigned int mesh_conv::MC_navigator_tool::old_time |
Definition at line 106 of file MC_navigator_tool.hpp.
Referenced by delta_time(), MC_navigator_tool(), and update_fps().
Definition at line 166 of file MC_navigator_tool.hpp.
Referenced by motion_callback(), and mouse_callback().
Definition at line 149 of file MC_navigator_tool.hpp.
Referenced by MC_navigator_tool().
Definition at line 45 of file MC_navigator_tool.hpp.
Referenced by current_cam1(), display_callback(), go_forward_trackball_cam1(), go_right_trackball_cam1(), go_up_trackball_cam1(), keyboard_callback(), motion_callback(), read_cam1(), update_plane(), and write_cam1().
Definition at line 53 of file MC_navigator_tool.hpp.
Referenced by current_light1(), read_light1(), and write_light1().
Definition at line 43 of file MC_navigator_tool.hpp.
Referenced by current_cam1(), display_callback(), draw_orientation(), draw_pointer(), go_forward_trackball_cam1(), go_right_trackball_cam1(), go_up_trackball_cam1(), motion_callback(), read_cam1(), and write_cam1().
Definition at line 51 of file MC_navigator_tool.hpp.
Referenced by current_light1(), read_light1(), and write_light1().
Definition at line 113 of file MC_navigator_tool.hpp.
Referenced by MC_navigator_tool(), motion_callback(), and mouse_callback().
Definition at line 119 of file MC_navigator_tool.hpp.
Referenced by display_callback(), main(), MC_navigator_tool(), motion_callback(), projection_param(), ray_world_space_cam1(), reshape_callback(), and setup_opengl().
Definition at line 113 of file MC_navigator_tool.hpp.
Referenced by MC_navigator_tool(), motion_callback(), and mouse_callback().
Definition at line 119 of file MC_navigator_tool.hpp.
Referenced by display_callback(), main(), MC_navigator_tool(), motion_callback(), projection_param(), ray_world_space_cam1(), reshape_callback(), and setup_opengl().
Definition at line 125 of file MC_navigator_tool.hpp.
Referenced by MC_navigator_tool(), projection_matrix(), and projection_param().
Definition at line 125 of file MC_navigator_tool.hpp.
Referenced by MC_navigator_tool(), projection_matrix(), projection_param(), and ray_world_space_cam1().
1.6.1