Molecule Visualizer
 All Classes Namespaces Files Functions Enumerations Enumerator Macros Groups Pages
Camera.h
Go to the documentation of this file.
1 
6 #ifndef CAMERA_H
7 #define CAMERA_H
8 
9 #include <glm/glm.hpp>
10 
15 #define M_PI 3.14159265358979323846
16 
17 class Camera
18 {
19 public:
20 
25 
30  Camera(glm::vec3 &pos);
31 
35  ~Camera(void);
36 
37  void reset();
38 
43  void buildViewMatrix(void);
44 
49  void buildProjectionMatrix(void);
50 
56  void zoom(float t);
57 
63  void rotateAzimuth(float t);
64 
70  void rotatePolar(float t);
71 
77  void moveLeft(float t);
78 
84  void moveRight(float t);
85 
91  void moveForwards(float t);
92 
98  void moveBackwards(float t);
99 
105  void moveUp(float t);
106 
112  void moveDown(float t);
113 
119  void rotateUp(float t);
120 
126  void rotateDown(float t);
127 
133  void rotateLeft(float t);
134 
140  void rotateRight(float t);
141 
150  void setOrthogonalBorders(float left, float right, float top, float bottom);
151 
156  glm::vec3 getUp(){return mUp;};
157 
162  glm::vec3 getTarget(){return mTarget;};
163 
168  bool isOrthogonal(){return mOrthogonal;};
169 
174  float getFieldOfView(){return mFieldOfView;};
175 
181  void setOrthogonal(bool orthogonal){mOrthogonal = orthogonal;};
182 
188  void setUp(glm::vec3 &up){mUp = up;};
189 
195  void setTarget(glm::vec3 &target){mTarget = target;};
196 
202  void setFieldOfView(float fieldOfView){mFieldOfView = fieldOfView;};
203 
209  void setNearPlane(float nearPlane){mNear = nearPlane;};
210 
216  void setFarPlane(float farPlane){mFar = farPlane;buildProjectionMatrix();};
217 
222  float getNearPlane() {return mNear;};
223 
228  float getFarPlane(){return mFar;};
229 
235  void setAspect(float aspect){mAspect = aspect;};
236 
241  const glm::mat4 & getViewMatrix() {return mViewMatrix;};
242 
247  const glm::mat4 & getProjectionMatrix() {return mProjectionMatrix;};
248 
249 
250 private:
251  glm::mat4 mViewMatrix;
252  glm::mat4 mProjectionMatrix;
253 
254  float mRadius;
255  float mAzimuth;
256  float mPolar;
257 
258  glm::vec3 mUp;
259  glm::vec3 mTarget;
260  glm::vec3 mPos;
261  float mFieldOfView;
262  float mAspect;
263  float mNear;
264  float mFar;
265  float mLeft;
266  float mRight;
267  float mTop;
268  float mBottom;
269  bool mOrthogonal;
270 };
271 
272 #endif /* CAMERA_H */
void moveRight(float t)
A member function to move the camera right.
Definition: Camera.cpp:126
void rotateAzimuth(float t)
A member function to rotate the camera(Azimuth).
Definition: Camera.cpp:82
void setTarget(glm::vec3 &target)
An inline member function to set the target vector of the camera.
Definition: Camera.h:195
void moveBackwards(float t)
A member function to move the camera backwards.
Definition: Camera.cpp:108
void moveForwards(float t)
A member function to move the camera forwards.
Definition: Camera.cpp:100
void buildViewMatrix(void)
A member function to build the view matrix.
Definition: Camera.cpp:51
void setFieldOfView(float fieldOfView)
An inline member function to set the field of view of the camera.
Definition: Camera.h:202
void setUp(glm::vec3 &up)
An inline member function to set the up vector of the camera.
Definition: Camera.h:188
void rotateLeft(float t)
A member function to rotate the camera left.
Definition: Camera.cpp:182
Definition: Camera.h:17
glm::vec3 getTarget()
An inline member function to get the target vector of the camera.
Definition: Camera.h:162
glm::vec3 getUp()
An inline member function to get the up vector of the camera.
Definition: Camera.h:156
void moveDown(float t)
A member function to move the camera down.
Definition: Camera.cpp:147
bool isOrthogonal()
An inline member function to check if it is orthogonal.
Definition: Camera.h:168
Camera()
Default constructor.
Definition: Camera.cpp:12
void moveUp(float t)
A member function to move the camera up.
Definition: Camera.cpp:136
void rotateDown(float t)
A member function to rotate the camera down.
Definition: Camera.cpp:170
void setAspect(float aspect)
An inline member function to set the aspect ratio of the camera.
Definition: Camera.h:235
void setOrthogonal(bool orthogonal)
An inline member function to set orthogonal.
Definition: Camera.h:181
void setNearPlane(float nearPlane)
An inline member function to set the near plane of the camera.
Definition: Camera.h:209
const glm::mat4 & getViewMatrix()
An inline member function to get the view matrix.
Definition: Camera.h:241
float getNearPlane()
An inline member function to get the near plane of the camera.
Definition: Camera.h:222
void moveLeft(float t)
A member function to move the camera left.
Definition: Camera.cpp:116
void setOrthogonalBorders(float left, float right, float top, float bottom)
A member function to set the orthogonal borders of the camera.
Definition: Camera.cpp:43
float getFieldOfView()
An inline member function to get the field of view.
Definition: Camera.h:174
void zoom(float t)
A member function to zoom.
Definition: Camera.cpp:70
float getFarPlane()
An inline member function to get the far plane of the camera.
Definition: Camera.h:228
~Camera(void)
Destructor.
Definition: Camera.cpp:17
const glm::mat4 & getProjectionMatrix()
An inline member function to get the projection matrix.
Definition: Camera.h:247
void rotateUp(float t)
A member function to rotate the camera up.
Definition: Camera.cpp:158
void setFarPlane(float farPlane)
An inline member function to set the far plane of the camera.
Definition: Camera.h:216
void rotateRight(float t)
A member function to rotate the camera right.
Definition: Camera.cpp:193
void rotatePolar(float t)
A member function to rotate the camera(Polar).
Definition: Camera.cpp:88
void buildProjectionMatrix(void)
A member function to build the projection matrix.
Definition: Camera.cpp:61