#include <Camera.h>
Public Member Functions | |
void | setOrthogonalProjection (f32 left, f32 right, f32 bottom, f32 top, f32 nnear, f32 nfar) |
void | setPerspectiveProjection (f32 fovy, f32 aspect, f32 nnear, f32 nfar) |
void | setProjection (mat4f &matrix) |
vec3f | unproject (vec3f screen_coord) |
mat4f | getProjectionMatrix () const |
mat4f | getProjectionMatrixInverse () |
mat4f | getViewMatrix () |
mat4f | getViewMatrixInverse () |
mat4f | getViewProjectionMatrix () |
mat4f | getViewProjectionMatrixInverse () |
void | calculateFrustum (vec4f frustum[6]) |
void | toggleIndicator (bool visible) |
bool | getIndicator () |
void | logInfo () |
Static Public Member Functions | |
static void | registerCommands () |
Protected Member Functions | |
Camera (const char *nname) | |
Friends | |
class | SceneGraph |
class | World |
Defines a Camera node.
void Camera::setOrthogonalProjection | ( | f32 | left, |
f32 | right, | ||
f32 | bottom, | ||
f32 | top, | ||
f32 | nnear, | ||
f32 | nfar | ||
) |
Set orthogonal projection
This sets the camera matrix to:
[ 2 / (left - right) 0 0 tx ; 0 2 / (top - bottom) 0 ty ; 0 0 2 / (nfar - nnear) tz ; 0 0 0 1 ]
tx = (right + left) / (right - left) ty = (top + bottom) / (top - bottom) tz = (nfar + nnear) / (nfar - nnear)
void Camera::setPerspectiveProjection | ( | f32 | fovy, |
f32 | aspect, | ||
f32 | nnear, | ||
f32 | nfar | ||
) |
Set perspective projection
This sets the camera matrix to: [ f / aspect 0 0 0 ; 0 f 0 0 ; 0 0 g h ; 0 0 -1 0 ]
f = cot(fovy / 2) g = (nfar + nnear) / (nnear - nfar) h = (2 * nfar * nnear) / (nnear - nfar)
fovy | Field of view in radians |
aspect | y / x |
void Camera::setProjection | ( | mat4f & | matrix ) |
Set projection matrix
This makes projection inverse computation much slower than for perspective or orthogonal matrices, since they are very easy to invert.
void Camera::toggleIndicator | ( | bool | visible ) |
Enable/disable light indicator for debugging purposes
Unproject a screen coordinate
screen_coord | Values should lie within [-1, 1]. Set Z to -1 for near plane and 1 for far plane. |