The camera object defines the view and projection matrices of a scene. More...

#include <Camera.h>

Public Member Functions

 Camera ()
 Constructor loading standard values for position, orientation and projection. More...
 
 Camera (GLfloat fov, GLfloat aspect, GLfloat near, GLfloat far)
 Constructor loading standard values for position and orientation. More...
 
 Camera (const vmml::Vector3f &position, const vmml::Vector3f &rotationAxes)
 Constructor loading standard values for projection. More...
 
 Camera (const vmml::Vector3f &position, const vmml::Vector3f &rotationAxes, GLfloat fov, GLfloat aspect, GLfloat near, GLfloat far)
 Constructor. More...
 
virtual ~Camera ()
 Virtual destructor. More...
 
virtual void moveCameraForward (GLfloat camSpeed)
 Moves the camera forward with a certain speed (based on previous position) More...
 
virtual void moveCameraSideward (GLfloat camSpeed)
 Moves the camera to the right with a certain speed (based on previous position) More...
 
virtual void moveCameraUpward (GLfloat camSpeed)
 Moves the camera upwards with a certain speed (based on previous position) More...
 
virtual void rotateCamera (GLfloat rotationX, GLfloat rotationY, GLfloat rotationZ)
 Rotates the camera based on previous orientation. More...
 
virtual void resetCamera ()
 Resets camera to the default position orientation. More...
 
void setPosition (const vmml::Vector3f &position)
 Sets the position of the camera. More...
 
void setRotation (const vmml::Vector3f &rotationAxes)
 Sets the rotation matrix of the camera. More...
 
void setFieldOfView (GLfloat fov)
 Sets field of view. More...
 
void setAspectRatio (GLfloat aspect)
 Sets aspect ratio. More...
 
void setNearClippingPlane (GLfloat near)
 Sets near clipping plane. More...
 
void setFarClippingPlane (GLfloat far)
 Sets far clipping plane. More...
 
virtual vmml::Matrix4f getViewMatrix ()
 Returns the view matrix of the camera. More...
 
virtual vmml::Matrix4f getInverseViewMatrix ()
 Returns the inverse of the view matrix of the camera. More...
 
virtual vmml::Matrix4f getProjectionMatrix ()
 Returns the view projection of the camera. More...
 
const vmml::Vector3f & getPosition ()
 Returns the position of the camera. More...
 
virtual vmml::Matrix4f getRotation ()
 Returns the rotation matrix of the camera. More...
 
virtual vmml::Matrix4f getInverseRotation ()
 Returns the inverse of the rotation matrix of the camera. More...
 
virtual vmml::Matrix4f getInverseRotationX ()
 Returns the inverse of the x-axis of the rotation matrix. More...
 
virtual vmml::Matrix4f getInverseRotationY ()
 Returns the inverse of the y-axis of the rotation matrix. More...
 
virtual vmml::Matrix4f getInverseRotationZ ()
 Returns the inverse of the z-axis of the rotation matrix. More...
 
virtual vmml::Vector3f getForward ()
 Returns the orientation of the camera. More...
 
virtual vmml::Vector3f getRight ()
 Returns the right vector of the camera. More...
 
virtual vmml::Vector3f getUp ()
 Returns the up vector of the camera. More...
 

Static Public Member Functions

static vmml::Matrix4f lookAt (const vmml::Vector3f &eye, const vmml::Vector3f &target, const vmml::Vector3f &up)
 Create a simple look at matrix. More...
 
static vmml::Matrix4f createPerspective (GLfloat fov, GLfloat aspect, GLfloat near, GLfloat far)
 Create a 3D perspective. More...
 

Detailed Description

The camera object defines the view and projection matrices of a scene.

Author
Benjamin Buergisser

Constructor & Destructor Documentation

Camera::Camera ( )

Constructor loading standard values for position, orientation and projection.

Camera::Camera ( GLfloat  fov,
GLfloat  aspect,
GLfloat  near,
GLfloat  far 
)

Constructor loading standard values for position and orientation.

Parameters
[in]fovField of view
[in]aspectAspect ratio
[in]nearNear clipping plane
[in]farFar clipping plane
Camera::Camera ( const vmml::Vector3f &  position,
const vmml::Vector3f &  rotationAxes 
)

Constructor loading standard values for projection.

Parameters
[in]positionPosition of the camera
[in]rotationAxesRotation axes of the camera
Camera::Camera ( const vmml::Vector3f &  position,
const vmml::Vector3f &  rotationAxes,
GLfloat  fov,
GLfloat  aspect,
GLfloat  near,
GLfloat  far 
)

