blob: 3ee692884532ca4f055cd150c8b7314f3917b3eb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
#ifndef CAMERASYSTEM_H
#define CAMERASYSTEM_H
#include "Game/GameWorld.h"
#include "Graphics/camera.h"
#include <memory>
#include "system.h"
class CameraSystem : public System
{
public:
CameraSystem(std::map<std::string, std::shared_ptr<GameObject>>& gameobjects,
std::shared_ptr<Camera>& camera,
std::map<int, Input>& input_map);
void draw() override;
void update(double deltaTime) override;
void scrollEvent(double distance) override;
void mousePosEvent(double xpos, double ypos) override;
private:
void firstPersonMode();
void thirdPersonMode(glm::vec3 curr_cam_pos);
void setCameraPos();
void calculateAngleAroundPlayer(double deltaX);
void calculatePitch(double deltaY);
void calculateZoom(float scrollDistance);
glm::vec3 calculateIdealOffset(glm::vec3 initial);
void arcballRotation(float deltaX, float deltaY);
float m_distance = -10.f;
std::shared_ptr<Camera>& m_camera;
std::map<std::string, std::shared_ptr<GameObject>>& m_gameobjects;
std::map<int, Input>& m_input_map;
bool first_person = false;
bool third_person = true;
float first_person_offset = 0.01f;
glm::vec2 prev_mouse_pos = glm::vec2(0.f);
float horiz_velocity = .005f;
std::shared_ptr<GameObject> m_player;
float m_distanceFromPlayer = 50.f;
float m_angleAroundPlayer = 0.f;
float m_pitch = 20.f;
float m_yaw = 0.f;
bool m_isInverted = false;
float m_angle = 0.f;
float m_height = 0.f;
int m_invertY = 1;
glm::vec3 m_currPos;
glm::vec3 m_currLook;
float m_currentTurnSpeed = 0.f;
float TURN_SPEED = 2.f;
float snapshot_time = 0.f;
};
#endif // CAMERASYSTEM_H
|