Cutout Vis2012
TUWienVisualisierung2(SS2012)-AdaptiveCutaways
 All Classes Namespaces Functions Pages
Public Member Functions | List of all members
Camera Class Reference

#include <Camera.h>

Public Member Functions

 Camera (const glm::vec3 &position, const glm::vec3 &target, const glm::vec3 &up, int width, int height, float nearPlane, float farPlane, float fov)
 
void setPerspective (int width, int height, float nearPlane, float farPlane, float fov)
 
void setDistance (float nearPlane, float farPlane)
 
void setWindowSize (int width, int height)
 
void setPosition (const glm::vec3 &position)
 
void setTarget (const glm::vec3 &target)
 
void setUp (const glm::vec3 &up)
 
void setView (const glm::vec3 &position, const glm::vec3 &target, const glm::vec3 &up)
 
const glm::vec3 & getPosition () const
 
const glm::vec3 & getTarget () const
 
const glm::vec3 & getUp () const
 
const glm::mat4 & getView () const
 
const glm::mat4 & getInverseView () const
 
const glm::mat4 & getPerspective () const
 
const glm::mat4 & getVP () const
 
float getRatio () const
 
float getNearPlane () const
 
float getFarPlane () const
 
float getFieldOfView () const
 
int getWidth () const
 
int getHeight () const
 
void getMouseRay (float mouseX, float mouseY, glm::vec3 &rayOrigin, glm::vec3 &rayDirection)
 
void updateTransform ()
 

Detailed Description

Perspective projection camera. Encapsulates a position, direction, view frustum and screen size. Provides corresponding view and perspective matrices. The matrices are not automatically updated after a new value has been set. updateTransform() will update them.

Constructor & Destructor Documentation

Camera::Camera ( const glm::vec3 &  position,
const glm::vec3 &  target,
const glm::vec3 &  up,
int  width,
int  height,
float  nearPlane,
float  farPlane,
float  fov 
)

Initializes position, direction, view frustum and screen size.

Parameters
fovopening angle of the camera in the vertical direction

Member Function Documentation

float Camera::getFieldOfView ( ) const

Returns the opening angle of the camera in the vertical direction

Returns
opening angle of the camera in the vertical direction
void Camera::getMouseRay ( float  mouseX,
float  mouseY,
glm::vec3 &  rayOrigin,
glm::vec3 &  rayDirection 
)

Returns the origin and direction of a ray shot from the camera position to the unprojection of the mouse position. The mouse coordinate system is thought to have (0,0) at the top-left corner of the frustum and (width,height) at the bottom-right corner.

Parameters
[in]mouseXx-coordinate of mouse position
[in]mouseYy-coordinate of mouse position
[out]rayOriginorigin of the mouse ray
[out]rayDirectiondirection of the mouse ray
float Camera::getRatio ( ) const

Returns the screen's image ratio

Returns
getWidth() / getHeight()
const glm::mat4 & Camera::getVP ( ) const

Returns the view projection matrix

Returns
the view projection matrix
void Camera::setDistance ( float  nearPlane,
float  farPlane 
)

sets near and far plane

void Camera::setPerspective ( int  width,
int  height,
float  nearPlane,
float  farPlane,
float  fov 
)
Parameters
fovopening angle of the camera in the vertical direction
void Camera::updateTransform ( )

Recalculates the view matrix, perspective matrix and their inverses if any changes have been made to their parameters.


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