Tucano  0.1
A library for rapid prototyping with modern OpenGL and GLSL
Tucano::Camera Class Reference

Defines an abstract camera with a projection and view matrices. More...

#include <camera.hpp>

Inheritance diagram for Tucano::Camera:
Tucano::Flycamera Tucano::Path Tucano::Trackball Tucano::Freecamera Tucano::DirectionalTrackball Tucano::Manipulator Tucano::RotationManipulator Tucano::TranslationManipulator

Public Member Functions

void resetViewMatrix (void)
 Reset view matrix. More...
 
void resetProjectionMatrix (void)
 Reset projection matrix. More...
 
void reset (void)
 Resets trackball to initial position and orientation. More...
 
Eigen::Vector3f getCenter (void) const
 Returns the center of the camera in world space. More...
 
void getViewMatrix (GLdouble *matrix)
 Return the modelview matrix as a GLdouble array. More...
 
void getProjectionMatrix (GLdouble *matrix)
 Return the projection matrix as a GLdouble array. More...
 
Eigen::Vector3f projectPoint (const Eigen::Vector4f &pt, Eigen::Vector4f &viewport)
 Returns screen space coordinates of a 3D point. More...
 
Eigen::Affine3f getViewMatrix (void) const
 Returns the view matrix as an Affine 3x3 matrix. More...
 
Eigen::Affine3f * viewMatrix (void)
 Returns a pointer to the view matrix as an Affine 3x3 matrix. More...
 
Eigen::Matrix4f getProjectionMatrix (void) const
 Returns the view matrix as an 4x4 matrix. More...
 
Eigen::Matrix4f * projectionMatrix (void)
 Returns a pointer to the projection matrix as an 4x4 matrix. More...
 
Eigen::Matrix3f getRotationMatrix (void) const
 Returns a 3x3 matrix containing only the rotation of the view matrix. More...
 
Eigen::Vector3f getTranslationMatrix (void) const
 Returns the translation part of the view matrix as a vector. More...
 
float getPerspectiveScale (void) const
 Returns the perspective scale. More...
 
Eigen::Vector4f getViewport (void) const
 Returns the viewport coordinates. More...
 
Eigen::Vector2i getViewportSize (void) const
 Returns the dimensions of the viewport. More...
 
float getViewportAspectRatio (void) const
 Returns the viewport aspect ratio. More...
 
void setViewport (const Eigen::Vector4f &vp)
 Sets the viewport coordinates. More...
 
void setViewport (const Eigen::Vector2i &vp)
 
void setViewport (const Eigen::Vector2f &vp)
 Sets the viewport coordinates considering that the minimum coordinates are zero. More...
 
void setProjectionMatrix (const Eigen::Matrix4f &mat)
 Sets the projection matrix from a given 4x4 matrix. More...
 
void setViewMatrix (const Eigen::Affine3f &mat)
 Sets the view matrix from a given an affine 3x3 matrix. More...
 
float getNearPlane (void) const
 Returns near plane value. More...
 
float getFarPlane (void) const
 Returns far plane value. More...
 
 ~Camera ()
 Default destructor. More...
 
float getFovy (void) const
 Returns current field of view angle in y axis. More...
 
 Camera (void)
 Default constructor. More...
 
Eigen::Matrix4f setPerspectiveMatrix (float fy, float in_aspect_ratio, float in_near_plane, float in_far_plane)
 Sets the projection matrix as a perspective matrix. More...
 
void changeFovy (float new_fovy)
 Changes the fovy and computes new perspective projection matrix. More...
 
Eigen::Matrix4f setOrthographicMatrix (float left, float right, float bottom, float top, float near_plane, float far_plane)
 Sets the projection matrix as a orthographic matrix. More...
 
void incrementFov (float inc)
 Increases the fov of the perspective matrix by a given increment. More...
 
void translate (const Eigen::Vector3f &translation)
 Translates the view matrix by a given vector. More...
 
void rotate (const Eigen::Quaternion< float > &rotation)
 Rotate the view matrix by a given quaternion. More...
 
void scale (const Eigen::Vector3f &scale_factors)
 Scales the view matrix by given factors. More...
 
void scale (float scale_factor)
 Scales the view matrix by given factor in all axis. More...
 

Static Public Member Functions

static Eigen::Matrix4f createPerspectiveMatrix (float fy, float in_aspect_ratio, float in_near_plane, float in_far_plane)
 Returns a perspective projection matrix with the given parameters. More...
 
static Eigen::Matrix4f createOrthographicMatrix (float left, float right, float bottom, float top, float near_plane, float far_plane)
 Returns an orthographic projection matrix with the given parameters. More...
 

Protected Attributes

Eigen::Matrix4f projection_matrix
 Projection, or intrinsic, matrix. More...
 
Eigen::Affine3f view_matrix
 View, or extrinsic, matrix. More...
 
Eigen::Vector4f viewport
 Viewport dimensions [minX, minY, width, height]. More...
 
Eigen::Affine3f default_view
 
