Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

CCamera Class Reference

Camera class. More...

#include <CCamera.h>

List of all members.

Public Types

enum  CameraType { orthographic, perspective }

Public Methods

 CCamera ()
 CCamera (double rdEyePosX, double rdEyePosY, double rdEyePosZ, double rdRefPointX, double rdRefPointY, double rdRefPointZ, double rdViewUpX, double rdViewUpY, double rdViewUpZ, const CBoundingBox3D &cBBox=CBoundingBox3D(-1,-1,-1, 1, 1, 1), double rdVerAngle=30.0, int nVPHeight=480, double rdRatio=4.0/3.0, double rdNearPlane=0.0001, double rdFarPlane=10000.0)
 CCamera (CP3D cEyePos, CP3D cRefPoint, CV3D cViewUp, const CBoundingBox3D &cBBox=CBoundingBox3D(-1,-1,-1, 1, 1, 1), double rdVerAngle=30.0, int nVPHeight=480, double rdRatio=4.0/3.0, double rdNearPlane=0.0001, double rdFarPlane=10000.0, CameraType ctype=perspective)
virtual ~CCamera ()
void rotate (double rdAngle, CV3D cAxis, bool global=true)
void translate (CV3D vDiff)
void setRefPoint (const CP3D &cRefPoint)
const CP3DgetRefPoint () const
void setEyePos (const CP3D &cEyePos)
const CP3DgetEyePos () const
void setViewUp (const CV3D &cViewUp)
const CV3DgetViewUp () const
const CV3DgetViewDir () const
const CV3DgetViewRight () const
void setHVAngle (double rdHorAngle, double rdVerAngle)
void getHVAngle (double &rdHorAngle, double &rdVerAngle) const
void setClipPlanes (double rdNearPlane, double rdFarPlane)
void getClipPlanes (double &rdNearPlane, double &rdFarPlane) const
void setBoundingBox (const CBoundingBox3D &cBBox, bool fViewAll=true)
const CBoundingBox3DgetBoundingBox () const
void setCameraType (CameraType type)
CameraType getCameraType () const
void getVVolume (double array[6])
void setVPRes (int nVPWidth, int nVPHeight)
void getVPRes (int &nVPWidth, int &nVPHeight) const
void getVPParams (CP3D &origin, CV3D &xStep, CV3D &yStep, int nXSize, int nYSize)
CMat4D getModelview ()
CMat4D getOrtho ()
CMat4D getFrustrum ()
CMat4D getProjection ()
CMat4D getVPTrans (int nXSize, int nYSize)
void setRatio (double rdRatio)
double getRatio () const
void setFovy (double rdFovy)
double getFovy () const
void setVPHeight (int nVPHeight)
int getVPHeight () const
void viewAll ()
void print ()

Private Attributes

CameraType m_CameraType
CBoundingBox3D m_cBBox
double m_rdVerAngle
double m_rdRatio
double m_rdNearPlane
double m_rdFarPlane
int m_nVPHeight
bool m_fValidViewDir
bool m_fValidViewRight
CP3D m_cEyePos
CP3D m_cRefPoint
CV3D m_cViewUp
CV3D m_cViewDir
CV3D m_cViewRight


Detailed Description

Camera class.

This class implements a camera including functionality to modify the camera (rotate, move, etc.).

Author:
Markus Janich


Member Enumeration Documentation

enum CCamera::CameraType
 

An enum type for the different types of projection.

Enumeration values:
orthographic   stands for a camera for parallel projection.
perspective   stands for a camera for perspective projection.


Constructor & Destructor Documentation

CCamera::CCamera   [inline]
 

Default Constructor Eye is at (0,0,-1), center is at (0,0,0), and up is (0,1,0) and it has a boundingbox with the edge (-1,-1,-1) and (1,1,1).

CCamera::CCamera double   rdEyePosX,
double   rdEyePosY,
double   rdEyePosZ,
double   rdRefPointX,
double   rdRefPointY,
double   rdRefPointZ,
double   rdViewUpX,
double   rdViewUpY,
double   rdViewUpZ,
const CBoundingBox3D &   cBBox = CBoundingBox3D(-1, -1, -1, 1, 1, 1),
double   rdVerAngle = 30.0,
int   nVPHeight = 480,
double   rdRatio = 4.0/3.0,
double   rdNearPlane = 0.0001,
double   rdFarPlane = 10000.0
[inline]
 

