overview wiki api reference download
 All Classes Functions Variables Typedefs Enumerations Enumerator
Classes | Public Types | Public Member Functions | Static Public Member Functions
gameplay::Camera Class Reference

#include <Camera.h>

Inheritance diagram for gameplay::Camera:
gameplay::Ref gameplay::Transform::Listener

List of all members.

Classes

class  Listener

Public Types

enum  Type { PERSPECTIVE = 1, ORTHOGRAPHIC = 2 }

Public Member Functions

Camera::Type getCameraType () const
float getFieldOfView () const
void setFieldOfView (float fieldOfView)
float getZoomX () const
void setZoomX (float zoomX)
float getZoomY () const
void setZoomY (float zoomY)
float getAspectRatio () const
void setAspectRatio (float aspectRatio)
float getNearPlane () const
void setNearPlane (float nearPlane)
float getFarPlane () const
void setFarPlane (float farPlane)
NodegetNode () const
const MatrixgetViewMatrix () const
const MatrixgetInverseViewMatrix () const
const MatrixgetProjectionMatrix () const
void setProjectionMatrix (const Matrix &matrix)
void resetProjectionMatrix ()
const MatrixgetViewProjectionMatrix () const
const MatrixgetInverseViewProjectionMatrix () const
const FrustumgetFrustum () const
void project (const Rectangle &viewport, const Vector3 &position, float *x, float *y, float *depth=NULL) const
void project (const Rectangle &viewport, const Vector3 &position, Vector2 *out) const
void project (const Rectangle &viewport, const Vector3 &position, Vector3 *out) const
void unproject (const Rectangle &viewport, float x, float y, float depth, Vector3 *dst) const
void pickRay (const Rectangle &viewport, float x, float y, Ray *dst) const
void addListener (Camera::Listener *listener)
void removeListener (Camera::Listener *listener)

Static Public Member Functions

static CameracreatePerspective (float fieldOfView, float aspectRatio, float nearPlane, float farPlane)
static CameracreateOrthographic (float zoomX, float zoomY, float aspectRatio, float nearPlane, float farPlane)
static Cameracreate (Properties *properties)

Detailed Description

Defines a camera which acts as a view of a scene to be rendered.


Member Enumeration Documentation

The type of camera.


Member Function Documentation

Adds a camera listener.

Parameters:
listenerThe listener to add.
static Camera* gameplay::Camera::create ( Properties properties) [static]

Creates a camera from a properties definition.

The properties object must contain a "type" parameter, specifying either PERSPECTIVE or ORTHOGRAPHIC, as well as values for all required parameters in the Camera::createPerspective and Camera::createOrthographic methods.

Parameters:
propertiesThe properties definition of the Camera.
Returns:
The new Camera.
static Camera* gameplay::Camera::createOrthographic ( float  zoomX,
float  zoomY,
float  aspectRatio,
float  nearPlane,
float  farPlane 
) [static]

Creates an orthographic camera.

Parameters:
zoomXThe zoom factor along the X-axis of the orthographic projection (the width of the ortho projection).
zoomYThe zoom factor along the Y-axis of the orthographic projection (the height of the ortho projection).
aspectRatioThe aspect ratio of the orthographic projection.
nearPlaneThe near plane distance.
farPlaneThe far plane distance.
Returns:
The new Camera.
static Camera* gameplay::Camera::createPerspective ( float  fieldOfView,
float  aspectRatio,
float  nearPlane,
float  farPlane 
) [static]

Creates a perspective camera.

Parameters:
fieldOfViewThe field of view in degrees for the perspective camera (normally in the range of 40-60 degrees).
aspectRatioThe aspect ratio of the camera (normally the width of the viewport divided by the height of the viewport).
nearPlaneThe near plane distance.
farPlaneThe far plane distance.
Returns:
The new Camera.

Gets the aspect ratio.

Returns:
The aspect ratio.

Gets the type of camera.

Returns:
The camera type.

Gets the far z clipping plane distance.

Returns:
The far z clipping plane distance.

Gets the field of view for a perspective camera.

Returns:
The field of view.

Gets the view bounding frustum.

Returns:
The viewing bounding frustum.

Gets the camera's inverse view matrix.

Returns:
The camera inverse view matrix.

Gets the camera's inverse view * projection matrix.

