Terminus
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
terminus::Camera Class Reference

The Camera class manages view and projection matrices that define a view of a 3D scene. More...

#include <camera.h>

Public Member Functions

 Camera (const QVector3D &eye=QVector3D(0.0, 0.0, 1.0), const QVector3D &center=QVector3D(0.0, 0.0, 0.0), const QVector3D &up=QVector3D(0.0, 1.0, 0.0))
 
virtual ~Camera ()
 
const QVector3D & eye () const
 
void setEye (const QVector3D &eye)
 
const QVector3D & center () const
 
void setCenter (const QVector3D &center)
 
const QVector3D & up () const
 
void setUp (const QVector3D &up)
 
QVector3D normalizedLook () const
 
float zNear () const
 
void setZNear (float zNear)
 
float zFar () const
 
void setZFar (float zFar)
 
float fovy () const
 
void setFovy (float fovy)
 
const QPoint & viewport () const
 
void setViewport (const QPoint &viewport)
 
void setViewport (int width, int height)
 
float aspectRatio () const
 
const QMatrix4x4 & view () const
 
const QMatrix4x4 & projection () const
 
const QMatrix4x4 & viewProjection () const
 
const QMatrix4x4 & viewInverted () const
 
const QMatrix4x4 & projectionInverted () const
 
const QMatrix4x4 & viewProjectionInverted () const
 
const QMatrix3x3 & normal () const
 
void setMatrices (Program &program, const QMatrix4x4 &model) const
 sets the view and projection as well as the given model matrix as uniforms on the given shader program More...
 
void bindTo (AbstractGraphicsObject *object)
 bind camera to track an AbstractGraphicsObject More...
 
void unbind ()
 release the camera from the object it is currently bound to More...
 
void unbound (AbstractGraphicsObject *object)
 is called if an object releases this camera More...
 
bool isBound () const
 
void moveEvent (QVector3D movement)
 called if the GUI requests the camera to be moved More...
 
void rotateEvent (QVector2D rotation)
 called if the GUI requests the camera to be rotated More...
 

Protected Member Functions

void invalidateMatrices () const
 

Protected Attributes

QVector3D m_eye
 
QVector3D m_center
 
QVector3D m_up
 
float m_fovy
 
float m_aspect
 
float m_zNear
 
float m_zFar
 
QPoint m_viewport
 
QMatrix4x4 m_view
 
QMatrix4x4 m_viewInverted
 
QMatrix4x4 m_projection
 
QMatrix4x4 m_projectionInverted
 
QMatrix4x4 m_viewProjection
 
QMatrix4x4 m_viewProjectionInverted
 
QMatrix3x3 m_normal
 
bool m_viewChanged
 
bool m_viewInvertedChanged
 
bool m_projectionChanged
 
bool m_projectionInvertedChanged
 
bool m_viewProjectionChanged
 
bool m_viewProjectionInvertedChanged
 
bool m_normalChanged
 
AbstractGraphicsObjectm_associatedObject
 object that this camera is bound to in order to track it More...
 

Detailed Description

The Camera class manages view and projection matrices that define a view of a 3D scene.

It also contains a mechanism that allows it to be bound to AbstractGraphicsObjects in order to track their movement and implements a simple navigation mechanism that is active if it is not bound.

See also
AbstractGraphicsObject

Constructor & Destructor Documentation

terminus::Camera::Camera ( const QVector3D &  eye = QVector3D(0.0, 0.0, 1.0),
const QVector3D &  center = QVector3D(0.0, 0.0, 0.0),
const QVector3D &  up = QVector3D(0.0, 1.0, 0.0) 
)
terminus::Camera::~Camera ( )
virtual

Member Function Documentation

float terminus::Camera::aspectRatio ( ) const
void terminus::Camera::bindTo ( AbstractGraphicsObject object)

bind camera to track an AbstractGraphicsObject

