#include <Camera.h>
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) |
Defines a camera which acts as a view of a scene to be rendered.
The type of camera.
void gameplay::Camera::addListener | ( | Camera::Listener * | listener | ) |
Adds a camera listener.
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.
properties | The properties definition of the Camera. |
static Camera* gameplay::Camera::createOrthographic | ( | float | zoomX, |
float | zoomY, | ||
float | aspectRatio, | ||
float | nearPlane, | ||
float | farPlane | ||
) | [static] |
Creates an orthographic camera.
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. |
static Camera* gameplay::Camera::createPerspective | ( | float | fieldOfView, |
float | aspectRatio, | ||
float | nearPlane, | ||
float | farPlane | ||
) | [static] |
Creates a perspective camera.
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. |
float gameplay::Camera::getAspectRatio | ( | ) | const |
Gets the aspect ratio.
Camera::Type gameplay::Camera::getCameraType | ( | ) | const |
Gets the type of camera.
float gameplay::Camera::getFarPlane | ( | ) | const |
Gets the far z clipping plane distance.
float gameplay::Camera::getFieldOfView | ( | ) | const |
Gets the field of view for a perspective camera.
const Frustum& gameplay::Camera::getFrustum | ( | ) | const |
Gets the view bounding frustum.
const Matrix& gameplay::Camera::getInverseViewMatrix | ( | ) | const |
Gets the camera's inverse view matrix.
const Matrix& gameplay::Camera::getInverseViewProjectionMatrix | ( | ) | const |
Gets the camera's inverse view * projection matrix.
float gameplay::Camera::getNearPlane | ( | ) | const |
Gets the near z clipping plane distance.
Node* gameplay::Camera::getNode | ( | ) | const |
Gets the node that this camera is attached to.
const Matrix& gameplay::Camera::getProjectionMatrix | ( | ) | const |
Gets the camera's projection matrix.
const Matrix& gameplay::Camera::getViewMatrix | ( | ) | const |
Gets the camera's view matrix.
const Matrix& gameplay::Camera::getViewProjectionMatrix | ( | ) | const |
Gets the camera's view * projection matrix.
float gameplay::Camera::getZoomX | ( | ) | const |
Gets the x-zoom (magnification) for an orthographic camera. Default is 1.0f.
float gameplay::Camera::getZoomY | ( | ) | const |
Gets the y-zoom (magnification) for a orthographic camera. Default is 1.0f.
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.
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.
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.
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.
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.
listener | The 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.
aspectRatio | The aspect ratio. |
void gameplay::Camera::setFarPlane | ( | float | farPlane | ) |
Sets the far z clipping plane distance.
farPlane | The far z clipping plane distance. |
void gameplay::Camera::setFieldOfView | ( | float | fieldOfView | ) |
Sets the field of view.
fieldOfView | The field of view. |
void gameplay::Camera::setNearPlane | ( | float | nearPlane | ) |
Sets the near z clipping plane distance.
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.
matrix | Custom projection matrix. |
void gameplay::Camera::setZoomX | ( | float | zoomX | ) |
Sets the x-zoom (magnification) for a orthographic camera. Default is 1.0f.
zoomX | The magnification (zoom) for x. |
void gameplay::Camera::setZoomY | ( | float | zoomY | ) |
Sets the y-zoom (magnification) for a orthographic camera.
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.
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. |