float near_plane
 Near plane used for projection matrix. More...
 
float far_plane
 Far plane used for projection matrix. More...
 
float frustum_left
 Frustum left dimension. More...
 
float frustum_right
 Frustum right dimension. More...
 
float frustum_top
 Frustum top dimension. More...
 
float frustum_bottom
 Frustum bottom dimension. More...
 
float aspect_ratio
 Aspect ratio for projection matrix. More...
 
float focal_length
 Camera's Focal Length. More...
 
float fovy
 Field of view angle in y axis. More...
 
bool use_perspective
 Flag to indicate if using a perspective or othograpic projection. More...
 

Detailed Description

Defines an abstract camera with a projection and view matrices.

For a visual representation of a camera use the Shapers::CameraRep class

Constructor & Destructor Documentation

Tucano::Camera::~Camera ( )
inline

Default destructor.

Tucano::Camera::Camera ( void  )
inline

Default constructor.

Member Function Documentation

void Tucano::Camera::changeFovy ( float  new_fovy)
inline

Changes the fovy and computes new perspective projection matrix.

Parameters
new_fovyNew value for field of view.
static Eigen::Matrix4f Tucano::Camera::createOrthographicMatrix ( float  left,
float  right,
float  bottom,
float  top,
float  near_plane,
float  far_plane 
)
inlinestatic

Returns an orthographic projection matrix with the given parameters.

Parameters
leftLeft plane for orthographic view.
rightRight plane for orthographic view.
bottomBottom plane for orthographic view.
topTop lane for orthographic view.
near_planeNear plane for orthographic view.
far_planeFar plane for orthographic view.
Returns
The created orthographic matrix.
static Eigen::Matrix4f Tucano::Camera::createPerspectiveMatrix ( float  fy,
float  in_aspect_ratio,
float  in_near_plane,
float  in_far_plane 
)
inlinestatic

Returns a perspective projection matrix with the given parameters.

Parameters
fyVertical field of view angle
in_aspect_ratioRatio of width to the height of the viewport
in_near_planeNear plane
in_far_planeFar plane
Returns
The created perspective matrix.
Eigen::Vector3f Tucano::Camera::getCenter ( void  ) const
inline

Returns the center of the camera in world space.

Returns
Camera center
float Tucano::Camera::getFarPlane ( void  ) const
inline

Returns far plane value.

Returns
Far plane.
float Tucano::Camera::getFovy ( void  ) const
inline

Returns current field of view angle in y axis.

Returns
Field of view angle.
float Tucano::Camera::getNearPlane ( void  ) const
inline

Returns near plane value.

Returns
Near plane.
float Tucano::Camera::getPerspectiveScale ( void  ) const
inline

Returns the perspective scale.

Usually this is element(1,1) of the projection matrix.

Returns
The perspective scale factor
void Tucano::Camera::getProjectionMatrix ( GLdouble *  matrix)
inline

Return the projection matrix as a GLdouble array.

Similar to OpenGL old method using glGet**(GL_PROJECTION_MATRIX)

Parameters
matrixA pointer to a GLdouble of at least 16 elements to fill with projection matrix.
Eigen::Matrix4f Tucano::Camera::getProjectionMatrix ( void  ) const
inline

Returns the view matrix as an 4x4 matrix.

Returns
Projection Matrix.
Eigen::Matrix3f Tucano::Camera::getRotationMatrix ( void  ) const
inline

Returns a 3x3 matrix containing only the rotation of the view matrix.

Returns
The rotation part of the view matrix as a 3x3 matrix.
Eigen::Vector3f Tucano::Camera::getTranslationMatrix ( void  ) const
inline

Returns the translation part of the view matrix as a vector.

Returns
The translation part of the view matrix.
void Tucano::Camera::getViewMatrix ( GLdouble *  matrix)
inline

Return the modelview matrix as a GLdouble array.

Similar to OpenGL old method using glGet**(GL_MODELVIEW_MATRIX)

Parameters
matrixA pointer to a GLdouble of at least 16 elements to fill with view matrix.
Eigen::Affine3f Tucano::Camera::getViewMatrix ( void  ) const
inline

Returns the view matrix as an Affine 3x3 matrix.

Returns
View Matrix.
Eigen::Vector4f Tucano::Camera::getViewport ( void  ) const
inline

Returns the viewport coordinates.

Viewport vector is as follows [minX, minY, width, height]

Returns
Viewport coordinates.
float Tucano::Camera::getViewportAspectRatio ( void  ) const
inline

Returns the viewport aspect ratio.

Returns
Viewport aspect ratio x/y
Eigen::Vector2i Tucano::Camera::getViewportSize ( void  ) const
inline

Returns the dimensions of the viewport.

Returns
Viewport dimensions.
void Tucano::Camera::incrementFov ( float  inc)
inline

Increases the fov of the perspective matrix by a given increment.

Parameters
incGiven increment to increase fov
Eigen::Matrix4f* Tucano::Camera::projectionMatrix ( void  )
inline

