ComputerGraphik TU WIEN
camera.hpp
Go to the documentation of this file.
1 #ifndef CAMERA_HPP
2 #define CAMERA_HPP
3 
4 #include <glm/vec3.hpp>
5 #include <glm/mat4x4.hpp>
6 #include "sceneObject.hpp"
7 
8 struct GLFWwindow;
9 
11 class Camera : public SceneObject {
12 public:
14 
27  Camera(const std::string& name,
28  Scene* scene,
29  const glm::vec3& eye = glm::vec3(0, -10, 5),
30  float vAngle = -3.14f,
31  float hAngle = 3.14f,
32  float fov = 60.0f,
33  float near = 0.01f,
34  float far = 20.0f);
35 
37 
40  Camera(const std::string& name,
41  Scene* scene,
42  glm::vec3& pos,
43  glm::vec3& up,
44  glm::vec3& eye,
45  float fov,
46  float near,
47  float far);
48 
49  virtual ~Camera();
50 
51  void draw() const;
52  bool animate(double time);
53  void update(double deltaT);
54  void setShader(Shader*) {}
55 
56  bool movement();
57 
58  float getNearClip() { return nearClip; }
59  float getFarClip() { return farClip; }
60 
62  void setViewMatrix(const glm::mat4& modelMatrix);
63  glm::mat4 getViewMatrix() const { return viewMatrix; }
64  glm::mat4 getProjectionMatrix() const { return projectionMatrix; }
65 
66 protected:
67  double cursorX;
68  double cursorY;
69 
70  float fov;
71  float farClip;
72  float nearClip;
73  glm::vec3 up;
74  glm::vec3 eye;
75  glm::vec3 pos;
76  glm::mat4 viewMatrix;
77  glm::mat4 projectionMatrix;
78 
79 private:
80  bool moved;
81  bool initState;
82 };
83 
84 #endif //CAMERA_HPP
double cursorX
Definition: camera.hpp:67
void initializeLookupVector()
Definition: camera.cpp:66
bool animate(double time)
Definition: camera.cpp:165
bool movement()
Definition: camera.cpp:82
bool moved
Definition: camera.hpp:80
void draw() const
Definition: camera.cpp:77
glm::vec3 up
Definition: camera.hpp:73
glm::vec3 eye
Definition: camera.hpp:74
Implements the camera movement with user input.
Definition: camera.hpp:11
bool initState
Definition: camera.hpp:81
void setViewMatrix(const glm::mat4 &modelMatrix)
Definition: camera.cpp:59
glm::mat4 projectionMatrix
Definition: camera.hpp:77
double cursorY
Definition: camera.hpp:68
void setShader(Shader *)
Definition: camera.hpp:54
glm::vec3 pos
Definition: camera.hpp:75
Encapsulates the Rendering Engine, holds a complete scene and it's assets.
Definition: scene.hpp:71
Scene * scene
Definition: sceneObject.hpp:68
float farClip
Definition: camera.hpp:71
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.
Definition: camera.cpp:10
glm::mat4 viewMatrix
Definition: camera.hpp:76
std::string name
Definition: sceneObject.hpp:73
glm::mat4 modelMatrix
Definition: sceneObject.hpp:71
glm::mat4 getViewMatrix() const
Definition: camera.hpp:63
Encapsulates a shader program.
Definition: shader.hpp:9
glm::mat4 getProjectionMatrix() const
Definition: camera.hpp:64
The base class of the objects which are rendered.
Definition: sceneObject.hpp:30
virtual ~Camera()
Definition: camera.cpp:72
float fov
Definition: camera.hpp:70
float getNearClip()
Definition: camera.hpp:58
void update(double deltaT)
Definition: camera.cpp:86
float nearClip
Definition: camera.hpp:72
float getFarClip()
Definition: camera.hpp:59