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.
starsystemcontroller.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 <optional>
20
21#include <glm/glm.hpp>
22
25#include "common/universe.h"
26#include "engine/application.h"
27
28namespace cqsp::client::systems {
29class StarSystemViewUI;
31 public:
33 void Update(float delta_time);
34
35 // Gets the intersection in 3d point between the mouse and any planet
37
44 glm::quat GetBodyRotation(double axial, double rotation, double day_offset);
45
47
48 const glm::vec3 &SelectedProvinceColor();
49
50 glm::vec3 CalculateCenteredObject(const entt::entity &);
51 glm::vec3 CalculateCenteredObject(const glm::vec3 &);
52
53 glm::vec3 CalculateObjectPos(const entt::entity &ent);
54
55 void PreRender();
56
57 entt::entity m_viewing_entity = entt::null;
58
59 private:
60 void SeeEntity();
61 void CenterCameraOnCity();
62 void MoveCamera(double delta_time);
63
64 void FocusOnEntity(entt::entity ent);
65 void SeePlanet(entt::entity ent);
66
67 void CalculateScroll();
68 float GetScrollValue();
69
70 void FocusPlanetView();
71 void FocusCityView();
72
74 void CityDetection();
75
76 void FoundCity();
77 bool IsFoundingCity();
78
79 glm::vec3 CalculateMouseRay(const glm::vec3 &ray_nds);
80 entt::entity GetMouseOnObject(int mouse_x, int mouse_y);
81 void CalculateViewChange(double deltaX, double deltaY);
82
84
85 glm::vec3 GetMouseIntersectionOnObject(int mouse_x, int mouse_y);
86 glm::vec3 GetMouseInScreenSpace(int mouse_x, int mouse_y);
87 std::optional<glm::vec3> CheckIntersection(const glm::vec3 &object_pos, const glm::vec3 &ray_wor, float radius);
88
89 void SelectCountry();
90
93
95
96 entt::entity terrain_displaying = entt::null;
97 entt::entity selected_city = entt::null;
98
101
102 entt::entity on_planet = entt::null;
103
107 int tex_x;
108 int tex_y;
109
113 int tex_r;
114 int tex_g;
115 int tex_b;
116
117 entt::entity hovering_province;
118 entt::entity selected_province;
119
122
124
127
128 const float CAMERA_MOVEMENT_SPEED = 30.f / 40.f;
129 const float PAN_SPEED = 4.0f;
130 const float SCROLL_SENSITIVITY = 3.f / 33.f;
131
133};
134} // namespace cqsp::client::systems
Definition: starsystemcontroller.h:30
void CalculateCityPositions()
Definition: starsystemcontroller.cpp:386
void SeeEntity()
Definition: starsystemcontroller.cpp:439
void CityDetection()
Definition: starsystemcontroller.cpp:154
entt::entity selected_city
Definition: starsystemcontroller.h:97
double previous_mouseX
Definition: starsystemcontroller.h:99
glm::vec3 CalculateMouseRay(const glm::vec3 &ray_nds)
Definition: starsystemcontroller.cpp:376
glm::vec3 CalculateCenteredObject(const entt::entity &)
Definition: starsystemcontroller.cpp:453
const float SCROLL_SENSITIVITY
Definition: starsystemcontroller.h:130
StarSystemController(common::Universe &, engine::Application &, StarSystemCamera &)
Definition: starsystemcontroller.cpp:44
void FoundCity()
Definition: starsystemcontroller.cpp:299
glm::vec3 selected_province_color
Definition: starsystemcontroller.h:121
void PreRender()
Definition: starsystemcontroller.cpp:317
glm::vec3 GetMouseOnObjectPosition()
Definition: starsystemcontroller.h:36
void Update(float delta_time)
Definition: starsystemcontroller.cpp:47
friend StarSystemViewUI
Definition: starsystemcontroller.h:132
entt::entity GetMouseOnObject(int mouse_x, int mouse_y)
Definition: starsystemcontroller.cpp:416
void FocusCityView()
Definition: starsystemcontroller.cpp:322
entt::entity m_viewing_entity
Definition: starsystemcontroller.h:57
void FocusPlanetView()
Definition: starsystemcontroller.cpp:469
glm::vec3 CalculateObjectPos(const entt::entity &ent)
Definition: starsystemcontroller.cpp:459
const glm::vec3 & SelectedProvinceColor()
Definition: starsystemcontroller.cpp:437
bool is_founding_city
Definition: starsystemcontroller.h:126
entt::entity selected_province
Definition: starsystemcontroller.h:118
entt::entity hovering_province
Definition: starsystemcontroller.h:117
void CalculateViewChange(double deltaX, double deltaY)
Definition: starsystemcontroller.cpp:136
void MoveCamera(double delta_time)
Definition: starsystemcontroller.cpp:90
void SeePlanet(entt::entity ent)
Definition: starsystemcontroller.cpp:294
const float PAN_SPEED
Definition: starsystemcontroller.h:129
glm::vec3 mouse_on_object
Definition: starsystemcontroller.h:123
engine::Application & app
Definition: starsystemcontroller.h:92
int tex_b
Definition: starsystemcontroller.h:115
glm::vec3 GetMouseInScreenSpace(int mouse_x, int mouse_y)
Definition: starsystemcontroller.cpp:409
glm::vec3 hovering_province_color
Definition: starsystemcontroller.h:120
int tex_r
Debugging colors
Definition: starsystemcontroller.h:113
int tex_g
Definition: starsystemcontroller.h:114
int tex_y
Definition: starsystemcontroller.h:108
void CalculateScroll()
Definition: starsystemcontroller.cpp:122
bool is_rendering_founding_city
Definition: starsystemcontroller.h:125
void SelectCountry()
Definition: starsystemcontroller.cpp:273
void CenterCameraOnCity()
Definition: starsystemcontroller.cpp:220
bool IsFoundingCity()
Definition: starsystemcontroller.cpp:152
float GetScrollValue()
Definition: starsystemcontroller.cpp:134
entt::entity terrain_displaying
Definition: starsystemcontroller.h:96
glm::quat GetBodyRotation(double axial, double rotation, double day_offset)
Gets the quaternion to calculate the planet's rotation from the axial rotation and the rotation perio...
Definition: starsystemcontroller.cpp:210
bool ShouldDrawCityPrototype()
Definition: starsystemcontroller.cpp:435
common::Universe & universe
Definition: starsystemcontroller.h:91
StarSystemCamera & camera
Definition: starsystemcontroller.h:94
double previous_mouseY
Definition: starsystemcontroller.h:100
common::components::types::SurfaceCoordinate GetMouseSurfaceIntersection()
Definition: starsystemcontroller.cpp:191
const float CAMERA_MOVEMENT_SPEED
Definition: starsystemcontroller.h:128
glm::vec3 GetMouseIntersectionOnObject(int mouse_x, int mouse_y)
Definition: starsystemcontroller.cpp:354
std::optional< glm::vec3 > CheckIntersection(const glm::vec3 &object_pos, const glm::vec3 &ray_wor, float radius)
Definition: starsystemcontroller.cpp:339
void FocusOnEntity(entt::entity ent)
Definition: starsystemcontroller.cpp:252
entt::entity on_planet
Definition: starsystemcontroller.h:102
int tex_x
Debugging mouse position
Definition: starsystemcontroller.h:107
Definition: universe.h:38
Definition: application.h:48
Definition: imguidebugger.cpp:19
Definition: starsystemcamera.h:28
Longitude and lattitude. Planet coordinates.
Definition: coordinates.h:77