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 "core/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
79 void FoundCity();
80 bool IsFoundingCity();
81
82 glm::vec3 CalculateMouseRay(const glm::vec3 &ray_nds);
83 entt::entity GetMouseOnObject(int mouse_x, int mouse_y);
84 void CalculateViewChange(double deltaX, double deltaY);
85
87
88 glm::vec3 GetMouseIntersectionOnObject(int mouse_x, int mouse_y);
89 glm::vec3 GetMouseInScreenSpace(int mouse_x, int mouse_y);
90 std::optional<glm::vec3> CheckIntersection(const glm::vec3 &object_pos, const glm::vec3 &ray_wor, float radius);
91
92 void SelectCountry();
93
96
98
99 entt::entity terrain_displaying = entt::null;
100 entt::entity selected_city = entt::null;
101
104
105 entt::entity on_planet = entt::null;
106
110 int tex_x;
111 int tex_y;
112
116 int tex_r;
117 int tex_g;
118 int tex_b;
119
120 entt::entity hovering_province;
121 entt::entity selected_province;
122
125
127
130
131 const float CAMERA_MOVEMENT_SPEED = 30.f / 40.f;
132 const float PAN_SPEED = 4.0f;
133 const float SCROLL_SENSITIVITY = 3.f / 33.f;
134
136
137 bool focus_on_city = false;
140
142};
143} // namespace cqsp::client::systems
Definition: starsystemcontroller.h:30
void CalculateCityPositions()
Definition: starsystemcontroller.cpp:449
void SeeEntity()
Definition: starsystemcontroller.cpp:502
void CityDetection()
Definition: starsystemcontroller.cpp:170
entt::entity selected_city
Definition: starsystemcontroller.h:100
double previous_mouseX
Definition: starsystemcontroller.h:102
core::components::types::SurfaceCoordinate target_surface_coordinate
Definition: starsystemcontroller.h:139
void SetCameraToSolarSystemReferenceFrame()
Definition: starsystemcontroller.cpp:375
glm::vec3 CalculateMouseRay(const glm::vec3 &ray_nds)
Definition: starsystemcontroller.cpp:439
bool focus_on_city
Definition: starsystemcontroller.h:137
bool planet_frame_scroll
Definition: starsystemcontroller.h:138
glm::vec3 CalculateCenteredObject(const entt::entity &)
Definition: starsystemcontroller.cpp:515
const float SCROLL_SENSITIVITY
Definition: starsystemcontroller.h:133
StarSystemController(core::Universe &, engine::Application &, StarSystemCamera &)
Definition: starsystemcontroller.cpp:44
void FoundCity()
Definition: starsystemcontroller.cpp:314
core::components::types::SurfaceCoordinate GetCameraOverCoordinate()
Definition: starsystemcontroller.cpp:295
glm::vec3 selected_province_color
Definition: starsystemcontroller.h:124
void PreRender()
Definition: starsystemcontroller.cpp:332
glm::vec3 GetMouseOnObjectPosition()
Definition: starsystemcontroller.h:36
void Update(float delta_time)
Definition: starsystemcontroller.cpp:47
core::Universe & universe
Definition: starsystemcontroller.h:94
friend StarSystemViewUI
Definition: starsystemcontroller.h:135
void SetCameraToPlanetReferenceFrame()
Definition: starsystemcontroller.cpp:367
entt::entity GetMouseOnObject(int mouse_x, int mouse_y)
Definition: starsystemcontroller.cpp:479
void FocusCityView()
Definition: starsystemcontroller.cpp:383
entt::entity m_viewing_entity
Definition: starsystemcontroller.h:57
void FocusPlanetView()
Definition: starsystemcontroller.cpp:531
glm::vec3 CalculateObjectPos(const entt::entity &ent)
Definition: starsystemcontroller.cpp:521
const glm::vec3 & SelectedProvinceColor()
Definition: starsystemcontroller.cpp:500
bool is_founding_city
Definition: starsystemcontroller.h:129
entt::entity selected_province
Definition: starsystemcontroller.h:121
entt::entity hovering_province
Definition: starsystemcontroller.h:120
void CalculateViewChange(double deltaX, double deltaY)
Definition: starsystemcontroller.cpp:149
void MoveCamera(double delta_time)
Definition: starsystemcontroller.cpp:90
void SeePlanet(entt::entity ent)
Definition: starsystemcontroller.cpp:309
const float PAN_SPEED
Definition: starsystemcontroller.h:132
void CenterCameraOnPoint()
Definition: starsystemcontroller.cpp:339
glm::vec3 mouse_on_object
Definition: starsystemcontroller.h:126
engine::Application & app
Definition: starsystemcontroller.h:95
int tex_b
Definition: starsystemcontroller.h:118
glm::vec3 GetMouseInScreenSpace(int mouse_x, int mouse_y)
Definition: starsystemcontroller.cpp:472
glm::vec3 hovering_province_color
Definition: starsystemcontroller.h:123
int tex_r
Debugging colors
Definition: starsystemcontroller.h:116
int tex_g
Definition: starsystemcontroller.h:117
int tex_y
Definition: starsystemcontroller.h:111
void CalculateScroll()
Definition: starsystemcontroller.cpp:123
bool is_rendering_founding_city
Definition: starsystemcontroller.h:128
void SelectCountry()
Definition: starsystemcontroller.cpp:274
void CenterCameraOnCity()
Definition: starsystemcontroller.cpp:236
bool IsFoundingCity()
Definition: starsystemcontroller.cpp:168
float GetScrollValue()
Definition: starsystemcontroller.cpp:147
entt::entity terrain_displaying
Definition: starsystemcontroller.h:99
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:226
bool ShouldDrawCityPrototype()
Definition: starsystemcontroller.cpp:498
StarSystemCamera & camera
Definition: starsystemcontroller.h:97
double previous_mouseY
Definition: starsystemcontroller.h:103
core::components::types::SurfaceCoordinate GetMouseSurfaceIntersection()
Definition: starsystemcontroller.cpp:207
const float CAMERA_MOVEMENT_SPEED
Definition: starsystemcontroller.h:131
glm::vec3 GetMouseIntersectionOnObject(int mouse_x, int mouse_y)
Definition: starsystemcontroller.cpp:417
std::optional< glm::vec3 > CheckIntersection(const glm::vec3 &object_pos, const glm::vec3 &ray_wor, float radius)
Definition: starsystemcontroller.cpp:402
void FocusOnEntity(entt::entity ent)
Definition: starsystemcontroller.cpp:253
entt::entity on_planet
Definition: starsystemcontroller.h:105
int tex_x
Debugging mouse position
Definition: starsystemcontroller.h:110
Definition: universe.h:59
Definition: application.h:48
Definition: imguidebugger.cpp:19
Definition: starsystemcamera.h:28
Longitude and lattitude. Planet coordinates.
Definition: coordinates.h:75