Returns:
The camera inverse view * projection matrix.

Gets the near z clipping plane distance.

Returns:
The near z clipping plane distance.

Gets the node that this camera is attached to.

Returns:
The node that this camera is attached to.

Gets the camera's projection matrix.

Returns:
The camera projection matrix.

Gets the camera's view matrix.

Returns:
The camera view matrix.

Gets the camera's view * projection matrix.

Returns:
The camera view * projection matrix.
float gameplay::Camera::getZoomX ( ) const

Gets the x-zoom (magnification) for an orthographic camera. Default is 1.0f.

Returns:
The magnification (zoom) for x.
float gameplay::Camera::getZoomY ( ) const

Gets the y-zoom (magnification) for a orthographic camera. Default is 1.0f.

Returns:
The magnification (zoom) for y.
void gameplay::Camera::pickRay ( const Rectangle viewport,
float  x,
float  y,
Ray dst 
) const

Picks a ray that can be used for picking given the specified viewport-space coordinates.

Parameters:
viewportThe viewport rectangle to use.
xThe viewport x-coordinate.
yThe viewport y-coordinate.
dstThe computed pick ray.
void gameplay::Camera::project ( const Rectangle viewport,
const Vector3 position,
float *  x,
float *  y,
float *  depth = NULL 
) const

Projects the specified world position into the viewport coordinates.

Parameters:
viewportThe viewport rectangle to use.
positionThe world space position.
xThe returned viewport x coordinate.
yThe returned viewport y coordinate.
depthThe returned pixel depth (can be NULL).
void gameplay::Camera::project ( const Rectangle viewport,
const Vector3 position,
Vector2 out 
) const

Projects the specified world position into the viewport coordinates.

Parameters:
viewportThe viewport rectangle to use.
positionThe world space position.
outPopulated with the resulting screen-space position.
void gameplay::Camera::project ( const Rectangle viewport,
const Vector3 position,
Vector3 out 
) const

Projects the specified world position into the viewport coordinates.

Parameters:
viewportThe viewport rectangle to use.
positionThe world space position.
outPopulated with the resulting screen-space position, with the pixel depth in the Z coordinate.

Removes a camera listener.

Parameters:
listenerThe listener to remove.

Resets the camera to use the internally computed projection matrix instead of any previously specified user-defined matrix.

void gameplay::Camera::setAspectRatio ( float  aspectRatio)

Sets the aspect ratio.

Parameters:
aspectRatioThe aspect ratio.
void gameplay::Camera::setFarPlane ( float  farPlane)

Sets the far z clipping plane distance.

Parameters:
farPlaneThe far z clipping plane distance.
void gameplay::Camera::setFieldOfView ( float  fieldOfView)

Sets the field of view.

Parameters:
fieldOfViewThe field of view.
void gameplay::Camera::setNearPlane ( float  nearPlane)

Sets the near z clipping plane distance.

Parameters:
nearPlaneThe near z clipping plane distance.

Sets a custom projection matrix to be used by the camera.

Setting a custom projection matrix results in the internally computed projection matrix being completely overridden until the resetProjectionMatrix method is called. A custom projection matrix is normally not necessary, but can be used for special projection effects, such as setting an oblique view frustum for near plane clipping.

Parameters:
matrixCustom projection matrix.
void gameplay::Camera::setZoomX ( float  zoomX)

Sets the x-zoom (magnification) for a orthographic camera. Default is 1.0f.

Parameters:
zoomXThe magnification (zoom) for x.
void gameplay::Camera::setZoomY ( float  zoomY)

Sets the y-zoom (magnification) for a orthographic camera.

Parameters:
zoomYThe magnification (zoom) for y.
void gameplay::Camera::unproject ( const Rectangle viewport,
float  x,
float  y,
float  depth,
Vector3 dst 
) const

Converts a viewport-space coordinate to a world-space position for the given depth value.

The depth parameter is a value ranging between 0 and 1, where 0 returns a point on the near clipping plane and 1 returns a point on the far clipping plane.

Parameters:
viewportThe viewport rectangle to use.
xThe viewport-space x coordinate.
yThe viewport-space y coordinate.
depthThe depth range.
dstThe world space position.
 All Classes Functions Variables Typedefs Enumerations Enumerator