Visualization LibraryA lightweight C++ OpenGL middleware for 2D/3D graphics |
[Home] [Tutorials] [All Classes] [Grouped Classes] |
Represents a virtual camera defining, among other things, the point of view from which scenes can be rendered. More...
#include <Camera.hpp>
Public Member Functions | |
| virtual const char * | className () |
| Returns the name of the class. | |
| Camera () | |
| Constructor. | |
| void | computeNearFarOptimizedProjMatrix (const Sphere &scene_bounding_sphere) |
The near and far clipping planes are adjusted to fit the provided scene_bounding_sphere. | |
| void | computeFrustumPlanes () |
| Computes the Camera's frustum planes in world space. | |
| void | applyModelViewMatrix (const mat4 &model_matrix) const |
| Loads the GL_MODELVIEW matrix with the Camera's view matrix multiplied by the specified model matrix. | |
| void | applyViewMatrix () const |
| Loads the GL_MODELVIEW matrix with the Camera's view matrix. | |
| void | applyProjMatrix () const |
| Loads the GL_PROJECTION matrix with the Camera's projection matrix. | |
| void | setActive (bool active) |
| bool | active () const |
| void | setFOV (Real fov) |
| Real | fov () const |
| Real | aspectRatio () const |
| Returns the aspect ratio computed as viewport()->width()/viewport()->height(). | |
| void | setNearPlane (Real nearplane) |
| Real | nearPlane () const |
| void | setFarPlane (Real farplane) |
| Real | farPlane () const |
| void | setFrustum (const Frustum &frustum) |
| const Frustum & | frustum () const |
| Frustum & | frustum () |
| void | setViewport (Viewport *viewport) |
| Viewport * | viewport () |
| const Viewport * | viewport () const |
| void | followTransform (Transform *transform) |
| const Transform * | followedTransform () const |
| Transform * | followedTransform () |
| void | setViewMatrix (const mat4 &mat) |
| Sets the Camera's view matrix. | |
| const mat4 & | viewMatrix () const |
| The Camera's view matrix. | |
| void | setInverseViewMatrix (const mat4 &mat) |
| The camera's reference frame matrix, the inverse of the view matrix. | |
| const mat4 & | inverseViewMatrix () const |
| The camera's reference frame matrix, the inverse of the view matrix. | |
| void | setProjectionMatrix (const mat4 &mat) |
| The camera's projection matrix. | |
| const mat4 & | projectionMatrix () const |
| The camera's projection matrix. | |
| void | setProjectionAsPerspective () |
| Builds a perspective projection matrix for the Camera based on the Camera's and Viewport's settings. | |
| void | setProjectionAsPerspective (Real fov, Real near, Real far) |
| Builds a perspective projection matrix for the Camera based on the Camera's and Viewport's settings. | |
| void | setProjectionAsFrustum (Real left, Real right, Real bottom, Real top, Real near, Real far) |
| Builds a perspective projection matrix for the Camera based on the give frustum. | |
| void | setProjectionAsOrtho (Real offset=-0.5f) |
| Builds an orthographic projection matrix for the Camera based on the Camera's near/far planes and its Viewport's settings. | |
| void | setProjectionAsOrtho2D (Real offset=-0.5f) |
| Builds an orthographic projection matrix for the Camera based on its Viewport's settings. | |
| void | setViewMatrixAsLookAt (const vec3 &eye, const vec3 ¢er, const vec3 &up) |
| void | getViewMatrixAsLookAt (vec3 &eye, vec3 &look, vec3 &up, vec3 &right) const |
| bool | project (const vec4 &in, vec4 &out) const |
| bool | unproject (const vec3 &win, vec4 &out) const |
| Unprojects a vector from window coordinates to world coordinates. | |
| bool | unproject (std::vector< vec3 > &points) const |
| Unprojects a set of points. See unproject(const vec3& win, vec4& out) for more information. | |
| Ray | computeRay (int winx, int winy) |
| Computes the ray passing through the point <winx,winy>. | |
| Frustum | computeRayFrustum (int winx, int winy) |
| Computes a frustum suitable to cull object during ray intersection detection. | |
| void | adjustView (const AABB &aabb, const vec3 &dir, const vec3 &up, Real bias=1.0f) |
| Adjusts the camera position so that the given aabb can be properly viewed. | |
Protected Attributes | |
| mat4 | mViewMatrix |
| mat4 | mInverseViewMatrix |
| mat4 | mProjectionMatrix |
| ref< Viewport > | mViewport |
| Frustum | mFrustum |
| ref< Transform > | mFollowTransform |
| Real | mFOV |
| Real | mNearPlane |
| Real | mFarPlane |
| bool | mActive |
Represents a virtual camera defining, among other things, the point of view from which scenes can be rendered.
| Camera::Camera | ( | ) |
Constructor.
| virtual const char* vl::Camera::className | ( | ) | [inline, virtual] |
Returns the name of the class.
Reimplemented from vl::Object.
| void Camera::computeNearFarOptimizedProjMatrix | ( | const Sphere & | scene_bounding_sphere ) |
The near and far clipping planes are adjusted to fit the provided scene_bounding_sphere.
Optimizing the near and far clipping planes results in an optimized usage of the z-buffer with the consequence of minimizing possible z-fighting artifacts, thus enhancing the rendering quality.
| void Camera::computeFrustumPlanes | ( | ) |
Computes the Camera's frustum planes in world space.
If nearFarClippingPlanesOptimized() == true the near and far culling planes distances are respectively set to nearPlane() and farPlane()
| void Camera::applyModelViewMatrix | ( | const mat4 & | model_matrix ) | const |
Loads the GL_MODELVIEW matrix with the Camera's view matrix multiplied by the specified model matrix.
| void Camera::applyViewMatrix | ( | ) | const |
Loads the GL_MODELVIEW matrix with the Camera's view matrix.
| void Camera::applyProjMatrix | ( | ) | const |
Loads the GL_PROJECTION matrix with the Camera's projection matrix.
| void vl::Camera::setActive | ( | bool | active ) | [inline] |
| bool vl::Camera::active | ( | ) | const [inline] |
| void vl::Camera::setFOV | ( | Real | fov ) | [inline] |
| Real vl::Camera::fov | ( | ) | const [inline] |
| Real vl::Camera::aspectRatio | ( | ) | const [inline] |
Returns the aspect ratio computed as viewport()->width()/viewport()->height().
If viewport() == NULL the function returns 0.
| void vl::Camera::setNearPlane | ( | Real | nearplane ) | [inline] |
| Real vl::Camera::nearPlane | ( | ) | const [inline] |
| void vl::Camera::setFarPlane | ( | Real | farplane ) | [inline] |
| Real vl::Camera::farPlane | ( | ) | const [inline] |
| void vl::Camera::setFrustum | ( | const Frustum & | frustum ) | [inline] |
| const Frustum& vl::Camera::frustum | ( | ) | const [inline] |
| Frustum& vl::Camera::frustum | ( | ) | [inline] |
| void vl::Camera::setViewport | ( | Viewport * | viewport ) | [inline] |
| Viewport* vl::Camera::viewport | ( | ) | [inline] |
| const Viewport* vl::Camera::viewport | ( | ) | const [inline] |
| void vl::Camera::followTransform | ( | Transform * | transform ) | [inline] |
| const Transform* vl::Camera::followedTransform | ( | ) | const [inline] |
| Transform* vl::Camera::followedTransform | ( | ) | [inline] |
| void vl::Camera::setViewMatrix | ( | const mat4 & | mat ) | [inline] |
Sets the Camera's view matrix.
| const mat4& vl::Camera::viewMatrix | ( | ) | const [inline] |
The Camera's view matrix.
This is what you would pass to OpenGL with "glMatrixMode(GL_MODELVIEW);glLoadMatrix(camera.viewMatrix().ptr());"
| void vl::Camera::setInverseViewMatrix | ( | const mat4 & | mat ) | [inline] |
The camera's reference frame matrix, the inverse of the view matrix.
| const mat4& vl::Camera::inverseViewMatrix | ( | ) | const [inline] |
The camera's reference frame matrix, the inverse of the view matrix.
| void vl::Camera::setProjectionMatrix | ( | const mat4 & | mat ) | [inline] |
The camera's projection matrix.
| const mat4& vl::Camera::projectionMatrix | ( | ) | const [inline] |
The camera's projection matrix.
| void Camera::setProjectionAsPerspective | ( | ) |
Builds a perspective projection matrix for the Camera based on the Camera's and Viewport's settings.
See also http://www.opengl.org/sdk/docs/man/xhtml/gluPerspective.xml for more information.
Builds a perspective projection matrix for the Camera based on the Camera's and Viewport's settings.
See also http://www.opengl.org/sdk/docs/man/xhtml/gluPerspective.xml for more information.
| void Camera::setProjectionAsFrustum | ( | Real | left, |
| Real | right, | ||
| Real | bottom, | ||
| Real | top, | ||
| Real | near, | ||
| Real | far | ||
| ) |
Builds a perspective projection matrix for the Camera based on the give frustum.
See also http://www.opengl.org/sdk/docs/man/xhtml/glFrustum.xml for more information.
| void Camera::setProjectionAsOrtho | ( | Real | offset = -0.5f ) |
Builds an orthographic projection matrix for the Camera based on the Camera's near/far planes and its Viewport's settings.
See also http://www.opengl.org/sdk/docs/man/xhtml/glOrtho.xml for more information. Equivalent to:
setProjectionMatrix( mat4::ortho( offset, (Real)mViewport->width() + offset, offset, (Real)mViewport->height() + offset, nearPlane(), farPlane()) );
| void Camera::setProjectionAsOrtho2D | ( | Real | offset = -0.5f ) |
Builds an orthographic projection matrix for the Camera based on its Viewport's settings.
See also http://www.opengl.org/sdk/docs/man/xhtml/glOrtho2D.xml for more information.
Equivalent to:
setProjectionMatrix( mat4::ortho( offset, viewport()->width() + offset, offset, viewport()->height() + offset, -1, +1) );
Unprojects a vector from window coordinates to world coordinates.
| win | The window coordinates point to be projected. Note that, in accordance to OpenGL conventions, the window coordinates have the Y axis pointing upwards and origin at the bottom left corner of the window. |
| out | The world coordinates of the projected point. |
w coordinate of win determines the position of the projected point along the ray passing through win. If w equals 0 then out will lay on the near clipping plane, if equals 1 then out will lay on the far clipping plane. | bool Camera::unproject | ( | std::vector< vec3 > & | points ) | const |
Unprojects a set of points. See unproject(const vec3& win, vec4& out) for more information.
| Ray Camera::computeRay | ( | int | winx, |
| int | winy | ||
| ) |
Computes the ray passing through the point <winx,winy>.
| winx | The x position of the point defining the ray |
| winy | The y position of the point defining the ray |
"opengl_y = window_height - coord_y". | Frustum Camera::computeRayFrustum | ( | int | winx, |
| int | winy | ||
| ) |
Computes a frustum suitable to cull object during ray intersection detection.
Adjusts the camera position so that the given aabb can be properly viewed.
| aabb | The AABB (in world coords) that should be visible from the newly computed camera position. |
| dir | The direction (in world coords) along which the camera should be displaced to view the given AABB. |
| up | The vector that defines the up direction (in world coords). Used to properly compute the new camera matrix. |
| bias | A bias factor used to adjust the computed camera distance from the given AABB. Values between 0 and 1 make the camera closer to the AABB center, values greater than 1 position the camera further away. |
mat4 vl::Camera::mViewMatrix [protected] |
mat4 vl::Camera::mInverseViewMatrix [protected] |
mat4 vl::Camera::mProjectionMatrix [protected] |
ref<Viewport> vl::Camera::mViewport [protected] |
Frustum vl::Camera::mFrustum [protected] |
ref<Transform> vl::Camera::mFollowTransform [protected] |
Real vl::Camera::mFOV [protected] |
Real vl::Camera::mNearPlane [protected] |
Real vl::Camera::mFarPlane [protected] |
bool vl::Camera::mActive [protected] |