scg3  0.6
scg::Camera Class Referenceabstract

Base class for all cameras (composite node, abstract). More...

#include "Camera.h"

Inheritance diagram for scg::Camera:
[legend]
Collaboration diagram for scg::Camera:
[legend]

Public Member Functions

 Camera ()
 
virtual ~Camera ()
 
virtual const glm::mat4 & getProjection ()
 
virtual const glm::mat4 & getViewTransform (RenderState *renderState)
 
virtual void updateProjection ()=0
 
const glm::vec3 & getPosition () const
 
CamerasetPosition (const glm::vec3 &position)
 
const glm::quat & getOrientation () const
 
CamerasetOrientation (const glm::quat &orientation)
 
const glm::vec3 & getViewDirection () const
 
GLfloat getCenterDist () const
 
virtual CamerasetMatrix (const glm::mat4 &matrix)
 
virtual Cameratranslate (glm::vec3 translation)
 
virtual CamerarotateRad (GLfloat angleRad, glm::vec3 axis)
 
virtual Camerarotate (GLfloat angleDeg, glm::vec3 axis)
 
virtual Camerascale (glm::vec3 scaling)
 
Cameradolly (GLfloat distance)
 
CamerarotateAzimuthRad (GLfloat angleRad)
 
CamerarotateAzimuth (GLfloat angleDeg)
 
CamerarotateElevationRad (GLfloat angleRad)
 
CamerarotateElevation (GLfloat angleDeg)
 
CamerarotatePitchRad (GLfloat angleRad)
 
CamerarotatePitch (GLfloat angleDeg)
 
CamerarotateRollRad (GLfloat angleRad)
 
CamerarotateRoll (GLfloat angleDeg)
 
CamerarotateYawRad (GLfloat angleRad)
 
CamerarotateYaw (GLfloat angleDeg)
 
bool isDrawCenter () const
 
CamerasetDrawCenter (bool isDrawCenter)
 
void accept (Traverser *traverser)
 
virtual void acceptPost (Traverser *traverser)
 
virtual void render (RenderState *renderState)
 
virtual void renderPost (RenderState *renderState)
 
- Public Member Functions inherited from scg::Transformation
 Transformation ()
 
virtual ~Transformation ()
 
const glm::mat4 & getMatrix () const
 
- Public Member Functions inherited from scg::Composite
 Composite ()
 
virtual ~Composite ()=0
 
virtual void destroy ()
 
CompositeaddChild (NodeSP child)
 
CompositeremoveChild (Node *node, bool &result)
 
CompositeremoveChild (Node *node)
 
virtual void traverse (Traverser *traverser)
 
- Public Member Functions inherited from scg::Node
 Node ()
 
virtual ~Node ()=0
 
virtual void clear ()
 
int getNCores () const
 
const std::string & getMetaInfo (const std::string &key) const
 
void setMetaInfo (const std::string &key, const std::string &value)
 
bool isVisible () const
 
void setVisible (bool isVisible=true)
 

Protected Member Functions

virtual void update_ ()
 
- Protected Member Functions inherited from scg::Node
void addSibling_ (NodeSP sibling)
 
void removeSibling_ (Node *node, bool &result)
 
void processCores_ (RenderState *renderState)
 
void postProcessCores_ (RenderState *renderState)
 

Protected Attributes

glm::mat4 projection_
 
glm::mat4 viewTransform_
 
glm::vec3 eyePt_
 
glm::vec3 centerPt_
 
GLfloat centerDist_
 
glm::vec3 viewDir_
 
glm::vec3 upDir_
 
glm::vec3 rightDir_
 
glm::quat orientation_
 
bool isDrawCenter_
 
- Protected Attributes inherited from scg::Transformation
glm::mat4 matrix_
 
- Protected Attributes inherited from scg::Composite
NodeSP leftChild_
 
- Protected Attributes inherited from scg::Node
NodeSP rightSibling_
 
Compositeparent_
 
std::vector< CoreSPcores_
 
bool isVisible_
 
std::unordered_map< std::string, std::string > metaInfo_
 

Additional Inherited Members

- Static Public Member Functions inherited from scg::Transformation
static TransformationSP create ()
 

Detailed Description

Base class for all cameras (composite node, abstract).

Camera offers transformation functions (partly inherited from Transformation) to change the position and orientation of the camera. It is possible to add further nodes, including shapes, as children of a camera, which will be transformed the same way as the camera itself.

