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_f (float focal_pt_x, float focal_pt_y, float focal_pt_z, float ref_pt_x, float ref_pt_y, float ref_pt_z, float up_x, float up_y, float up_z, float aperture, float clip_near, float clip_far) throw (jwscxx::base::Arg_error) | |
Constructs a Stereo_camera_f. | |
Stereo_camera_f (const jwsc::Vector_f *focal_pt, const jwsc::Vector_f *ref_pt, const jwsc::Vector_f *up, float aperture, float clip_near, float clip_far) throw (jwscxx::base::Arg_error) | |
Constructs a Stereo_camera_f. | |
Stereo_camera_f (const Stereo_camera_f &c) | |
Constructs a camera by copying another. | |
Stereo_camera_f (const char *fname) throw (jwscxx::base::Arg_error, jwscxx::base::IO_error) | |
Reads a camera from an input file. | |
Stereo_camera_f (std::istream &in) throw (jwscxx::base::Arg_error, jwscxx::base::IO_error) | |
Reads a camera from an input stream. | |
virtual | ~Stereo_camera_f () |
Deletes this Camera_f. | |
virtual Stereo_camera_f & | operator= (const Stereo_camera_f &c) |
Copies a camera into this one. | |
virtual Stereo_camera_f * | clone () const |
Clones this camera. | |
const jwsc::Vector_f * | get_left_prp () const |
Returns a constant pointer to the left camera focal point. | |
const jwsc::Vector_f * | get_right_prp () const |
Returns a constant pointer to the right camera focal point. | |
const jwsc::Vector_f * | get_left_vrp () const |
Returns a constant pointer to the left camera reference point. | |
const jwsc::Vector_f * | get_right_vrp () const |
Returns a constant pointer to the right camera reference point. | |
void | set_aperture (float aperture) throw (jwscxx::base::Arg_error) |
Sets the vertical aperture. | |
void | set_f_with_new_aperture_using_prp (float 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 (float 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 (float 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 (float f) throw (jwscxx::base::Arg_error) |
Sets the focal length using the same aperture by changing the vrp. | |
void | set_clipping (float clip_near, float clip_far) throw (jwscxx::base::Arg_error) |
Sets the clipping planes. | |
void | rotate (float angle, float x, float y, float z) throw (jwscxx::base::Arg_error) |
Rotates this Stereo_camera_f around a vector. | |
void | rotate (float angle, const jwsc::Vector_f *r) throw (jwscxx::base::Arg_error) |
Rotates this Stereo_camera_f around a vector. | |
void | translate (float x, float y, float z) |
Translates this Stereo_camera_f. | |
void | translate (const jwsc::Vector_f *t) throw (jwscxx::base::Arg_error) |
Translates this Stereo_camera_f. | |
void | look_at (float focal_pt_x, float focal_pt_y, float focal_pt_z, float ref_pt_x, float ref_pt_y, float ref_pt_z, float up_x, float up_y, float 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_f * | left_vrp |
Left view reference point. | |
jwsc::Vector_f * | right_vrp |
Right view reference point. | |
jwsc::Vector_f * | left_prp |
Left projection reference point. | |
jwsc::Vector_f * | right_prp |
Right projection reference point. | |
float | separation |
Seperation between the stereo cameras. | |
float | 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_f::Stereo_camera_f | ( | float | focal_pt_x, |
float | focal_pt_y, | ||
float | focal_pt_z, | ||
float | ref_pt_x, | ||
float | ref_pt_y, | ||
float | ref_pt_z, | ||
float | up_x, | ||
float | up_y, | ||
float | up_z, | ||
float | aperture, | ||
float | clip_near, | ||
float | clip_far | ||
) | throw (jwscxx::base::Arg_error) |
Constructs a Stereo_camera_f.
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 2767 of file camera.cpp.
Stereo_camera_f::Stereo_camera_f | ( | const jwsc::Vector_f * | focal_pt, |
const jwsc::Vector_f * | ref_pt, | ||
const jwsc::Vector_f * | up, | ||
float | aperture, | ||
float | clip_near, | ||
float | clip_far | ||
) | throw (jwscxx::base::Arg_error) |
Constructs a Stereo_camera_f.
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 2811 of file camera.cpp.
Stereo_camera_f::Stereo_camera_f | ( | const Stereo_camera_f & | c | ) |
Constructs a camera by copying another.
c | Camera to copy into this one. |
Definition at line 2832 of file camera.cpp.
Stereo_camera_f::Stereo_camera_f | ( | 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 2869 of file camera.cpp.
Stereo_camera_f::Stereo_camera_f | ( | 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 2907 of file camera.cpp.
Stereo_camera_f::~Stereo_camera_f | ( | ) | [virtual] |
Deletes this Camera_f.
Definition at line 2920 of file camera.cpp.
Stereo_camera_f & Stereo_camera_f::operator= | ( | const Stereo_camera_f & | 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 2936 of file camera.cpp.
Stereo_camera_f * Stereo_camera_f::clone | ( | ) | const [virtual] |
Clones this camera.
Reimplemented from jwscxx::graphics::Camera_f.
Definition at line 2953 of file camera.cpp.
const jwsc::Vector_f * Stereo_camera_f::get_left_prp | ( | ) | const |
Returns a constant pointer to the left camera focal point.
Definition at line 2959 of file camera.cpp.
const jwsc::Vector_f * Stereo_camera_f::get_right_prp | ( | ) | const |
Returns a constant pointer to the right camera focal point.
Definition at line 2965 of file camera.cpp.
const jwsc::Vector_f * Stereo_camera_f::get_left_vrp | ( | ) | const |
Returns a constant pointer to the left camera reference point.
Definition at line 2971 of file camera.cpp.
const jwsc::Vector_f * Stereo_camera_f::get_right_vrp | ( | ) | const |
Returns a constant pointer to the right camera reference point.
Definition at line 2977 of file camera.cpp.
void Stereo_camera_f::set_aperture | ( | float | 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_f.
Definition at line 2988 of file camera.cpp.
void Stereo_camera_f::set_f_with_new_aperture_using_prp | ( | float | 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_f.
Definition at line 3004 of file camera.cpp.
void Stereo_camera_f::set_f_with_same_aperture_using_prp | ( | float | 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_f.
Definition at line 3040 of file camera.cpp.
void Stereo_camera_f::set_f_with_new_aperture_using_vrp | ( | float | 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_f.
Definition at line 3076 of file camera.cpp.
void Stereo_camera_f::set_f_with_same_aperture_using_vrp | ( | float | 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_f.
Definition at line 3112 of file camera.cpp.
void Stereo_camera_f::set_clipping | ( | float | clip_near, |
float | 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_f.
Definition at line 3146 of file camera.cpp.
void Stereo_camera_f::rotate | ( | float | phi, |
float | x, | ||
float | y, | ||
float | z | ||
) | throw (jwscxx::base::Arg_error) [virtual] |
Rotates this Stereo_camera_f 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_f.
Definition at line 3164 of file camera.cpp.
void Stereo_camera_f::rotate | ( | float | angle, |
const jwsc::Vector_f * | r | ||
) | throw (jwscxx::base::Arg_error) [virtual] |
Rotates this Stereo_camera_f around a vector.
Reimplemented from jwscxx::graphics::Camera_f.
Definition at line 3176 of file camera.cpp.
void Stereo_camera_f::translate | ( | float | x, |
float | y, | ||
float | z | ||
) | [virtual] |
Translates this Stereo_camera_f.
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_f.
Definition at line 3188 of file camera.cpp.
void Stereo_camera_f::translate | ( | const jwsc::Vector_f * | t | ) | throw (jwscxx::base::Arg_error) [virtual] |
Translates this Stereo_camera_f.
t | Vector to translate by. |
Reimplemented from jwscxx::graphics::Camera_f.
Definition at line 3205 of file camera.cpp.
void Stereo_camera_f::look_at | ( | float | focal_pt_x, |
float | focal_pt_y, | ||
float | focal_pt_z, | ||
float | ref_pt_x, | ||
float | ref_pt_y, | ||
float | ref_pt_z, | ||
float | up_x, | ||
float | up_y, | ||
float | 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_f.
Definition at line 3231 of file camera.cpp.
void Stereo_camera_f::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 3274 of file camera.cpp.
void Stereo_camera_f::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 3296 of file camera.cpp.
void Stereo_camera_f::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 3318 of file camera.cpp.
void Stereo_camera_f::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 3338 of file camera.cpp.
void Stereo_camera_f::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_f.
Definition at line 3379 of file camera.cpp.
void Stereo_camera_f::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_f.
Definition at line 3476 of file camera.cpp.
jwsc::Vector_f* jwscxx::graphics::Stereo_camera_f::left_vrp [protected] |
jwsc::Vector_f* jwscxx::graphics::Stereo_camera_f::right_vrp [protected] |
jwsc::Vector_f* jwscxx::graphics::Stereo_camera_f::left_prp [protected] |
jwsc::Vector_f* jwscxx::graphics::Stereo_camera_f::right_prp [protected] |
float jwscxx::graphics::Stereo_camera_f::separation [protected] |
float jwscxx::graphics::Stereo_camera_f::ndfl [protected] |