SuzanneIsland: An island of Real-time rendering effects!
Public Member Functions
Camera Class Reference

A Camera is a SceneObject that maintains a view matrix, as well as parameters defining the projection matrix, i.e. More...

#include <camera.h>

Inheritance diagram for Camera:
SceneObject

Public Member Functions

 Camera (GLFWwindow *window_, const glm::mat4 &matrix_, float fieldOfView_, float aspectRatio_, float nearPlane_, float farPlane_)
 
 Camera (GLFWwindow *window_, const glm::mat4 &matrix_)
 
virtual void update (float timeDelta, float cameraPathSpeed)
 Update the state of the Camera. More...
 
glm::mat4 getViewMat () const
 get the view matrix, i.e. More...
 
glm::mat4 getProjMat () const
 get the current projection matrix defining the view frustum calculated from the parameters stored More...
 
float getFieldOfView () const
 Get field of view of the viewing frustum. More...
 
void setFieldOfView (float fieldOfView_)
 Set field of view of the viewing frustum. More...
 
float getAspectRatio () const
 Get the aspect ratio of the viewing frustum (width/height) More...
 
void setAspectRatio (float aspectRatio_)
 Set the aspect ratio of the viewing frustum (width / height) More...
 
float getNearPlane () const
 Get distance from camera to near plane of the viewing frustum. More...
 
void setNearPlane (float nearPlane_)
 Set distance from camera to near plane of the viewing frustum. More...
 
float getFarPlane () const
 Get distance from camera to near plane of the viewing frustum. More...
 
void setFarPlane (float farPlane_)
 Set distance from camera to far plane of the viewing frustum. More...
 
void lookAt (const glm::vec3 &target)
 Rotate camera to look at a given target point The target should not be the camera location. More...
 
bool checkSphereInFrustum (const glm::vec3 &sphereCenterWorldSpace, const glm::vec3 &sphereFarthestPointWorldSpace, const glm::mat4 &viewMat)
 Determine whether a sphere with given center and farthest point in world space lies completely within the view frustum. More...
 
void toggleNavMode ()
 Toggle the camera navigation mode.
 
void clearCameraPath ()
 clears the current camera path
 
void appendPath (std::vector< std::vector< glm::vec3 > > newPath)
 appends a number of path segments to current camera path (control points of bezier curve segments). More...
 
const std::vector< std::vector< glm::vec3 > > & getPath () const
 returns the current camera path (control points of bezier curve segments). More...
 
const glm::vec3 & getTargetLookAtPos () const
 get target look at position for FOLLOW_PATH mode
 
void setTargetLookAtPos (const glm::vec3 &lookAtPos)
 set target look at position for FOLLOW_PATH mode
 
- Public Member Functions inherited from SceneObject
 SceneObject (const glm::mat4 &modelMatrix_)
 
void applyTransformation (const glm::mat4 &trans_mat, const glm::mat4 &invtrans_mat, Order mult_order)
 Apply a transformation matrix to the current matrix. More...
 
const glm::mat4 & getMatrix () const
 
void setTransform (const glm::mat4 &new_trans_mat)
 Replaces current matrix and sets its inverse. More...
 
const glm::mat4 & getInverseMatrix () const
 
glm::vec3 getLocation () const
 Returns the location of the SceneObject. More...
 
void setLocation (const glm::vec3 &location)
 Set SceneObject's location: rightmost column of the model matrix. More...
 
void rotateX (float radians, Order mult_order)
 Applies an X axis rotation operation to the current transformation. More...
 
void rotateY (float radians, Order mult_order)
 Applies a Y axis rotation operation to the current transformation. More...
 
void rotateZ (float radians, Order mult_order)
 Applies a Z axis rotation operation to the current transformation. More...
 
void rotate (float radians, Order mult_order, const glm::vec3 &rot_axis)
 Applies a rotation around a given vector (= axis) More...
 
void translate (const glm::vec3 &trans_vec, Order mult_order)
 Applies a translation operation to the current transformation. More...
 
void scale (const glm::vec3 &scaling_vec, Order mult_order)
 Applies a scale operation to the current transformation. More...
 