If enabled by setDrawCenterMode(), xyz coordinate axes are drawn at the center point, i.e., the center of examination (x red, y green, z blue).

Initial parameters:

  • center point distace: 1.0
  • draw center mode: off
Examples
scg3_minimal_example.cpp, and scg3_table_scene_example.cpp.

Definition at line 51 of file Camera.h.

Constructor & Destructor Documentation

◆ Camera()

scg::Camera::Camera ( )

Constructor.

◆ ~Camera()

virtual scg::Camera::~Camera ( )
virtual

Destructor.

Member Function Documentation

◆ accept()

void scg::Camera::accept ( Traverser traverser)
virtual

Accept traverser (visitor pattern).

Reimplemented from scg::Transformation.

◆ acceptPost()

virtual void scg::Camera::acceptPost ( Traverser traverser)
virtual

Accept traverser after traversing sub-tree (visitor pattern).

Reimplemented from scg::Transformation.

◆ dolly()

Camera* scg::Camera::dolly ( GLfloat  distance)

Dolly camera in/out, leave center point fixed.

Parameters
distancepositive for dolly in/forward
Returns
this pointer for method chaining
Examples
scg3_minimal_example.cpp.

◆ getCenterDist()

GLfloat scg::Camera::getCenterDist ( ) const

Get distance to center point.

◆ getOrientation()

const glm::quat& scg::Camera::getOrientation ( ) const

Get camera orientation as quaternion.

◆ getPosition()

const glm::vec3& scg::Camera::getPosition ( ) const

Get camera position.

◆ getProjection()

virtual const glm::mat4& scg::Camera::getProjection ( )
virtual

Get projection matrix.

Reimplemented in scg::StereoCamera.

◆ getViewDirection()

const glm::vec3& scg::Camera::getViewDirection ( ) const

Get view direction.

◆ getViewTransform()

virtual const glm::mat4& scg::Camera::getViewTransform ( RenderState renderState)
virtual

Get view transformation matrix according to camera position and orientation.

Reimplemented in scg::StereoCamera.

◆ isDrawCenter()

bool scg::Camera::isDrawCenter ( ) const

Get mode for drawing coordinate axes at center point.

◆ render()

virtual void scg::Camera::render ( RenderState renderState)
virtual

Render node, i.e., update model-view matrix of RenderState, draw center point (if enabled).

Reimplemented from scg::Transformation.

Reimplemented in scg::StereoCamera.

◆ renderPost()

virtual void scg::Camera::renderPost ( RenderState renderState)
virtual

Render transformaton after traversing sub-tree, i.e., restore model-view matrix.

Reimplemented from scg::Transformation.

◆ rotate()

virtual Camera* scg::Camera::rotate ( GLfloat  angleDeg,
glm::vec3  axis 
)
inlinevirtual

Rotate camera around given axis (degrees).

Returns
this pointer for method chaining

Reimplemented from scg::Transformation.

Definition at line 135 of file Camera.h.

◆ rotateAzimuth()

Camera* scg::Camera::rotateAzimuth ( GLfloat  angleDeg)
inline

Rotate camera around center point in azimuth direction.

Parameters
angleDegrotation angle (degrees)
Returns
this pointer for method chaining

Definition at line 164 of file Camera.h.

◆ rotateAzimuthRad()

Camera* scg::Camera::rotateAzimuthRad ( GLfloat  angleRad)

Rotate camera around center point in azimuth direction.

Parameters
angleDegrotation angle (radians)
Returns
this pointer for method chaining

◆ rotateElevation()

Camera* scg::Camera::rotateElevation ( GLfloat  angleDeg)
inline

Rotate camera around center point in elevation direction.

Parameters
angleDegrotation angle (degrees)
Returns
this pointer for method chaining

Definition at line 180 of file Camera.h.

◆ rotateElevationRad()

Camera* scg::Camera::rotateElevationRad ( GLfloat  angleRad)

Rotate camera around center point in elevation direction.

Parameters
angleDegrotation angle (radians)
Returns
this pointer for method chaining

◆ rotatePitch()

Camera* scg::Camera::rotatePitch ( GLfloat  angleDeg)
inline

Rotate camera around pitch axis.

Parameters
angleDegrotation angle (degrees)
Returns
this pointer for method chaining

Definition at line 196 of file Camera.h.

◆ rotatePitchRad()

