NoJobEngine 2.0.7
Loading...
Searching...
No Matches
EditorCamera.h
Go to the documentation of this file.
1
6#pragma once
7
8#include <glm/glm.hpp>
9
10struct GLFWwindow;
11
12namespace NoJob
13{
15 {
16 public:
18 float fovDegrees = 45.0f,
19 float aspectRatio = 16.0f / 9.0f,
20 float nearClip = 0.1f,
21 float farClip = 1000.0f);
22
23 void OnUpdate(
24 GLFWwindow* window,
25 float deltaTime,
26 bool viewportHovered);
27
28 void SetViewportSize(float width, float height);
29
30 const glm::mat4& GetViewMatrix() const { return m_ViewMatrix; }
31 const glm::mat4& GetProjectionMatrix() const { return m_ProjectionMatrix; }
32 glm::mat4 GetViewProjection() const
33 {
34 return m_ProjectionMatrix * m_ViewMatrix;
35 }
36
37 const glm::vec3& GetPosition() const { return m_Position; }
38
39 private:
40 void RecalculateView();
41 void RecalculateProjection();
42
43 glm::vec3 GetForwardDirection() const;
44 glm::vec3 GetRightDirection() const;
45
46 float m_FOV = 45.0f;
47 float m_AspectRatio = 16.0f / 9.0f;
48 float m_NearClip = 0.1f;
49 float m_FarClip = 1000.0f;
50
51 glm::vec3 m_Position{ 0.0f, 1.5f, 5.0f };
52 float m_Yaw = -90.0f;
53 float m_Pitch = -12.0f;
54
55 float m_MoveSpeed = 4.0f;
56 float m_MouseSensitivity = 0.12f;
57
58 bool m_WasLooking = false;
59 double m_LastMouseX = 0.0;
60 double m_LastMouseY = 0.0;
61
62 glm::mat4 m_ViewMatrix{ 1.0f };
63 glm::mat4 m_ProjectionMatrix{ 1.0f };
64 };
65}
const glm::mat4 & GetViewMatrix() const
const glm::mat4 & GetProjectionMatrix() const
const glm::vec3 & GetPosition() const
EditorCamera(float fovDegrees=45.0f, float aspectRatio=16.0f/9.0f, float nearClip=0.1f, float farClip=1000.0f)
void OnUpdate(GLFWwindow *window, float deltaTime, bool viewportHovered)
void SetViewportSize(float width, float height)
glm::mat4 GetViewProjection() const