Visualization Library 2.0.0

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 | List of all members
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:

Public Member Functions

 Camera ()
 Constructs a perspective projecting camera with FOV = 60.0, Near Plane = 0.05, Far Plane = 10000.0. More...
 
void computeNearFarOptimizedProjMatrix (const Sphere &scene_bounding_sphere)
 The near and far clipping planes are adjusted to fit the provided scene_bounding_sphere. More...
 
void computeFrustumPlanes ()
 Computes the Camera's frustum planes in world space. More...
 
void applyModelViewMatrix (const mat4 &model_matrix) const
 Loads the GL_MODELVIEW matrix with the Camera's view matrix multiplied by the specified model matrix. More...
 
void applyViewMatrix () const
 Loads the GL_MODELVIEW matrix with the Camera's view matrix. More...
 
void applyProjMatrix () const
 Loads the GL_PROJECTION matrix with the Camera's projection matrix. More...
 
real aspectRatio () const
 Returns the aspect ratio computed as viewport()->width()/viewport()->height(). More...
 
void setFOV (real fov)
 The field of view of the camera. More...
 
real fov () const
 The field of view of the camera. More...
 
void setNearPlane (real nearplane)
 The near clipping plane. More...
 
real nearPlane () const
 The near clipping plane. More...
 
void setFarPlane (real farplane)
 The far clipping plane. More...
 
real farPlane () const
 The far clipping plane. More...
 
real left () const
 'left' parameter as passed to the last setProjectionFrustum() or setProjectionOrtho*() More...
 
void setLeft (real v)
 
real right () const
 'right' parameter as passed to the last setProjectionFrustum() or setProjectionOrtho*() More...
 
void setRight (real v)
 
real bottom () const
 'bottom' parameter as passed to the last setProjectionFrustum() or setProjectionOrtho*() More...
 
void setBottom (real v)
 
real top () const
 'top' parameter as passed to the last setProjectionFrustum() or setProjectionOrtho*() More...
 
void setTop (real v)
 
void setFrustum (const Frustum &frustum)
 The view frustum of the camera used to perform frustum culling. More...
 
const Frustumfrustum () const
 The view frustum of the camera used to perform frustum culling. More...
 
Frustumfrustum ()
 The view frustum of the camera used to perform frustum culling. More...
 
void setViewport (Viewport *viewport)
 The viewport bound to a camera. More...
 
Viewportviewport ()
 The viewport bound to a camera. More...
 
const Viewportviewport () const
 The viewport bound to a camera. More...
 
void bindTransform (Transform *transform)
 Bind the camera to a Transform. More...
 
const TransformboundTransform () const
 Returns the Transform bound to a camera. More...
 
TransformboundTransform ()
 Returns the Transform bound to a camera. More...
 
void setViewMatrix (const mat4 &mat)
 Sets the Camera's view matrix (inverse of the modeling matrix). More...
 
const mat4viewMatrix () const
 Returns the Camera's view matrix (inverse of the modeling matrix). More...
 
void setModelingMatrix (const mat4 &mat)
 Sets the Camera's modelingMatrix() (inverse of the view matrix). More...
 
const mat4modelingMatrix () const
 Returns the Camera's modelingMatrix() (inverse of the view matrix). More...
 
void setProjectionMatrix (const mat4 &mat, EProjectionMatrixType proj_type)
 The Camera's projection matrix. More...
 
const mat4projectionMatrix () const
 The Camera's projection matrix. More...
 
EProjectionMatrixType projectionMatrixType () const
 The Camera's projection matrix type. More...
 
void setProjectionPerspective ()
 Builds a perspective projection matrix for the Camera based on the Camera's and Viewport's settings. More...
 
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. More...
 
void setProjectionFrustum (real left, real right, real bottom, real top, real znear, real zfar)
 Produces a perspective projection matrix. More...
 
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. More...
 
