V-ART
Public Types | Public Member Functions | Protected Attributes | Friends | List of all members
VART::Camera Class Reference

Virtual camera. More...

#include <camera.h>

Public Types

enum  ProjectionType { ORTHOGRAPHIC, PERSPECTIVE }
 

Public Member Functions

 Camera ()
 
 Camera (const Point4D &position, const Point4D &focus, const Point4D &upVec)
 
 Camera (const Camera &cam)
 
Cameraoperator= (const Camera &cam)
 
const std::string & GetDescription () const
 Gets the description associated with the camera. More...
 
void SetDescription (const std::string &descriptionValue)
 Sets the description associated with the camera. More...
 
ProjectionType GetProjectionType () const
 Gets the projection type (PERSPECTIVE/ORTHOGRAPHIC). More...
 
void SetProjectionType (ProjectionType newValue)
 Sets the projection type (PERSPECTIVE/ORTHOGRAPHIC). More...
 
float GetAspectRatio () const
 Gets the camera's width/height ratio. More...
 
void SetAspectRatio (float newAR)
 Sets the camera's width/height ratio. More...
 
float GetNearPlaneDistance () const
 Returns the distance to the near plane. More...
 
void SetNearPlaneDistance (float newValue)
 Sets the distance to the near plane. More...
 
float GetFarPlaneDistance () const
 Returns the distance to the far plane. More...
 
void SetFarPlaneDistance (float newValue)
 Sets the distance to the far plane distance. More...
 
float GetFovY () const
 Returns the vertical field of view (in degrees). More...
 
void SetFovY (float f)
 Sets the vertical field of view (in degrees). More...
 
Point4D GetLocation () const
 Returns the camera location (its position). More...
 
void SetLocation (const Point4D &locationValue)
 Sets the camera location. More...
 
Point4D GetTarget () const
 Returns the camera target (where it is looking at). More...
 
void SetTarget (const Point4D &targetValue)
 Sets the camera target (where it is looking at). More...
 
Point4D GetUp () const
 Returns the camera up vector. More...
 
void LeftVector (Point4D *resultPtr) const
 Computes the vector pointing left. More...
 
void FrontVector (Point4D *resultPtr) const
 Computes the vector pointing ahead. More...
 
void SetUp (const Point4D &upValue)
 Sets the camera up vector. More...
 
void SetVisibleVolumeHLimits (double left, double right)
 Sets the horizontal limit coordinates of the orthographic view volume. More...
 
void SetVisibleVolumeVLimits (double top, double bottom)
 Sets the vertical limit coordinates of the orthographic view volume. More...
 
const double GetVisibleVolumeLeftLimit () const
 Gets the coordinates of the orthographic view volume. More...
 
const double GetVisibleVolumeRightLimit () const
 Gets the coordinates of the orthographic view volume. More...
 
const double GetVisibleVolumeTopLimit () const
 Gets the coordinates of the orthographic view volume. More...
 
const double GetVisibleVolumeBottomLimit () const
 Gets the coordinates of the orthographic view volume. More...
 
void SetVisibleVolumeHeight (double newValue)
 Sets the visible volume by given height. More...
 
void ScaleVisibleVolume (float horScale, float verScale)
 Scales the visible volume. More...
 
void YawAroundTarget (float radians)
 Rotates the Camera around the axis defined by the target and up vector. More...
 
void Yaw (float radians)
 Rotates the Camera around itself (location and up vector). More...
 
void Roll (float radians)
 Rolls the Camera around itself. More...
 
void PitchAroundTarget (float radians)
 Rotates the Camera around the axis defined by the target and left vector. More...
 
void MoveForward (double distance)
 Moves the camera forward (relative to the camera). More...
 
void MoveSideways (double distance)
 Moves the camera sideways. More...
 
void MoveUp (double distance)
 Moves the camera up and down. More...
 
bool DrawOGL () const
 Positions a camera using OpenGL commands. More...
 
void SetMatrices () const
 Loads camera transform into rendering engine. More...
 

Protected Attributes

ProjectionType projectionType
 Indicates whether a perspective ou orthographic projection should be used. More...
 
