|
|
Various member functions are available to modify the position and the orientation of the camera. By calling Camera::Set passing in a RenderTarget instance the camera will be made active, i.e. the viewport of the render target and the view and projection matrices of the render context used by the render target will be set. The view matrix is computed by taking the inverse of the camera matrix.
Using Camera::SetCameraMatrix, or if you prefer Camera::SetViewMatrix, and Camera::SetProjectionMatrix the internally stored matrices of this camera object can be set directly. To compute appropriate view and projection matrices for XEngine the Matrix4x4 class provides a number of member functions, such as Matrix4x4::SetView or Matrix4x4::SetPerspectiveProjectionFov. One important thing to note is that the camera (and thus also the view matrix) must only contain rotations and translations to work for this camera class. No scaling, shearing, or other transformation allowed.
Additionally, you can retrieve the camera's view frustum in world space (which is useful for view frustum culling, for example) by calling Camera::GetFrustumInWorldSpace or in view space by calling Camera::GetFrustumInViewSpace.
Public Member Functions | |
| Camera () | |
| Constructs a camera object positioned at the origin looking down the negative z axis. | |
| Camera (const Vector3 &position, const Quaternion &orientation) | |
| Constructs a camera object using the given initial position and orientation. | |
| Camera (const Vector3 &position, const Matrix3x3 &orientation) | |
| Constructs a camera object using the given initial position and orientation. | |
| Camera (const Matrix4x4 &cameraMatrix) | |
| Constructs a camera object using the given initial camera matrix. | |
| void | Set (const boost::shared_ptr< RenderTarget > &pRenderTarget) |
| Sets this camera as the current camera for the given render target and its associated render context. | |
| void | SetViewport (const Viewport &viewport) |
| Sets the viewport used by this camera. | |
| const Viewport & | GetViewport () const |
| Returns the viewport used by this camera. | |
| void | SetPosition (const Vector3 &v) |
| Sets the camera's position in world coordinates. | |
| void | SetPosition (real x, real y, real z) |
| Sets the camera's position in world coordinates. | |
| void | SetOrientation (const Quaternion &q) |
| Sets the camera's orientation from the given quaternion. | |
| void | SetOrientation (const Matrix3x3 &m) |
| Sets the camera's orientation from the given 3x3 rotation matrix. | |
| Vector3 | GetPosition () const |
| Returns the current position of the camera in world space. | |
| Quaternion | GetOrientation () const |
| Returns the current orientation of the camera in world space. | |
| void | Translate (const Vector3 &v) |
| Translates the camera's position according to the given direction vector in world space. | |
| void | Translate (real x, real y, real z) |
| Translates the camera's position according to the given direction in world space. | |
| void | Rotate (const Quaternion &q) |
| Rotates the camera according to the given quaternion. | |
| void | Rotate (real pitch, real yaw, real roll) |
| Rotates the camera according to the given pitch, yaw, and roll angles. | |
| void | Rotate (const Matrix3x3 &m) |
| Rotates the camera using the given 3x3 rotation matrix. | |
| void | LookAt (const Vector3 &eye, const Vector3 &lookAt, const Vector3 &up) |
| Sets the view matrix of this camera to look at the given look-at point from the given eye/camera point. | |
| void | SetCameraMatrix (const Matrix4x4 &m) |
| Directly sets the camera matrix, which represents the position and orientation of the camera in world space. | |
| void | SetViewMatrix (const Matrix4x4 &m) |
| Directly sets the view matrix of this camera. | |
| void | SetProjectionMatrix (const Matrix4x4 &m) |
| Directly sets the projection matrix of this camera. | |
| const Matrix4x4 & | GetCameraMatrix () const |
| Returns the camera matrix of this camera. | |
| Matrix4x4 | GetViewMatrix () const |
| Returns the view matrix of this camera. | |
| const Matrix4x4 & | GetProjectionMatrix () const |
| Returns the projection matrix of this camera. | |
| Frustum | GetFrustumInWorldSpace () const |
| Returns the view frustum of this camera in world space. | |
| Frustum | GetFrustumInViewSpace () const |
| Returns the view frustum of this camera in view space. | |
| void | SetFrustumInViewSpace (const Frustum &frustum) |
| Sets the projection matrix of this camera using the given view frustum in view space. | |
|
|
Constructs a camera object whose camera matrix is set to the identity, thus the camera is positioned in world space at the origin looking straight down the negative z axis. The projection matrix is set to a perspective projection matrix with a vertical field-of-view of 60 degrees, an aspect ratio of 4/3, a near plane of 0.1 and a far plane of 1000. The default viewport is set to (0, 0, 1, 1). |
|
||||||||||||
|
Constructs a camera object using the given initial position and orientation. The given quaternion that represents the initial camera orientation must be a unit quaternion. The projection matrix is set to a perspective projection matrix with a vertical field-of-view of 60 degrees, an aspect ratio of 4/3, a near plane of 0.1 and a far plane of 1000. The default viewport is set to (0, 0, 1, 1). |
|
||||||||||||
|
Constructs a camera object using the given initial position and orientation. The given matrix that represents the initial camera orientation must be a rotation matrix. The projection matrix is set to a perspective projection matrix with a vertical field-of-view of 60 degrees, an aspect ratio of 4/3, a near plane of 0.1 and a far plane of 1000. The default viewport is set to (0, 0, 1, 1). |
|
|
Constructs a camera object using the given initial camera matrix. The given camera matrix must be a matrix containing only translations and rotations. The projection matrix is set to a perspective projection matrix with a vertical field-of-view of 60 degrees, an aspect ratio of 4/3, a near plane of 0.1 and a far plane of 1000. The default viewport is set to (0, 0, 1, 1). |
|
|
Returns the camera matrix of this camera. |
|
|
Returns the view frustum of this camera in view space. |
|
|
Returns the view frustum of this camera in world space. |
|
|
Returns the current orientation of the camera in world space. |
|
|
Returns the current position of the camera in world space. |
|
|
Returns the projection matrix of this camera. |
|
|
Returns the view matrix of this camera. |
|
|
Returns the viewport used by this camera. |
|
||||||||||||||||
|
Sets the view matrix of this camera to look at the given look-at point from the given eye/camera point. Note that the vector (lookAt - eye) must not be parallel or near parallel to the given up vector. This is just a convenient way of using a matrix created by Matrix4x4::SetView and then calling Camera::SetViewMatrix. |
|
|
Rotates the camera using the given 3x3 rotation matrix. Note that the debug build asserts if the given matrix is not a rotation matrix. The rotation matrix is pre-multiplied with the current camera matrix. So the rotation is performed in the current local camera coordinate system. |
|
||||||||||||||||
|
Rotates the camera according to the given pitch, yaw, and roll Euler angles. Pitch is around the positive x axis, yaw around the positive y axis, and roll around the positive z axis. The rotation is pre-multiplied with the current camera matrix. So the rotation is performed in the current local camera coordinate system. |
|
|
Rotates the camera according to the given quaternion. The given quaternion must be a unit quaternion. The quaternion is pre-multiplied with the current camera matrix. So the rotation is done in the current local camera coordinate system. |
|
|
Sets this camera as the current camera for the given render target. In particular, this member function makes sure the given render target is the active render target, sets the viewport accordingly, and sets the view and projection matrix of the render context used by the given render target as defined by this camera. Only after calling this member function any of the changes applied to the camera will be put into effect. |
|
|
Directly sets the camera matrix, which represents the position and orientation of the camera in world space. Note that the camera matrix must only contain translations and rotations (no scaling). |
|
|
Sets the projection matrix of this camera using the given view frustum in view space. |
|
|
Sets the camera's orientation from the given 3x3 rotation matrix. The given matrix must be a rotation matrix, i.e. an orthogonal matrix with its determinant equal to 1. |
|
|
Sets the camera's orientation from the given quaternion. The given quaternion must be a unit quaternion. |
|
||||||||||||||||
|
Sets the camera's position in world coordinates. |
|
|
Sets the camera's position in world coordinates. |
|
|
Directly sets the projection matrix of this camera. |
|
|
Directly sets the view matrix of this camera. Note that the view matrix must only contain translations and rotations (no scaling). |
|
|
Sets the viewport used by this camera. |
|
||||||||||||||||
|
Translates the camera's position according to the given direction in world space. The translation is pre-multiplied with the current camera matrix, so it is performed in the current local camera space. |
|
|
Translates the camera's position according to the given direction vector in world space. The translation is pre-multiplied with the current camera matrix, so it is performed in the current local camera space. |
|
Copyright © by Martin Ecker |