Visualization Library v1.0.3

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
Public Member Functions | Protected Attributes

vl::Camera Class Reference

Represents a virtual camera defining, among other things, the point of view from which scenes can be rendered. More...

#include <Camera.hpp>

Inheritance diagram for vl::Camera:
vl::Object

List of all members.

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 Frustumfrustum () const
 The view frustum of the camera used to perform frustum culling.
Frustumfrustum ()
 The view frustum of the camera used to perform frustum culling.
void setViewport (Viewport *viewport)
 The viewport bound to a camera.
Viewportviewport ()
 The viewport bound to a camera.
const Viewportviewport () const
 The viewport bound to a camera.
void bindTransform (Transform *transform)
 Bind the camera to a Transform.
const TransformboundTransform () const
 Returns the Transform bound to a camera.
TransformboundTransform ()
 Returns the Transform bound to a camera.
void setViewMatrix (const mat4 &mat)
 Sets the Camera's view matrix (inverse of the modeling matrix).
const mat4viewMatrix () 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 mat4modelingMatrix () 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 mat4projectionMatrix () 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< ViewportmViewport
Frustum mFrustum
ref< TransformmBoundTransform
real mFOV
real mLeft
real mRight
real mBottom
real mTop
real mNearPlane
real mFarPlane
EProjectionMatrixType mProjectionType

Detailed Description

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.


Constructor & Destructor Documentation

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.


Member Function Documentation

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.

Note:
Optimizing the near and far clipping planes might slightly impact the rendering performances if the scene contains a huge number of objects.
At the moment the near and far clipping planes optimization is available only when using a projection matrix set up by setProjectionPerspective() or setProjectionOrtho*().

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.

Note:
This setting will not take effect until setProjectionPerspective() is called.

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.

Note:
This setting will not take effect until setProjectionPerspective() or setProjectionOrtho() is called.

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.

Note:
This setting will not take effect until setProjectionPerspective() or setProjectionOrtho() is called.

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]
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().

Remarks:
The modelingMatrix() bring points from camera space to world space, where the viewMatrix() brings points from world space to camera space.

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());"

Remarks:
The modelingMatrix() bring points from camera space to world space, where the viewMatrix() brings points from world space to camera space.

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().

Remarks:
The modelingMatrix() bring points from camera space to world space, where the viewMatrix() brings points from world space to camera space.

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]
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]
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().

void Camera::setProjectionPerspective ( real  fov,
real  near,
real  far 
)

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.

See also:

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.

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.

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.

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().

void Camera::setViewMatrixLookAt ( const vec3 eye,
const vec3 at,
const vec3 up 
)

Setup the modelview transform of the camera based on look-at parameters.

Parameters:
eyeThe position of the camera.
centerThe point the camera is looking at.
upThe vector defining the up direction.

Definition at line 234 of file Camera.cpp.

References vl::Matrix4< float >::getLookAt(), and setViewMatrix().

void Camera::getViewMatrixAsLookAt ( vec3 eye,
vec3 at,
vec3 up,
vec3 right 
) const

Returns the look-at parameters of the modelview transform.

Parameters:
eyeThe position of the camera.
lookThe direction the camera is looking at.
upThe vector defining the Y positive direction of the camera.
rightThe 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.

bool Camera::project ( const vec4 in_world,
vec4 out_viewp 
) const
bool Camera::unproject ( const vec3 in_viewp,
vec4 out_world 
) const

Unprojects a vector from viewport coordinates to world coordinates.

Parameters:
in_viewpThe 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_worldThe world coordinates of the projected point.
Note:
The 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>.

Parameters:
viewp_xThe x position of the point defining the ray
viewp_yThe y position of the point defining the ray
Note:
<viewp_x,viewp_y> is considered to be a point in viewport coordinate. In accordance to the OpenGL conventions the viewport coordinates have origin on the bottom left corner of the viewport, with the Y axis pointing upwards. Most GUI libraries define the the orgin at the top left corner of the window and Y axis pointing downwards. You can convert such coordinates to OpenGL ones using the folloviewp_g simple formula: "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().

void Camera::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.

Parameters:
aabbThe AABB (in world coords) that should be visible from the newly computed camera position.
dirThe direction (in world coords) along which the camera should be displaced to view the given AABB.
upThe vector that defines the up direction (in world coords). Used to properly compute the new camera matrix.
biasA 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().


Member Data Documentation

Definition at line 273 of file Camera.hpp.

Referenced by project(), and unproject().

Definition at line 274 of file Camera.hpp.

Referenced by getViewMatrixAsLookAt().

Definition at line 275 of file Camera.hpp.

Referenced by Camera(), project(), and unproject().

Definition at line 276 of file Camera.hpp.

Referenced by Camera(), project(), setProjectionOrtho(), and unproject().

Definition at line 277 of file Camera.hpp.

Referenced by Camera(), and computeFrustumPlanes().

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().

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().

Definition at line 281 of file Camera.hpp.

Referenced by Camera(), computeNearFarOptimizedProjMatrix(), and setProjectionOrtho().

Definition at line 282 of file Camera.hpp.

Referenced by Camera(), computeNearFarOptimizedProjMatrix(), and setProjectionOrtho().

Definition at line 283 of file Camera.hpp.

Referenced by Camera().


The documentation for this class was generated from the following files:

Visualization Library v1.0.3 Reference Documentation
Copyright Michele Bosi. All rights reserved.
Updated on Tue Feb 7 2017 00:55:09.
Permission is granted to use this page to write and publish articles regarding Visualization Library.