Karma Engine
Loading...
Searching...
No Matches
Camera.h
1#pragma once
2
3#include "krpch.h"
4
5#include "glm/glm.hpp"
6
7namespace Karma
8{
9 class KARMA_API Camera
10 {
11 public:
12 Camera(const glm::vec3& initialCameraPosition);
13 virtual ~Camera();
14
15 const glm::vec3& GetPosition() const { return m_Position; }
16 float GetRotation() const { return m_Rotation; }
17
18 void LeftMouseButtonPressed();
19 void LeftMouseButtonReleased();
20 void ComputeCameraFront();
21
22 void SetPosition(const glm::vec3& position);
23 void SetRotation(float rotation) { m_Rotation = rotation; RecalculateViewMatrix(); }
24 inline void SetCameraFront(const glm::vec3& front) { m_CameraFront = front; }
25 inline void SetCameraUp(const glm::vec3& up) { m_CameraUp = up; }
26
27 void MoveForward(float amount);
28 void MoveSideways(float amount);
29 void MoveUp(float amount);
30 void RotateAboutYAxis(float amount);
31 void RotateAboutXAxis(float amount);
32
33 const glm::mat4& GetProjectionMatrix() const { return m_ProjectionMatrix; }
34 const glm::mat4& GetViewMatirx() const { return m_ViewMatrix; }
35
36 private:
37 void RecalculateViewMatrix();
38
39 protected:
40 void InitializePitchRoll();
41
42 protected:
43 glm::mat4 m_ProjectionMatrix;
44 glm::mat4 m_ViewMatrix;
45
46 glm::vec3 m_Position;
47 glm::vec3 m_CameraFront;
48 glm::vec3 m_CameraUp;
49 float m_Rotation = 0.0f;
50
51 bool m_IsLeftMouseButtonPressed = false;
52 float m_LastMouseX, m_LastMouseY;
53
54 const float m_Sensitivity = 0.1f;
55 float m_Roll = 0.0f;
56 float m_Pitch = 0.0f;
57 };
58}
Definition Camera.h:10