JWS C++ Library
C++ language utility library
|
Stereo pair of cameras for 3D viewing in OpenGL. More...
#include <camera.h>
Public Member Functions | |
Stereo_camera_d (double focal_pt_x, double focal_pt_y, double focal_pt_z, double ref_pt_x, double ref_pt_y, double ref_pt_z, double up_x, double up_y, double up_z, double aperture, double clip_near, double clip_far) throw (jwscxx::base::Arg_error) | |
Constructs a Stereo_camera_d. | |
Stereo_camera_d (const jwsc::Vector_d *focal_pt, const jwsc::Vector_d *ref_pt, const jwsc::Vector_d *up, double aperture, double clip_near, double clip_far) throw (jwscxx::base::Arg_error) | |
Constructs a Stereo_camera_d. | |
Stereo_camera_d (const Stereo_camera_d &c) | |
Constructs a camera by copying another. | |
Stereo_camera_d (const char *fname) throw (jwscxx::base::Arg_error, jwscxx::base::IO_error) | |
Reads a camera from an input file. | |
Stereo_camera_d (std::istream &in) throw (jwscxx::base::Arg_error, jwscxx::base::IO_error) | |
Reads a camera from an input stream. | |
virtual | ~Stereo_camera_d () |
Deletes this Camera_d. | |
virtual Stereo_camera_d & | operator= (const Stereo_camera_d &c) |
Copies a camera into this one. | |
virtual Stereo_camera_d * | clone () const |
Clones this camera. | |
const jwsc::Vector_d * | get_left_prp () const |
Returns a constant pointer to the left camera focal point. | |
const jwsc::Vector_d * | get_right_prp () const |
Returns a constant pointer to the right camera focal point. | |
const jwsc::Vector_d * | get_left_vrp () const |
Returns a constant pointer to the left camera reference point. | |
const jwsc::Vector_d * | get_right_vrp () const |
Returns a constant pointer to the right camera reference point. | |
void | set_aperture (double aperture) throw (jwscxx::base::Arg_error) |
Sets the vertical aperture. | |
void | set_f_with_new_aperture_using_prp (double f) throw (jwscxx::base::Arg_error) |
Sets the focal length and updates the aperture by changing the left and right prp. | |
void | set_f_with_same_aperture_using_prp (double f) throw (jwscxx::base::Arg_error) |
Sets the focal length using the same aperture by changing the left and right prp. | |
void | set_f_with_new_aperture_using_vrp (double f) throw (jwscxx::base::Arg_error) |
Sets the focal length and updates the aperture by changing the vrp. | |
void | set_f_with_same_aperture_using_vrp (double f) throw (jwscxx::base::Arg_error) |
Sets the focal length using the same aperture by changing the vrp. | |
void | set_clipping (double clip_near, double clip_far) throw (jwscxx::base::Arg_error) |
Sets the clipping planes. | |
void | rotate (double angle, double x, double y, double z) throw (jwscxx::base::Arg_error) |
Rotates this Stereo_camera_d around a vector. | |
void | rotate (double angle, const jwsc::Vector_d *r) throw (jwscxx::base::Arg_error) |
Rotates this Stereo_camera_d around a vector. | |
void | translate (double x, double y, double z) |
Translates this Stereo_camera_d. | |
void | translate (const jwsc::Vector_d *t) throw (jwscxx::base::Arg_error) |
Translates this Stereo_camera_d. | |
void | look_at (double focal_pt_x, double focal_pt_y, double focal_pt_z, double ref_pt_x, double ref_pt_y, double ref_pt_z, double up_x, double up_y, double up_z) throw (jwscxx::base::Arg_error) |
Sets the position, direction and focal length of the camera. | |
void | set_left_gl_modelview () |
Sets the left GL model view matrix. | |
void | set_right_gl_modelview () |
Sets the right GL model view matrix. | |
void | set_left_gl_projection () |
Sets the left GL projection matrix. | |
void | set_right_gl_projection () |
Sets the right GL projection matrix. | |
void | read (std::istream &in) throw (jwscxx::base::IO_error, jwscxx::base::Arg_error) |
Reads this stereo camera from an input stream. | |
void | write (std::ostream &out) const throw (jwscxx::base::IO_error) |
Writes this stereo camera to an output stream. | |
Protected Attributes | |
jwsc::Vector_d * | left_vrp |
Left view reference point. | |
jwsc::Vector_d * | right_vrp |
Right view reference point. | |
jwsc::Vector_d * | left_prp |
Left projection reference point. | |
jwsc::Vector_d * | right_prp |
Right projection reference point. | |
double | separation |
Seperation between the stereo cameras. | |
double | ndfl |
Distance to the near clipping plane divided by the focal length. |
Stereo pair of cameras for 3D viewing in OpenGL.
Uses single precision, floating point values.
Stereo_camera_d::Stereo_camera_d | ( | double | focal_pt_x, |
double | focal_pt_y, | ||
double | focal_pt_z, | ||
double | ref_pt_x, | ||
double | ref_pt_y, | ||
double | ref_pt_z, | ||
double | up_x, | ||
double | up_y, | ||
double | up_z, | ||
double | aperture, | ||
double | clip_near, | ||
double | clip_far | ||
) | throw (jwscxx::base::Arg_error) |
Constructs a Stereo_camera_d.
focal_pt_x | X-coord of the focal point. |
focal_pt_y | Y-coord of the focal point. |
focal_pt_z | Z-coord of the focal point. |
ref_pt_x | X-coord of the reference point. |
ref_pt_y | Y-coord of the reference point. |
ref_pt_z | Z-coord of the reference point. |
up_x | X-coord of the up vector. |
up_y | Y-coord of the up vector. |
up_z | Z-coord of the up vector. |
aperture | Angle, in degrees, of the vertical field of view. |
clip_near | Near clipping plane for the GL frustum. Must be >= 0. |
clip_far | Far clipping plane for the GL frustum. Must be >= 0. |
focal_length / 30
jwscxx::base::Arg_error | Invalid up vector, aperture, or clipping planes. |
Definition at line 3519 of file camera.cpp.
Stereo_camera_d::Stereo_camera_d | ( | const jwsc::Vector_d * | focal_pt, |
const jwsc::Vector_d * | ref_pt, | ||
const jwsc::Vector_d * | up, | ||
double | aperture, | ||
double | clip_near, | ||
double | clip_far | ||
) | throw (jwscxx::base::Arg_error) |
Constructs a Stereo_camera_d.
focal_pt | Focal point. |
ref_pt | Reference point. |
up | Up vector. |
aperture | Angle, in degrees, of the vertical field of view. |
clip_near | Near clipping plane for the GL frustum. Must be >= 0. |
clip_far | Far clipping plane for the GL frustum. Must be >= 0. |
focal_length / 30
jwscxx::base::Arg_error | Invalid up vector, aperture, or clipping planes. |
Definition at line 3563 of file camera.cpp.
Stereo_camera_d::Stereo_camera_d | ( | const Stereo_camera_d & | c | ) |
Constructs a camera by copying another.
c | Camera to copy into this one. |
Definition at line 3584 of file camera.cpp.
Stereo_camera_d::Stereo_camera_d | ( | const char * | fname | ) | throw (jwscxx::base::Arg_error, jwscxx::base::IO_error) |
Reads a camera from an input file.
The file format is expected to be in ASCII as follows
Type: type_info name VRP: x y z PRP: x y z U: x y z V: x y z N: x y z F: focal_length Aperture: aperture Near: near Far: far Left VRP: x y z Right VRP: x y z Left PRP: x y z Right PRP: x y z
fname | Input file to read this camera from. |
jwscxx::base::IO_error | Could not read from in. |
jwscxx::base::Arg_error | Invalid arguments in file to read from. |
Definition at line 3621 of file camera.cpp.
Stereo_camera_d::Stereo_camera_d | ( | std::istream & | in | ) | throw (jwscxx::base::Arg_error, jwscxx::base::IO_error) |
Reads a camera from an input stream.
The file format is expected to be in ASCII as follows
Type: type_info name VRP: x y z PRP: x y z U: x y z V: x y z N: x y z F: focal_length Aperture: aperture Near: near Far: far Left VRP: x y z Right VRP: x y z Left PRP: x y z Right PRP: x y z
in | Input stream to read this camera from. |
jwscxx::base::IO_error | Could not read from in. |
jwscxx::base::Arg_error | Invalid arguments in file to read from. |
Definition at line 3659 of file camera.cpp.
Stereo_camera_d::~Stereo_camera_d | ( | ) | [virtual] |
Deletes this Camera_d.
Definition at line 3672 of file camera.cpp.
Stereo_camera_d & Stereo_camera_d::operator= | ( | const Stereo_camera_d & | c | ) | [virtual] |
Copies a camera into this one.
Performs a deep copy of this camera.
c | Camera to copy into this one. |
Definition at line 3688 of file camera.cpp.
Stereo_camera_d * Stereo_camera_d::clone | ( | ) | const [virtual] |
Clones this camera.
Reimplemented from jwscxx::graphics::Camera_d.
Definition at line 3705 of file camera.cpp.
const jwsc::Vector_d * Stereo_camera_d::get_left_prp | ( | ) | const |
Returns a constant pointer to the left camera focal point.
Definition at line 3711 of file camera.cpp.
const jwsc::Vector_d * Stereo_camera_d::get_right_prp | ( | ) | const |
Returns a constant pointer to the right camera focal point.
Definition at line 3717 of file camera.cpp.
const jwsc::Vector_d * Stereo_camera_d::get_left_vrp | ( | ) | const |
Returns a constant pointer to the left camera reference point.
Definition at line 3723 of file camera.cpp.
const jwsc::Vector_d * Stereo_camera_d::get_right_vrp | ( | ) | const |
Returns a constant pointer to the right camera reference point.
Definition at line 3729 of file camera.cpp.
void Stereo_camera_d::set_aperture | ( | double | aperture | ) | throw (jwscxx::base::Arg_error) [virtual] |
Sets the vertical aperture.
aperture | New vertical aperture, in degrees. |
jwscxx::base::Arg_error | Angle must be >= 0. |
Reimplemented from jwscxx::graphics::Camera_d.
Definition at line 3740 of file camera.cpp.
void Stereo_camera_d::set_f_with_new_aperture_using_prp | ( | double | f | ) | throw (jwscxx::base::Arg_error) [virtual] |
Sets the focal length and updates the aperture by changing the left and right prp.
In order to keep the size of the view the same, computes a new aperture from the new focal length.
f | New focal length. |
jwscxx::base::Arg_error | Invalid focal length. |
Reimplemented from jwscxx::graphics::Camera_d.
Definition at line 3756 of file camera.cpp.
void Stereo_camera_d::set_f_with_same_aperture_using_prp | ( | double | f | ) | throw (jwscxx::base::Arg_error) [virtual] |
Sets the focal length using the same aperture by changing the left and right prp.
The aperture is not changed, instead the size of the image plane is changed.
f | New focal length. |
jwscxx::base::Arg_error | Invalid focal length. |
Reimplemented from jwscxx::graphics::Camera_d.
Definition at line 3792 of file camera.cpp.
void Stereo_camera_d::set_f_with_new_aperture_using_vrp | ( | double | f | ) | throw (jwscxx::base::Arg_error) [virtual] |
Sets the focal length and updates the aperture by changing the vrp.
The aperture is updated to make the image plane the same size with the new focal length.
f | New focal length. |
jwscxx::base::Arg_error | Invalid focal length. |
Reimplemented from jwscxx::graphics::Camera_d.
Definition at line 3828 of file camera.cpp.
void Stereo_camera_d::set_f_with_same_aperture_using_vrp | ( | double | f | ) | throw (jwscxx::base::Arg_error) [virtual] |
Sets the focal length using the same aperture by changing the vrp.
The aperture is not changed, instead the size of the image plane is changed.
f | New focal length. |
jwscxx::base::Arg_error | Invalid focal length. |
Reimplemented from jwscxx::graphics::Camera_d.
Definition at line 3864 of file camera.cpp.
void Stereo_camera_d::set_clipping | ( | double | clip_near, |
double | clip_far | ||
) | throw (jwscxx::base::Arg_error) [virtual] |
Sets the clipping planes.
clip_near | Near clipping plane for the GL frustum. Must be >= 0. |
clip_far | Far clipping plane for the GL frustum. Must be >= 0. |
jwscxx::base::Arg_error | Invalid clipping planes. |
Reimplemented from jwscxx::graphics::Camera_d.
Definition at line 3898 of file camera.cpp.
void Stereo_camera_d::rotate | ( | double | phi, |
double | x, | ||
double | y, | ||
double | z | ||
) | throw (jwscxx::base::Arg_error) [virtual] |
Rotates this Stereo_camera_d around a vector.
phi | Angle to rotate, in radians. Use a positive value for clockwise, negative for counter-clockwise. |
x | X-coord of the vector to rotate around. |
y | Y-coord of the vector to rotate around. |
z | Z-coord of the vector to rotate around. |
jwscxx::base::Arg_error | Invalid vector to rotate around. |
Reimplemented from jwscxx::graphics::Camera_d.
Definition at line 3916 of file camera.cpp.
void Stereo_camera_d::rotate | ( | double | angle, |
const jwsc::Vector_d * | r | ||
) | throw (jwscxx::base::Arg_error) [virtual] |
Rotates this Stereo_camera_d around a vector.
Reimplemented from jwscxx::graphics::Camera_d.
Definition at line 3928 of file camera.cpp.
void Stereo_camera_d::translate | ( | double | x, |
double | y, | ||
double | z | ||
) | [virtual] |
Translates this Stereo_camera_d.
x | X-coord of the vector to translate by. |
y | Y-coord of the vector to translate by. |
z | Z-coord of the vector to translate by. |
Reimplemented from jwscxx::graphics::Camera_d.
Definition at line 3940 of file camera.cpp.
void Stereo_camera_d::translate | ( | const jwsc::Vector_d * | t | ) | throw (jwscxx::base::Arg_error) [virtual] |
Translates this Stereo_camera_d.
t | Vector to translate by. |
Reimplemented from jwscxx::graphics::Camera_d.
Definition at line 3957 of file camera.cpp.
void Stereo_camera_d::look_at | ( | double | focal_pt_x, |
double | focal_pt_y, | ||
double | focal_pt_z, | ||
double | ref_pt_x, | ||
double | ref_pt_y, | ||
double | ref_pt_z, | ||
double | up_x, | ||
double | up_y, | ||
double | up_z | ||
) | throw (jwscxx::base::Arg_error) [virtual] |
Sets the position, direction and focal length of the camera.
focal_pt_x | X-coord of the focal point. |
focal_pt_y | Y-coord of the focal point. |
focal_pt_z | Z-coord of the focal point. |
ref_pt_x | X-coord of the reference point. |
ref_pt_y | Y-coord of the reference point. |
ref_pt_z | Z-coord of the reference point. |
up_x | X-coord of the up vector. |
up_y | Y-coord of the up vector. |
up_z | Z-coord of the up vector. |
jwscxx::base::Arg_error | Invalid arguments. |
Reimplemented from jwscxx::graphics::Camera_d.
Definition at line 3983 of file camera.cpp.
void Stereo_camera_d::set_left_gl_modelview | ( | ) |
Sets the left GL model view matrix.
Switches the GL matrix mode to GL_MODELVIEW, loads the identity matrix, and multiplies the camera rotation and translation matrices.
Definition at line 4026 of file camera.cpp.
void Stereo_camera_d::set_right_gl_modelview | ( | ) |
Sets the right GL model view matrix.
Switches the GL matrix mode to GL_MODELVIEW, loads the identity matrix, and multiplies the camera rotation and translation matrices.
Definition at line 4048 of file camera.cpp.
void Stereo_camera_d::set_left_gl_projection | ( | ) |
Sets the left GL projection matrix.
Switches the GL matrix mode to GL_PROJECTION, loads the identity matrix, and sets the perspective frustum.
Definition at line 4070 of file camera.cpp.
void Stereo_camera_d::set_right_gl_projection | ( | ) |
Sets the right GL projection matrix.
Switches the GL matrix mode to GL_PROJECTION, loads the identity matrix, and sets the perspective frustum.
Definition at line 4090 of file camera.cpp.
void Stereo_camera_d::read | ( | std::istream & | in | ) | throw (jwscxx::base::IO_error, jwscxx::base::Arg_error) [virtual] |
Reads this stereo camera from an input stream.
The file format is expected to be in ASCII as follows
Type: type_info name VRP: x y z PRP: x y z U: x y z V: x y z N: x y z F: focal_length Aperture: aperture Near: near Far: far Left VRP: x y z Right VRP: x y z Left PRP: x y z Right PRP: x y z
in | Input stream to read this camera from. |
jwscxx::base::IO_error | Could not read from in. |
jwscxx::base::Arg_error | Invalid arguments in file to read from. |
Reimplemented from jwscxx::graphics::Camera_d.
Definition at line 4131 of file camera.cpp.
void Stereo_camera_d::write | ( | std::ostream & | out | ) | const throw (jwscxx::base::IO_error) [virtual] |
Writes this stereo camera to an output stream.
The file format is in ASCII as follows
Type: type_info name VRP: x y z PRP: x y z U: x y z V: x y z N: x y z F: focal_length Aperture: aperture Near: near Far: far Left VRP: x y z Right VRP: x y z Left PRP: x y z Right PRP: x y z
out | Output stream to write this camera to. |
jwscxx::base::IO_error | Could not write to out. |
Reimplemented from jwscxx::graphics::Camera_d.
Definition at line 4228 of file camera.cpp.
jwsc::Vector_d* jwscxx::graphics::Stereo_camera_d::left_vrp [protected] |
jwsc::Vector_d* jwscxx::graphics::Stereo_camera_d::right_vrp [protected] |
jwsc::Vector_d* jwscxx::graphics::Stereo_camera_d::left_prp [protected] |
jwsc::Vector_d* jwscxx::graphics::Stereo_camera_d::right_prp [protected] |
double jwscxx::graphics::Stereo_camera_d::separation [protected] |
double jwscxx::graphics::Stereo_camera_d::ndfl [protected] |