Cutout Vis2012
TUWienVisualisierung2(SS2012)-AdaptiveCutaways
 All Classes Namespaces Functions Pages
Camera.h
1 #ifndef _CAMERA_H_
2 #define _CAMERA_H_
3 
4 #include <glm/glm.hpp>
5 
11 class Camera
12 {
13 public:
18  Camera(const glm::vec3& position, const glm::vec3& target, const glm::vec3& up, int width, int height, float nearPlane, float farPlane, float fov);
19 
20  // setter
24  void setPerspective(int width, int height, float nearPlane, float farPlane, float fov);
28  void setDistance(float nearPlane, float farPlane);
29  void setWindowSize(int width, int height);
30  void setPosition(const glm::vec3& position);
31  void setTarget(const glm::vec3& target);
32  void setUp(const glm::vec3& up);
33  void setView(const glm::vec3& position, const glm::vec3& target, const glm::vec3& up);
34 
35  // getter
36  const glm::vec3& getPosition() const;
37  const glm::vec3& getTarget() const;
38  const glm::vec3& getUp() const;
39 
40  const glm::mat4& getView() const;
41  const glm::mat4& getInverseView() const;
42  const glm::mat4& getPerspective() const;
47  const glm::mat4& getVP() const;
48 
53  float getRatio() const;
54  float getNearPlane() const;
55  float getFarPlane() const;
60  float getFieldOfView() const;
61  int getWidth() const;
62  int getHeight() const;
63 
73  void getMouseRay(float mouseX, float mouseY, glm::vec3& rayOrigin, glm::vec3& rayDirection);
74 
78  void updateTransform();
79 private:
80  int _width, _height; // window
81  float _ratio;
82  float _nearPlane, _farPlane;
83  float _fov; // in degrees
84 
85  glm::vec3 _position;
86  glm::vec3 _target;
87  glm::vec3 _up;
88 
89  glm::mat4 _view; // look in direction Z-, Y+ is up
90  glm::mat4 _invView;
91  glm::mat4 _perspective;
92  glm::mat4 _vp;
93 
94  bool _changedView, _changedPerspective;
95 
96 };
97 
98 #endif