Parameters
objectpassing a nullptr releases the camera
const QVector3D & terminus::Camera::center ( ) const
const QVector3D & terminus::Camera::eye ( ) const
float terminus::Camera::fovy ( ) const
void terminus::Camera::invalidateMatrices ( ) const
protected
bool terminus::Camera::isBound ( ) const
Returns
true if this camera is currently bound to track an AbstractGraphicsObject
void terminus::Camera::moveEvent ( QVector3D  movement)

called if the GUI requests the camera to be moved

Parameters
movementIf this camera is bound to an object, this object's moveEvent() method will be called. Otherwise the camera is moved according to a simple navigation mechanism.
const QMatrix3x3 & terminus::Camera::normal ( ) const
QVector3D terminus::Camera::normalizedLook ( ) const
const QMatrix4x4 & terminus::Camera::projection ( ) const
const QMatrix4x4 & terminus::Camera::projectionInverted ( ) const
void terminus::Camera::rotateEvent ( QVector2D  rotation)

called if the GUI requests the camera to be rotated

Parameters
rotationIf this camera is bound to an object, this object's rotateEvent() method will be called. Otherwise the camera is rotated according to a simple navigation mechanism.
void terminus::Camera::setCenter ( const QVector3D &  center)
void terminus::Camera::setEye ( const QVector3D &  eye)
void terminus::Camera::setFovy ( float  fovy)
void terminus::Camera::setMatrices ( Program program,
const QMatrix4x4 &  model 
) const

sets the view and projection as well as the given model matrix as uniforms on the given shader program

Parameters
program
model
void terminus::Camera::setUp ( const QVector3D &  up)
void terminus::Camera::setViewport ( const QPoint &  viewport)
void terminus::Camera::setViewport ( int  width,
int  height 
)
void terminus::Camera::setZFar ( float  zFar)
void terminus::Camera::setZNear ( float  zNear)
void terminus::Camera::unbind ( )

release the camera from the object it is currently bound to

void terminus::Camera::unbound ( AbstractGraphicsObject object)

is called if an object releases this camera

Parameters
object
const QVector3D & terminus::Camera::up ( ) const
const QMatrix4x4 & terminus::Camera::view ( ) const
const QMatrix4x4 & terminus::Camera::viewInverted ( ) const
const QPoint & terminus::Camera::viewport ( ) const
const QMatrix4x4 & terminus::Camera::viewProjection ( ) const
const QMatrix4x4 & terminus::Camera::viewProjectionInverted ( ) const
float terminus::Camera::zFar ( ) const
float terminus::Camera::zNear ( ) const

Member Data Documentation

float terminus::Camera::m_aspect
protected
AbstractGraphicsObject* terminus::Camera::m_associatedObject
protected

object that this camera is bound to in order to track it

QVector3D terminus::Camera::m_center
protected
QVector3D terminus::Camera::m_eye
protected
float terminus::Camera::m_fovy
protected
QMatrix3x3 terminus::Camera::m_normal
mutableprotected
bool terminus::Camera::m_normalChanged
mutableprotected
QMatrix4x4 terminus::Camera::m_projection
mutableprotected
bool terminus::Camera::m_projectionChanged
mutableprotected
QMatrix4x4 terminus::Camera::m_projectionInverted
mutableprotected
bool terminus::Camera::m_projectionInvertedChanged
mutableprotected
QVector3D terminus::Camera::m_up
protected
QMatrix4x4 terminus::Camera::m_view
mutableprotected
bool terminus::Camera::m_viewChanged
mutableprotected
QMatrix4x4 terminus::Camera::m_viewInverted
mutableprotected
bool terminus::Camera::m_viewInvertedChanged
mutableprotected
QPoint terminus::Camera::m_viewport
protected
QMatrix4x4 terminus::Camera::m_viewProjection
mutableprotected
bool terminus::Camera::m_viewProjectionChanged
mutableprotected
QMatrix4x4 terminus::Camera::m_viewProjectionInverted
mutableprotected
bool terminus::Camera::m_viewProjectionInvertedChanged
mutableprotected
float terminus::Camera::m_zFar
protected
float terminus::Camera::m_zNear
protected

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