Om  1.0.0
A universal framework for multimedia simulation
Public Member Functions | Static Public Attributes | List of all members
om::graphics::cameras::Camera Class Reference

A class that represents a viewpoint in 3D space with a projection transformation. More...

#include <omGraphicsCamera.h>

Inheritance diagram for om::graphics::cameras::Camera:
om::graphics::base::Transformable

Public Member Functions

 Camera (const ProjectionType &projectionType=ProjectionType::PERSPECTIVE, Real aspectRatio=Real(1))
 Create a new perspective camera with the specified aspect ratio. More...
 
const Vector3getPosition () const
 Get the position of the camera. More...
 
void setPosition (const Vector3 &newPosition)
 Set the position of the camera. More...
 
const Matrix3getOrientation () const
 Get the orientation of the camera. More...
 
void setOrientation (const Matrix3 &newOrientation)
 Set the orientation of the camera. More...
 
Vector3 getViewDirection () const
 Get a unit vector along the camera's view direction. More...
 
const Vector3getUpDirection () const
 Get a unit vector pointing to the camera's up direction. More...
 
Vector3 getLeftDirection () const
 Get a unit vector pointing to the camera's left. More...
 
const Vector3getRightDirection () const
 Get a unit vector pointing to the camera's left. More...
 
Real getNearPlaneDistance () const
 Get the distance to the near clipping plane. More...
 
void setNearPlaneDistance (Real newNearPlaneDistance)
 Set the distance to the near clipping plane. More...
 
Real getFarPlaneDistance () const
 Get the distance to the far clipping plane. More...
 
void setFarPlaneDistance (Real newFarPlaneDistance)
 Set the distance to the far clipping plane. More...
 