void setProjectionOrtho ()
 Builds an orthographic projection matrix for the Camera based on the Camera's near/far planes and its Viewport's settings. More...
 
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. More...
 
void setViewMatrixLookAt (const vec3 &eye, const vec3 &at, const vec3 &up)
 Setup the modelview transform of the camera based on look-at parameters. More...
 
void getViewMatrixAsLookAt (vec3 &eye, vec3 &at, vec3 &up, vec3 &right) const
 Returns the look-at parameters of the modelview transform. More...
 
bool project (const vec4 &in_world, vec4 &out_viewp) const
 Projects a vector from world coordinates to viewport coordinates. More...
 
bool unproject (const vec3 &in_viewp, vec4 &out_world) const
 Unprojects a vector from viewport coordinates to world coordinates. More...
 
bool unproject (std::vector< vec3 > &points) const
 Unprojects a set of points. More...
 
Ray computeRay (int viewp_x, int viewp_y)
 Computes the ray passing through the point <viewp_x,viewp_y>. More...
 
Frustum computeRayFrustum (int viewp_x, int viewp_y)
 Computes a 1 pixel wide frustum suitable to cull objects during ray intersection detection. More...
 
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. More...
 
- Public Member Functions inherited from vl::Object
 Object ()
 Constructor. More...
 
 Object (const Object &other)
 Copy constructor: copies the name, ref count mutex and user data. More...
 
Objectoperator= (const Object &other)
 Copy operator: copies the object's name, ref count mutex and user data. More...
 
const std::string & objectName () const
 The name of the object, by default set to the object's class name. More...
 
void setObjectName (const char *name)
 The name of the object, by default set to the object's class name in debug builds. More...
 
void setObjectName (const std::string &name)
 The name of the object, by default set to the object's class name in debug builds. More...
 
void setRefCountMutex (IMutex *mutex)
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
IMutexrefCountMutex ()
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
const IMutexrefCountMutex () const
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
int referenceCount () const
 Returns the number of references of an object. More...
 
void incReference () const
 Increments the reference count of an object. More...
 
void decReference ()
 Decrements the reference count of an object and deletes it if both automaticDelete() is true the count reaches 0. More...
 
void setAutomaticDelete (bool autodel_on)
 If set to true the Object is deleted when its reference count reaches 0. More...
 
bool automaticDelete () const
 If set to true the Object is deleted when its reference count reaches 0. More...
 
template<class T >
T * as ()
 Casts an Object to the specified class. More...
 
template<class T >
const T * as () const
 Casts an Object to the specified class. More...
 

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
 
- Protected Attributes inherited from vl::Object
std::string mObjectName
 
IMutexmRefCountMutex
 
int mReferenceCount
 
bool mAutomaticDelete
 

Additional Inherited Members

- Protected Member Functions inherited from vl::Object
virtual ~Object ()
 

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::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(), and vl::PMT_PerspectiveProjection.

Member Function Documentation

◆ adjustView()

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

◆ applyModelViewMatrix()

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(), and viewMatrix().

Referenced by vl::Light::apply().

◆ applyProjMatrix()

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

Referenced by vl::EdgeRenderer::render().

◆ applyViewMatrix()

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(), and viewMatrix().

Referenced by vl::EdgeRenderer::renderLines(), and vl::EdgeRenderer::renderSolids().

◆ aspectRatio()

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

◆ bindTransform()

void vl::Camera::bindTransform ( Transform transform)
inline

Bind the camera to a Transform.

Definition at line 147 of file Camera.hpp.

Referenced by vlX::VLXClassWrapper_Camera::importCamera().

◆ bottom()

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 vlX::VLXClassWrapper_Camera::exportCamera(), and setProjectionOrtho().

◆ boundTransform() [1/2]

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 vlX::VLXClassWrapper_Camera::exportCamera().

◆ boundTransform() [2/2]

Transform* vl::Camera::boundTransform ( )
inline

Returns the Transform bound to a camera.

Definition at line 153 of file Camera.hpp.