Constructor.

Parameters
[in]positionPosition of the camera
[in]rotationAxesRotation axes of the camera
[in]fovField of view
[in]aspectAspect ratio
[in]nearNear clipping plane
[in]farFar clipping plane
virtual Camera::~Camera ( )
inlinevirtual

Virtual destructor.

Member Function Documentation

vmml::Matrix4f Camera::createPerspective ( GLfloat  fov,
GLfloat  aspect,
GLfloat  near,
GLfloat  far 
)
static

Create a 3D perspective.

Parameters
[in]fovField of view
[in]aspectAspect ratio
[in]nearNear clipping plane
[in]farFar clipping plane
vmml::Vector3f Camera::getForward ( )
virtual

Returns the orientation of the camera.

vmml::Matrix4f Camera::getInverseRotation ( )
virtual

Returns the inverse of the rotation matrix of the camera.

The inverse view matrix may be useful to keep an object to face the camera (e.g. a sprite)

vmml::Matrix4f Camera::getInverseRotationX ( )
virtual

Returns the inverse of the x-axis of the rotation matrix.

vmml::Matrix4f Camera::getInverseRotationY ( )
virtual

Returns the inverse of the y-axis of the rotation matrix.

vmml::Matrix4f Camera::getInverseRotationZ ( )
virtual

Returns the inverse of the z-axis of the rotation matrix.

vmml::Matrix4f Camera::getInverseViewMatrix ( )
virtual

Returns the inverse of the view matrix of the camera.

The inverse view matrix may be useful to keep an object at the cameras position

const vmml::Vector3f& Camera::getPosition ( )
inline

Returns the position of the camera.

vmml::Matrix4f Camera::getProjectionMatrix ( )
virtual

Returns the view projection of the camera.

vmml::Vector3f Camera::getRight ( )
virtual

Returns the right vector of the camera.

vmml::Matrix4f Camera::getRotation ( )
virtual

Returns the rotation matrix of the camera.

vmml::Vector3f Camera::getUp ( )
virtual

Returns the up vector of the camera.

vmml::Matrix4f Camera::getViewMatrix ( )
virtual

Returns the view matrix of the camera.

vmml::Matrix4f Camera::lookAt ( const vmml::Vector3f &  eye,
const vmml::Vector3f &  target,
const vmml::Vector3f &  up 
)
static

Create a simple look at matrix.

Parameters
[in]eyeSpecifies the position of the eye point
[in]targetSpecifies the position of the reference point
[in]upSpecifies the direction of the up vector
void Camera::moveCameraForward ( GLfloat  camSpeed)
virtual

Moves the camera forward with a certain speed (based on previous position)

Parameters
[in]camSpeedThe velocity of the movement
void Camera::moveCameraSideward ( GLfloat  camSpeed)
virtual

Moves the camera to the right with a certain speed (based on previous position)

Parameters
[in]camSpeedThe velocity of the movement
void Camera::moveCameraUpward ( GLfloat  camSpeed)
virtual

Moves the camera upwards with a certain speed (based on previous position)

Parameters
[in]camSpeedThe velocity of the movement
void Camera::resetCamera ( )
virtual

Resets camera to the default position orientation.

void Camera::rotateCamera ( GLfloat  rotationX,
GLfloat  rotationY,
GLfloat  rotationZ 
)
virtual

Rotates the camera based on previous orientation.

Parameters
[in]rotationXThe rotation around the x axis in radians
[in]rotationYThe rotation around the y axis in radians
[in]rotationZThe rotation around the z axis in radians
void Camera::setAspectRatio ( GLfloat  aspect)
inline

Sets aspect ratio.

Parameters
[in]aspectAspect ratio
void Camera::setFarClippingPlane ( GLfloat  far)
inline

Sets far clipping plane.

Parameters
[in]farFar clipping plane
void Camera::setFieldOfView ( GLfloat  fov)
inline

Sets field of view.

Parameters
[in]fovField of view
void Camera::setNearClippingPlane ( GLfloat  near)
inline

Sets near clipping plane.

Parameters
[in]nearNear clipping plane
void Camera::setPosition ( const vmml::Vector3f &  position)
inline

Sets the position of the camera.

Parameters
[in]positionPosition of the camera
void Camera::setRotation ( const vmml::Vector3f &  rotationAxes)
inline

Sets the rotation matrix of the camera.

Parameters
[in]rotationAxesRotation axes of the camera