Wrath of Zeus
Made by Torchlight Games for CSE 125 SP24
Loading...
Searching...
No Matches
camera.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "client/core.hpp"
4
5#include <iostream>
6#include <ostream>
7#include <utility>
8#include <unordered_map>
9
10#include "client/util.hpp"
11
12#include <glm/gtc/matrix_transform.hpp>
13#include <glm/gtc/type_ptr.hpp>
14
15#define GLM_ENABLE_EXPERIMENTAL
16#include "glm/gtx/string_cast.hpp"
17
23class Camera {
24
25public:
30 Camera();
31
36 ~Camera();
37
38 // Access functions
44 void setAspect(float a) { aspect = a; }
45
52 virtual void update(float xpos, float ypos);
53
63 glm::vec3 move(bool is_x_axis, float dir);
64
70 glm::mat4 getViewProj() { return viewProjMat; }
71
77 glm::vec3 getFacing() { return cameraFront; }
78
84 void updatePos(glm::vec3 pos);
85
86 glm::vec3 getPos();
87
88 glm::mat4 getProjection();
89
90 glm::mat4 getView();
91
92 void setPitch(float pitch);
93
94protected:
95 // Perspective controls
96 float FOV; // Field of View Angle (degrees)
97 float aspect; // Aspect Ratio
98 float nearClip; // Near clipping plane distance
99 float farClip; // Far clipping plane distance
100
101 float yaw;
102 float pitch;
103 float lastX;
104 float lastY;
105 float fov;
106
109
110 glm::vec3 cameraPos;
111 glm::vec3 cameraFront;
112 glm::vec3 cameraUp;
113 glm::vec3 cameraRight;
114 glm::vec3 worldUp;
115
116 float speed;
117
118 glm::mat4 viewProjMat;
119
120 glm::mat4 projection;
121 glm::mat4 view;
122};
123
125public:
128
129 void update(float xpos, float ypos) override;
130};
131
Class representing a camera for rendering. Primarily used to compute the view-projection matrix and p...
Definition: camera.hpp:23
Camera()
Constructs a new Camera object.
Definition: camera.cpp:4
float nearClip
Definition: camera.hpp:98
glm::vec3 cameraFront
Definition: camera.hpp:111
float aspect
Definition: camera.hpp:97
glm::mat4 viewProjMat
Definition: camera.hpp:118
virtual void update(float xpos, float ypos)
Updates the the camera based on the input screen coordinates.
Definition: camera.cpp:43
float speed
Definition: camera.hpp:116
void updatePos(glm::vec3 pos)
Updates the position of the camera.
Definition: camera.cpp:96
float lastY
Definition: camera.hpp:104
float FOV
Definition: camera.hpp:96
glm::vec3 cameraPos
Definition: camera.hpp:110
glm::mat4 projection
Definition: camera.hpp:120
glm::vec3 cameraUp
Definition: camera.hpp:112
float sensitivity
Definition: camera.hpp:108
void setPitch(float pitch)
Definition: camera.cpp:100
float lastX
Definition: camera.hpp:103
glm::vec3 worldUp
Definition: camera.hpp:114
glm::mat4 getView()
Definition: camera.cpp:35
glm::vec3 getPos()
Definition: camera.cpp:30
float pitch
Definition: camera.hpp:102
float farClip
Definition: camera.hpp:99
void setAspect(float a)
Sets the aspect ratio of the camera.
Definition: camera.hpp:44
glm::vec3 cameraRight
Definition: camera.hpp:113
glm::mat4 getViewProj()
Returns the view-projection matrix of the Camera, for use in rendering.
Definition: camera.hpp:70
~Camera()
Destroys the Camera object.
Definition: camera.cpp:26
float yaw
Definition: camera.hpp:101
glm::mat4 getProjection()
Definition: camera.cpp:39
glm::vec3 getFacing()
Returns a normalized vector representing the direction that the camera is facing.
Definition: camera.hpp:77
glm::mat4 view
Definition: camera.hpp:121
bool firstMouse
Definition: camera.hpp:107
glm::vec3 move(bool is_x_axis, float dir)
Moves the camera based on the axis, direction, and speed. Factors in the current direction of the cam...
Definition: camera.cpp:85
float fov
Definition: camera.hpp:105
Definition: camera.hpp:124
void update(float xpos, float ypos) override
Updates the the camera based on the input screen coordinates.
Definition: camera.cpp:113
DungeonMasterCamera()
Definition: camera.cpp:104
~DungeonMasterCamera()
Definition: camera.cpp:109
GLboolean GLboolean GLboolean GLboolean a
Definition: glad.h:2133