KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
glut_perspective_camera.h
Go to the documentation of this file.
1 
35 /* =========================================================================== *
36 |
37 | Copyright (c) 1994-2008 by Kobus Barnard (author).
38 |
39 | Personal and educational use of this code is granted, provided that this
40 | header is kept intact, and that the authorship is not misrepresented, that
41 | its use is acknowledged in publications, and relevant papers are cited.
42 |
43 | For other use contact the author (kobus AT cs DOT arizona DOT edu).
44 |
45 | Please note that the code in this file has not necessarily been adequately
46 | tested. Naturally, there is no guarantee of performance, support, or fitness
47 | for any particular task. Nonetheless, I am interested in hearing about
48 | problems that you encounter.
49 |
50 | Authors:
51 | Luca Del Pero
52 |
53 * =========================================================================== */
54 
55 
66 #ifndef GLUT_PERSPECTIVE_CAMERA_H_
67 #define GLUT_PERSPECTIVE_CAMERA_H_
68 
69 #include <gr_cpp/gr_opengl.h>
70 
71 #ifdef KJB_HAVE_GLUT
72 #ifdef MAC_OSX
73 #include <GLUT/glut.h>
74 #else
75 #include <GL/glut.h>
76 #endif
77 #endif
78 
82 
83 #define GLUT_PC_DECREMENT_CHARACTER 'j'
84 #define GLUT_PC_INCREMENT_CHARACTER 'k'
85 #define GLUT_PC_NUMBER_OF_CAMERA_PARAMETERS 16
86 
87 #include <m_cpp/m_vector.h>
89 
90 namespace kjb{
91 
107  {
108  public:
109  static int create_glut_perspective_camera_submenu(void (*icamera_submenu_callback)(int i), kjb::Perspective_camera * pc,
110  bool enable_translation = true, bool enable_pitch = true, bool enable_yaw = true, bool enable_roll = true,
111  bool enable_focal_length = true, bool enable_principal_point = true, bool enable_skew = true,
112  bool enable_aspect_ratio = true, bool enable_world_scale = true, bool enable_clipping = true,
113  bool enable_viewport = true, bool icentre_when_scaling_viewport = true,
114  unsigned char iincrement_char = GLUT_PC_INCREMENT_CHARACTER,
115  unsigned char idecrement_char = GLUT_PC_DECREMENT_CHARACTER);
116 
121  static void camera_submenu_glut(int i);
122 
127  static void keyboard_callback(unsigned char key);
128 
133  static void enable_camera() {camera_enabled = true;}
134 
139  static void disable_camera() {camera_enabled = false;}
140 
142  static double retrieve_translation_x_increment() { return increment_steps(GLUT_PC_CENTRE_X);}
144  static double retrieve_translation_y_increment() { return increment_steps(GLUT_PC_CENTRE_Y);}
146  static double retrieve_translation_z_increment() { return increment_steps(GLUT_PC_CENTRE_Z);}
148  static double retrieve_pitch_increment() { return increment_steps(GLUT_PC_PITCH);}
150  static double retrieve_yaw_increment() { return increment_steps(GLUT_PC_YAW);}
152  static double retrieve_roll_increment() { return increment_steps(GLUT_PC_ROLL);}
154  static double retrieve_focal_length_increment() { return increment_steps(GLUT_PC_FOCAL_LENGTH);}
156  static double retrieve_principal_point_x_increment() { return increment_steps(GLUT_PC_PRINCIPAL_POINT_X);}
158  static double retrieve_principal_point_y_increment() { return increment_steps(GLUT_PC_PRINCIPAL_POINT_Y);}
160  static double retrieve_skew_increment() { return increment_steps(GLUT_PC_SKEW);}
162  static double retrieve_aspect_ratio_increment() { return increment_steps(GLUT_PC_ASPECT_RATIO);}
164  static double retrieve_world_scale_increment() { return increment_steps(GLUT_PC_WORLD_SCALE);}
166  static double retrieve_near_clipping_increment() {return increment_steps(GLUT_PC_NEAR);}
168  static double retrieve_far_clipping_increment() {return increment_steps(GLUT_PC_FAR);}
170  static double retrieve_width_increment() {return increment_steps(GLUT_PC_WIDTH);}
172  static double retrieve_height_increment() {return increment_steps(GLUT_PC_HEIGHT);}
173 
175  static void update_translation_x_increment(double iincrement) { increment_steps(GLUT_PC_CENTRE_X) = iincrement;}
177  static void update_translation_y_increment(double iincrement) { increment_steps(GLUT_PC_CENTRE_Y) = iincrement;}
179  static void update_translation_z_increment(double iincrement) { increment_steps(GLUT_PC_CENTRE_Z) = iincrement;}
181  static void update_pitch_increment(double iincrement) { increment_steps(GLUT_PC_PITCH) = iincrement;}
183  static void update_yaw_increment(double iincrement) { increment_steps(GLUT_PC_YAW) = iincrement;}
185  static void update_roll_increment(double iincrement) { increment_steps(GLUT_PC_ROLL) = iincrement;}
187  static void update_focal_length_increment(double iincrement) { increment_steps(GLUT_PC_FOCAL_LENGTH) = iincrement;}
189  static void update_principal_point_x_increment(double iincrement) { increment_steps(GLUT_PC_PRINCIPAL_POINT_X) = iincrement;}
191  static void update_principal_point_y_increment(double iincrement) { increment_steps(GLUT_PC_PRINCIPAL_POINT_Y) = iincrement;}
193  static void update_skew_increment(double iincrement) { increment_steps(GLUT_PC_SKEW) = iincrement;}
195  static void update_aspect_ratio_increment(double iincrement) { increment_steps(GLUT_PC_ASPECT_RATIO) = iincrement;}
197  static void update_world_scale_increment(double iincrement) { increment_steps(GLUT_PC_WORLD_SCALE) = iincrement;}
199  static void update_near_clipping_increment(double iincrement) { increment_steps(GLUT_PC_NEAR) = iincrement;}
201  static void update_far_clipping_increment(double iincrement) { increment_steps(GLUT_PC_FAR) = iincrement;}
203  static void update_width_increment(double iincrement){ increment_steps(GLUT_PC_WIDTH) = iincrement;}
205  static void update_height_increment(double iincrement) { increment_steps(GLUT_PC_HEIGHT) = iincrement;}
206 
207  private:
208  static bool camera_enabled;
209  static unsigned int selected_parameter;
211  static kjb::Perspective_camera * camera;
212  static unsigned char increment_character;
213  static unsigned char decrement_character;
214  static kjb::Vector increment_steps;
215 
219  static bool centre_when_scaling_viewport;
220  };
221 }
222 static void (*camera_submenu_callback)(int i);
223 
224 #endif
static void update_pitch_increment(double iincrement)
sets the increment step used for the pitch
Definition: glut_perspective_camera.h:181
static double retrieve_focal_length_increment()
returns the increment step used for the focal length
Definition: glut_perspective_camera.h:154
Definition: glut_perspective_camera.h:81
Definition: glut_perspective_camera.h:79
static void update_translation_y_increment(double iincrement)
sets the increment step used for the y-coordinate of the camera centre
Definition: glut_perspective_camera.h:177
static double retrieve_translation_x_increment()
returns the increment step used for the x-coordinate of the camera centre
Definition: glut_perspective_camera.h:142
static void update_near_clipping_increment(double iincrement)
sets the increment step used for the near clipping plane
Definition: glut_perspective_camera.h:199
static void update_principal_point_y_increment(double iincrement)
sets the increment step used for the y coordinate of the principal point
Definition: glut_perspective_camera.h:191
static double retrieve_width_increment()
returns the increment step used for the viewport width
Definition: glut_perspective_camera.h:170
static void update_height_increment(double iincrement)
sets the increment step used for the viewport height
Definition: glut_perspective_camera.h:205
static void update_yaw_increment(double iincrement)
sets the increment step used for the yaw
Definition: glut_perspective_camera.h:183
Definition: glut_perspective_camera.h:80
static void update_far_clipping_increment(double iincrement)
sets the increment step used for the far clipping plane
Definition: glut_perspective_camera.h:201
static void update_principal_point_x_increment(double iincrement)
sets the increment step used for the x coordinate of the principal point
Definition: glut_perspective_camera.h:189
static double retrieve_far_clipping_increment()
returns the increment step used for the far clipping plane
Definition: glut_perspective_camera.h:168
static void update_translation_x_increment(double iincrement)
sets the increment step used for the x-coordinate of the camera centre
Definition: glut_perspective_camera.h:175
Definition: glut_perspective_camera.h:81
static void enable_camera()
Enables the camera. When the camera is not enabled all submenu selections and the submenu keyboard ca...
Definition: glut_perspective_camera.h:133
#define GLUT_PC_DECREMENT_CHARACTER
Definition: glut_perspective_camera.h:83
static int create_glut_perspective_camera_submenu(void(*icamera_submenu_callback)(int i), kjb::Perspective_camera *pc, bool enable_translation=true, bool enable_pitch=true, bool enable_yaw=true, bool enable_roll=true, bool enable_focal_length=true, bool enable_principal_point=true, bool enable_skew=true, bool enable_aspect_ratio=true, bool enable_world_scale=true, bool enable_clipping=true, bool enable_viewport=true, bool icentre_when_scaling_viewport=true, unsigned char iincrement_char=GLUT_PC_INCREMENT_CHARACTER, unsigned char idecrement_char=GLUT_PC_DECREMENT_CHARACTER)
Definition: glut_perspective_camera.cpp:88
#define GLUT_PC_INCREMENT_CHARACTER
Definition: glut_perspective_camera.h:84
static double retrieve_yaw_increment()
returns the increment step used for the yaw
Definition: glut_perspective_camera.h:150
This class implements vectors, in the linear-algebra sense, with real-valued elements.
Definition: m_vector.h:87
Definition: glut_perspective_camera.h:79
static double retrieve_skew_increment()
returns the increment step used for the skew
Definition: glut_perspective_camera.h:160
Definition: glut_perspective_camera.h:79
static double retrieve_roll_increment()
returns the increment step used for the roll
Definition: glut_perspective_camera.h:152
static double retrieve_principal_point_y_increment()
returns the increment step used for the y coordinate of the principal point
Definition: glut_perspective_camera.h:158
St_perspective_camera for modeling a perspective camera using the classic Forsyth and Ponce parametri...
static void disable_camera()
Disable the camera. When the camera is not enabled all submenu selections and the submenu keyboard ca...
Definition: glut_perspective_camera.h:139
static void camera_submenu_glut(int i)
This callback will be executed any time an entry of the camera submenu is selected. This is automatically called. Within this function the user defined callback will be called.
Definition: glut_perspective_camera.cpp:175
static double retrieve_height_increment()
returns the increment step used for the viewport height
Definition: glut_perspective_camera.h:172
static void update_skew_increment(double iincrement)
sets the increment step used for the skew
Definition: glut_perspective_camera.h:193
Definition: perspective_camera.h:93
static double retrieve_aspect_ratio_increment()
returns the increment step used for the aspect ratio
Definition: glut_perspective_camera.h:162
Definition: glut_perspective_camera.h:106
Definition: glut_perspective_camera.h:79
static void update_focal_length_increment(double iincrement)
sets the increment step used for the focal length
Definition: glut_perspective_camera.h:187
Definition: glut_perspective_camera.h:80
static double retrieve_world_scale_increment()
returns the increment step used for the world scale
Definition: glut_perspective_camera.h:164
static void update_width_increment(double iincrement)
sets the increment step used for the viewport width
Definition: glut_perspective_camera.h:203
Definition: glut_perspective_camera.h:80
static double retrieve_translation_y_increment()
returns the increment step used for the y-coordinate of the camera centre
Definition: glut_perspective_camera.h:144
static void update_world_scale_increment(double iincrement)
sets the increment step used for the world scale
Definition: glut_perspective_camera.h:197
Definition: glut_perspective_camera.h:80
Definition: glut_perspective_camera.h:80
Definition: glut_perspective_camera.h:79
static void update_aspect_ratio_increment(double iincrement)
sets the increment step used for the aspect ratio
Definition: glut_perspective_camera.h:195
get the indices of edges in each direction for i
Definition: APPgetLargeConnectedEdges.m:48
Definition: glut_perspective_camera.h:79
static double retrieve_pitch_increment()
returns the increment step used for the pitch
Definition: glut_perspective_camera.h:148
static double retrieve_translation_z_increment()
returns the increment step used for the z-coordinate of the camera centre
Definition: glut_perspective_camera.h:146
static void keyboard_callback(unsigned char key)
This is the keyboard_callback for this camera submenu. The user HAS to call this in the GLUT keyboard...
Definition: glut_perspective_camera.cpp:182
Definition: glut_perspective_camera.h:81
Definition for the Vector class, a thin wrapper on the KJB Vector struct and its related functionalit...
static double retrieve_near_clipping_increment()
returns the increment step used for the near clipping plane
Definition: glut_perspective_camera.h:166
static void update_translation_z_increment(double iincrement)
sets the increment step used for the z-coordinate of the camera centre
Definition: glut_perspective_camera.h:179
Definition: glut_perspective_camera.h:81
static double retrieve_principal_point_x_increment()
returns the increment step used for the x coordinate of the principal point
Definition: glut_perspective_camera.h:156
static void update_roll_increment(double iincrement)
sets the increment step used for the roll
Definition: glut_perspective_camera.h:185
Definition: glut_perspective_camera.h:81