dms::PerspCamera

Source Code

Class Specification

#include <dms/PerspCamera.h>

PerspCamera(GLdouble fovy = 45.0, GLdouble aspect = 1.0,
            GLdouble near = 1.0, GLdouble far = 100.0);
virtual void applyProjection(void) const;

void zoom(GLdouble angle);

void setFovy(GLdouble);
void setAspect(GLdouble);
void setNear(GLdouble);
void setFar(GLdouble);
GLdouble fovy(void) const;
GLdouble aspect(void) const;
GLdouble near(void) const;
GLdouble far(void) const;

Description

PerspCamera(GLdouble fovy, GLdouble aspect, GLdouble near, GLdouble far)

The constructor sets values for the field-of-view-in-Y, aspect ratio, near clipping distance, and far clipping distance. The defaults are: fovy = 45 degrees, aspect = 1, near = 1 unit, far = 100 units.

void applyProjection(void)

Loads a perspective projection, using the camera's values, into the GL_PROJECTION matrix. This function is not normally called directly, but is used by Camera's apply() function.

void setFovy(GLdouble angle)
GLdouble fovy(void)

Sets / returns the camera's field-of-view-in-Y angle, in degrees.
Example:

PerspCamera camera;
camera.setFovy(90.0);
void setAspect(GLdouble aspect)
GLdouble aspect(void)

Sets / returns the camera's aspect ratio. An aspect of 1.0 gives a square projection (i.e. a projection appropriate for a square window); an aspect greater than 1.0 gives a projection for a window wider than it is tall; an aspect less than 1.0 gives a projection for a window taller than it is wide.
Example:

camera.setAspect(1.333);  /* Standard NTSC 4:3 aspect ratio */
void setNear(GLdouble near)
GLdouble near(void)

Sets / returns the camera's near clipping plane distance. Objects closer than near units to the camera will be clipped.
Example:

camera.setNear(0.001);
void setFar(GLdouble far)
GLdouble far(void)

Sets / returns the camera's far clipping plane distance. Objects farther than far units from the camera will be clipped.
Example:

camera.setFar(1000.0);
void zoom(GLdouble delta)

Changes the camera's field-of-view angle by delta degrees. The field-of-view will not be changed if this would put it outside of the range 0 to 180.
Example:

camera.zoom(1.0);  /* Zoom in slightly */