Fling Engine  0.00.1
Fling Engine is a game engine written in Vulkan
Camera.h
Go to the documentation of this file.
1 #pragma once
2 #include "FlingMath.h"
3 
4 namespace Fling
5 {
10  class Camera
11  {
12  public:
13  Camera() :
14  m_nearPlane(0.1f),
15  m_farPlane(1000.0f),
16  m_fieldOfView(glm::radians(45.0f)),
17  m_aspectRatio(1.6180f) //golden ratio
18  {
19  }
20 
21  virtual ~Camera() = default;
22  virtual void Update(float dt) = 0;
23 
29  const float GetNearPlane() const { return m_nearPlane; }
30  void SetNearPlane(const float& nearPlane) { m_nearPlane = nearPlane; }
31 
37  const float GetFarPlane() const { return m_farPlane; }
38  void SetFarPlane(const float& farPlane) { m_farPlane = farPlane; }
39 
45  const float GetFieldOfView() const { return m_fieldOfView; }
46  void SetFieldOfView(const float& fieldOfView) { m_fieldOfView = fieldOfView; }
47 
48  const glm::vec3& GetPosition() const { return m_position; }
49  const glm::vec3& GetRotation() const { return m_rotation; }
50  const float GetSpeed() const { return m_speed; }
51  const float GetAspectRatio() const { return m_aspectRatio; }
52 
58  const glm::mat4& GetViewMatrix() const {return m_viewMatrix; }
59 
65  const glm::mat4& GetProjectionMatrix() const { return m_projectionMatrix; }
66 
67  float GetGamma() const { return m_Gamma; }
68  void SetGamma(float t_Gam) { m_Gamma = t_Gam; }
69 
70  float GetExposure() const { return m_Exposure; }
71  void SetExposure(float t_Val) { m_Exposure = t_Val; }
72 
73  protected:
74  glm::mat4 m_viewMatrix;
75  glm::mat4 m_projectionMatrix;
76 
77  glm::vec3 m_position;
78  float m_speed; //padding 12 + 4 = 16
79 
80  glm::vec3 m_rotation;
82 
83  float m_nearPlane;
84  float m_farPlane;
86 
87  float m_Gamma = 2.2f;
88  float m_Exposure = 4.5f;
89  };
90 } //namespace fling
float GetGamma() const
Definition: Camera.h:67
glm::vec3 m_position
Definition: Camera.h:77
float m_fieldOfView
Definition: Camera.h:85
float m_speed
Definition: Camera.h:78
float m_farPlane
Definition: Camera.h:84
glm::mat4 m_viewMatrix
Definition: Camera.h:74
Base class for camera, meant to be overridden.
Definition: Camera.h:10
const glm::vec3 & GetRotation() const
Definition: Camera.h:49
void SetGamma(float t_Gam)
Definition: Camera.h:68
glm::vec3 m_rotation
Definition: Camera.h:80
float m_nearPlane
Definition: Camera.h:83
float m_Exposure
Definition: Camera.h:88
const float GetAspectRatio() const
Definition: Camera.h:51
void SetNearPlane(const float &nearPlane)
Definition: Camera.h:30
const float GetNearPlane() const
Gets the near plane of the view frustrum.
Definition: Camera.h:29
const glm::vec3 & GetPosition() const
Definition: Camera.h:48
glm::mat4 m_projectionMatrix
Definition: Camera.h:75
virtual ~Camera()=default
const glm::mat4 & GetProjectionMatrix() const
Gets the projection matrix used by camera.
Definition: Camera.h:65
virtual void Update(float dt)=0
const float GetFieldOfView() const
Gets the field of view angle from the view frustrum.
Definition: Camera.h:45
void SetFieldOfView(const float &fieldOfView)
Definition: Camera.h:46
const float GetSpeed() const
Definition: Camera.h:50
const glm::mat4 & GetViewMatrix() const
Gets the view matrix created by the current camera position and rotation.
Definition: Camera.h:58
void SetExposure(float t_Val)
Definition: Camera.h:71
void SetFarPlane(const float &farPlane)
Definition: Camera.h:38
const float GetFarPlane() const
Gets the far plane of the view frustrum.
Definition: Camera.h:37
float m_aspectRatio
Definition: Camera.h:81
Definition: Engine.h:29
float m_Gamma
Definition: Camera.h:87
float GetExposure() const
Definition: Camera.h:70
Camera()
Definition: Camera.h:13