Conquer Space 0.0.0
A space themed grand strategy game set in the near future, with realistic orbital mechanics, and an emphasis on economics and politics.
starsystemcamera.h
Go to the documentation of this file.
1/* Conquer Space
2 * Copyright (C) 2021-2025 Conquer Space
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17#pragma once
18
19#include <glm/glm.hpp>
20
21#include "core/universe.h"
22#include "engine/application.h"
23
24namespace cqsp::client::systems {
29 public:
31 void CalculateCameraMatrix(int window_width, int window_height, float delta_time);
32 glm::vec3 CameraPositionNormalized();
33
34 glm::vec3 cam_pos;
35 const glm::vec3 default_cam_up = glm::vec3(0.0f, 0.0f, 1.0f);
37 glm::mat4 camera_matrix;
38 glm::mat4 projection;
39 glm::vec4 viewport;
40 glm::vec3 view_center;
41 double scroll;
42
43 // The angle the camera is looking from
44 float view_x = 0;
45 // The angle the camera is looking away from
46 float view_y = 0;
47
49 glm::vec3 initial_cam_up;
50
51 const float max_camera_time = 2.f;
52 float camera_time = 0.f;
53
54 void SetCameraUp(const glm::vec3 _target_cam_up);
55 void FixCameraUp(const glm::vec3 _target_cam_up);
56 void ResetCameraUp();
57
59
60 private:
61 // Custom animation function to go from 0 to 1.
62 float Tween(float t);
63 float TweenOut(float t);
64 float TweenFunction(float t);
65};
66} // namespace cqsp::client::systems
Definition: imguidebugger.cpp:19
Definition: starsystemcamera.h:28
glm::vec3 target_cam_up
Definition: starsystemcamera.h:48
float TweenFunction(float t)
Definition: starsystemcamera.cpp:60
const float max_camera_time
Definition: starsystemcamera.h:51
void CalculateCameraMatrix(int window_width, int window_height, float delta_time)
Definition: starsystemcamera.cpp:24
bool CameraUpDone()
Definition: starsystemcamera.h:58
glm::vec3 initial_cam_up
Definition: starsystemcamera.h:49
double scroll
Definition: starsystemcamera.h:41
glm::vec3 cam_pos
Definition: starsystemcamera.h:34
float TweenOut(float t)
Definition: starsystemcamera.cpp:58
StarSystemCamera()
Definition: starsystemcamera.cpp:22
glm::mat4 camera_matrix
Definition: starsystemcamera.h:37
glm::vec3 CameraPositionNormalized()
Definition: starsystemcamera.cpp:34
void FixCameraUp(const glm::vec3 _target_cam_up)
Definition: starsystemcamera.cpp:62
float view_x
Definition: starsystemcamera.h:44
const glm::vec3 default_cam_up
Definition: starsystemcamera.h:35
float view_y
Definition: starsystemcamera.h:46
float Tween(float t)
Definition: starsystemcamera.cpp:50
glm::mat4 projection
Definition: starsystemcamera.h:38
glm::vec3 view_center
Definition: starsystemcamera.h:40
void SetCameraUp(const glm::vec3 _target_cam_up)
Definition: starsystemcamera.cpp:38
glm::vec3 cam_up
Definition: starsystemcamera.h:36
void ResetCameraUp()
Definition: starsystemcamera.cpp:44
glm::vec4 viewport
Definition: starsystemcamera.h:39
float camera_time
Definition: starsystemcamera.h:52