Class Avogadro::Rendering::Camera#

class Avogadro::Rendering::Camera#

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

Author

Marcus D. Hanwell

Public Functions

Camera()#
Camera(const Camera &o)#
Camera &operator=(const Camera &o)#
~Camera()#
void translate(const Vector3f &translate)#

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

void preTranslate(const Vector3f &translate)#

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

void rotate(float angle, const Vector3f &axis)#

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

void preRotate(float angle, const Vector3f &axis)#

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

void scale(float scale)#

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

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

Set the model-view matrix to the “look at” transformation matrix.

Parameters
  • eye – the position of the eye/camera.

  • center – the position to look at.

  • up – the vector pointing up.

float distance(const Vector3f &point) const#

Distance to supplied point point and the camera.

Vector3f project(const Vector3f &point) const#

Projects a point from the scene to the window.

Vector3f unProject(const Vector3f &point) const#

Unprojects a point from the window to the scene.

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

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

Calculate the perspective projection matrix.

Parameters
  • fieldOfView – angle in degrees in the y direction.

  • aspectRatio – is the ratio of width to height.

  • zNear – is the distance from the viewer to the near clipping plane.

  • zFar – is the distance from the viewer to the far clipping plane.

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
  • fieldOfView – angle in degrees in the y direction.

  • zNear – is the distance from the viewer to the near clipping plane.

  • zFar – is the distance from the viewer to the far clipping plane.

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

Calculate the orthographic projection matrix.

Parameters
  • left – left vertical clipping plane.

  • right – right vertical clipping plane.

  • bottom – bottom horizontal clipping plane.

  • top – top horizontal clipping plane.

  • zNear – distance to the near clipping plane.

  • zFar – distance to the far clipping plane.

void setViewport(int w, int h)#

Set the dimensions of the viewport in pixels.

inline int width() const#

Get the width of the viewport in pixels.

inline int height() const#

Get the height of the viewport in pixels.

inline void setIdentity()#

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

void setProjection(const Eigen::Affine3f &transform)#

Set the projection transform.

inline const Eigen::Affine3f &projection() const#

Get a reference to the projection matrix.

void setModelView(const Eigen::Affine3f &transform)#

Set the model view transform.

inline const Eigen::Affine3f &modelView() const#

Get a reference to the model view matrix.

inline void setProjectionType(Projection proj)#

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

Parameters

proj – The projection type to use.

inline Projection projectionType() const#

Get the projection type the camera is using.

Returns

The current projection type.

inline void setOrthographicScale(float newScale)#

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

Parameters

newScale – The factor to scale orthographic projection by.

inline float orthographicScale() const#

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

Returns

The current value of the orthographic scale.

inline 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.

inline Vector3f focus() const#

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