◆ computeFrustumPlanes()

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 172 of file Camera.cpp.

References vl::extractPlanes(), mFrustum, vl::Frustum::planes(), projectionMatrix(), and viewMatrix().

Referenced by vl::Rendering::render().

◆ computeNearFarOptimizedProjMatrix()

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

◆ computeRay()

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

◆ computeRayFrustum()

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 349 of file Camera.cpp.

References vl::cross(), frustum(), vl::Frustum::planes(), unproject(), and vl::Vector4< T_Scalar >::xyz().

◆ farPlane()

real vl::Camera::farPlane ( ) const
inline

The far clipping plane.

Definition at line 110 of file Camera.hpp.

Referenced by Camera(), vlX::VLXClassWrapper_Camera::exportCamera(), and setProjectionPerspective().

◆ fov()

real vl::Camera::fov ( ) const
inline

The field of view of the camera.

Definition at line 96 of file Camera.hpp.

Referenced by Camera(), vlX::VLXClassWrapper_Camera::exportCamera(), and setProjectionPerspective().

◆ frustum() [1/2]

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::ActorTreeAbstract::extractVisibleActors(), vl::SceneManagerPortals::extractVisibleActors(), and vl::Rendering::render().

◆ frustum() [2/2]

Frustum& vl::Camera::frustum ( )
inline

The view frustum of the camera used to perform frustum culling.

Definition at line 135 of file Camera.hpp.

◆ getViewMatrixAsLookAt()

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 243 of file Camera.cpp.

References vl::Matrix4< T_Scalar >::getAsLookAtModeling(), and mModelingMatrix.

◆ left()

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 vlX::VLXClassWrapper_Camera::exportCamera(), and setProjectionOrtho().

◆ modelingMatrix()

const mat4& vl::Camera::modelingMatrix ( ) const
inline

◆ nearPlane()

real vl::Camera::nearPlane ( ) const
inline

The near clipping plane.

Definition at line 103 of file Camera.hpp.

Referenced by Camera(), vlX::VLXClassWrapper_Camera::exportCamera(), and setProjectionPerspective().

◆ project()

bool Camera::project ( const vec4 in_world,
vec4 out_viewp 
) const

◆ projectionMatrix()

const mat4& vl::Camera::projectionMatrix ( ) const
inline

◆ projectionMatrixType()

EProjectionMatrixType vl::Camera::projectionMatrixType ( ) const
inline

The Camera's projection matrix type.

Definition at line 178 of file Camera.hpp.

Referenced by computeNearFarOptimizedProjMatrix(), and vlX::VLXClassWrapper_Camera::exportCamera().

◆ right()

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 vlX::VLXClassWrapper_Camera::exportCamera(), and setProjectionOrtho().

◆ setBottom()

void vl::Camera::setBottom ( real  v)
inline

Definition at line 122 of file Camera.hpp.

Referenced by vlX::VLXClassWrapper_Camera::importCamera().

◆ setFarPlane()

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 vlX::VLXClassWrapper_Camera::importCamera(), setProjectionFrustum(), and setProjectionPerspective().

◆ setFOV()

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 vlX::VLXClassWrapper_Camera::importCamera(), setProjectionFrustum(), and setProjectionPerspective().

◆ setFrustum()

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.

◆ setLeft()

void vl::Camera::setLeft ( real  v)
inline

Definition at line 114 of file Camera.hpp.

Referenced by vlX::VLXClassWrapper_Camera::importCamera().

◆ setModelingMatrix()

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

◆ setNearPlane()

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 vlX::VLXClassWrapper_Camera::importCamera(), setProjectionFrustum(), and setProjectionPerspective().

◆ setProjectionFrustum()

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 181 of file Camera.cpp.

References vl::atan(), vl::Matrix4< float >::getFrustum(), vl::PMT_PerspectiveProjectionFrustum, setFarPlane(), setFOV(), setNearPlane(), and setProjectionMatrix().

◆ setProjectionMatrix()

