ComputerGraphik TU WIEN
Public Member Functions | Protected Attributes | Private Attributes | List of all members
Camera Class Reference

Implements the camera movement with user input. More...

#include <camera.hpp>

Inheritance diagram for Camera:
SceneObject LightCamera

Public Member Functions

 Camera (const std::string &name, Scene *scene, const glm::vec3 &eye=glm::vec3(0,-10, 5), float vAngle=-3.14f, float hAngle=3.14f, float fov=60.0f, float near=0.01f, float far=20.0f)
 Construct new camera. More...
 
 Camera (const std::string &name, Scene *scene, glm::vec3 &pos, glm::vec3 &up, glm::vec3 &eye, float fov, float near, float far)
 Construct new camera. More...
 
virtual ~Camera ()
 
void draw () const
 
bool animate (double time)
 
void update (double deltaT)
 
void setShader (Shader *)
 
bool movement ()
 
float getNearClip ()
 
float getFarClip ()
 
void initializeLookupVector ()
 
void setViewMatrix (const glm::mat4 &modelMatrix)
 
glm::mat4 getViewMatrix () const
 
glm::mat4 getProjectionMatrix () const
 
- Public Member Functions inherited from SceneObject
 SceneObject (std::shared_ptr< SceneObject > &effectParent, const glm::mat4 &modelMatrix=glm::mat4(1))
 
 SceneObject (const std::string &name, Scene *scene=0, Model *model=0, const glm::mat4 &modelMatrix=glm::mat4(1))
 
virtual ~SceneObject ()
 
ModelgetModel () const
 
ShadergetShader () const
 
glm::mat4 getModelMatrix () const
 
glm::mat4 getGlobalModelMatrix () const
 
std::string getName () const
 
std::shared_ptr< SceneObjectgetParent () const
 
void setAnimationTime (double time)
 
bool setAnimation (const Animation &anim)
 
bool delChild (size_t idx)
 
bool getChild (size_t idx, std::shared_ptr< SceneObject > &child) const
 
bool addChild (std::shared_ptr< SceneObject > &child)
 
bool remEffect (const std::string &name)
 
SceneObjectgetEffect (const std::string &name) const
 
bool addEffect (const std::string &name, std::unique_ptr< SceneObject > &effect)
 
bool doNotRender ()
 
bool getIsVolSun ()
 
virtual void reset ()
 

Protected Attributes

double cursorX
 
double cursorY
 
float fov
 
float farClip
 
float nearClip
 
glm::vec3 up
 
glm::vec3 eye
 
glm::vec3 pos
 
glm::mat4 viewMatrix
 
glm::mat4 projectionMatrix
 
- Protected Attributes inherited from SceneObject
GLuint vao
 
Scenescene
 
Modelmodel
 
Shadershader
 
glm::mat4 modelMatrix
 
std::string name
 
std::weak_ptr< SceneObjectparent
 
std::vector< std::shared_ptr< SceneObject > > childs
 
std::map< std::string, std::unique_ptr< SceneObject > > effectChilds
 
size_t animIDX
 
Animation animation
 
bool norender
 
bool isVolSun
 

Private Attributes

bool moved
 
bool initState
 

Additional Inherited Members

- Public Types inherited from SceneObject
typedef std::vector< std::pair< double, glm::mat4 > > Animation
 

Detailed Description

Implements the camera movement with user input.

Constructor & Destructor Documentation

Camera::Camera ( const std::string &  name,
Scene scene,
const glm::vec3 &  eye = glm::vec3(0, -10, 5),
float  vAngle = -3.14f,
float  hAngle = 3.14f,
float  fov = 60.0f,
float  near = 0.01f,
float  far = 20.0f 
)

Construct new camera.

The camera is a SceneObject, but it has also a view matrix. The computation of the view matrix is done from the horizontal and vertical angles of the camera. From these Spherical coordinates the Cartesian coordinates are computed, these are the direction and the right vector. The cross product of this two vector gives the up vector. Then using the glm::lookAt function, the view matrix is computed. The camera has a projection matrix. On zooming this projection matrix is recomputed using the glm::perspective function. When an object is being rendered, the view matrix of the camera is returned.

See also
http://www.opengl-tutorial.org/beginners-tutorials/tutorial-6-keyboard-and-mouse
Todo:
fix documentation
Camera::Camera ( const std::string &  name,
Scene scene,
glm::vec3 &  pos,
glm::vec3 &  up,
glm::vec3 &  eye,
float  fov,
float  near,
float  far 
)

Construct new camera.

Camera::~Camera ( )
virtual

Member Function Documentation

bool Camera::animate ( double  time)
virtual

Reimplemented from SceneObject.

void Camera::draw ( ) const
virtual

Reimplemented from SceneObject.

Reimplemented in LightCamera.

float Camera::getFarClip ( )
inline
float Camera::getNearClip ( )
inline
glm::mat4 Camera::getProjectionMatrix ( ) const
inline
glm::mat4 Camera::getViewMatrix ( ) const
inline
void Camera::initializeLookupVector ( )
bool Camera::movement ( )
void Camera::setShader ( Shader )
inlinevirtual

Reimplemented from SceneObject.

Reimplemented in LightCamera.

void Camera::setViewMatrix ( const glm::mat4 &  modelMatrix)
void Camera::update ( double  deltaT)
virtual

Reimplemented from SceneObject.

Reimplemented in LightCamera.

Member Data Documentation

double Camera::cursorX
protected
double Camera::cursorY
protected
glm::vec3 Camera::eye
protected
float Camera::farClip
protected
float Camera::fov
protected
bool Camera::initState
private
bool Camera::moved
private
float Camera::nearClip
protected
glm::vec3 Camera::pos
protected
glm::mat4 Camera::projectionMatrix
protected
glm::vec3 Camera::up
protected
glm::mat4 Camera::viewMatrix
protected

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