Camera* scg::Camera::rotatePitchRad ( GLfloat  angleRad)

Rotate camera around pitch axis.

Parameters
angleDegrotation angle (radians)
Returns
this pointer for method chaining

◆ rotateRad()

virtual Camera* scg::Camera::rotateRad ( GLfloat  angleRad,
glm::vec3  axis 
)
virtual

Rotate camera around given axis (radians).

Returns
this pointer for method chaining

Reimplemented from scg::Transformation.

◆ rotateRoll()

Camera* scg::Camera::rotateRoll ( GLfloat  angleDeg)
inline

Rotate camera around roll axis.

Parameters
angleDegrotation angle (degrees)
Returns
this pointer for method chaining

Definition at line 212 of file Camera.h.

◆ rotateRollRad()

Camera* scg::Camera::rotateRollRad ( GLfloat  angleRad)

Rotate camera around roll axis.

Parameters
angleDegrotation angle (radians)
Returns
this pointer for method chaining

◆ rotateYaw()

Camera* scg::Camera::rotateYaw ( GLfloat  angleDeg)
inline

Rotate camera around yaw axis.

Parameters
angleDegrotation angle (degrees)
Returns
this pointer for method chaining

Definition at line 228 of file Camera.h.

◆ rotateYawRad()

Camera* scg::Camera::rotateYawRad ( GLfloat  angleRad)

Rotate camera around yaw axis.

Parameters
angleDegrotation angle (radians)
Returns
this pointer for method chaining

◆ scale()

virtual Camera* scg::Camera::scale ( glm::vec3  scaling)
virtual

Ignore scaling (do nothing) for camera transformation.

Returns
this pointer for method chaining

Reimplemented from scg::Transformation.

◆ setDrawCenter()

Camera* scg::Camera::setDrawCenter ( bool  isDrawCenter)

Set mode for drawing coordinate axes at center point.

Returns
this pointer for method chaining

◆ setMatrix()

virtual Camera* scg::Camera::setMatrix ( const glm::mat4 &  matrix)
virtual

Set camera transformation matrix.

Returns
this pointer for method chaining

Reimplemented from scg::Transformation.

◆ setOrientation()

Camera* scg::Camera::setOrientation ( const glm::quat &  orientation)

Set camera orientation as quaternion.

Returns
this pointer for method chaining

◆ setPosition()

Camera* scg::Camera::setPosition ( const glm::vec3 &  position)

Set camera position.

Returns
this pointer for method chaining

◆ translate()

virtual Camera* scg::Camera::translate ( glm::vec3  translation)
virtual

Translate camera, move center point accordingly.

Returns
this pointer for method chaining

Reimplemented from scg::Transformation.

Examples
scg3_minimal_example.cpp.

◆ update_()

virtual void scg::Camera::update_ ( )
protectedvirtual

Update direction vectors, center point, transformation matrix, and camera.

◆ updateProjection()

virtual void scg::Camera::updateProjection ( )
pure virtual

Update projection matrix from current viewport dimensions, called by Renderer::render() (or derived class) if window has been resized.

Implemented in scg::StereoCamera, scg::OrthographicCamera, and scg::PerspectiveCamera.

Member Data Documentation

◆ centerDist_

GLfloat scg::Camera::centerDist_
protected

Definition at line 277 of file Camera.h.

◆ centerPt_

glm::vec3 scg::Camera::centerPt_
protected

Definition at line 276 of file Camera.h.

◆ eyePt_

glm::vec3 scg::Camera::eyePt_
protected

Definition at line 275 of file Camera.h.

◆ isDrawCenter_

bool scg::Camera::isDrawCenter_
protected

Definition at line 282 of file Camera.h.

◆ orientation_

glm::quat scg::Camera::orientation_
protected

Definition at line 281 of file Camera.h.

◆ projection_

glm::mat4 scg::Camera::projection_
protected

Definition at line 273 of file Camera.h.

◆ rightDir_

glm::vec3 scg::Camera::rightDir_
protected

Definition at line 280 of file Camera.h.

◆ upDir_

glm::vec3 scg::Camera::upDir_
protected

Definition at line 279 of file Camera.h.

◆ viewDir_

glm::vec3 scg::Camera::viewDir_
protected

Definition at line 278 of file Camera.h.

◆ viewTransform_

glm::mat4 scg::Camera::viewTransform_
protected

Definition at line 274 of file Camera.h.


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