void vl::Camera::setProjectionMatrix ( const mat4 mat,
EProjectionMatrixType  proj_type 
)
inline

◆ setProjectionOrtho() [1/3]

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

◆ setProjectionOrtho() [2/3]

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

◆ setProjectionOrtho() [3/3]

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

◆ setProjectionPerspective() [1/2]

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

◆ setProjectionPerspective() [2/2]

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 190 of file Camera.cpp.

References aspectRatio(), vl::Matrix4< float >::getPerspective(), vl::PMT_PerspectiveProjection, setFarPlane(), setFOV(), setNearPlane(), and setProjectionMatrix().

◆ setRight()

void vl::Camera::setRight ( real  v)
inline

Definition at line 118 of file Camera.hpp.

Referenced by vlX::VLXClassWrapper_Camera::importCamera().

◆ setTop()

void vl::Camera::setTop ( real  v)
inline

Definition at line 126 of file Camera.hpp.

Referenced by vlX::VLXClassWrapper_Camera::importCamera().

◆ setViewMatrix()

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(), vlX::VLXClassWrapper_Camera::importCamera(), vl::FlatManipulator::mouseMoveEvent(), and setViewMatrixLookAt().

◆ setViewMatrixLookAt()

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 237 of file Camera.cpp.

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

◆ setViewport()

void vl::Camera::setViewport ( Viewport viewport)
inline

The viewport bound to a camera.

Definition at line 138 of file Camera.hpp.

Referenced by vlX::VLXClassWrapper_Camera::importCamera().

◆ top()

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 vlX::VLXClassWrapper_Camera::exportCamera(), and setProjectionOrtho().

◆ unproject() [1/2]

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

◆ unproject() [2/2]

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

◆ viewMatrix()

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(), vlX::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().

◆ viewport() [1/2]

Viewport* vl::Camera::viewport ( )
inline

◆ viewport() [2/2]

const Viewport* vl::Camera::viewport ( ) const
inline

The viewport bound to a camera.

Definition at line 144 of file Camera.hpp.

Member Data Documentation

◆ mBottom

real vl::Camera::mBottom
protected

Definition at line 280 of file Camera.hpp.

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

◆ mBoundTransform

ref<Transform> vl::Camera::mBoundTransform
protected

Definition at line 278 of file Camera.hpp.

◆ mFarPlane

real vl::Camera::mFarPlane
protected

◆ mFOV

real vl::Camera::mFOV
protected

Definition at line 279 of file Camera.hpp.

Referenced by Camera(), and setProjectionOrtho().

◆ mFrustum

Frustum vl::Camera::mFrustum
protected

Definition at line 277 of file Camera.hpp.

Referenced by Camera(), and computeFrustumPlanes().

◆ mLeft

real vl::Camera::mLeft
protected

Definition at line 280 of file Camera.hpp.

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

◆ mModelingMatrix

mat4 vl::Camera::mModelingMatrix
protected

Definition at line 274 of file Camera.hpp.

Referenced by getViewMatrixAsLookAt().

◆ mNearPlane

real vl::Camera::mNearPlane
protected

◆ mProjectionMatrix

mat4 vl::Camera::mProjectionMatrix
protected

Definition at line 275 of file Camera.hpp.

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

◆ mProjectionType

EProjectionMatrixType vl::Camera::mProjectionType
protected

Definition at line 283 of file Camera.hpp.

Referenced by Camera().

◆ mRight

real vl::Camera::mRight
protected

Definition at line 280 of file Camera.hpp.

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

◆ mTop

real vl::Camera::mTop
protected

Definition at line 280 of file Camera.hpp.

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

◆ mViewMatrix

mat4 vl::Camera::mViewMatrix
protected

Definition at line 273 of file Camera.hpp.

Referenced by project(), and unproject().

◆ mViewport

ref<Viewport> vl::Camera::mViewport
protected

Definition at line 276 of file Camera.hpp.

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


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