Real getAspectRatio () const
 Return the aspect ratio of this camera (the ratio of the view's width to its height). More...
 
void setAspectRatio (Real newAspectRatio)
 Set the aspect ratio of this camera (the ratio of the view's width to its height). More...
 
Real getFieldOfView () const
 Get the horizontal field of view of the camera's view frustum. More...
 
void setFieldOfView (Real newFieldOfViewX)
 Set the horizontal field of view of the camera's view frustum. More...
 
Real getFieldOfViewX () const
 Get the horizontal field of view of the camera's view frustum. More...
 
void setFieldOfViewX (Real newFieldOfViewX)
 Set the horizontal field of view of the camera's view frustum. More...
 
Real getFieldOfViewY () const
 Get the vertical field of view of the camera's view frustum. More...
 
void setFieldOfViewY (Real newFieldOfViewY)
 Get the vertical field of view of the camera's view frustum. More...
 
const AABB2getViewBounds () const
 Return the camera-space bounding box of this camera's view if it has an orthographic projection. More...
 
void setViewBounds (const AABB2 &newViewBounds)
 Set the 2D camera-space bounding box of this camera's view if it has an orthographic projection. More...
 
void setViewBounds (const AABB3 &newViewBounds)
 Set the 3D camera-space bounding box of this camera's view if it has an orthographic projection. More...
 
const ProjectionTypegetProjectionType () const
 Return a reference to the projection type for this camera. More...
 
void setProjectionType (const ProjectionType &newProjectionType)
 Set the projection type for this camera. More...
 
CameraFlagsgetFlags ()
 Return a reference to an object that contains boolean parameters of the camera. More...
 
const CameraFlagsgetFlags () const
 Return an object that contains boolean parameters of the camera. More...
 
void setFlags (const CameraFlags &newFlags)
 Set an object that contains boolean parameters of the camera. More...
 
Bool flagIsSet (CameraFlags::Flag flag) const
 Return whether or not the specified boolan flag is set for this camera. More...
 
void setFlag (CameraFlags::Flag flag, Bool newIsSet=true)
 Set whether or not the specified boolan flag is set for this camera. More...
 
void lookAt (const Vector3 &point)
 Rotate the camera at its current position so that the specified point is in the center of its view. More...
 
void lookAt (const Vector3 &point, const Vector3 &up)
 Rotate the camera at its current position so that the specified point is in the center of its view. More...
 
virtual Matrix4 getProjectionMatrix () const
 Get a matrix which projects points in camera space onto the near plane of the camera. More...
 
virtual Matrix4 getDepthBiasProjectionMatrix (Real depth, Real bias) const
 Return a depth-biased projection matrix for this camera for the given depth and bias distance. More...
 
virtual ViewVolume getViewVolume () const
 Return an object specifying the volume of this camera's view. More...
 
virtual void getViewVolumeCorners (StaticArray< Vector3, 8 > &corners) const
 Compute the 8 corners of this camera's view volume and place them in the output array. More...
 
virtual Bool canViewDirection (const Vector3f &direction) const
 Return whether or not the specified direction is within the camera's field of view. More...
 
virtual Vector2 getScreenSpaceRadius (const Sphere3 &sphere) const
 Return the screen-space radius in pixels of the specified world-space bounding sphere. More...
 
Real getDepth (const Vector3 &point) const
 Return the distance to the specified point along the view direction. More...
 
virtual Ray3 getViewRay (const Vector2 &viewportPosition) const
 Return the ray along this camera's view direction passing through the specified viewport position. More...
 
- Public Member Functions inherited from om::graphics::base::Transformable
 Transformable ()
 Create a new transformable with the identity transformation. More...
 
 Transformable (const Transform3 &newTransform)
 Create a new transformable with the specified transformation. More...
 
virtual ~Transformable ()
 Destroy this transformable, releasing all associated resources. More...
 
const Vector3getPosition () const
 Return the position of this transformable. More...
 
void setPosition (const Vector3 &newPosition)
 Set the position of this transformable. More...
 
const Matrix3getOrientation () const
 Return the orientation of this transformable. More...
 
void setOrientation (const Matrix3 &newOrientation)
 Set the orientation of this transformable. More...
 
const Vector3getScale () const
 Get the scale of the transformable. More...
 
void setScale (Real newScale)
 Set the scale of the transformable uniformly for all dimensions. More...
 
void setScale (const Vector3 &newScale)
 Set the scale of the transformable. More...
 
const Transform3getTransform () const
 Return the transformation for this transformable between its local and parent coordinate frame. More...
 
void setTransform (const Transform3 &newTransform)
 Set the transformation for this transformable between its local and parent coordinate frame. More...
 
Matrix4 getTransformMatrix () const
 Return a 4x4 matrix representing the transformation from object to world space. More...
 
Matrix4 getTransformMatrixInverse () const
 Return a 4x4 matrix which transforms points from world space to object space. More...
 
Sphere3 getBoundingSphere () const
 Return a bounding sphere for this transformable in its parent coordinate space. More...
 
Sphere3 getLocalBoundingSphere () const
 Return a bounding sphere for this transformable in its local coordinate space. More...
 
const AABB3getBoundingBox () const
 Return an axis-aligned bounding box that encompases this entire transformable in its parent coordinate space. More...
 
const AABB3getLocalBoundingBox () const
 Return an axis-aligned bounding box that encompases this entire transformable in its local coordinate space. More...
 
virtual void updateBoundingBox ()
 Update the transformable's bounding box based on its current geometric representation. More...
 

Static Public Attributes

static const ResourceType RESOURCE_TYPE
 The resource type for a graphics camera. More...
 

Additional Inherited Members

- Protected Member Functions inherited from om::graphics::base::Transformable
void setLocalBoundingBox (const AABB3 &newLocalBoundingBox)
 Set the local axis-aligned bounding box for this shape. More...
 
- Protected Attributes inherited from om::graphics::base::Transformable
Transform3 transform
 The transformation for this transformable between its local and parent coordinate frame. More...
 

Detailed Description

A class that represents a viewpoint in 3D space with a projection transformation.

Constructor & Destructor Documentation

om::graphics::cameras::Camera::Camera ( const ProjectionType projectionType = ProjectionType::PERSPECTIVE,
Real  aspectRatio = Real(1) 
)

Create a new perspective camera with the specified aspect ratio.

Member Function Documentation

const Vector3& om::graphics::cameras::Camera::getPosition ( ) const
inline

Get the position of the camera.

void om::graphics::cameras::Camera::setPosition ( const Vector3 newPosition)
inline

Set the position of the camera.

const Matrix3& om::graphics::cameras::Camera::getOrientation ( ) const
inline

Get the orientation of the camera.

void om::graphics::cameras::Camera::setOrientation ( const Matrix3 newOrientation)
inline

Set the orientation of the camera.

This method ensures that the new camera orientation matrix is orthonormal.

Vector3 om::graphics::cameras::Camera::getViewDirection ( ) const
inline

Get a unit vector along the camera's view direction.

const Vector3& om::graphics::cameras::Camera::getUpDirection ( ) const
inline

Get a unit vector pointing to the camera's up direction.

Vector3 om::graphics::cameras::Camera::getLeftDirection ( ) const
inline

Get a unit vector pointing to the camera's left.

const Vector3& om::graphics::cameras::Camera::getRightDirection ( ) const
inline

Get a unit vector pointing to the camera's left.

Real om::graphics::cameras::Camera::getNearPlaneDistance ( ) const
inline

Get the distance to the near clipping plane.

void om::graphics::cameras::Camera::setNearPlaneDistance ( Real  newNearPlaneDistance)
inline

Set the distance to the near clipping plane.

Real om::graphics::cameras::Camera::getFarPlaneDistance ( ) const
inline

Get the distance to the far clipping plane.

void om::graphics::cameras::Camera::setFarPlaneDistance ( Real  newFarPlaneDistance)
inline

Set the distance to the far clipping plane.

Real om::graphics::cameras::Camera::getAspectRatio ( ) const
inline

Return the aspect ratio of this camera (the ratio of the view's width to its height).

The default aspect ratio is 1.

void om::graphics::cameras::Camera::setAspectRatio ( Real  newAspectRatio)
inline

Set the aspect ratio of this camera (the ratio of the view's width to its height).

The default aspect ratio is 1.

Real om::graphics::cameras::Camera::getFieldOfView ( ) const
inline

Get the horizontal field of view of the camera's view frustum.

This value is specified in degrees.

void om::graphics::cameras::Camera::setFieldOfView ( Real  newFieldOfViewX)
inline

Set the horizontal field of view of the camera's view frustum.

This value, specified in degrees, is clamped between 0 and 180.

Real om::graphics::cameras::Camera::getFieldOfViewX ( ) const
inline

Get the horizontal field of view of the camera's view frustum.

This value is specified in degrees.

void om::graphics::cameras::Camera::setFieldOfViewX ( Real  newFieldOfViewX)
inline

Set the horizontal field of view of the camera's view frustum.

This value, specified in degrees, is clamped between 0 and 180.

Real om::graphics::cameras::Camera::getFieldOfViewY ( ) const
inline

Get the vertical field of view of the camera's view frustum.

This value is specified in degrees.

void om::graphics::cameras::Camera::setFieldOfViewY ( Real  newFieldOfViewY)
inline

Get the vertical field of view of the camera's view frustum.

This value, specified in degrees, is clamped between 0 and 180.

const AABB2& om::graphics::cameras::Camera::getViewBounds ( ) const
inline

Return the camera-space bounding box of this camera's view if it has an orthographic projection.

void om::graphics::cameras::Camera::setViewBounds ( const AABB2 newViewBounds)
inline

Set the 2D camera-space bounding box of this camera's view if it has an orthographic projection.

void om::graphics::cameras::Camera::setViewBounds ( const AABB3 newViewBounds)
inline

Set the 3D camera-space bounding box of this camera's view if it has an orthographic projection.

const ProjectionType& om::graphics::cameras::Camera::getProjectionType ( ) const
inline

Return a reference to the projection type for this camera.

void om::graphics::cameras::Camera::setProjectionType ( const ProjectionType newProjectionType)
inline

Set the projection type for this camera.

CameraFlags& om::graphics::cameras::Camera::getFlags ( )
inline

Return a reference to an object that contains boolean parameters of the camera.

const CameraFlags& om::graphics::cameras::Camera::getFlags ( ) const
inline

Return an object that contains boolean parameters of the camera.

void om::graphics::cameras::Camera::setFlags ( const CameraFlags newFlags)
inline

Set an object that contains boolean parameters of the camera.

Bool om::graphics::cameras::Camera::flagIsSet ( CameraFlags::Flag  flag) const
inline

Return whether or not the specified boolan flag is set for this camera.

void om::graphics::cameras::Camera::setFlag ( CameraFlags::Flag  flag,
Bool  newIsSet = true 
)
inline

Set whether or not the specified boolan flag is set for this camera.

void om::graphics::cameras::Camera::lookAt ( const Vector3 point)

Rotate the camera at its current position so that the specified point is in the center of its view.

This method uses the camera's current up vector in determining the camera's new orientation.

void om::graphics::cameras::Camera::lookAt ( const Vector3 point,
const Vector3 up 
)

Rotate the camera at its current position so that the specified point is in the center of its view.

This method uses the specified up vector in determining the camera's new orientation.

virtual Matrix4 om::graphics::cameras::Camera::getProjectionMatrix ( ) const
virtual

Get a matrix which projects points in camera space onto the near plane of the camera.

virtual Matrix4 om::graphics::cameras::Camera::getDepthBiasProjectionMatrix ( Real  depth,
Real  bias 
) const
virtual

Return a depth-biased projection matrix for this camera for the given depth and bias distance.

virtual ViewVolume om::graphics::cameras::Camera::getViewVolume ( ) const
virtual

Return an object specifying the volume of this camera's view.

virtual void om::graphics::cameras::Camera::getViewVolumeCorners ( StaticArray< Vector3, 8 > &  corners) const
virtual

Compute the 8 corners of this camera's view volume and place them in the output array.

The corners are stored in the following order: near bottom left, near bottom right, near top left, near top right, far bottom left, far bottom right, far top left, far top right.

virtual Bool om::graphics::cameras::Camera::canViewDirection ( const Vector3f direction) const
virtual

Return whether or not the specified direction is within the camera's field of view.

virtual Vector2 om::graphics::cameras::Camera::getScreenSpaceRadius ( const Sphere3 sphere) const
virtual

Return the screen-space radius in pixels of the specified world-space bounding sphere.

Real om::graphics::cameras::Camera::getDepth ( const Vector3 point) const
inline

Return the distance to the specified point along the view direction.

virtual Ray3 om::graphics::cameras::Camera::getViewRay ( const Vector2 viewportPosition) const
virtual

Return the ray along this camera's view direction passing through the specified viewport position.

The viewport position is specified where (0,0) is the lower left corner of the screen and (1,1) is the upper right corner. The ray's origin is the viewport position on the camera's near plane in world space.

Member Data Documentation

const ResourceType om::graphics::cameras::Camera::RESOURCE_TYPE
static

The resource type for a graphics camera.


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