|  | overview |  | wiki |  | api reference |  | download

- Main Page
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

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:

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)
Node * | getNode () const
const Matrix & | getViewMatrix () const
const Matrix & | getInverseViewMatrix () const
const Matrix & | getProjectionMatrix () const
void | setProjectionMatrix (const Matrix &matrix)
void | resetProjectionMatrix ()
const Matrix & | getViewProjectionMatrix () const
const Matrix & | getInverseViewProjectionMatrix () const
const Frustum & | getFrustum () 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 Camera * | createPerspective (float fieldOfView, float aspectRatio, float nearPlane, float farPlane)
static Camera * | createOrthographic (float zoomX, float zoomY, float aspectRatio, float nearPlane, float farPlane)
static Camera * | create (Properties *properties)

## Detailed Description

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

## Member Enumeration Documentation

enum gameplay::Camera::Type

The type of camera.

## Member Function Documentation

void gameplay::Camera::addListener | ( | Camera::Listener * | listener | ) |

Adds a camera listener.

Parameters:

  listener | The 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:

  properties | The 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:

  zoomX | The zoom factor along the X-axis of the orthographic projection (the width of the ortho projection).
  zoomY | The zoom factor along the Y-axis of the orthographic projection (the height of the ortho projection).
  aspectRatio | The aspect ratio of the orthographic projection.
  nearPlane | The near plane distance.
  farPlane | The 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:

  fieldOfView | The field of view in degrees for the perspective camera (normally in the range of 40-60 degrees).
  aspectRatio | The aspect ratio of the camera (normally the width of the viewport divided by the height of the viewport).
  nearPlane | The near plane distance.
  farPlane | The far plane distance.

Returns:
  The new Camera.

float gameplay::Camera::getAspectRatio | ( |  | ) | const

Gets the aspect ratio.

Returns:
  The aspect ratio.

Camera::Type gameplay::Camera::getCameraType | ( |  | ) | const

Gets the type of camera.

Returns:
  The camera type.

float gameplay::Camera::getFarPlane | ( |  | ) | const

Gets the far z clipping plane distance.

Returns:
  The far z clipping plane distance.

float gameplay::Camera::getFieldOfView | ( |  | ) | const

Gets the field of view for a perspective camera.

Returns:
  The field of view.

const Frustum& gameplay::Camera::getFrustum | ( |  | ) | const

Gets the view bounding frustum.

Returns:
  The viewing bounding frustum.

const Matrix& gameplay::Camera::getInverseViewMatrix | ( |  | ) | const

Gets the camera's inverse view matrix.

Returns:
  The camera inverse view matrix.

const Matrix& gameplay::Camera::getInverseViewProjectionMatrix | ( |  | ) | const

Gets the camera's inverse view * projection matrix.

Returns:
  The camera inverse view * projection matrix.

float gameplay::Camera::getNearPlane | ( |  | ) | const

Gets the near z clipping plane distance.

Returns:
  The near z clipping plane distance.

Node* gameplay::Camera::getNode | ( |  | ) | const

Gets the node that this camera is attached to.

Returns:
  The node that this camera is attached to.

const Matrix& gameplay::Camera::getProjectionMatrix | ( |  | ) | const

Gets the camera's projection matrix.

Returns:
  The camera projection matrix.

const Matrix& gameplay::Camera::getViewMatrix | ( |  | ) | const

Gets the camera's view matrix.

Returns:
  The camera view matrix.

const Matrix& gameplay::Camera::getViewProjectionMatrix | ( |  | ) | const

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:

  viewport | The viewport rectangle to use.
  x | The viewport x-coordinate.
  y | The viewport y-coordinate.
  dst | The 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:

  viewport | The viewport rectangle to use.
  position | The world space position.
  x | The returned viewport x coordinate.
  y | The returned viewport y coordinate.
  depth | The 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:

  viewport | The viewport rectangle to use.
  position | The world space position.
  out | Populated 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:

  viewport | The viewport rectangle to use.
  position | The world space position.
  out | Populated with the resulting screen-space position, with the pixel depth in the Z coordinate.

void gameplay::Camera::removeListener | ( | Camera::Listener * | listener | ) |

Removes a camera listener.

Parameters:

  listener | The listener to remove.

void gameplay::Camera::resetProjectionMatrix | ( |  | ) |

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:

  aspectRatio | The aspect ratio.

void gameplay::Camera::setFarPlane | ( | float | farPlane | ) |

Sets the far z clipping plane distance.

Parameters:

  farPlane | The far z clipping plane distance.

void gameplay::Camera::setFieldOfView | ( | float | fieldOfView | ) |

Sets the field of view.

Parameters:

  fieldOfView | The field of view.

void gameplay::Camera::setNearPlane | ( | float | nearPlane | ) |

Sets the near z clipping plane distance.

Parameters:

  nearPlane | The near z clipping plane distance.

void gameplay::Camera::setProjectionMatrix | ( | const Matrix & | matrix | ) |

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:

  matrix | Custom projection matrix.

void gameplay::Camera::setZoomX | ( | float | zoomX | ) |

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

Parameters:

  zoomX | The magnification (zoom) for x.

void gameplay::Camera::setZoomY | ( | float | zoomY | ) |

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

Parameters:

  zoomY | The 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:

  viewport | The viewport rectangle to use.
  x | The viewport-space x coordinate.
  y | The viewport-space y coordinate.
  depth | The depth range.
  dst | The world space position.

All Classes Functions Variables Typedefs Enumerations Enumerator