Constructor defining the view parameters.

Parameters:
cEyePos   defines the eye position
cRefPoint   defines the reference point (focuspoint)
cViewUp   defines the view up vector
rdNearPlane   distance between the eyepoint and the near clipping plane
cBBox   the boundingbox of the whole scene
rdFarPlane   distance between the eyepoint and the far clipping plane
rdVerAngle   vertical open angle of the field of view
nVPHeight   resolution (in pixels) of the viewplane in y-direction
rdRatio   ratio between height and width, or hor. and vert. angle

CCamera::CCamera CP3D   cEyePos,
CP3D   cRefPoint,
CV3D   cViewUp,
const CBoundingBox3D &   cBBox = CBoundingBox3D(-1, -1, -1, 1, 1, 1),
double   rdVerAngle = 30.0,
int   nVPHeight = 480,
double   rdRatio = 4.0/3.0,
double   rdNearPlane = 0.0001,
double   rdFarPlane = 10000.0,
CameraType   ctype = perspective
[inline]
 

The same as above but different types of parameters.

virtual CCamera::~CCamera   [inline, virtual]
 

Default Destructor.


Member Function Documentation

const CBoundingBox3D& CCamera::getBoundingBox   const [inline]
 

Returns the boundingbox.

CameraType CCamera::getCameraType   const [inline]
 

Returns the type of the camera (perspective or orthographic).

void CCamera::getClipPlanes double &   rdNearPlane,
double &   rdFarPlane
const [inline]
 

Returns the distance between eye point and near/far clipplane.

const CP3D& CCamera::getEyePos   const [inline]
 

Get the current eye-point.

double CCamera::getFovy   const [inline]
 

This method returns the fovy angle.

CMat4D CCamera::getFrustrum  
 

This method returns the glFrustrum() like matrix.

void CCamera::getHVAngle double &   rdHorAngle,
double &   rdVerAngle
const [inline]
 

Get horizontal and vertical angle of view of the camera.

NOTE:
This is a similar workaround in reversed direction as used in in the method 'setHVAngle()'.

CMat4D CCamera::getModelview  
 

This method gets you the modelview matrix of the current setup just like gluLookAt().

CMat4D CCamera::getOrtho  
 

This method returns the glOrtho() like matrix.

CMat4D CCamera::getProjection  
 

This method gets you the projection matrix of the current setup just like glFrustrum()/glOrtho().

double CCamera::getRatio   const [inline]
 

This method returns the ratio.

const CP3D& CCamera::getRefPoint   const [inline]
 

Get the current reference-point.

int CCamera::getVPHeight   const [inline]
 

This method returns the vertical resolution of the viewplane.

void CCamera::getVPParams CP3D &   origin,
CV3D &   xStep,
CV3D &   yStep,
int   nXSize,
int   nYSize
 

Returns all parameters of a viewplane which is orthogonal to the viewdirection and with a dimension of nXSize x nYSize.

Parameters:
origin   returns the upper left point.
xStep   returns the vector in x-direction from one pixel to another.
yStep   returns the vector in y-direction from one pixel to another.
rdXSize   the resolution of the viewplane in x-direction.
rdYSize   the resolution of the viewplane in y-direction.

void CCamera::getVPRes int &   nVPWidth,
int &   nVPHeight
const [inline]
 

Returns the resolution of the viewplane in x- and y-direction.

CMat4D CCamera::getVPTrans int   nXSize,
int   nYSize
 

This method gets you the viewport transformation matrix of the current setup just like glViewport().

void CCamera::getVVolume double   array[6]
 

Returns the viewing volume. The values are in right order:
x-coordinate of the upper left corner,
x-coordinate of the lower right corner,
y-coordinate of the upper left corner,
y-coordinate of the lower right corner, and
the distance between eye point and near/far clipplane.
Hey, what a surprise! These are the values especially needed for the OpenGL functions 'glFrustum' or 'glOrtho' to set the projection matrix.

const CV3D & CCamera::getViewDir   const
 