float fovY
 Vertical angle of frustum. Used if projectionType == PERSPECTIVE. More...
 
float aspectRatio
 Viewing aspect ratio (width/height). More...
 
float nearPlaneDistance
 Distance to near plane. More...
 
float farPlaneDistance
 Distance to far plane. More...
 
double vvLeft
 Visible Volume left coordinate (in world coordinates). Used if projectionType is ORTHOGRAPHIC. More...
 
double vvRight
 Visible Volume right coordinate (in world coordinates). Used if projectionType is ORTHOGRAPHIC. More...
 
double vvTop
 Visible Volume top coordinate (in world coordinates). Used if projectionType is ORTHOGRAPHIC. More...
 
double vvBottom
 Visible Volume bottom coordinate (in world coordinates). Used if projectionType is ORTHOGRAPHIC. More...
 
Point4D location
 Position where the camera is at. More...
 
Point4D target
 Position where the camera is looking at. More...
 
Point4D up
 Up direction, relative to the camera. More...
 

Friends

std::ostream & operator<< (std::ostream &output, const Camera &cam)
 

Detailed Description

Virtual camera.

FixMe: A detailed class description is needed here.

Definition at line 16 of file camera.h.

Member Enumeration Documentation

Enumerator
ORTHOGRAPHIC 
PERSPECTIVE 

Definition at line 19 of file camera.h.

Constructor & Destructor Documentation

VART::Camera::Camera ( )

Definition at line 20 of file camera.cpp.

VART::Camera::Camera ( const Point4D position,
const Point4D focus,
const Point4D upVec 
)

Creates a camera.

Parameters
position[in] Location of the new camera
focus[in] Position at which the new camera is looking at
upVec[in] Up vector specifing camera's orientation

Creates a camera with given parameters. The "up vector" is modified in order to be orthogonal to the camera line of view and is normalized.

Definition at line 35 of file camera.cpp.

References VART::Point4D::CrossProduct(), and VART::Point4D::Normalize().

VART::Camera::Camera ( const Camera cam)

Member Function Documentation

bool VART::Camera::DrawOGL ( ) const

Positions a camera using OpenGL commands.

Returns
false if V-ART was not compiled with OpenGL support.

Definition at line 276 of file camera.cpp.

Referenced by VART::Scene::DrawOGL().

void VART::Camera::FrontVector ( Point4D resultPtr) const

Computes the vector pointing ahead.

Definition at line 187 of file camera.cpp.

References VART::Point4D::Normalize().

float VART::Camera::GetAspectRatio ( ) const
inline

Gets the camera's width/height ratio.

Definition at line 49 of file camera.h.

References aspectRatio.

const std::string& VART::Camera::GetDescription ( ) const
inline

Gets the description associated with the camera.

Definition at line 37 of file camera.h.

float VART::Camera::GetFarPlaneDistance ( ) const
inline

Returns the distance to the far plane.

Definition at line 61 of file camera.h.

References farPlaneDistance.

float VART::Camera::GetFovY ( ) const

Returns the vertical field of view (in degrees).

Definition at line 173 of file camera.cpp.

VART::Point4D VART::Camera::GetLocation ( ) const

Returns the camera location (its position).

Definition at line 149 of file camera.cpp.

float VART::Camera::GetNearPlaneDistance ( ) const
inline

Returns the distance to the near plane.

Definition at line 55 of file camera.h.

References nearPlaneDistance.

ProjectionType VART::Camera::GetProjectionType ( ) const
inline

Gets the projection type (PERSPECTIVE/ORTHOGRAPHIC).

Definition at line 43 of file camera.h.

References projectionType.

VART::Point4D VART::Camera::GetTarget ( ) const

Returns the camera target (where it is looking at).

Definition at line 157 of file camera.cpp.

VART::Point4D VART::Camera::GetUp ( ) const

Returns the camera up vector.

Definition at line 165 of file camera.cpp.

const double VART::Camera::GetVisibleVolumeBottomLimit ( ) const
inline

Gets the coordinates of the orthographic view volume.

Returns
bottom vertical limit

Definition at line 118 of file camera.h.

