Lugdunum  0.1.0
Camera.hpp
Go to the documentation of this file.
1 #pragma once
2 
4 #include <lug/Graphics/Node.hpp>
8 #include <lug/Math/Matrix.hpp>
9 
10 namespace lug {
11 namespace Graphics {
12 
13 namespace Scene {
14 class Scene;
15 class Node;
16 } // Scene
17 
18 namespace Render {
19 
20 class View;
21 
22 namespace Camera {
23 
30 class LUG_GRAPHICS_API Camera : public Resource, public DirtyObject {
31 public:
32  Camera(const Camera&) = delete;
33  Camera(Camera&&) = delete;
34 
35  Camera& operator=(const Camera&) = delete;
36  Camera& operator=(Camera&&) = delete;
37 
38  virtual ~Camera() = default;
39 
45  void setZNear(float znear);
46 
52  float getZNear() const;
53 
59  void setZFar(float zfar);
60 
66  float getZFar() const;
67 
74  const Math::Mat4x4f& getProjectionMatrix();
75 
82  const Math::Mat4x4f& getViewMatrix();
83 
92  void update(const Renderer& renderer, const View& renderView, Queue& renderQueue);
93 
94  void setRenderView(View* renderView);
95 
96  Scene::Node* getParent() const;
97  void setParent(Scene::Node* parent);
98 
99  void needUpdateProj();
100  void needUpdateView();
101 
102  void lookAt(const Math::Vec3f& targetPosition, const Math::Vec3f& up, Node::TransformSpace space = Node::TransformSpace::Local);
103 
104 protected:
105  explicit Camera(const std::string& name);
106 
107  virtual void updateProj() = 0;
108  void updateView();
109 
110 protected:
111  Scene::Node* _parent{nullptr};
112 
113  View* _renderView{nullptr};
114 
115  float _znear{0.1f};
116  float _zfar{100.0f};
117 
118  bool _needUpdateProj{true};
119  bool _needUpdateView{true};
120 
121  Math::Mat4x4f _projMatrix{Math::Mat4x4f::identity()};
122  Math::Mat4x4f _viewMatrix{Math::Mat4x4f::identity()};
123 };
124 
126 
127 } // Camera
128 } // Render
129 } // Graphics
130 } // lug
#define LUG_GRAPHICS_API
Definition: Export.hpp:11
Matrix< 4, 4, T > lookAt(const Vector< 3, T > &eye, const Vector< 3, T > &center, const Vector< 3, T > &up)
Definition: Transform.inl:52
Class for resource.
Definition: Resource.hpp:17