20 glm::vec3 cameraPos = POSITION;
21 glm::vec3 cameraFront = glm::vec3(0, 0, -1);
22 glm::vec3 cameraUp = glm::vec3(0, 1, 0);
23 glm::vec3 cameraRight = glm::vec3(1, 0, 0);
24 glm::vec3 cameraDirection = glm::vec3(0);
25 glm::vec3 cameraTarget = glm::vec3(0);
45 glm::mat4 getViewProjMatrix()
const;
47 inline glm::mat4 getProjMatrix()
const {
return this->m_proj; }
48 inline glm::mat4 getViewMatrix()
const {
return this->m_view; }
51 inline void updateOrthoProjection(
const float &left,
const float &right,
const float &bot,
const float &top) {
52 this->m_proj = glm::ortho(left, right, bot, top);
53 this->m_view = glm::mat4(1);
54 this->m_viewProj = this->m_proj * this->m_view;
57 inline void updatePerspProjection(
const float &fov,
const float &width,
const float &height,
const float &near,
const float &far) {
58 this->m_proj = glm::perspective(glm::radians(fov), width / height, near, far);
59 this->m_info.ratio = width / height;
60 this->updateCameraVectors();
63 inline void updatePerspProjection(
const float &fov,
const float &ratio,
const float &near,
const float &far) {
64 this->m_proj = glm::perspective(glm::radians(fov), ratio, near, far);
65 this->m_info.ratio = ratio;
66 this->updateCameraVectors();
69 void moveCamera(
const glm::vec3 &axis);
71 void processMouseMovement(
const float &xoffset,
const float &yoffset,
const bool &constrainPitch =
true);
73 inline void setCameraFront(glm::vec3 vec) { this->m_vectors.cameraFront = vec; }
75 inline glm::vec3 getCameraFront()
const {
return this->m_vectors.cameraFront; }
77 inline glm::vec3 getCameraUp()
const {
return this->m_vectors.cameraUp; }
79 inline void setCameraVelocity(
const float velocity) { this->m_info.speed = velocity; }
81 inline float getCameraVelocity()
const {
return this->m_info.speed; }
83 inline glm::vec3 getCameraRight()
const {
return this->m_vectors.cameraRight; }
85 inline glm::vec3 getCameraPosition()
const {
return this->m_vectors.cameraPos; }
87 void setCameraPosition(
const glm::vec3 &position);
89 inline float getMouseSensitivity()
const {
return this->m_info.sensitivity; }
91 inline void setMouseSensitivity(
float val) { this->m_info.sensitivity = val; }
93 inline float getCameraZoom()
const {
return this->m_info.zoom; }
95 inline void setCameraZoom(
const float zoom) {
96 this->m_info.zoom = zoom;
97 this->updatePerspProjection(this->m_info.zoom, this->m_info.ratio, 0.1f, 100.f);
100 inline CameraRotation getCameraRotation()
const {
return this->m_rotation; }
102 inline void setCameraYaw(
const float &yaw) {
103 this->m_rotation.yaw = yaw;
104 this->updateCameraVectors();
107 inline void setCameraPitch(
const float &pitch) {
108 this->m_rotation.pitch = pitch;
109 this->updateCameraVectors();
112 inline float getTrackballSpeed() {
return this->m_info.tbSpeed; }
114 inline void setTrackballSpeed(
const float speed) { this->m_info.tbSpeed = speed; }
116 inline glm::vec3 getCameraDirection()
const {
return this->m_vectors.cameraDirection; }
118 inline void setCameraDirection(glm::vec3 dir) { this->m_vectors.cameraDirection = dir; }
120 inline glm::vec3 getCameraTarget()
const {
return this->m_vectors.cameraTarget; }
122 inline void setCameraTarget(glm::vec3 target) { this->m_vectors.cameraTarget = target; }
124 Camera() { this->updateCameraVectors(); }
129 glm::vec3 m_worldUp = glm::vec3(0, 1, 0);
134 glm::mat4 m_view = glm::mat4(0);
135 glm::mat4 m_proj = glm::mat4(0);
136 glm::mat4 m_viewProj = glm::mat4(0);
138 void updateCameraVectors();