Gem Illuminator
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
Public Slots | Signals | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Camera Class Reference

The Camera class provides view and perspective projection matrices. Additional the viewport of camera is stored. The view of camera has to be specified by eye, center and up or by position, viewdirection and up. It is allowed to mix both definitions, but it might lead to unexpected behaviour. The perspective projection is specified by field of view, viewport, and near and far plane. More...

#include <camera.h>

Inheritance diagram for Camera:

Public Slots

void setPosition (const QVector3D &position)
 Sets position of camera to given value. center() will be changed in order to keep viewDirection() the same. More...
 
void setViewDirection (const QVector3D &viewDirection)
 Sets viewDirection of camera to given vector. center() will be changed in order to keep eye() consistent. More...
 
void setEye (const QVector3D &eye)
 Sets eye (position) of camera to given value. center() will not be changed, so viewDirection() is set to center() - eye() More...
 
void setCenter (const QVector3D &center)
 Sets center of camera to given value. viewDirection() will be set to new center() - eye(). More...
 
void setUp (const QVector3D &up)
 Sets up-vector of camera. More...
 
void setView (const QVector3D &eye, const QVector3D &center, const QVector3D &up)
 Convenience method to specify view with one method call. More...
 
void setViewport (const QSize &viewport)
 
void setViewport (int x, int y)
 
void setFovy (float angle)
 
void setZNear (float zNear)
 
void setZFar (float zFar)
 

Signals

void viewChanged ()
 

Public Member Functions

 Camera (QObject *parent=0)
 
 Camera (const Camera &camera, QObject *parent=0)
 Creates a new Camera with matrices copied. More...
 
virtual ~Camera ()
 
const QMatrix4x4 & view () const
 
const QMatrix4x4 & viewInverted () const
 
const QMatrix4x4 & viewProjection () const
 
const QMatrix4x4 & viewProjectionInverted () const
 
const QMatrix4x4 & projection () const
 
const QMatrix4x4 & projectionInverted () const
 
const QVector3D & position () const
 
QVector3D viewDirection () const
 
const QVector3D & center () const
 
const QVector3D & eye () const
 
const QVector3D & up () const
 
const QSize & viewport () const
 
float fovy () const
 
float zNear () const
 
float zFar () const
 

Protected Member Functions

void invalidateView () const
 
void invalidateProjection () const
 
void recalculateView () const
 
void recalculateProjection () const
 
void recalculateViewProjection () const
 

Protected Attributes

QVector3D * m_eye
 
QVector3D * m_center
 
QVector3D * m_up
 
QSize * m_viewport
 
float m_zNear
 
float m_zFar
 
float m_fovy
 
QMatrix4x4 * m_view
 
QMatrix4x4 * m_viewInverted
 
QMatrix4x4 * m_projection
 
QMatrix4x4 * m_projectionInverted
 
QMatrix4x4 * m_viewProjection
 
QMatrix4x4 * m_viewProjectionInverted
 
bool m_isViewInvalid
 
bool m_isProjectionInvalid
 
bool m_isViewProjectionInvalid
 

Detailed Description

The Camera class provides view and perspective projection matrices. Additional the viewport of camera is stored. The view of camera has to be specified by eye, center and up or by position, viewdirection and up. It is allowed to mix both definitions, but it might lead to unexpected behaviour. The perspective projection is specified by field of view, viewport, and near and far plane.

Constructor & Destructor Documentation

Camera::Camera ( QObject *  parent = 0)
explicit
Camera::Camera ( const Camera camera,
QObject *  parent = 0 
)

Creates a new Camera with matrices copied.

Parameters
cameraSpecifies the camera the matrices are copied from.
parentSpecifies the parent
Camera::~Camera ( )
virtual

Member Function Documentation

const QVector3D& Camera::center ( ) const
const QVector3D& Camera::eye ( ) const
float Camera::fovy ( ) const
void Camera::invalidateProjection ( ) const
protected
void Camera::invalidateView ( ) const
protected
const QVector3D& Camera::position ( ) const
QMatrix4x4 const & Camera::projection ( ) const
QMatrix4x4 const & Camera::projectionInverted ( ) const
void Camera::recalculateProjection ( ) const
protected
void Camera::recalculateView ( ) const
protected
void Camera::recalculateViewProjection ( ) const
protected
void Camera::setCenter ( const QVector3D &  center)
slot

Sets center of camera to given value. viewDirection() will be set to new center() - eye().

Parameters
centerPosition the camera is looking to.
void Camera::setEye ( const QVector3D &  eye)
slot

Sets eye (position) of camera to given value. center() will not be changed, so viewDirection() is set to center() - eye()

Parameters
eyeCamera will be set to this position.
void Camera::setFovy ( float  angle)
slot
void Camera::setPosition ( const QVector3D &  position)
slot

Sets position of camera to given value. center() will be changed in order to keep viewDirection() the same.

Parameters
positionCamera will be set to this position.
void Camera::setUp ( const QVector3D &  up)
slot

Sets up-vector of camera.

Parameters
upNew up vector.
void Camera::setView ( const QVector3D &  eye,
const QVector3D &  center,
const QVector3D &  up 
)
slot

Convenience method to specify view with one method call.

Parameters
eyeSee setEye()
centerSee setCenter()
upSee setUp()
void Camera::setViewDirection ( const QVector3D &  viewDirection)
slot

Sets viewDirection of camera to given vector. center() will be changed in order to keep eye() consistent.

Parameters
viewDirectionDirection the camera should look.
void Camera::setViewport ( const QSize &  viewport)
slot
void Camera::setViewport ( int  x,
int  y 
)
slot
void Camera::setZFar ( float  zFar)
slot
void Camera::setZNear ( float  zNear)
slot
const QVector3D& Camera::up ( ) const
QMatrix4x4 const & Camera::view ( ) const
void Camera::viewChanged ( )
signal
QVector3D Camera::viewDirection ( ) const
QMatrix4x4 const & Camera::viewInverted ( ) const
const QSize& Camera::viewport ( ) const
QMatrix4x4 const & Camera::viewProjection ( ) const
QMatrix4x4 const & Camera::viewProjectionInverted ( ) const
float Camera::zFar ( ) const
float Camera::zNear ( ) const

Member Data Documentation

QVector3D* Camera::m_center
protected
QVector3D* Camera::m_eye
protected
float Camera::m_fovy
protected
bool Camera::m_isProjectionInvalid
mutableprotected
bool Camera::m_isViewInvalid
mutableprotected
bool Camera::m_isViewProjectionInvalid
mutableprotected
QMatrix4x4* Camera::m_projection
mutableprotected
QMatrix4x4* Camera::m_projectionInverted
mutableprotected
QVector3D* Camera::m_up
protected
QMatrix4x4* Camera::m_view
mutableprotected
QMatrix4x4* Camera::m_viewInverted
mutableprotected
QSize* Camera::m_viewport
protected
QMatrix4x4* Camera::m_viewProjection
mutableprotected
QMatrix4x4* Camera::m_viewProjectionInverted
mutableprotected
float Camera::m_zFar
protected
float Camera::m_zNear
protected

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