Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages  

sglPerspectiveCamera Class Reference

#include <sglPerspectiveCamera.hpp>

Inheritance diagram for sglPerspectiveCamera::

sglCamera sglObject List of all members.

Public Methods

 sglPerspectiveCamera ()
virtual ~sglPerspectiveCamera ()
bool setFOV (double fovy, double aspect, double near_clip, double far_clip)
bool getFOV (double &fovy, double &aspect, double &near_clip, double &far_clip) const
double getFOVY () const
double getFOVX () const
void setSimple (double left, double right, double bottom, double top, double near_clip, double far_clip)
void getSimple (double &left, double &right, double &bottom, double &top, double &near_clip, double &far_clip) const
virtual void applyProjection () const
virtual void printInfo (ostream &ostrm, const char *indent_string) const

Protected Methods

 sglPerspectiveCamera (const sglPerspectiveCamera &)
sglPerspectiveCamera& operator= (const sglPerspectiveCamera &)

Protected Attributes

bool m_simple_flag
double m_left
double m_right
double m_bottom
double m_top
double m_fovx

Detailed Description

This subclass of sglCamera provides the interface for specifying perspective frustums/projections. The sglPerspectiveCamera::setFOV(..) method takes the same arguments as the gluPerspective function, except that the fovy argument must be given in radians instead of degrees. The user may also use this class' sglPerspectiveCamera::setSimple(..) function to setup the projection just like that provided by OpenGL's glFrustum command. This is useful for specifying off-axis projections that cannot be specifed with FOV and aspect alone. Note that when this function has been used to specify the projection, then sglPerspective::getFOV(..) will return false to indicate that some of the values were computed (estimated?) internal because setSimple (and not setFOV) was used to define projection.


   sglPerspectiveCamera *view_camera = new sglPerspectiveCamera;
   view_camera->setFOV(0.25*M_PI, (double)win_x/(double)win_y, 1.0, 200.0);

   // OR
   view_camera->setSimple(0.0, 0.4, 0.0, 0.3, 1.0, 200.0); // off-axis

Definition at line 57 of file sglPerspectiveCamera.hpp.

Constructor & Destructor Documentation

sglPerspectiveCamera::sglPerspectiveCamera ( )

default constructor.

sglPerspectiveCamera::~sglPerspectiveCamera ( ) [virtual]

virtual destructor.

Member Function Documentation

bool sglPerspectiveCamera::setFOV ( double fovy,
double aspect,
double near_clip,
double far_clip )

This function is used to specify a symmetric perspective frusta (projections). The arguments match those of the gluPerspective function in OpenGL. If any of the parameters are out of range then the function returns false, and none of the parameters are set. If near_clip is greater than the far_clip then the parameters are swapped.

fovy   Vertical field of view in radian in the range (0..PI). The default is PI/4.
aspect   The width to height aspect ratio and must be greater than zero. The default is 640/480.
near_clip   The near clip distance and must be greater than zero. The default is 0.1.
far_clip   The far clip distance and should be greater than the near clip distance. The default is 1000.
false if one or more arguments were out of range.

bool sglPerspectiveCamera::getFOV ( double & fovy,
double & aspect,
double & near_clip,
double & far_clip ) const

This function gets the parameter values, but returns false if setSimple was last called to indicate that the fovy parameter returned is computed internally based on the parameters to setSimple (and not that specified in setFOV) and does not have the implied symmetry.

double sglPerspectiveCamera::getFOVY ( ) const [inline]

Returns the vertical field of view in radians.

Definition at line 92 of file sglPerspectiveCamera.hpp.

double sglPerspectiveCamera::getFOVX ( ) const [inline]

Returns the horizontal field of view in radians.

Definition at line 94 of file sglPerspectiveCamera.hpp.

void sglPerspectiveCamera::setSimple ( double left,
double right,
double bottom,
double top,
double near_clip,
double far_clip )

The most basic method for setting frusta (parameters corresponds to those in glFrustum) which can also be used to set off-axis projections. The lower left and upper right locations on the near clip plane is defined as (left, bottom, -near) and (right, top, -near) with the camera positioned at the origin.

left   Left edge of the frustum.
right   Right edge of the frustum.
bottom   Bottom edge of the frustum.
top   Top edge of the frustum.
near_clip   The near clip plane distance.
far_clip   The far clip plane distance.

void sglPerspectiveCamera::getSimple ( double & left,
double & right,
double & bottom,
double & top,
double & near_clip,
double & far_clip ) const

Query the parameters for the current perspective frustum.

virtual void sglPerspectiveCamera::applyProjection ( ) const [virtual]

Setup the OpenGL projection matrix to match the specified frustum. This function leaves the glMatrixMode(GL_PROJECTION) in effect (current) upon return.

Reimplemented from sglCamera.

virtual void sglPerspectiveCamera::printInfo ( ostream & ostrm,
const char * indent_string ) const [virtual]

Output the state of this node to the specified ostream.

ostrm   the ostream to which the output is sent
indent_string   the string (usually spaces) that is output at the beginning of every line of output

Reimplemented from sglCamera.

The documentation for this class was generated from the following file:
Generated at Mon Jul 1 18:00:09 2002 for SGL by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001