Camera Class Reference

A simple pinhole camera. More...

#include <Camera.h>

List of all members.

Public Member Functions

 Camera ()
 ~Camera ()
void SetAttributes (double angle, double aspect_ratio, double near_cutoff, double far_cutoff)
void ApplyAttributes ()
void ApplyPosition (int time)
void ComputeInverseView (int time)
float * GetInverseView ()
void BuildPlanes (int time)
void BuildPlanes2 ()
void DrawFrustum ()
void DrawFrustum2 (int time)
void MoveForward (double amount)
void MoveRight (double amount)
void MoveUp (double amount)

Public Attributes

PositionPathposition
Plane left
Plane right
Plane top
Plane bottom
Plane front
Plane back
Plane planes [6]

Private Attributes

double angle
double aspect_ratio
double near_cutoff
double far_cutoff
float inverse_view [16]


Detailed Description

A simple pinhole camera.

This class implements a simple pinhole camera. It has attributes like the aspect ratio between the horizontal and vertical size of the capture window, the size of the viewing angle and a near and far cutoff threshold which define the interval in which the objects are visibible to the camera.

The camera class also provides means to apply its position and orientation to the current OpenGL matrix as well as some functionality that can be used for viewing frustum culling.

It is important to notice, that the viewing direction of this camera is along the positive x axis (and not the z axis as in most other implementations). This choice has been made to make camera placement in world coordinates simpler as the rotation angles to be applied get more intuitive.

Definition at line 35 of file Camera.h.


Constructor & Destructor Documentation

Camera::Camera  ) 
 

Constructor: Initializes the camera with some standard values.

Definition at line 11 of file Camera.cpp.

Camera::~Camera  ) 
 

Destructor.

Definition at line 21 of file Camera.cpp.


Member Function Documentation

void Camera::ApplyAttributes  ) 
 

Sets up the projection matrix of OpenGL.

Definition at line 34 of file Camera.cpp.

void Camera::ApplyPosition int  time  ) 
 

Sets up the modelview matrix of OpenGL at any given time.

Parameters:
time Specifies the time which the position shall be applied at.

Definition at line 45 of file Camera.cpp.

void Camera::BuildPlanes int  time  ) 
 

Builds the planes of the viewing frustum in world coordinates. Since the camera may change its position as well as orientation over time, these planes may vary over time.

Parameters:
time Specifies the time which the view frustum planes shall be built at.

Definition at line 96 of file Camera.cpp.

void Camera::BuildPlanes2  ) 
 

Builds the planes of the viewing frustum in the coordinate system right before the projection. Since the camera position is just another transformation used to express everything our desired world coordinates, these planes are time independent.

Definition at line 300 of file Camera.cpp.

void Camera::ComputeInverseView int  time  ) 
 

Computes the inverse view matrix at any given time.

Parameters:
time Specifies the time which the inverse view matrix shall be computed at.

Definition at line 63 of file Camera.cpp.

void Camera::DrawFrustum  ) 
 

Draws the view frustum of the camera by using the planes defined in world coordinates. This routine does not display a meaningful frustum unless BuildPlanes (...) has been called before.

Definition at line 200 of file Camera.cpp.

void Camera::DrawFrustum2 int  time  ) 
 

Draws the view frustum of the camera by using the planes defined in the coordinate system right before the projection. Since this frustum is independent of the camera position, it must be transformed back into world coordinates before it can be drawn. This routine does not display a meaningful frustum unless BuildPlanes2 () has been called before.

Parameters:
time Specifies the time which the view frustum shall be drawn at.

Definition at line 230 of file Camera.cpp.

float * Camera::GetInverseView  ) 
 

Returns a pointer to the inverse view matrix. The returned values are only valid if ComputeInverseView (...) has been called before.

Returns:
Pointer to an array, wich contains a 4x4, column-major matrix

Definition at line 91 of file Camera.cpp.

void Camera::MoveForward double  amount  ) 
 

Moves the camera forward by a certain distance.

Parameters:
amount Specifies the moving distance. A negative value can be used to move backwards.

Definition at line 356 of file Camera.cpp.

void Camera::MoveRight double  amount  ) 
 

Moves the camera to the right by a certain distance.

Parameters:
amount Specifies the moving distance. A negative value can be used to move to the left.

Definition at line 370 of file Camera.cpp.

void Camera::MoveUp double  amount  ) 
 

Moves the camera upwards by a certain distance.

Parameters:
amount Specifies the moving distance. A negative value can be used to move downwards.

Definition at line 384 of file Camera.cpp.

void Camera::SetAttributes double  angle,
double  aspect_ratio,
double  near_cutoff,
double  far_cutoff
 

Set the attributes of the camera.

Parameters:
angle The vertical viewing angle of the camera, measured in degrees.
aspect_ratio The horizontal length divided by the vertical length of the viewing-window.
near_cutoff All points that are closer to the camera than this threshold won't get displayed.
far_cutoff All points that are farther away from the camera than this threshold won't get displayed.

Definition at line 26 of file Camera.cpp.


Member Data Documentation

double Camera::angle [private]
 

viewing angle in degrees

Definition at line 154 of file Camera.h.

double Camera::aspect_ratio [private]
 

aspect_ratio

Definition at line 157 of file Camera.h.

double Camera::far_cutoff [private]
 

far cutoff value

Definition at line 163 of file Camera.h.

float Camera::inverse_view[16] [private]
 

stores the inverse view matrix

Definition at line 166 of file Camera.h.

Plane Camera::left
 

class members: the view frustum planes in world coordinates.

Definition at line 107 of file Camera.h.

double Camera::near_cutoff [private]
 

near cutoff value

Definition at line 160 of file Camera.h.

Plane Camera::planes[6]
 

class members: the view frustum planes in the coordinate system right before projection takes place.

Definition at line 110 of file Camera.h.

PositionPath* Camera::position
 

The path of the camera over time.

Definition at line 89 of file Camera.h.


Generated on Sun Jul 2 13:20:40 2006 for Demo by  doxygen 1.4.6-NO