Get the current normalized viewdirection-vector.

const CV3D & CCamera::getViewRight   const
 

Get the current normalized viewright-vector.

const CV3D& CCamera::getViewUp   const [inline]
 

Get the current viewup-vector.

void CCamera::print void  
 

Prints the camera parameter to standard output.

void CCamera::rotate double   rdAngle,
CV3D   cAxis,
bool   global = true
 

Rotates the camera by an angle of 'rdAngle' degrees around an axis which goes through the reference point if 'global' is set to 'true'. If 'global' is 'false' the axis goes through the point of the eye position (for pitch, roll and yaw the camera). The direction of the axis is specified with 'cAxis'. This method changes the position of the camera if 'global' is 'true'.

void CCamera::setBoundingBox const CBoundingBox3D &   cBBox,
bool   fViewAll = true
[inline]
 

Sets the dimension of the scene as a boundingbox in world coordinates.

void CCamera::setCameraType CameraType   type [inline]
 

Sets the type of the camera (perspective or orthographic).

void CCamera::setClipPlanes double   rdNearPlane,
double   rdFarPlane
[inline]
 

Set distance between eye point and near/far clipplane.

void CCamera::setEyePos const CP3D &   cEyePos
 

Set a new eye-point.

void CCamera::setFovy double   rdFovy [inline]
 

This method sets the fovy (i.e. vertical opening) angle of the camera.

void CCamera::setHVAngle double   rdHorAngle,
double   rdVerAngle
[inline]
 

Deprecated:
This method is is just for downwards compatibility.
Don't use this method in new programs use 'setFovy()' and 'setRatio()' instead.
Set horizontal and vertical angle of view of the camera. The range for the angles goes from 0 to 180 degrees. Remember to adjust the resolution of the viewplane of the camera to the right ratio. If you don't do that you will get a distorted view volume by calling 'getVVolume()'.
NOTE:
What this function real does is setting the vertical opening angle and the ratio which it calculates out of the given angles.

void CCamera::setRatio double   rdRatio [inline]
 

This method sets the ratio between width and height (horizontal and vertical opening angle).

void CCamera::setRefPoint const CP3D &   cRefPoint [inline]
 

Sets a new reference-point.

void CCamera::setVPHeight int   nVPHeight [inline]
 

This method sets the vertical resolution of the viewplane.

void CCamera::setVPRes int   nVPWidth,
int   nVPHeight
[inline]
 

Deprecated:
This method is is just for downwards compatibility.
Don't use this method in new programs use 'setVPHeight()' and 'setRatio()' instead.
Set resolution of the viewplane in x- and y-direction. Remember to adjust the opening angles of the camera to the right ratio if don't want to get distorted view volume by calling 'getVVolume()'.
NOTE:
What this function real does is setting the vertical resolution of the viewplane and the ratio which it calculates out of the given x,y-resolution.

void CCamera::setViewUp const CV3D &   cViewUp [inline]
 

Set a new viewup-vector.

void CCamera::translate CV3D   vDiff
 

Move the camera relative to the current position by any distance in a 3-dimensional direction given by 'vDiff'.

NOTE: The view direction doesn't change!

void CCamera::viewAll  
 

Modifies the camera that the bounding box fits within the currently defined view frustum.


Member Data Documentation

CameraType CCamera::m_CameraType [private]
 

Reads a vector from the given stream.

CBoundingBox3D CCamera::m_cBBox [private]
 

CP3D CCamera::m_cEyePos [private]
 

CP3D CCamera::m_cRefPoint [private]
 

CV3D CCamera::m_cViewDir [private]
 

CV3D CCamera::m_cViewRight [private]
 

CV3D CCamera::m_cViewUp [private]
 

bool CCamera::m_fValidViewDir [private]
 

bool CCamera::m_fValidViewRight [private]
 

int CCamera::m_nVPHeight [private]
 

double CCamera::m_rdFarPlane [private]
 

double CCamera::m_rdNearPlane [private]
 

double CCamera::m_rdRatio [private]
 

double CCamera::m_rdVerAngle [private]
 


The documentation for this class was generated from the following files:
Generated at Thu Oct 4 17:17:28 2001 for QGLViewer by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001