Visualization Library v1.0.3A lightweight C++ OpenGL middleware for 2D/3D graphics |
[Download] [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 | |
Camera () | |
Constructs a perspective projecting camera with FOV = 60.0, Near Plane = 0.05, Far Plane = 10000.0. | |
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. | |
real | aspectRatio () const |
Returns the aspect ratio computed as viewport()->width()/viewport()->height(). | |
void | setFOV (real fov) |
The field of view of the camera. | |
real | fov () const |
The field of view of the camera. | |
void | setNearPlane (real nearplane) |
The near clipping plane. | |
real | nearPlane () const |
The near clipping plane. | |
void | setFarPlane (real farplane) |
The far clipping plane. | |
real | farPlane () const |
The far clipping plane. | |
real | left () const |
'left' parameter as passed to the last setProjectionFrustum() or setProjectionOrtho*() | |
void | setLeft (real v) |
real | right () const |
'right' parameter as passed to the last setProjectionFrustum() or setProjectionOrtho*() | |
void | setRight (real v) |
real | bottom () const |
'bottom' parameter as passed to the last setProjectionFrustum() or setProjectionOrtho*() | |
void | setBottom (real v) |
real | top () const |
'top' parameter as passed to the last setProjectionFrustum() or setProjectionOrtho*() | |
void | setTop (real v) |
void | setFrustum (const Frustum &frustum) |
The view frustum of the camera used to perform frustum culling. | |
const Frustum & | frustum () const |
The view frustum of the camera used to perform frustum culling. | |
Frustum & | frustum () |
The view frustum of the camera used to perform frustum culling. | |
void | setViewport (Viewport *viewport) |
The viewport bound to a camera. | |
Viewport * | viewport () |
The viewport bound to a camera. | |
const Viewport * | viewport () const |
The viewport bound to a camera. | |
void | bindTransform (Transform *transform) |
Bind the camera to a Transform. | |
const Transform * | boundTransform () const |
Returns the Transform bound to a camera. | |
Transform * | boundTransform () |
Returns the Transform bound to a camera. | |
void | setViewMatrix (const mat4 &mat) |
Sets the Camera's view matrix (inverse of the modeling matrix). | |
const mat4 & | viewMatrix () const |
Returns the Camera's view matrix (inverse of the modeling matrix). | |
void | setModelingMatrix (const mat4 &mat) |
Sets the Camera's modelingMatrix() (inverse of the view matrix). | |
const mat4 & | modelingMatrix () const |
Returns the Camera's modelingMatrix() (inverse of the view matrix). | |
void | setProjectionMatrix (const mat4 &mat, EProjectionMatrixType proj_type) |
The Camera's projection matrix. | |
const mat4 & | projectionMatrix () const |
The Camera's projection matrix. | |
EProjectionMatrixType | projectionMatrixType () const |
The Camera's projection matrix type. | |
void | setProjectionPerspective () |
Builds a perspective projection matrix for the Camera based on the Camera's and Viewport's settings. | |
void | setProjectionPerspective (real fov, real near, real far) |
Builds a perspective projection matrix for the Camera based on the Camera's and Viewport's settings. | |
void | setProjectionFrustum (real left, real right, real bottom, real top, real znear, real zfar) |
Produces a perspective projection matrix. | |
void | setProjectionOrtho (real left, real right, real bottom, real top, real znear, real zfar) |
Builds an orthographic projection matrix for the Camera based on the Camera's near/far planes and its Viewport's settings. | |
void | setProjectionOrtho () |
Builds an orthographic projection matrix for the Camera based on the Camera's near/far planes and its Viewport's settings. | |
void | setProjectionOrtho (real offset) |
Builds an orthographic projection matrix for the Camera based on the Camera's near/far planes and its Viewport's settings. | |
void | setViewMatrixLookAt (const vec3 &eye, const vec3 &at, const vec3 &up) |
Setup the modelview transform of the camera based on look-at parameters. | |
void | getViewMatrixAsLookAt (vec3 &eye, vec3 &at, vec3 &up, vec3 &right) const |
Returns the look-at parameters of the modelview transform. | |
bool | project (const vec4 &in_world, vec4 &out_viewp) const |
Projects a vector from world coordinates to viewport coordinates. | |
bool | unproject (const vec3 &in_viewp, vec4 &out_world) const |
Unprojects a vector from viewport coordinates to world coordinates. | |
bool | unproject (std::vector< vec3 > &points) const |
Unprojects a set of points. | |
Ray | computeRay (int viewp_x, int viewp_y) |
Computes the ray passing through the point <viewp_x,viewp_y>. | |
Frustum | computeRayFrustum (int viewp_x, int viewp_y) |
Computes a 1 pixel wide frustum suitable to cull objects 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 | mModelingMatrix |
mat4 | mProjectionMatrix |
ref< Viewport > | mViewport |
Frustum | mFrustum |
ref< Transform > | mBoundTransform |
real | mFOV |
real | mLeft |
real | mRight |
real | mBottom |
real | mTop |
real | mNearPlane |
real | mFarPlane |
EProjectionMatrixType | mProjectionType |
Represents a virtual camera defining, among other things, the point of view from which scenes can be rendered.
Definition at line 50 of file Camera.hpp.
Camera::Camera | ( | ) |
Constructs a perspective projecting camera with FOV = 60.0, Near Plane = 0.05, Far Plane = 10000.0.
Definition at line 46 of file Camera.cpp.
References farPlane(), fov(), vl::Matrix4< float >::getPerspective(), mBottom, mFarPlane, mFOV, mFrustum, mLeft, mNearPlane, mProjectionMatrix, mProjectionType, mRight, mTop, mViewport, nearPlane(), vl::Frustum::planes(), vl::PMT_PerspectiveProjection, and VL_DEBUG_SET_OBJECT_NAME.
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.
Definition at line 100 of file Camera.cpp.
References vl::Log::bug(), vl::Sphere::center(), vl::Sphere::isNull(), vl::max(), mBottom, mFarPlane, mLeft, mNearPlane, mRight, mTop, vl::PMT_OrthographicProjection, vl::PMT_PerspectiveProjection, projectionMatrixType(), vl::Sphere::radius(), setProjectionOrtho(), setProjectionPerspective(), vl::Sphere::transformed(), viewMatrix(), and vl::Vector3< T_Scalar >::z().
Referenced by vl::Rendering::render().
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().
Definition at line 169 of file Camera.cpp.
References vl::extractPlanes(), mFrustum, vl::Frustum::planes(), projectionMatrix(), and viewMatrix().
Referenced by vl::Rendering::render().
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.
Definition at line 60 of file Camera.cpp.
References vl::Matrix4< T_Scalar >::e(), vl::Matrix4< T_Scalar >::ptr(), viewMatrix(), VL_glLoadMatrix, and VL_glMultMatrix.
Referenced by vl::Light::apply().
void Camera::applyViewMatrix | ( | ) | const |
Loads the GL_MODELVIEW matrix with the Camera's view matrix.
Definition at line 88 of file Camera.cpp.
References vl::Matrix4< T_Scalar >::e(), vl::Matrix4< T_Scalar >::ptr(), viewMatrix(), and VL_glLoadMatrix.
Referenced by vl::EdgeRenderer::renderLines(), and vl::EdgeRenderer::renderSolids().
void Camera::applyProjMatrix | ( | ) | const |
Loads the GL_PROJECTION matrix with the Camera's projection matrix.
Definition at line 81 of file Camera.cpp.
References projectionMatrix(), and VL_glLoadMatrix.
Referenced by vl::EdgeRenderer::render().
real vl::Camera::aspectRatio | ( | ) | const [inline] |
Returns the aspect ratio computed as viewport()->width()/viewport()->height().
If viewport() == NULL the function returns 0.
Definition at line 83 of file Camera.hpp.
Referenced by setProjectionPerspective().
void vl::Camera::setFOV | ( | real | fov ) | [inline] |
The field of view of the camera.
Definition at line 93 of file Camera.hpp.
Referenced by vl::VLXClassWrapper_Camera::importCamera(), setProjectionFrustum(), and setProjectionPerspective().
real vl::Camera::fov | ( | ) | const [inline] |
The field of view of the camera.
Definition at line 96 of file Camera.hpp.
Referenced by Camera(), vl::VLXClassWrapper_Camera::exportCamera(), and setProjectionPerspective().
void vl::Camera::setNearPlane | ( | real | nearplane ) | [inline] |
The near clipping plane.
Definition at line 100 of file Camera.hpp.
Referenced by vl::VLXClassWrapper_Camera::importCamera(), setProjectionFrustum(), and setProjectionPerspective().
real vl::Camera::nearPlane | ( | ) | const [inline] |
The near clipping plane.
Definition at line 103 of file Camera.hpp.
Referenced by Camera(), vl::VLXClassWrapper_Camera::exportCamera(), and setProjectionPerspective().
void vl::Camera::setFarPlane | ( | real | farplane ) | [inline] |
The far clipping plane.
Definition at line 107 of file Camera.hpp.
Referenced by vl::VLXClassWrapper_Camera::importCamera(), setProjectionFrustum(), and setProjectionPerspective().
real vl::Camera::farPlane | ( | ) | const [inline] |
The far clipping plane.
Definition at line 110 of file Camera.hpp.
Referenced by Camera(), vl::VLXClassWrapper_Camera::exportCamera(), and setProjectionPerspective().
real vl::Camera::left | ( | ) | const [inline] |
'left' parameter as passed to the last setProjectionFrustum() or setProjectionOrtho*()
Definition at line 113 of file Camera.hpp.
Referenced by vl::VLXClassWrapper_Camera::exportCamera(), and setProjectionOrtho().
void vl::Camera::setLeft | ( | real | v ) | [inline] |
Definition at line 114 of file Camera.hpp.
Referenced by vl::VLXClassWrapper_Camera::importCamera().
real vl::Camera::right | ( | ) | const [inline] |
'right' parameter as passed to the last setProjectionFrustum() or setProjectionOrtho*()
Definition at line 117 of file Camera.hpp.
Referenced by vl::VLXClassWrapper_Camera::exportCamera(), and setProjectionOrtho().
void vl::Camera::setRight | ( | real | v ) | [inline] |
Definition at line 118 of file Camera.hpp.
Referenced by vl::VLXClassWrapper_Camera::importCamera().
real vl::Camera::bottom | ( | ) | const [inline] |
'bottom' parameter as passed to the last setProjectionFrustum() or setProjectionOrtho*()
Definition at line 121 of file Camera.hpp.
Referenced by vl::VLXClassWrapper_Camera::exportCamera(), and setProjectionOrtho().
void vl::Camera::setBottom | ( | real | v ) | [inline] |
Definition at line 122 of file Camera.hpp.
Referenced by vl::VLXClassWrapper_Camera::importCamera().
real vl::Camera::top | ( | ) | const [inline] |
'top' parameter as passed to the last setProjectionFrustum() or setProjectionOrtho*()
Definition at line 125 of file Camera.hpp.
Referenced by vl::VLXClassWrapper_Camera::exportCamera(), and setProjectionOrtho().
void vl::Camera::setTop | ( | real | v ) | [inline] |
Definition at line 126 of file Camera.hpp.
Referenced by vl::VLXClassWrapper_Camera::importCamera().
void vl::Camera::setFrustum | ( | const Frustum & | frustum ) | [inline] |
The view frustum of the camera used to perform frustum culling.
Definition at line 129 of file Camera.hpp.
const Frustum& vl::Camera::frustum | ( | ) | const [inline] |
The view frustum of the camera used to perform frustum culling.
Definition at line 132 of file Camera.hpp.
Referenced by adjustView(), computeRayFrustum(), vl::SceneManagerPortals::extractVisibleActors(), vl::ActorTreeAbstract::extractVisibleActors(), and vl::Rendering::render().
Frustum& vl::Camera::frustum | ( | ) | [inline] |
The view frustum of the camera used to perform frustum culling.
Definition at line 135 of file Camera.hpp.
void vl::Camera::setViewport | ( | Viewport * | viewport ) | [inline] |
The viewport bound to a camera.
Definition at line 138 of file Camera.hpp.
Referenced by vl::VLXClassWrapper_Camera::importCamera().
Viewport* vl::Camera::viewport | ( | ) | [inline] |
The viewport bound to a camera.
Definition at line 141 of file Camera.hpp.
Referenced by vl::Text::boundingRectTransformed(), vl::TrackballManipulator::computeVector(), vl::GhostCameraManipulator::enableEvent(), vl::PixelLODEvaluator::evaluate(), vl::expandResourceDatabase(), vl::VLXClassWrapper_Camera::exportCamera(), vl::TrackballManipulator::mouseDownEvent(), vl::FlatManipulator::mouseDownEvent(), vl::FlatManipulator::mouseInViewport(), vl::TrackballManipulator::mouseMoveEvent(), vl::GhostCameraManipulator::mouseMoveEvent(), vl::Renderer::render(), vl::EdgeRenderer::render(), vl::DrawPixels::render_Implementation(), vl::Clear::render_Implementation(), vl::OcclusionCullRenderer::render_pass2(), vl::Text::renderBackground(), vl::Text::renderBorder(), vl::Text::renderText(), vl::Applet::resizeEvent(), and setProjectionOrtho().
const Viewport* vl::Camera::viewport | ( | ) | const [inline] |
The viewport bound to a camera.
Definition at line 144 of file Camera.hpp.
void vl::Camera::bindTransform | ( | Transform * | transform ) | [inline] |
Bind the camera to a Transform.
Definition at line 147 of file Camera.hpp.
Referenced by vl::VLXClassWrapper_Camera::importCamera().
const Transform* vl::Camera::boundTransform | ( | ) | const [inline] |
Returns the Transform bound to a camera.
Definition at line 150 of file Camera.hpp.
Referenced by vl::expandResourceDatabase(), and vl::VLXClassWrapper_Camera::exportCamera().
Transform* vl::Camera::boundTransform | ( | ) | [inline] |
Returns the Transform bound to a camera.
Definition at line 153 of file Camera.hpp.
void vl::Camera::setViewMatrix | ( | const mat4 & | mat ) | [inline] |
Sets the Camera's view matrix (inverse of the modeling matrix).
The modelingMatrix() is also set as the inverse of the viewMatrix().
Definition at line 157 of file Camera.hpp.
References vl::Matrix4< T_Scalar >::getInverse().
Referenced by adjustView(), vl::VLXClassWrapper_Camera::importCamera(), vl::FlatManipulator::mouseMoveEvent(), and setViewMatrixLookAt().
const mat4& vl::Camera::viewMatrix | ( | ) | const [inline] |
Returns the Camera's view matrix (inverse of the modeling matrix).
This is what you would pass to OpenGL with "glMatrixMode(GL_MODELVIEW); glLoadMatrix(camera.viewMatrix().ptr());"
Definition at line 161 of file Camera.hpp.
Referenced by adjustView(), vl::ClipPlane::apply(), applyModelViewMatrix(), applyViewMatrix(), computeFrustumPlanes(), computeNearFarOptimizedProjMatrix(), vl::PixelLODEvaluator::evaluate(), vl::VLXClassWrapper_Camera::exportCamera(), vl::FlatManipulator::mouseMoveEvent(), vl::SlicedVolume::onActorRenderStarted(), vl::EdgeUpdateCallback::onActorRenderStarted(), vl::DepthSortCallback::onActorRenderStarted(), vl::EdgeRenderer::renderLines(), vl::EdgeRenderer::renderSolids(), vl::RenderQueue::sort(), and vl::ProjViewTransfCallback::updateMatrices().
void vl::Camera::setModelingMatrix | ( | const mat4 & | mat ) | [inline] |
Sets the Camera's modelingMatrix() (inverse of the view matrix).
The view matrix is also set as the inverse of the modelingMatrix().
Definition at line 165 of file Camera.hpp.
References vl::Matrix4< T_Scalar >::getInverse().
Referenced by vl::TrackballManipulator::mouseMoveEvent(), vl::Rendering::render(), and vl::GhostCameraManipulator::updateEvent().
const mat4& vl::Camera::modelingMatrix | ( | ) | const [inline] |
Returns the Camera's modelingMatrix() (inverse of the view matrix).
Definition at line 169 of file Camera.hpp.
Referenced by adjustView(), vl::TextureMatrix::apply(), computeRay(), vl::SceneManagerPortals::computeStartingSector(), vl::Billboard::computeWorldMatrix(), vl::GhostCameraManipulator::enableEvent(), vl::DistanceLODEvaluator::evaluate(), vl::SceneManagerPortals::extractVisibleActors(), vl::TrackballManipulator::mouseDownEvent(), vl::TrackballManipulator::mouseMoveEvent(), vl::OcclusionCullRenderer::render_pass2(), vl::TrackballManipulator::trackballRotation(), vl::GhostCameraManipulator::updateEvent(), vl::SlicedVolume::updateUniforms(), and vl::RaycastVolume::updateUniforms().
void vl::Camera::setProjectionMatrix | ( | const mat4 & | mat, |
EProjectionMatrixType | proj_type | ||
) | [inline] |
The Camera's projection matrix.
Definition at line 172 of file Camera.hpp.
Referenced by vl::VLXClassWrapper_Camera::importCamera(), setProjectionFrustum(), setProjectionOrtho(), and setProjectionPerspective().
const mat4& vl::Camera::projectionMatrix | ( | ) | const [inline] |
The Camera's projection matrix.
Definition at line 175 of file Camera.hpp.
Referenced by adjustView(), applyProjMatrix(), computeFrustumPlanes(), vl::PixelLODEvaluator::evaluate(), vl::VLXClassWrapper_Camera::exportCamera(), vl::FlatManipulator::mouseDownEvent(), and vl::ProjViewTransfCallback::updateMatrices().
EProjectionMatrixType vl::Camera::projectionMatrixType | ( | ) | const [inline] |
The Camera's projection matrix type.
Definition at line 178 of file Camera.hpp.
Referenced by computeNearFarOptimizedProjMatrix(), and vl::VLXClassWrapper_Camera::exportCamera().
void Camera::setProjectionPerspective | ( | ) |
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.
Definition at line 195 of file Camera.cpp.
References aspectRatio(), farPlane(), fov(), vl::Matrix4< float >::getPerspective(), nearPlane(), vl::PMT_PerspectiveProjection, and setProjectionMatrix().
Referenced by computeNearFarOptimizedProjMatrix(), and vl::Applet::resizeEvent().
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.
Definition at line 187 of file Camera.cpp.
References aspectRatio(), vl::Matrix4< float >::getPerspective(), vl::PMT_PerspectiveProjection, setFarPlane(), setFOV(), setNearPlane(), and setProjectionMatrix().
void Camera::setProjectionFrustum | ( | real | left, |
real | right, | ||
real | bottom, | ||
real | top, | ||
real | znear, | ||
real | zfar | ||
) |
Produces a perspective projection matrix.
The <left, bottom, zfar> and <right, top, znear> parameters specify the points on the near clipping plane that are mapped to the lower-left and upper-right corners of the viewport, respectively, assuming that the eye is located at (0,0,0). The zfar parameter specifies the location of the far clipping plane. Both znear and zfar must be positive.
This function is more general that setProjectionPerspective() as it's capable of generating off-axis projections, while setProjectionPerspective() only produces symmetrical (on-axis) projections. Since setProjectionFrustum() is more general than setProjectionPerspective(), you can use it in cases where setProjectionPerspective() can't be used. Some examples include shadows projection, tiled renderings, and stereo views.
Definition at line 178 of file Camera.cpp.
References vl::atan(), vl::Matrix4< float >::getFrustum(), vl::PMT_PerspectiveProjectionFrustum, setFarPlane(), setFOV(), setNearPlane(), and setProjectionMatrix().
void Camera::setProjectionOrtho | ( | real | left, |
real | right, | ||
real | bottom, | ||
real | top, | ||
real | znear, | ||
real | zfar | ||
) |
Builds an orthographic projection matrix for the Camera based on the Camera's near/far planes and its Viewport's settings.
setProjectionMatrix( mat4::getOrtho(left, right, bottom, top, znear, zfar), PMT_OrthographicProjection );
Definition at line 210 of file Camera.cpp.
References bottom(), vl::Matrix4< float >::getOrtho(), left(), mBottom, mFarPlane, mFOV, mLeft, mNearPlane, mRight, mTop, vl::PMT_OrthographicProjection, right(), setProjectionMatrix(), and top().
void Camera::setProjectionOrtho | ( | ) |
Builds an orthographic projection matrix for the Camera based on the Camera's near/far planes and its Viewport's settings.
setProjectionMatrix( mat4::getOrtho(0, viewport()->width(), 0, viewport()->height(), nearPlane(), farPlane()), PMT_OrthographicProjection );
Definition at line 200 of file Camera.cpp.
References vl::Matrix4< float >::getOrtho(), mBottom, mFarPlane, mFOV, mLeft, mNearPlane, mRight, mTop, mViewport, vl::PMT_OrthographicProjection, and setProjectionMatrix().
Referenced by computeNearFarOptimizedProjMatrix().
void Camera::setProjectionOrtho | ( | real | offset ) |
Builds an orthographic projection matrix for the Camera based on the Camera's near/far planes and its Viewport's settings.
This function is similar to glOrtho2D() with the difference that it can optionally add a translation offset on both x and y. For example with an offset of -0.5 the center of the pixels will be exactly at integer coordinates 0, 1, 2, etc.
setProjectionMatrix( mat4::getOrtho(offset, viewport()->width() + offset, offset, viewport()->height() + offset, -1.0, +1.0), PMT_OrthographicProjection );
Definition at line 222 of file Camera.cpp.
References vl::Matrix4< float >::getOrtho(), vl::Viewport::height(), mBottom, mFarPlane, mFOV, mLeft, mNearPlane, mRight, mTop, vl::PMT_OrthographicProjection, setProjectionMatrix(), viewport(), and vl::Viewport::width().
Setup the modelview transform of the camera based on look-at parameters.
eye | The position of the camera. |
center | The point the camera is looking at. |
up | The vector defining the up direction. |
Definition at line 234 of file Camera.cpp.
References vl::Matrix4< float >::getLookAt(), and setViewMatrix().
Returns the look-at parameters of the modelview transform.
eye | The position of the camera. |
look | The direction the camera is looking at. |
up | The vector defining the Y positive direction of the camera. |
right | The vector defining the X positive direction of the camera. |
Definition at line 240 of file Camera.cpp.
References vl::Matrix4< T_Scalar >::getAsLookAtModeling(), and mModelingMatrix.
Projects a vector from world coordinates to viewport coordinates.
Definition at line 245 of file Camera.cpp.
References mProjectionMatrix, mViewMatrix, mViewport, vl::Vector4< T_Scalar >::w(), vl::Vector4< T_Scalar >::x(), vl::Vector4< T_Scalar >::y(), and vl::Vector4< T_Scalar >::z().
Referenced by vl::Text::boundingRectTransformed(), vl::DrawPixels::render_Implementation(), and vl::Text::renderText().
Unprojects a vector from viewport coordinates to world coordinates.
in_viewp | The viewport coordinates point to be projected. Note that, in accordance to OpenGL conventions, the viewport coordinates have the Y axis pointing upwards and origin at the bottom left corner of the viewport. |
out_world | The world coordinates of the projected point. |
z
coordinate of in_viewp
determines the position of the projected point along the ray passing through in_viewp
. If z
equals 0 then out_world
will lay on the near clipping plane, if z
equals 1 then out_world
will lay on the far clipping plane. Definition at line 267 of file Camera.cpp.
References mProjectionMatrix, mViewMatrix, mViewport, vl::Vector4< T_Scalar >::w(), vl::Vector3< T_Scalar >::x(), vl::Vector4< T_Scalar >::x(), vl::Vector3< T_Scalar >::y(), vl::Vector4< T_Scalar >::y(), vl::Vector3< T_Scalar >::z(), and vl::Vector4< T_Scalar >::z().
Referenced by computeRay(), and computeRayFrustum().
bool Camera::unproject | ( | std::vector< vec3 > & | points ) | const |
Unprojects a set of points.
See unproject(const vec3& in_viewp, vec4& out_world) for more information.
Definition at line 297 of file Camera.cpp.
References mProjectionMatrix, mViewMatrix, mViewport, vl::Vector4< T_Scalar >::w(), vl::Vector4< T_Scalar >::x(), vl::Vector4< T_Scalar >::y(), and vl::Vector4< T_Scalar >::z().
Ray Camera::computeRay | ( | int | viewp_x, |
int | viewp_y | ||
) |
Computes the ray passing through the point <viewp_x,viewp_y>.
viewp_x | The x position of the point defining the ray |
viewp_y | The y position of the point defining the ray |
"opengl_y = window_height - coord_y"
. Definition at line 332 of file Camera.cpp.
References vl::Matrix4< T_Scalar >::getT(), modelingMatrix(), vl::normalize(), vl::Ray::setDirection(), vl::Ray::setOrigin(), unproject(), and vl::Vector4< T_Scalar >::xyz().
Frustum Camera::computeRayFrustum | ( | int | viewp_x, |
int | viewp_y | ||
) |
Computes a 1 pixel wide frustum suitable to cull objects during ray intersection detection.
Definition at line 346 of file Camera.cpp.
References vl::cross(), frustum(), vl::Frustum::planes(), unproject(), and vl::Vector4< T_Scalar >::xyz().
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. |
Definition at line 135 of file Camera.cpp.
References vl::Log::bug(), vl::AABB::center(), vl::dot(), vl::extractPlanes(), frustum(), vl::Matrix4< float >::getLookAt(), vl::Matrix4< T_Scalar >::getT(), vl::Matrix4< T_Scalar >::getZ(), vl::AABB::isNull(), modelingMatrix(), vl::Plane::normal(), vl::Plane::origin(), vl::Frustum::plane(), vl::Frustum::planes(), projectionMatrix(), vl::Sphere::radius(), setViewMatrix(), viewMatrix(), and VL_CHECK.
Referenced by vl::TrackballManipulator::adjustView().
mat4 vl::Camera::mViewMatrix [protected] |
Definition at line 273 of file Camera.hpp.
Referenced by project(), and unproject().
mat4 vl::Camera::mModelingMatrix [protected] |
Definition at line 274 of file Camera.hpp.
Referenced by getViewMatrixAsLookAt().
mat4 vl::Camera::mProjectionMatrix [protected] |
Definition at line 275 of file Camera.hpp.
Referenced by Camera(), project(), and unproject().
ref<Viewport> vl::Camera::mViewport [protected] |
Definition at line 276 of file Camera.hpp.
Referenced by Camera(), project(), setProjectionOrtho(), and unproject().
Frustum vl::Camera::mFrustum [protected] |
Definition at line 277 of file Camera.hpp.
Referenced by Camera(), and computeFrustumPlanes().
ref<Transform> vl::Camera::mBoundTransform [protected] |
Definition at line 278 of file Camera.hpp.
real vl::Camera::mFOV [protected] |
Definition at line 279 of file Camera.hpp.
Referenced by Camera(), and setProjectionOrtho().
real vl::Camera::mLeft [protected] |
Definition at line 280 of file Camera.hpp.
Referenced by Camera(), computeNearFarOptimizedProjMatrix(), and setProjectionOrtho().
real vl::Camera::mRight [protected] |
Definition at line 280 of file Camera.hpp.
Referenced by Camera(), computeNearFarOptimizedProjMatrix(), and setProjectionOrtho().
real vl::Camera::mBottom [protected] |
Definition at line 280 of file Camera.hpp.
Referenced by Camera(), computeNearFarOptimizedProjMatrix(), and setProjectionOrtho().
real vl::Camera::mTop [protected] |
Definition at line 280 of file Camera.hpp.
Referenced by Camera(), computeNearFarOptimizedProjMatrix(), and setProjectionOrtho().
real vl::Camera::mNearPlane [protected] |
Definition at line 281 of file Camera.hpp.
Referenced by Camera(), computeNearFarOptimizedProjMatrix(), and setProjectionOrtho().
real vl::Camera::mFarPlane [protected] |
Definition at line 282 of file Camera.hpp.
Referenced by Camera(), computeNearFarOptimizedProjMatrix(), and setProjectionOrtho().
EProjectionMatrixType vl::Camera::mProjectionType [protected] |
Definition at line 283 of file Camera.hpp.
Referenced by Camera().