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.
bodies.h
Go to the documentation of this file.
1/* Conquer Space
2 * Copyright (C) 2021-2023 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 <limits>
20#include <map>
21#include <string>
22#include <tuple>
23#include <vector>
24
25#include <entt/entt.hpp>
26
28
30struct Body {
31 /*
32 * Radius of the body
33 */
35
40 types::kilometer SOI = std::numeric_limits<double>::infinity();
42
43 // gravitational constant in km^3 * s^-2
44 double GM;
45
46 // Rotation period in seconds
47 double rotation;
48
49 // Axial rotation
50 double axial = 0.0;
51
52 double rotation_offset = 0.0;
53};
54
63inline double CalculateSOI(const double& mass, const double& reference_mass, const double& sma) {
64 return sma * std::pow(mass / reference_mass, 0.4);
65}
66
73inline double CalculateMass(const double& GM) { return GM / types::G_km; }
74
82inline double GetPlanetRotationAngle(const double& time, const double& day_length, const double& offset) {
83 return (time / day_length - offset) * types::TWOPI;
84}
85
87 std::string terrain_name;
88 std::string normal_name;
89 std::string roughness_name;
90};
91
92struct NautralObject {};
93
98 // Set the tree
99 std::vector<entt::entity> children;
100 void push_back(const entt::entity& entity) { children.push_back(entity); }
101};
102
103struct DirtyOrbit {};
104
105struct Terrain {
106 int seed;
107 entt::entity terrain_type;
108};
109
112 std::map<float, std::tuple<int, int, int, int>> data;
113};
114
115struct Star {};
116
117struct Planet {};
118
119struct LightEmitter {};
120} // namespace cqsp::common::components::bodies
Definition: bodies.h:29
double GetPlanetRotationAngle(const double &time, const double &day_length, const double &offset)
Calculates the current planet rotation angle
Definition: bodies.h:82
double CalculateMass(const double &GM)
Calculates mass from gravitational constant
Definition: bodies.h:73
double CalculateSOI(const double &mass, const double &reference_mass, const double &sma)
Calculates SOI
Definition: bodies.h:63
double kilogram
Definition: units.h:39
double kilometer
Definition: units.h:34
constexpr double TWOPI
Definition: units.h:46
constexpr double G_km
Definition: units.h:54
glm::vec3 offset
Definition: starsystemview.cpp:72
double rotation_offset
Definition: bodies.h:52
types::kilogram mass
Definition: bodies.h:41
types::kilometer SOI
Radius of sphere of influence rsoi = a(m/M)^2/5
Definition: bodies.h:40
types::kilometer radius
Definition: bodies.h:34
double rotation
Definition: bodies.h:47
double axial
Definition: bodies.h:50
double GM
Definition: bodies.h:44
An object for the children of an orbital object.
Definition: bodies.h:97
std::vector< entt::entity > children
Definition: bodies.h:99
void push_back(const entt::entity &entity)
Definition: bodies.h:100
float sea_level
Definition: bodies.h:111
std::map< float, std::tuple< int, int, int, int > > data
Definition: bodies.h:112
entt::entity terrain_type
Definition: bodies.h:107
int seed
Definition: bodies.h:106
std::string terrain_name
Definition: bodies.h:87
std::string normal_name
Definition: bodies.h:88
std::string roughness_name
Definition: bodies.h:89