ComputerGraphik TU WIEN
|
Implements the camera movement with user input. More...
#include <camera.hpp>
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 () |
Model * | getModel () const |
Shader * | getShader () const |
glm::mat4 | getModelMatrix () const |
glm::mat4 | getGlobalModelMatrix () const |
std::string | getName () const |
std::shared_ptr< SceneObject > | getParent () 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) |
SceneObject * | getEffect (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 |
Scene * | scene |
Model * | model |
Shader * | shader |
glm::mat4 | modelMatrix |
std::string | name |
std::weak_ptr< SceneObject > | parent |
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 |
Implements the camera movement with user input.
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.
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.
|
virtual |
|
virtual |
Reimplemented from SceneObject.
|
virtual |
Reimplemented from SceneObject.
Reimplemented in LightCamera.
|
inline |
|
inline |
|
inline |
|
inline |
void Camera::initializeLookupVector | ( | ) |
bool Camera::movement | ( | ) |
|
inlinevirtual |
Reimplemented from SceneObject.
Reimplemented in LightCamera.
void Camera::setViewMatrix | ( | const glm::mat4 & | modelMatrix | ) |
|
virtual |
Reimplemented from SceneObject.
Reimplemented in LightCamera.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
private |
|
private |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |