KJB
|
#include <perspective_camera.h>
Public Member Functions | |
Perspective_camera (double inear=10, double ifar=10000) | |
Perspective_camera (double icentre_x, double icentre_y, double icentre_z, double ipitch, double iyaw, double iroll, double ifocal_length, double iprincipal_point_x, double iprincipal_point_y, double iskew, double iaspect_ratio, double world_scale=1.0, double inear=10, double ifar=10000) | |
Perspective_camera (const kjb::Vector &icamera_centre, double ipitch, double iyaw, double iroll, double ifocal_length, double iprincipal_point_x, double iprincipal_point_y, double iskew, double iaspect_ratio, double world_scale=1.0, double inear=10, double ifar=10000) | |
Perspective_camera (const char *fname) | |
Reads a camera from an input file. More... | |
Perspective_camera (std::istream &in) | |
Reads a camera from an input stream. More... | |
Perspective_camera (const Perspective_camera &pc) | |
virtual Perspective_camera & | operator= (const Perspective_camera &pc) |
virtual Perspective_camera * | clone () const |
virtual void | swap (Perspective_camera &other) |
virtual | ~Perspective_camera () |
virtual void | read (std::istream &in) |
Reads this camera from an input stream. More... | |
virtual void | read (const char *fname) |
Reads this camera from a file. More... | |
virtual void | write (std::ostream &out) const |
Writes this camera to an output stream. More... | |
virtual void | write (const char *fname) const |
Writes this camera to an output stream. More... | |
virtual void | update_rendering_interface () const |
This funcation makes sure that the rendering interface is consistent with the camera parameters stored in this class. More... | |
double | get_near () const |
get near plane z-distance from camera center (always positive) More... | |
void | set_near (double near) |
double | get_far () const |
get farplane z-distance from camera center (always positive) More... | |
void | set_far (double far) |
Vector | get_world_origin () const |
returns the world origin in camera coordinates More... | |
const kjb::Vector & | get_camera_centre () const |
returns the camera centre More... | |
double | get_camera_centre_x () const |
returns the x-coordinate of the camera centre More... | |
double | get_camera_centre_y () const |
returns the y-coordinate of the camera centre More... | |
double | get_camera_centre_z () const |
returns the y-coordinate of the camera centre More... | |
double | get_pitch () const |
returns the pitch angle in radian More... | |
double | get_yaw () const |
returns the yaw angle in radian More... | |
double | get_roll () const |
returns the roll angle in radian More... | |
const Vector & | get_rotation_angles () const |
returns the rotation angles [pitch, yaw, roll] More... | |
double | get_focal_length () const |
returns the focal length More... | |
const kjb::Vector & | get_principal_point () const |
returns the principal point More... | |
double | get_principal_point (unsigned int index) const |
returns the coordinate of the principal point specified by the input index More... | |
double | get_principal_point_x () const |
returns the x-coordinate of the principal point More... | |
double | get_principal_point_y () const |
returns the y-coordinate of the principal point More... | |
double | get_skew () const |
returns the skew in radian More... | |
double | get_aspect_ratio () const |
returns the aspect ratio More... | |
double | get_world_scale () const |
returns the world scale More... | |
void | set_world_origin (const kjb::Vector &origin) |
This returns a 3X4 camera matrix, built from the intrinsic and extrinsic parameters. More... | |
virtual void | set_camera_centre (const kjb::Vector &icentre) |
sets the camera centre More... | |
virtual void | set_camera_centre (unsigned int index, double ivalue) |
sets the coordinate of the camera centre specified by the input index More... | |
virtual void | set_camera_centre_x (double ix) |
sets the x-coordinate of the camera centre More... | |
virtual void | set_camera_centre_y (double iy) |
sets the y-coordinate of the camera centre More... | |
virtual void | set_camera_centre_z (double iz) |
sets the y-coordinate of the camera centre More... | |
virtual void | set_pitch (double ipitch) |
sets the pitch angle in radian More... | |
virtual void | set_yaw (double iyaw) |
sets the yaw angle in radian More... | |
virtual void | set_roll (double iroll) |
sets the roll angle in radian More... | |
virtual void | rotate_around_x_axis (double theta) |
rotates the camera around its x-axis More... | |
virtual void | rotate_around_y_axis (double theta) |
rotates the camera around its x-axis More... | |
virtual void | rotate_around_z_axis (double theta) |
rotates the camera around its x-axis More... | |
virtual void | rotate_around_camera_axes (double thetax, double thetay, double thetaz) |
rotates the camera around its x,y,z axes in this order More... | |
virtual void | set_rotation_angles (double ipitch, double iyaw, double iroll) |
sets pitch, yaw and roll for this camera, in radian More... | |
virtual void | set_focal_length (double ifocal) |
sets the focal length More... | |
virtual void | update_focal_with_scale (double ifocal) |
virtual void | set_principal_point (const kjb::Vector &ip) |
sets the principal point More... | |
virtual void | set_principal_point (unsigned int index, double ip) |
sets the coordinate of the principal point specified by the input index More... | |
virtual void | set_principal_point_x (double ix) |
sets the x-coordinate of the principal point More... | |
virtual void | set_principal_point_y (double iy) |
sets the y-coordinate of the principal point More... | |
virtual void | set_skew (double is) |
sets the skew angle More... | |
virtual void | set_aspect_ratio (double iar) |
sets the aspect ratio More... | |
virtual void | set_world_scale (double iscale) |
sets the world scale More... | |
virtual void | set_look_at (double deyex, double deyey, double deyez, double dlookx, double dlooky, double dlookz, double dupx, double dupy, double dupz) |
sets the position and orientation with the semantics similar to gluLookAt More... | |
virtual void | set_look_at (const kjb::Vector &eye, const kjb::Vector &look, const kjb::Vector &up) |
sets the position and orientation with the semantics similar to gluLookAt in a more convenient form More... | |
virtual void | translate (double dx, double dy, double dz, unsigned int frame=FRAME_CAMERA_WORLD_COORDINATES) |
virtual void | prepare_for_rendering (bool clean_buffers) const |
const Matrix & | get_modelview_matrix () const |
const Matrix & | get_projection_matrix () const |
Matrix | get_gl_projection_matrix () const |
void | mult_projection_matrix () const |
void | mult_modelview_matrix () const |
virtual Parametric_camera_gl_interface & | get_rendering_interface () const |
void | set_rotation_mode (kjb::Quaternion::Euler_mode imode) |
virtual void | set_angles_from_quaternion (const kjb::Quaternion &q) |
sets the rotation angles from an input quaternion More... | |
virtual void | set_orientation (const kjb::Quaternion &q) |
Alias of set_angles_from_quaternion() More... | |
const kjb::Quaternion & | get_rotations_as_a_quaternion () const |
returns the rotations of this camera as a quaternion More... | |
const kjb::Quaternion & | get_orientation () const |
Alias of get_angles_as_a_quaternion() More... | |
void | rotate_point_to_camera_frame (kjb::Vector &ipoint) |
Rotates the input point into the camera coordinate system. More... | |
void | get_point_in_world_coordinates (const kjb::Vector &point_in_camera_coordinates, kjb::Vector &point_in_world_coordinates) const |
Given a point in camera coordinates, it converts it to world coordinates. More... | |
bool | is_point_in_camera_frustum (const kjb::Vector &point_in_world_coordinates, double &x_, double &y_, unsigned int num_image_rows, unsigned int num_image_cols) const |
Given a point in world coordinates, it returns true if the point is in the viewing frustum, false otherwise. Notice that the OpenGL context will be set in this function, since it is needed for the computation. More... | |
void | get_point_in_camera_coordinates (kjb::Vector &io_point) const |
Given a point in world coordinates, it converts it to camera coordinates. More... | |
void | compute_new_euler_angles_on_rotations (double dpitch, double dyaw, double droll) |
const Matrix & | get_camera_matrix () const |
const Matrix & | build_camera_matrix () const |
Vector | to_camera_coordinates (const Vector &v) const |
Public Member Functions inherited from kjb::Cloneable | |
virtual | ~Cloneable () |
Deletes this Cloneable. More... | |
Public Member Functions inherited from kjb::Readable | |
virtual | ~Readable () |
Deletes this Readable. More... | |
Public Member Functions inherited from kjb::Writeable | |
virtual | ~Writeable () |
Deletes this Writeable. More... | |
Protected Attributes | |
Parametric_camera_gl_interface | rendering_interface |
bool | intrinsic_dirty |
bool | extrinsic_dirty |
bool | cam_matrix_dirty |
Matrix | m_camera_matrix |
Additional Inherited Members | |
Static Public Member Functions inherited from kjb::Readable | |
static const char * | read_field_value (std::istream &in, const char *field_name, char *field_buf, size_t buf_len, char separator=':') |
Reads a line off in into a buffer and returns a pointer to the field value in the buffer. More... | |
static const char * | read_field_value (std::istream &in, const char *field_name, char separator=':') |
Reads a line off in into an internal buffer and returns a pointer to the field value in the buffer. More... | |
kjb::Perspective_camera::Perspective_camera | ( | double | inear = 10 , |
double | ifar = 10000 |
||
) |
inear | The distance between the camera centre and the near clipping plane |
ifar | The distance between the camera centre and the far clipping plane |
kjb::Perspective_camera::Perspective_camera | ( | double | icentre_x, |
double | icentre_y, | ||
double | icentre_z, | ||
double | ipitch, | ||
double | iyaw, | ||
double | iroll, | ||
double | ifocal_length, | ||
double | iprincipal_point_x, | ||
double | iprincipal_point_y, | ||
double | iskew, | ||
double | iaspect_ratio, | ||
double | iscale = 1.0 , |
||
double | inear = 10 , |
||
double | ifar = 10000 |
||
) |
icentre_x | The x coordinate of the camera centre |
icentre_y | The y coordinate of the camera centre |
icentre_z | The z coordinate of the camera centre |
ipitch | The rotation around the camera's x axis |
iyaw | The rotation around the camera's y axis |
iroll | The rotation around the camera's x axis |
ifocal_length | The focal length |
iprincipal_point_x | The x coordinate of the principal point |
iprincipal_point_y | The y coordinate of the principal point |
iskew | The skew angle in radian |
iaspect_ratio | The camera aspect ratio |
iscale | The scale of the world |
inear | The distance between the camera centre and the near clipping plane |
ifar | The distance between the camera centre and the far clipping plane |
kjb::Perspective_camera::Perspective_camera | ( | const kjb::Vector & | icamera_centre, |
double | ipitch, | ||
double | iyaw, | ||
double | iroll, | ||
double | ifocal_length, | ||
double | iprincipal_point_x, | ||
double | iprincipal_point_y, | ||
double | iskew, | ||
double | iaspect_ratio, | ||
double | iscale = 1.0 , |
||
double | inear = 10 , |
||
double | ifar = 10000 |
||
) |
icamera_centre | The camera centre position [x,y,z], optionally in homogeneous coordinates |
ipitch | The rotation around the camera's x axis |
iyaw | The rotation around the camera's y axis |
iroll | The rotation around the camera's x axis |
ifocal_length | The focal length |
iprincipal_point_x | The x coordinate of the principal point |
iprincipal_point_y | The y coordinate of the principal point |
iskew | The skew angle in radian |
iaspect_ratio | The camera aspect ratio |
iscale | The scale of the world |
inear | The distance between the camera centre and the near clipping plane |
ifar | The distance between the camera centre and the far clipping plane |
kjb::Perspective_camera::Perspective_camera | ( | const char * | fname | ) |
Reads a camera from an input file.
The name of the file to read this camera from
kjb::Perspective_camera::Perspective_camera | ( | std::istream & | in | ) |
Reads a camera from an input stream.
The input stream to read this camera from
kjb::Perspective_camera::Perspective_camera | ( | const Perspective_camera & | pc | ) |
The camera to copy into this one
|
inlinevirtual |
|
inline |
Returns the camera matrix. This is a legacy call. get_camera_matrix() is preferred.
Note: I left this class for backward-compatability. However, it is now much faster (it simply returns the matrix, updating if necessary. (Ernesto – 2013/10/23)
|
virtual |
void kjb::Perspective_camera::compute_new_euler_angles_on_rotations | ( | double | dpitch, |
double | dyaw, | ||
double | droll | ||
) |
Given 3 rotation angles, sets the corresponding Euler angles given the current Euler convention
dpitch | The amount of rotation arount the x-axis of this camera |
dyaw | The amount of rotation arount the y-axis of this camera |
droll | The amount of rotation arount the z-axis of this camera |
|
inline |
returns the aspect ratio
|
inline |
returns the camera centre
|
inline |
returns the x-coordinate of the camera centre
|
inline |
returns the y-coordinate of the camera centre
|
inline |
returns the y-coordinate of the camera centre
|
inline |
Get the camera matrix corresponding to this camera
|
inline |
get farplane z-distance from camera center (always positive)
|
inline |
returns the focal length
|
inline |
Return opengl projection matrix, which can be passed to kjb::opengl::glMultMatrix(). This is the exact matrix that is passed to opengl; i.e. the effect of the glOrtho call is included in this matrix.
|
inline |
Return opengl modelview matrix, which can be passed to kjb::opengl::glMultMatrix()
|
inline |
get near plane z-distance from camera center (always positive)
|
inline |
Alias of get_angles_as_a_quaternion()
|
inline |
returns the pitch angle in radian
|
inline |
Given a point in world coordinates, it converts it to camera coordinates.
|
inline |
Given a point in camera coordinates, it converts it to world coordinates.
|
inline |
returns the principal point
|
inline |
returns the coordinate of the principal point specified by the input index
|
inline |
returns the x-coordinate of the principal point
|
inline |
returns the y-coordinate of the principal point
|
inline |
Return opengl projection matrix, which can be passed to kjb::opengl::glMultMatrix(). Note that this needs to be preceeded by a call to glOrtho()
|
inlinevirtual |
|
inline |
returns the roll angle in radian
|
inline |
returns the rotation angles [pitch, yaw, roll]
|
inline |
returns the rotations of this camera as a quaternion
|
inline |
returns the skew in radian
Vector kjb::Perspective_camera::get_world_origin | ( | ) | const |
returns the world origin in camera coordinates
returns the world origin in camera coordinates as a 3-vector.
|
inline |
returns the world scale
|
inline |
returns the yaw angle in radian
|
inline |
Given a point in world coordinates, it returns true if the point is in the viewing frustum, false otherwise. Notice that the OpenGL context will be set in this function, since it is needed for the computation.
void kjb::Perspective_camera::mult_modelview_matrix | ( | ) | const |
|
inline |
|
virtual |
The camera to assign to this one
|
virtual |
This function makes sure that the rendering mechanism (OpenGL in this case) is set properly so that anything that will be rendered will be seen through a camera having the parameters specified in this class
clean_buffers | if true, the gl buffers will be cleared |
|
virtual |
Reads this camera from an input stream.
in | The input stream to read from |
Implements kjb::Readable.
|
inlinevirtual |
Reads this camera from a file.
Reimplemented from kjb::Readable.
|
virtual |
rotates the camera around its x,y,z axes in this order
|
virtual |
rotates the camera around its x-axis
|
virtual |
rotates the camera around its x-axis
|
virtual |
rotates the camera around its x-axis
|
inline |
Rotates the input point into the camera coordinate system.
|
virtual |
sets the rotation angles from an input quaternion
Sets the rotation angles from an input quaternion
q | the input quaternion |
|
virtual |
sets the aspect ratio
|
virtual |
sets the camera centre
|
virtual |
sets the coordinate of the camera centre specified by the input index
|
virtual |
sets the x-coordinate of the camera centre
|
virtual |
sets the y-coordinate of the camera centre
|
virtual |
sets the y-coordinate of the camera centre
|
inline |
|
virtual |
sets the focal length
|
virtual |
sets the position and orientation with the semantics similar to gluLookAt
deyex | Specifies the x position of the eye point. |
deyey | Specifies the y position of the eye point. |
deyex | Specifies the z position of the eye point. |
dlookx | Specifies the x position of the reference point. |
dlooky | Specifies the y position of the reference point. |
dlookz | Specifies the z position of the reference point. |
dupx | Specifies the x direction of the up vector. |
dupy | Specifies the y direction of the up vector. |
dupz | Specifies the z direction of the up vector. |
|
virtual |
sets the position and orientation with the semantics similar to gluLookAt in a more convenient form
eye | Specifies the position of the eye point. |
look | Specifies the position of the reference point. |
up | Specifies the direction of the up vector. |
|
inline |
|
inlinevirtual |
Alias of set_angles_from_quaternion()
Reimplemented in kjb::Calibrated_camera.
|
virtual |
sets the pitch angle in radian
|
virtual |
sets the principal point
|
virtual |
sets the coordinate of the principal point specified by the input index
|
virtual |
sets the x-coordinate of the principal point
|
virtual |
sets the y-coordinate of the principal point
|
virtual |
sets the roll angle in radian
|
virtual |
sets pitch, yaw and roll for this camera, in radian
|
inline |
Sets the rotation mode. This will have an impact on how pitch, yaw and roll are interpreted (standard is Euler Mode XYZ with rotating axes, see class Quaternion). No matter what mode you specify here, pitch will be interpreted as Euler angle 1, yaw as Euler angle 2, and roll as Euler angle 3. This function (except for standard mode XYZR) is not adequately tested
|
virtual |
sets the skew angle
void kjb::Perspective_camera::set_world_origin | ( | const kjb::Vector & | origin | ) |
This returns a 3X4 camera matrix, built from the intrinsic and extrinsic parameters.
Setters sets the world origin in camera coordinates.
|
virtual |
sets the world scale
|
virtual |
sets the yaw angle in radian
|
virtual |
Swap contents with another Perspective_camera. This is implemented to run much more quickly than: Perspective_camera tmp = b; b = a; a = tmp;
|
virtual |
|
virtual |
|
virtual |
This funcation makes sure that the rendering interface is consistent with the camera parameters stored in this class.
This makes sure that the rendering interface is consistent with the camera parameters
|
virtual |
Writes this camera to an output stream.
Implements kjb::Writeable.
|
inlinevirtual |
Writes this camera to an output stream.
Reimplemented from kjb::Writeable.
|
mutableprotected |
True if the camera matrix was not updated to reflect changes.
|
mutableprotected |
True if the gl interface was not updated to reflect the changes to an extrinsic parameter
|
mutableprotected |
True if the gl interface was not updated to reflect the changes to an intrinsic parameter
|
mutableprotected |
Camera matrix
|
mutableprotected |
Interface to opengl