Returns a pointer to the projection matrix as an 4x4 matrix.

Returns
Pointer to projection Matrix.
Eigen::Vector3f Tucano::Camera::projectPoint ( const Eigen::Vector4f &  pt,
Eigen::Vector4f &  viewport 
)
inline

Returns screen space coordinates of a 3D point.

Projects a given point to screen space using given viewport coordinates.

Parameters
ptGiven point to be projected.
viewportVector containing viewport coordinates in following order [minX, minY, maxX, maxY]
void Tucano::Camera::reset ( void  )
inline

Resets trackball to initial position and orientation.

void Tucano::Camera::resetProjectionMatrix ( void  )
inline

Reset projection matrix.

void Tucano::Camera::resetViewMatrix ( void  )
inline

Reset view matrix.

void Tucano::Camera::rotate ( const Eigen::Quaternion< float > &  rotation)
inline

Rotate the view matrix by a given quaternion.

Parameters
rotationRotation to apply to view matrix.
void Tucano::Camera::scale ( const Eigen::Vector3f &  scale_factors)
inline

Scales the view matrix by given factors.

Parameters
scale_factorsScale factors in x, y, and z axis.
void Tucano::Camera::scale ( float  scale_factor)
inline

Scales the view matrix by given factor in all axis.

Parameters
scale_factorScale factors in all axis.
Eigen::Matrix4f Tucano::Camera::setOrthographicMatrix ( float  left,
float  right,
float  bottom,
float  top,
float  near_plane,
float  far_plane 
)
inline

Sets the projection matrix as a orthographic matrix.

Creates an orthographic projection matrix with the given parameters and sets as the projection matrix.

Parameters
leftLeft plane for orthographic view.
rightRight plane for orthographic view.
bottomBottom plane for orthographic view.
topTop lane for orthographic view.
near_planeNear plane for orthographic view.
far_planeFar plane for orthographic view.
Returns
The created orthographic matrix.
Eigen::Matrix4f Tucano::Camera::setPerspectiveMatrix ( float  fy,
float  in_aspect_ratio,
float  in_near_plane,
float  in_far_plane 
)
inline

Sets the projection matrix as a perspective matrix.

Creates a perspective matrix with the given parameters and sets as the projection matrix.

Parameters
fyVertical field of view angle
in_aspect_ratioRatio of width to the height of the viewport
in_near_planeNear plane
in_far_planeFar plane
Returns
The created perspective matrix.
void Tucano::Camera::setProjectionMatrix ( const Eigen::Matrix4f &  mat)
inline

Sets the projection matrix from a given 4x4 matrix.

Parameters
matGiven 4x4 matrix to set as projection matrix.
void Tucano::Camera::setViewMatrix ( const Eigen::Affine3f &  mat)
inline

Sets the view matrix from a given an affine 3x3 matrix.

Parameters
matGiven Affine 3x3 matrix to set as view matrix.
void Tucano::Camera::setViewport ( const Eigen::Vector4f &  vp)
inline

Sets the viewport coordinates.

Parameters
vpViewport coordinates.
void Tucano::Camera::setViewport ( const Eigen::Vector2i &  vp)
inline
void Tucano::Camera::setViewport ( const Eigen::Vector2f &  vp)
inline

Sets the viewport coordinates considering that the minimum coordinates are zero.

Sets the new viewport as [0, 0, vp[0], vp[1]]

Parameters
vpViewport coordinates.
void Tucano::Camera::translate ( const Eigen::Vector3f &  translation)
inline

Translates the view matrix by a given vector.

Parameters
translationTranslation to apply to view matrix.
Eigen::Affine3f* Tucano::Camera::viewMatrix ( void  )
inline

Returns a pointer to the view matrix as an Affine 3x3 matrix.

Returns
Pointer to View Matrix.

Member Data Documentation

float Tucano::Camera::aspect_ratio
protected

Aspect ratio for projection matrix.

Eigen::Affine3f Tucano::Camera::default_view
protected
float Tucano::Camera::far_plane
protected

Far plane used for projection matrix.

float Tucano::Camera::focal_length
protected

Camera's Focal Length.

float Tucano::Camera::fovy
protected

Field of view angle in y axis.

float Tucano::Camera::frustum_bottom
protected

Frustum bottom dimension.

float Tucano::Camera::frustum_left
protected

Frustum left dimension.

float Tucano::Camera::frustum_right
protected

Frustum right dimension.

float Tucano::Camera::frustum_top
protected

Frustum top dimension.

float Tucano::Camera::near_plane
protected

Near plane used for projection matrix.

Eigen::Matrix4f Tucano::Camera::projection_matrix
protected

Projection, or intrinsic, matrix.

bool Tucano::Camera::use_perspective
protected

Flag to indicate if using a perspective or othograpic projection.

Eigen::Affine3f Tucano::Camera::view_matrix
protected

View, or extrinsic, matrix.

Eigen::Vector4f Tucano::Camera::viewport
protected

Viewport dimensions [minX, minY, width, height].


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