AvogadroLibs 1.97.0
Public Member Functions | List of all members
Camera Class Reference

The Camera class provides utility functionality useful in camera's used with 3D scenes. More...

#include <avogadro/rendering/camera.h>

Public Member Functions

 Camera (const Camera &o)
 
Cameraoperator= (const Camera &o)
 
void translate (const Vector3f &translate)
 
void preTranslate (const Vector3f &translate)
 
void rotate (float angle, const Vector3f &axis)
 
void preRotate (float angle, const Vector3f &axis)
 
void scale (float scale)
 
void lookAt (const Vector3f &eye, const Vector3f &center, const Vector3f &up)
 
float distance (const Vector3f &point) const
 
Vector3f project (const Vector3f &point) const
 
Vector3f unProject (const Vector3f &point) const
 
Vector3f unProject (const Vector2f &point, const Vector3f &reference=Vector3f::Zero()) const
 
void calculatePerspective (float fieldOfView, float aspectRatio, float zNear, float zFar)
 
void calculatePerspective (float fieldOfView, float zNear, float zFar)
 
void calculateOrthographic (float left, float right, float bottom, float top, float zNear, float zFar)
 
void setViewport (int w, int h)
 
int width () const
 
int height () const
 
void setIdentity ()
 
void setProjection (const Eigen::Affine3f &transform)
 
const Eigen::Affine3f & projection () const
 
void setModelView (const Eigen::Affine3f &transform)
 
const Eigen::Affine3f & modelView () const
 
void setProjectionType (Projection proj)
 
Projection projectionType () const
 
void setOrthographicScale (float newScale)
 
float orthographicScale () const
 
void setFocus (const Eigen::Vector3f &newFocus)
 
Vector3f focus () const
 

Detailed Description

Author
Marcus D. Hanwell

Member Function Documentation

◆ translate()

void translate ( const Vector3f &  translate)

Translate the camera's model view matrix using the supplied translation vector translate.

◆ preTranslate()

void preTranslate ( const Vector3f &  translate)

Pretranslate the camera's model view matrix using the supplied translation vector translate.

◆ rotate()

void rotate ( float  angle,
const Vector3f &  axis 
)

Rotate the camera about the supplied axis by angle (degrees).

◆ preRotate()

void preRotate ( float  angle,
const Vector3f &  axis 
)

Prerotate the camera about the supplied axis by angle (degrees).

◆ scale()

void scale ( float  scale)

Modify the matrix, to give the effect of zooming in or out.

◆ lookAt()

void lookAt ( const Vector3f &  eye,
const Vector3f &  center,
const Vector3f &  up 
)

Set the model-view matrix to the "look at" transformation matrix.

Parameters
eyethe position of the eye/camera.
centerthe position to look at.
upthe vector pointing up.

◆ distance()

float distance ( const Vector3f &  point) const

Distance to supplied point point and the camera.

◆ project()

Vector3f project ( const Vector3f &  point) const

Projects a point from the scene to the window.

◆ unProject() [1/2]

Vector3f unProject ( const Vector3f &  point) const

Unprojects a point from the window to the scene.

◆ unProject() [2/2]

Vector3f unProject ( const Vector2f &  point,
const Vector3f &  reference = Vector3f::Zero() 
) const

Unprojects a point from the window to the scene, using the supplied reference point (defaults to the origin if nothing is supplied).

◆ calculatePerspective() [1/2]

void calculatePerspective ( float  fieldOfView,
float  aspectRatio,
float  zNear,
float  zFar 
)

Calculate the perspective projection matrix.

Parameters
fieldOfViewangle in degrees in the y direction.
aspectRatiois the ratio of width to height.
zNearis the distance from the viewer to the near clipping plane.
zFaris the distance from the viewer to the far clipping plane.

◆ calculatePerspective() [2/2]

void calculatePerspective ( float  fieldOfView,
float  zNear,
float  zFar 
)

Calculate the perspective projection matrix. Computes the aspect ratio from the width and height stored by the Camera object.

Parameters
fieldOfViewangle in degrees in the y direction.
zNearis the distance from the viewer to the near clipping plane.
zFaris the distance from the viewer to the far clipping plane.

◆ calculateOrthographic()

void calculateOrthographic ( float  left,
float  right,
float  bottom,
float  top,
float  zNear,
float  zFar 
)

Calculate the orthographic projection matrix.

Parameters
leftleft vertical clipping plane.
rightright vertical clipping plane.
bottombottom horizontal clipping plane.
toptop horizontal clipping plane.
zNeardistance to the near clipping plane.
zFardistance to the far clipping plane.

◆ setViewport()

void setViewport ( int  w,
int  h 
)

Set the dimensions of the viewport in pixels.

◆ width()

int width ( ) const

Get the width of the viewport in pixels.

◆ height()

int height ( ) const

Get the height of the viewport in pixels.

◆ setIdentity()

void setIdentity ( )

Set the model view matrix to the identity. This resets the model view matrix.

◆ setProjection()

void setProjection ( const Eigen::Affine3f &  transform)

Set the projection transform.

◆ projection()

const Eigen::Affine3f & projection ( ) const

Get a reference to the projection matrix.

◆ setModelView()

void setModelView ( const Eigen::Affine3f &  transform)

Set the model view transform.

◆ modelView()

const Eigen::Affine3f & modelView ( ) const

Get a reference to the model view matrix.

◆ setProjectionType()

void setProjectionType ( Projection  proj)

Set the projection type for this camera (Perspective or Orthographic).

Parameters
projThe projection type to use.

◆ projectionType()

Projection projectionType ( ) const

Get the projection type the camera is using.

Returns
The current projection type.

◆ setOrthographicScale()

void setOrthographicScale ( float  newScale)

Set the orthographic scale, this defaults to 1.0. Affects calculation of the orthographic projection matrix.

Parameters
newScaleThe factor to scale orthographic projection by.

◆ orthographicScale()

float orthographicScale ( ) const

Get the value of the orthographic scale, defaults to 1.0.

Returns
The current value of the orthographic scale.

◆ setFocus()

void setFocus ( const Eigen::Vector3f &  newFocus)

Set focused point. Navigation actions shall occur relative to it. Note that this method does not cause any change in camera matrices.

◆ focus()

Vector3f focus ( ) const

Get focused point. Navigation actions shall occur relative to it.


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