vengine  0.0.1
3D graphics engine
Loading...
Searching...
No Matches
Camera.hpp
Go to the documentation of this file.
1///
2/// @file Camera.hpp
3/// @brief This file contains the Camera class
4/// @namespace ven
5///
6
7#pragma once
8
10
11namespace ven {
12
13 static constexpr glm::vec3 DEFAULT_POSITION{0.F, 0.F, -2.5F};
14 static constexpr glm::vec3 DEFAULT_ROTATION{0.F, 0.F, 0.F};
15
16 static constexpr float DEFAULT_FOV = glm::radians(50.0F);
17 static constexpr float DEFAULT_NEAR = 0.1F;
18 static constexpr float DEFAULT_FAR = 100.F;
19
20 static constexpr float DEFAULT_MOVE_SPEED = 3.F;
21 static constexpr float DEFAULT_LOOK_SPEED = 1.5F;
22
23 ///
24 /// @class Camera
25 /// @brief Class for camera
26 /// @namespace ven
27 ///
28 class Camera {
29
30 public:
31
32 Camera(const float fov, const float near, const float far, const float moveSpeed, const float lookSpeed) : m_fov(fov), m_near(near), m_far(far), m_moveSpeed(moveSpeed), m_lookSpeed(lookSpeed) { }
33 ~Camera() = default;
34
35 Camera(const Camera&) = delete;
36 Camera& operator=(const Camera&) = delete;
37 Camera(Camera&&) = default;
38 Camera& operator=(Camera&&) = default;
39
40 void setOrthographicProjection(float left, float right, float top, float bottom, float near, float far);
41 void setPerspectiveProjection(float aspect);
42 void setViewDirection(glm::vec3 position, glm::vec3 direction, glm::vec3 up = {0.F, -1.F, 0.F});
43 void setViewTarget(const glm::vec3 position, const glm::vec3 target, const glm::vec3 up = {0.F, -1.F, 0.F}) { setViewDirection(position, target - position, up); }
44 void setViewXYZ(glm::vec3 position, glm::vec3 rotation);
45 void setFov(const float fov) { m_fov = fov; }
46 void setNear(const float near) { m_near = near; }
47 void setFar(const float far) { m_far = far; }
48 void setMoveSpeed(const float moveSpeed) { m_moveSpeed = moveSpeed; }
49 void setLookSpeed(const float lookSpeed) { m_lookSpeed = lookSpeed; }
50
51 [[nodiscard]] const glm::mat4& getProjection() const { return m_projectionMatrix; }
52 [[nodiscard]] const glm::mat4& getView() const { return m_viewMatrix; }
53 [[nodiscard]] const glm::mat4& getInverseView() const { return m_inverseViewMatrix; }
54 [[nodiscard]] float getFov() const { return m_fov; }
55 [[nodiscard]] float getNear() const { return m_near; }
56 [[nodiscard]] float getFar() const { return m_far; }
57 [[nodiscard]] float getMoveSpeed() const { return m_moveSpeed; }
58 [[nodiscard]] float getLookSpeed() const { return m_lookSpeed; }
59
61
62 private:
63
64 float m_fov;
65 float m_near;
66 float m_far;
69 glm::mat4 m_projectionMatrix{1.F};
70 glm::mat4 m_viewMatrix{1.F};
71 glm::mat4 m_inverseViewMatrix{1.F};
72
73 }; // class Camera
74
75} // namespace ven
This file contains the Transform3D class.
Class for camera.
Definition Camera.hpp:28
Transform3D transform
Definition Camera.hpp:60
float getFov() const
Definition Camera.hpp:54
const glm::mat4 & getView() const
Definition Camera.hpp:52
Camera & operator=(Camera &&)=default
float m_near
Definition Camera.hpp:65
const glm::mat4 & getInverseView() const
Definition Camera.hpp:53
float getNear() const
Definition Camera.hpp:55
void setViewTarget(const glm::vec3 position, const glm::vec3 target, const glm::vec3 up={0.F, -1.F, 0.F})
Definition Camera.hpp:43
void setViewXYZ(glm::vec3 position, glm::vec3 rotation)
Definition camera.cpp:64
glm::mat4 m_inverseViewMatrix
Definition Camera.hpp:71
Camera(const Camera &)=delete
~Camera()=default
Camera & operator=(const Camera &)=delete
void setMoveSpeed(const float moveSpeed)
Definition Camera.hpp:48
const glm::mat4 & getProjection() const
Definition Camera.hpp:51
float m_moveSpeed
Definition Camera.hpp:67
Camera(Camera &&)=default
Camera(const float fov, const float near, const float far, const float moveSpeed, const float lookSpeed)
Definition Camera.hpp:32
glm::mat4 m_projectionMatrix
Definition Camera.hpp:69
float getMoveSpeed() const
Definition Camera.hpp:57
float getLookSpeed() const
Definition Camera.hpp:58
void setNear(const float near)
Definition Camera.hpp:46
void setLookSpeed(const float lookSpeed)
Definition Camera.hpp:49
glm::mat4 m_viewMatrix
Definition Camera.hpp:70
void setPerspectiveProjection(float aspect)
Definition camera.cpp:17
void setViewDirection(glm::vec3 position, glm::vec3 direction, glm::vec3 up={0.F, -1.F, 0.F})
Definition camera.cpp:29
void setOrthographicProjection(float left, float right, float top, float bottom, float near, float far)
Definition camera.cpp:6
void setFov(const float fov)
Definition Camera.hpp:45
float getFar() const
Definition Camera.hpp:56
float m_fov
Definition Camera.hpp:64
float m_lookSpeed
Definition Camera.hpp:68
void setFar(const float far)
Definition Camera.hpp:47
float m_far
Definition Camera.hpp:66
Class for 3D transformation.
static constexpr glm::vec3 DEFAULT_POSITION
Definition Camera.hpp:13
static constexpr float DEFAULT_FOV
Definition Camera.hpp:16
static constexpr float DEFAULT_LOOK_SPEED
Definition Camera.hpp:21
static constexpr float DEFAULT_MOVE_SPEED
Definition Camera.hpp:20
static constexpr float DEFAULT_NEAR
Definition Camera.hpp:17
static constexpr glm::vec3 DEFAULT_ROTATION
Definition Camera.hpp:14
static constexpr float DEFAULT_FAR
Definition Camera.hpp:18