References vvBottom.

const double VART::Camera::GetVisibleVolumeLeftLimit ( ) const
inline

Gets the coordinates of the orthographic view volume.

Returns
left horizontal limit

Definition at line 106 of file camera.h.

References vvLeft.

const double VART::Camera::GetVisibleVolumeRightLimit ( ) const
inline

Gets the coordinates of the orthographic view volume.

Returns
right horizontal limit

Definition at line 110 of file camera.h.

References vvRight.

const double VART::Camera::GetVisibleVolumeTopLimit ( ) const
inline

Gets the coordinates of the orthographic view volume.

Returns
top vertical limit

Definition at line 114 of file camera.h.

References vvTop.

void VART::Camera::LeftVector ( Point4D resultPtr) const

Computes the vector pointing left.

Definition at line 181 of file camera.cpp.

References VART::Point4D::CrossProduct(), and VART::Point4D::Normalize().

void VART::Camera::MoveForward ( double  distance)

Moves the camera forward (relative to the camera).

Definition at line 241 of file camera.cpp.

References VART::Transform::ApplyTo(), VART::Transform::MakeTranslation(), and VART::Point4D::Normalize().

void VART::Camera::MoveSideways ( double  distance)
void VART::Camera::MoveUp ( double  distance)

Moves the camera up and down.

Definition at line 265 of file camera.cpp.

References VART::Transform::ApplyTo(), VART::Transform::MakeTranslation(), and VART::Point4D::Normalize().

VART::Camera & VART::Camera::operator= ( const Camera cam)
void VART::Camera::PitchAroundTarget ( float  radians)

Rotates the Camera around the axis defined by the target and left vector.

Definition at line 230 of file camera.cpp.

References VART::Transform::ApplyTo(), VART::Point4D::CrossProduct(), VART::Transform::MakeRotation(), and VART::Point4D::Normalize().

void VART::Camera::Roll ( float  radians)

Rolls the Camera around itself.

Definition at line 221 of file camera.cpp.

References VART::Transform::ApplyTo(), VART::Transform::MakeRotation(), and VART::Point4D::Normalize().

void VART::Camera::ScaleVisibleVolume ( float  horScale,
float  verScale 
)

Scales the visible volume.

The visible volume is changed by scaling horizontal and vertical limits by given factors. Usefull when changing the viewer size.

Definition at line 202 of file camera.cpp.

void VART::Camera::SetAspectRatio ( float  newAR)
inline

Sets the camera's width/height ratio.

Definition at line 52 of file camera.h.

References aspectRatio.

void VART::Camera::SetDescription ( const std::string &  descriptionValue)

Sets the description associated with the camera.

Definition at line 96 of file camera.cpp.

void VART::Camera::SetFarPlaneDistance ( float  newValue)
inline

Sets the distance to the far plane distance.

Definition at line 64 of file camera.h.

References farPlaneDistance.

void VART::Camera::SetFovY ( float  f)

Sets the vertical field of view (in degrees).

Definition at line 177 of file camera.cpp.

void VART::Camera::SetLocation ( const Point4D locationValue)

Sets the camera location.

Definition at line 153 of file camera.cpp.

void VART::Camera::SetMatrices ( ) const

Loads camera transform into rendering engine.

This method if much like DrawOGL, it only does not clear the camera transformation before setting loading the camera transform. It is usefull for object selection, if called after a call to gluPickMatrix.

Definition at line 297 of file camera.cpp.

void VART::Camera::SetNearPlaneDistance ( float  newValue)
inline

Sets the distance to the near plane.

Definition at line 58 of file camera.h.

References nearPlaneDistance.

void VART::Camera::SetProjectionType ( ProjectionType  newValue)
inline

Sets the projection type (PERSPECTIVE/ORTHOGRAPHIC).

Definition at line 46 of file camera.h.

References projectionType.

void VART::Camera::SetTarget ( const Point4D targetValue)

Sets the camera target (where it is looking at).

Definition at line 161 of file camera.cpp.

void VART::Camera::SetUp ( const Point4D upValue)

Sets the camera up vector.

Definition at line 169 of file camera.cpp.

