Voxellancer  0.3
A game about voxels in space
 All Classes Functions Pages
camera.h
1 #pragma once
2 
3 #include <glm/glm.hpp>
4 
5 #include "geometry/transform.h"
6 
10 class Camera : protected Transform { //protected so we don't have matrix, because we want view
11 public:
12  Camera(int viewportWidth, int viewportHeight);
13  virtual ~Camera();
14 
15  /* Overwrite WorldObject functions for performance:
16  * WorldObject recalculates the matrix on every read access,
17  * Camera should recalculate on every write access, as reads are more common */
18 
19  void move(glm::vec3 dist);
20  void setPosition(glm::vec3 pos);
21 
22  void rotateX(float rot);
23  void rotateY(float rot);
24  void rotateZ(float rot);
25  void setOrientation(glm::quat quat);
26 
27  const glm::mat4& view() const;
28  const glm::mat4& viewInverted() const;
29  const glm::quat& orientation() const;
30  const glm::vec3& position() const;
31 
32  /* Projection from glow::Camera */
33 
34  float zNear() const;
35  void setZNear(float zNear);
36  float zFar() const;
37  void setZFar(float zFar);
38 
39  float fovy() const;
40  void setFovy(float fovy);
41 
42  const glm::ivec2 viewport() const;
43  void setViewport(const glm::ivec2 & viewport);
44 
45  const glm::vec3& projectionOffset() const;
46  void setProjectionOffset(const glm::vec3& projectionOffset);
47 
48  float aspectRatio() const;
49 
50  const glm::mat4& projection() const;
51 
52  const glm::mat4& viewProjection() const;
53 
54 
55 protected:
56  void viewDirty();
57  void projectionDirty();
58 
59  float m_fovy;
60  float m_aspect;
61  float m_zNear;
62  float m_zFar;
63 
64  glm::ivec2 m_viewport;
65 
66  glm::vec3 m_projectionOffset;
67 
68  glm::mat4 m_view;
69  glm::mat4 m_projection;
70  glm::mat4 m_viewProjection;
71 };
72 
Definition: camera.h:10
Definition: transform.h:9