std::string matrixToString (const glm::mat4 &matrix)
 Get a string to visualize the given matrix. More...
 

Additional Inherited Members

- Public Types inherited from SceneObject
enum  Order { LEFT, RIGHT }
 enum specifying matrix multiplication order. More...
 

Detailed Description

A Camera is a SceneObject that maintains a view matrix, as well as parameters defining the projection matrix, i.e.

the viewing frustum, as well as functions for input handling in different camera modes.

Member Function Documentation

§ appendPath()

void Camera::appendPath ( std::vector< std::vector< glm::vec3 > >  newPath)

appends a number of path segments to current camera path (control points of bezier curve segments).

a path segment is a bezier curve determined via linear interpolation (lerping) of three control points. for parameter position [0,1] on bezier curve with control points A,B,C: lerp A,B and B,C and lerp the lerped points.

§ checkSphereInFrustum()

bool Camera::checkSphereInFrustum ( const glm::vec3 &  sphereCenterWorldSpace,
const glm::vec3 &  sphereFarthestPointWorldSpace,
const glm::mat4 &  viewMat 
)

Determine whether a sphere with given center and farthest point in world space lies completely within the view frustum.

Note that the farthest point is passed instead of the radius to apply matrices to do the checks in clip space.

Returns
whether the sphere lies completely within the view frustum
Parameters
[in]sphereCenterWorldSpacethe center of the sphere in world space
[in]sphereFarthestPointWorldSpacethe farthest point from sphere center in world space
[in]viewMatViewing matrix

§ getAspectRatio()

float Camera::getAspectRatio ( ) const

Get the aspect ratio of the viewing frustum (width/height)

Returns
the aspect ratio (width/height)

§ getFarPlane()

float Camera::getFarPlane ( ) const

Get distance from camera to near plane of the viewing frustum.

Returns
the distance from camera to near plane

§ getFieldOfView()

float Camera::getFieldOfView ( ) const

Get field of view of the viewing frustum.

Returns
the field of view angle in radians

§ getNearPlane()

float Camera::getNearPlane ( ) const

Get distance from camera to near plane of the viewing frustum.

Returns
the distance from camera to near plane

§ getPath()

const std::vector<std::vector<glm::vec3> >& Camera::getPath ( ) const
inline

returns the current camera path (control points of bezier curve segments).

a path segment is a bezier curve determined via linear interpolation of three control points. for parameter position [0,1] on bezier curve with control points A,B,C: lerp A,B and B,C and lerp the lerped points.

§ getProjMat()

glm::mat4 Camera::getProjMat ( ) const

get the current projection matrix defining the view frustum calculated from the parameters stored

Returns
the current projection matrix defining the view frustum

§ getViewMat()

glm::mat4 Camera::getViewMat ( ) const

get the view matrix, i.e.

the inverse camera model matrix in which the camera is at the origin and looking in -z direction

Returns
the view matrix

§ lookAt()

void Camera::lookAt ( const glm::vec3 &  target)

Rotate camera to look at a given target point The target should not be the camera location.

Parameters
[in]targetthe target point to look at.

§ setAspectRatio()

void Camera::setAspectRatio ( float  aspectRatio_)

Set the aspect ratio of the viewing frustum (width / height)

Parameters
[in]aspectRatio_the new aspect ratio (width/height)

§ setFarPlane()

void Camera::setFarPlane ( float  farPlane_)

Set distance from camera to far plane of the viewing frustum.

Returns
farPlane_ the new distance from camera to far plane

§ setFieldOfView()

void Camera::setFieldOfView ( float  fieldOfView_)

Set field of view of the viewing frustum.

Parameters
[in]fieldOfView_the new field of view angle in radians

§ setNearPlane()

void Camera::setNearPlane ( float  nearPlane_)

Set distance from camera to near plane of the viewing frustum.

Parameters
[in]nearPlane_the new distance from camera to near plane

§ update()

void Camera::update ( float  timeDelta,
float  cameraPathSpeed 
)
virtual

Update the state of the Camera.

Parameters
[in]timeDeltatime passed since the last frame in seconds
[in]cameraPathSpeedspeed at which camera moves along path

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