VisualizeVideo
 All Classes Functions Pages
Camera.h
1 #pragma once
2 
3 #include <glm/glm.hpp>
4 #include <glm/gtx/quaternion.hpp>
5 
6 #include "Program.h"
8 
13 class Camera
14 {
15 public:
22  Camera(const glm::vec3 &cameraPosition, int width, int height);
23  ~Camera(void);
24 
26  void updateCameraPosition(const glm::vec3 &cameraPosition);
28  void initMouse(int x, int y);
30  void updateMouse(int x, int y, float dt);
31 
32  std::vector<glm::vec4> getPlanes() const;
33 
35  void bindMatrices(Program &shaderProgram);
37  glm::vec3 getCameraDirection() const;
39  glm::vec3 getNormalizedXZPlaneDirection() const;
40 
42  glm::mat4 getViewMatrix() const { return _viewMatrix; }
44  glm::mat4 getInverseViewMatrix() const { return _inverseViewMatrix; }
46  glm::mat4 getProjectionMatrix() const { return _projectionMatrix; }
48  glm::vec3 getCameraLocation() const;
50  void setViewMatrix(const glm::mat4 &viewMat);
52  void setProjectionMatrix(const glm::mat4 &projMat);
56  bool canClipPoint(const glm::vec4 &point, float threshold = 0.0f) const;
58  bool canClipBox(const glm::vec3 &mi, const glm::vec3 &ma) const;
59 
60  void setCulling(bool c) { _doCulling = c; }
61 
62  bool isShadow() const { return _isShadow; }
63  void setShadow(bool f) { _isShadow = f; }
64 
65  glm::quat getRotation() const { return _cameraRotation; }
66 private:
67  glm::mat4 computeRotation(int x, int y, float dt);
68 
69  glm::vec3 _cameraPosition;
70  glm::quat _cameraRotation;
71  int _width, _height;
72  int _mouseStartX, _mouseStartY;
73 
74  float _accumHeight;
75  glm::mat4 _viewMatrix;
76  glm::mat4 _inverseViewMatrix;
77  glm::mat4 _projectionMatrix;
78 
80  glm::vec4 _top;
81  glm::vec4 _bottom;
82  glm::vec4 _left;
83  glm::vec4 _right;
84  glm::vec4 _near;
85  glm::vec4 _far;
86 
88  std::vector<glm::vec4*> _faces;
89 
91  bool _doCulling;
92 
94  bool _isShadow;
95 
96 };