void VART::Camera::SetVisibleVolumeHeight ( double  newValue)

Sets the visible volume by given height.

The visible volume is changed so that the origin is centered. The camera's aspect ratio is used to compute the visible volume's width. Usefull only for orthographic cameras.

Definition at line 193 of file camera.cpp.

void VART::Camera::SetVisibleVolumeHLimits ( double  left,
double  right 
)
inline

Sets the horizontal limit coordinates of the orthographic view volume.

Definition at line 97 of file camera.h.

References vvLeft, and vvRight.

void VART::Camera::SetVisibleVolumeVLimits ( double  top,
double  bottom 
)
inline

Sets the vertical limit coordinates of the orthographic view volume.

Definition at line 101 of file camera.h.

References vvBottom, and vvTop.

void VART::Camera::Yaw ( float  radians)

Rotates the Camera around itself (location and up vector).

Definition at line 215 of file camera.cpp.

References VART::Transform::ApplyTo(), and VART::Transform::MakeRotation().

void VART::Camera::YawAroundTarget ( float  radians)

Rotates the Camera around the axis defined by the target and up vector.

Definition at line 209 of file camera.cpp.

References VART::Transform::ApplyTo(), and VART::Transform::MakeRotation().

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  output,
const Camera cam 
)
friend

Member Data Documentation

float VART::Camera::aspectRatio
protected

Viewing aspect ratio (width/height).

Definition at line 165 of file camera.h.

Referenced by Camera(), GetAspectRatio(), operator=(), and SetAspectRatio().

float VART::Camera::farPlaneDistance
protected

Distance to far plane.

Definition at line 169 of file camera.h.

Referenced by Camera(), GetFarPlaneDistance(), operator=(), and SetFarPlaneDistance().

float VART::Camera::fovY
protected

Vertical angle of frustum. Used if projectionType == PERSPECTIVE.

Definition at line 163 of file camera.h.

Referenced by Camera(), and operator=().

Point4D VART::Camera::location
protected

Position where the camera is at.

Definition at line 185 of file camera.h.

Referenced by Camera(), and operator=().

float VART::Camera::nearPlaneDistance
protected

Distance to near plane.

Definition at line 167 of file camera.h.

Referenced by Camera(), GetNearPlaneDistance(), operator=(), and SetNearPlaneDistance().

ProjectionType VART::Camera::projectionType
protected

Indicates whether a perspective ou orthographic projection should be used.

Definition at line 161 of file camera.h.

Referenced by Camera(), GetProjectionType(), operator=(), and SetProjectionType().

Point4D VART::Camera::target
protected

Position where the camera is looking at.

Definition at line 187 of file camera.h.

Referenced by Camera(), and operator=().

Point4D VART::Camera::up
protected

Up direction, relative to the camera.

Definition at line 190 of file camera.h.

Referenced by Camera(), and operator=().

double VART::Camera::vvBottom
protected

Visible Volume bottom coordinate (in world coordinates). Used if projectionType is ORTHOGRAPHIC.

Definition at line 182 of file camera.h.

Referenced by Camera(), GetVisibleVolumeBottomLimit(), operator=(), and SetVisibleVolumeVLimits().

double VART::Camera::vvLeft
protected

Visible Volume left coordinate (in world coordinates). Used if projectionType is ORTHOGRAPHIC.

Definition at line 173 of file camera.h.

Referenced by Camera(), GetVisibleVolumeLeftLimit(), operator=(), and SetVisibleVolumeHLimits().

double VART::Camera::vvRight
protected

Visible Volume right coordinate (in world coordinates). Used if projectionType is ORTHOGRAPHIC.

Definition at line 176 of file camera.h.

Referenced by Camera(), GetVisibleVolumeRightLimit(), operator=(), and SetVisibleVolumeHLimits().

double VART::Camera::vvTop
protected

Visible Volume top coordinate (in world coordinates). Used if projectionType is ORTHOGRAPHIC.

Definition at line 179 of file camera.h.

Referenced by Camera(), GetVisibleVolumeTopLimit(), operator=(), and SetVisibleVolumeVLimits().


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