JWS C++ Library
C++ language utility library
jwscxx::graphics::Stereo_camera_f Class Reference

Stereo pair of cameras for 3D viewing in OpenGL. More...

#include <camera.h>

Inheritance diagram for jwscxx::graphics::Stereo_camera_f:
Collaboration diagram for jwscxx::graphics::Stereo_camera_f:

List of all members.

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_foperator= (const Stereo_camera_f &c)
 Copies a camera into this one.
virtual Stereo_camera_fclone () 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.

Detailed Description

Stereo pair of cameras for 3D viewing in OpenGL.

Uses single precision, floating point values.

Definition at line 842 of file camera.h.


Constructor & Destructor Documentation

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.

Parameters:
focal_pt_xX-coord of the focal point.
focal_pt_yY-coord of the focal point.
focal_pt_zZ-coord of the focal point.
ref_pt_xX-coord of the reference point.
ref_pt_yY-coord of the reference point.
ref_pt_zZ-coord of the reference point.
up_xX-coord of the up vector.
up_yY-coord of the up vector.
up_zZ-coord of the up vector.
apertureAngle, in degrees, of the vertical field of view.
clip_nearNear clipping plane for the GL frustum. Must be >= 0.
clip_farFar clipping plane for the GL frustum. Must be >= 0.
Note:
The view seperation is calculated as
Exceptions:
jwscxx::base::Arg_errorInvalid 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.

Parameters:
focal_ptFocal point.
ref_ptReference point.
upUp vector.
apertureAngle, in degrees, of the vertical field of view.
clip_nearNear clipping plane for the GL frustum. Must be >= 0.
clip_farFar clipping plane for the GL frustum. Must be >= 0.
Note:
The view seperation is calculated as
Exceptions:
jwscxx::base::Arg_errorInvalid 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.

Parameters:
cCamera 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
Parameters:
fnameInput file to read this camera from.
Exceptions:
jwscxx::base::IO_errorCould not read from in.
jwscxx::base::Arg_errorInvalid 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
Parameters:
inInput stream to read this camera from.
Exceptions:
jwscxx::base::IO_errorCould not read from in.
jwscxx::base::Arg_errorInvalid 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.


Member Function Documentation

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.

Parameters:
cCamera to copy into this one.
Returns:
A reference to this camera.

Definition at line 2936 of file camera.cpp.

Stereo_camera_f * Stereo_camera_f::clone ( ) const [virtual]

Clones this camera.

Returns:
A new copy of 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.

Parameters:
apertureNew vertical aperture, in degrees.
Exceptions:
jwscxx::base::Arg_errorAngle 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.

Parameters:
fNew focal length.
Exceptions:
jwscxx::base::Arg_errorInvalid 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.

Parameters:
fNew focal length.
Exceptions:
jwscxx::base::Arg_errorInvalid 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.

Parameters:
fNew focal length.
Exceptions:
jwscxx::base::Arg_errorInvalid 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.

Parameters:
fNew focal length.
Exceptions:
jwscxx::base::Arg_errorInvalid 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.

Parameters:
clip_nearNear clipping plane for the GL frustum. Must be >= 0.
clip_farFar clipping plane for the GL frustum. Must be >= 0.
Exceptions:
jwscxx::base::Arg_errorInvalid 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.

Parameters:
phiAngle to rotate, in radians. Use a positive value for clockwise, negative for counter-clockwise.
xX-coord of the vector to rotate around.
yY-coord of the vector to rotate around.
zZ-coord of the vector to rotate around.
Exceptions:
jwscxx::base::Arg_errorInvalid 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.

Parameters:
xX-coord of the vector to translate by.
yY-coord of the vector to translate by.
zZ-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.

Parameters:
tVector 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.

Parameters:
focal_pt_xX-coord of the focal point.
focal_pt_yY-coord of the focal point.
focal_pt_zZ-coord of the focal point.
ref_pt_xX-coord of the reference point.
ref_pt_yY-coord of the reference point.
ref_pt_zZ-coord of the reference point.
up_xX-coord of the up vector.
up_yY-coord of the up vector.
up_zZ-coord of the up vector.
Exceptions:
jwscxx::base::Arg_errorInvalid 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
Parameters:
inInput stream to read this camera from.
Exceptions:
jwscxx::base::IO_errorCould not read from in.
jwscxx::base::Arg_errorInvalid 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
Parameters:
outOutput stream to write this camera to.
Exceptions:
jwscxx::base::IO_errorCould not write to out.

Reimplemented from jwscxx::graphics::Camera_f.

Definition at line 3476 of file camera.cpp.


Member Data Documentation

jwsc::Vector_f* jwscxx::graphics::Stereo_camera_f::left_vrp [protected]

Left view reference point.

Definition at line 1034 of file camera.h.

jwsc::Vector_f* jwscxx::graphics::Stereo_camera_f::right_vrp [protected]

Right view reference point.

Definition at line 1037 of file camera.h.

jwsc::Vector_f* jwscxx::graphics::Stereo_camera_f::left_prp [protected]

Left projection reference point.

Definition at line 1040 of file camera.h.

jwsc::Vector_f* jwscxx::graphics::Stereo_camera_f::right_prp [protected]

Right projection reference point.

Definition at line 1043 of file camera.h.

Seperation between the stereo cameras.

Definition at line 1046 of file camera.h.

Distance to the near clipping plane divided by the focal length.

Definition at line 1052 of file camera.h.


The documentation for this class was generated from the following files: