| Fling Engine 0.00.1 Fling Engine is a game engine written in Vulkan

FirstPersonCamera.h
Go to the documentation of this file.
1 #pragma once
2 #include "Camera.h"
3
4 namespace Fling
5 {
9 class FirstPersonCamera : public Camera
10 {
11 public:
12 FirstPersonCamera(float aspectRatio, float t_MoveSpeed = 10.0f, float t_RotSpeed = 40.f);
13
14 FirstPersonCamera(
15 glm::vec3 position,
16 glm::vec3 rotation,
17 float speed,
18 float aspectRatio);
19
20 FirstPersonCamera(
21 glm::vec3 front, glm::vec3 up,
22 glm::vec3 position, glm::vec3 rotation,
23 float speed,
24 float nearPlane, float farPlane,
25 float fov, float aspectRatio);
26
27 void Update(float dt) override;
28
29 float GetRotationSpeed() const { return m_RotationSpeed; }
30 void SetRotationSpeed(float t_NewSpeed) { m_RotationSpeed = t_NewSpeed; }
31
32 bool IsRotating() const { return m_IsRotating; }
33
34 private:
35 glm::vec3 m_front;
36 glm::vec3 m_up;
37 glm::vec3 m_right;
38 glm::vec3 m_worldUp;
39 glm::vec3 m_worldFront = { 0.f, 0.f, -1.0 };
40
41 float m_RotationSpeed = 20.0f;
42 bool m_IsRotating = false;
43
44 const float MAX_PITCH = (glm::pi<float>() / 2.0f) - .017f; //subtract one degrees for gimbal lock
45 MousePos m_PrevMousePos;
46
47 void UpdateViewMatrix();
48 void UpdateProjectionMatrix();
49 void UpdateCameraVectors();
50 };
51 }
Fling::MousePos
represents the current mouse position in screen space
Definition: Input.h:13
Fling::FirstPersonCamera::GetRotationSpeed
float GetRotationSpeed() const
Definition: FirstPersonCamera.h:29
Fling::FirstPersonCamera::Update
void Update(float dt) override
Definition: FirstPersonCamera.cpp:67
Fling::FirstPersonCamera::SetRotationSpeed
void SetRotationSpeed(float t_NewSpeed)
Definition: FirstPersonCamera.h:30
Fling::FirstPersonCamera::UpdateViewMatrix
void UpdateViewMatrix()
Definition: FirstPersonCamera.cpp:140
Fling::FirstPersonCamera::m_worldFront
glm::vec3 m_worldFront
Definition: FirstPersonCamera.h:39
Camera.h
Fling::Camera
Base class for camera, meant to be overridden.
Definition: Camera.h:10
Fling::FirstPersonCamera
A simple first person camera.
Definition: FirstPersonCamera.h:9
Fling::FirstPersonCamera::IsRotating
bool IsRotating() const
Definition: FirstPersonCamera.h:32
Fling::FirstPersonCamera::m_PrevMousePos
MousePos m_PrevMousePos
Definition: FirstPersonCamera.h:45
Fling::FirstPersonCamera::m_right
glm::vec3 m_right
Definition: FirstPersonCamera.h:37
Fling::FirstPersonCamera::m_worldUp
glm::vec3 m_worldUp
Definition: FirstPersonCamera.h:38
Fling::FirstPersonCamera::UpdateCameraVectors
void UpdateCameraVectors()
Definition: FirstPersonCamera.cpp:150
Fling::FirstPersonCamera::UpdateProjectionMatrix
void UpdateProjectionMatrix()
Definition: FirstPersonCamera.cpp:145
Fling::FirstPersonCamera::m_IsRotating
bool m_IsRotating
Definition: FirstPersonCamera.h:42
Fling::FirstPersonCamera::FirstPersonCamera
FirstPersonCamera(float aspectRatio, float t_MoveSpeed=10.0f, float t_RotSpeed=40.f)
Definition: FirstPersonCamera.cpp:9
Fling::FirstPersonCamera::m_front
glm::vec3 m_front
Definition: FirstPersonCamera.h:35
Fling::FirstPersonCamera::m_up
glm::vec3 m_up
Definition: FirstPersonCamera.h:36
Fling::FirstPersonCamera::MAX_PITCH
const float MAX_PITCH
Definition: FirstPersonCamera.h:44
Fling::FirstPersonCamera::m_RotationSpeed
float m_RotationSpeed
Definition: FirstPersonCamera.h:41
Fling
Definition: Engine.h:29