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.
src
common
components
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
27
#include "
common/components/units.h
"
28
29
namespace
cqsp::common::components::bodies
{
30
struct
Body
{
31
/*
32
* Radius of the body
33
*/
34
types::kilometer
radius
;
35
40
types::kilometer
SOI
= std::numeric_limits<double>::infinity();
41
types::kilogram
mass
;
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
63
inline
double
CalculateSOI
(
const
double
& mass,
const
double
& reference_mass,
const
double
& sma) {
64
return
sma * std::pow(mass / reference_mass, 0.4);
65
}
66
73
inline
double
CalculateMass
(
const
double
& GM) {
return
GM /
types::G_km
; }
74
82
inline
double
GetPlanetRotationAngle
(
const
double
& time,
const
double
& day_length,
const
double
&
offset
) {
83
return
(time / day_length -
offset
) *
types::TWOPI
;
84
}
85
86
struct
TexturedTerrain
{
87
std::string
terrain_name
;
88
std::string
normal_name
;
89
std::string
roughness_name
;
90
};
91
92
struct
NautralObject
{};
93
97
struct
OrbitalSystem
{
98
// Set the tree
99
std::vector<entt::entity>
children
;
100
void
push_back
(
const
entt::entity& entity) {
children
.push_back(entity); }
101
};
102
103
struct
DirtyOrbit
{};
104
105
struct
Terrain
{
106
int
seed
;
107
entt::entity
terrain_type
;
108
};
109
110
struct
TerrainData
{
111
float
sea_level
;
112
std::map<float, std::tuple<int, int, int, int>>
data
;
113
};
114
115
struct
Star
{};
116
117
struct
Planet
{};
118
119
struct
LightEmitter
{};
120
}
// namespace cqsp::common::components::bodies
cqsp::common::components::bodies
Definition:
bodies.h:29
cqsp::common::components::bodies::GetPlanetRotationAngle
double GetPlanetRotationAngle(const double &time, const double &day_length, const double &offset)
Calculates the current planet rotation angle
Definition:
bodies.h:82
cqsp::common::components::bodies::CalculateMass
double CalculateMass(const double &GM)
Calculates mass from gravitational constant
Definition:
bodies.h:73
cqsp::common::components::bodies::CalculateSOI
double CalculateSOI(const double &mass, const double &reference_mass, const double &sma)
Calculates SOI
Definition:
bodies.h:63
cqsp::common::components::types::kilogram
double kilogram
Definition:
units.h:39
cqsp::common::components::types::kilometer
double kilometer
Definition:
units.h:34
cqsp::common::components::types::TWOPI
constexpr double TWOPI
Definition:
units.h:46
cqsp::common::components::types::G_km
constexpr double G_km
Definition:
units.h:54
offset
glm::vec3 offset
Definition:
starsystemview.cpp:72
cqsp::common::components::bodies::Body
Definition:
bodies.h:30
cqsp::common::components::bodies::Body::rotation_offset
double rotation_offset
Definition:
bodies.h:52
cqsp::common::components::bodies::Body::mass
types::kilogram mass
Definition:
bodies.h:41
cqsp::common::components::bodies::Body::SOI
types::kilometer SOI
Radius of sphere of influence rsoi = a(m/M)^2/5
Definition:
bodies.h:40
cqsp::common::components::bodies::Body::radius
types::kilometer radius
Definition:
bodies.h:34
cqsp::common::components::bodies::Body::rotation
double rotation
Definition:
bodies.h:47
cqsp::common::components::bodies::Body::axial
double axial
Definition:
bodies.h:50
cqsp::common::components::bodies::Body::GM
double GM
Definition:
bodies.h:44
cqsp::common::components::bodies::DirtyOrbit
Definition:
bodies.h:103
cqsp::common::components::bodies::LightEmitter
Definition:
bodies.h:119
cqsp::common::components::bodies::NautralObject
Definition:
bodies.h:92
cqsp::common::components::bodies::OrbitalSystem
An object for the children of an orbital object.
Definition:
bodies.h:97
cqsp::common::components::bodies::OrbitalSystem::children
std::vector< entt::entity > children
Definition:
bodies.h:99
cqsp::common::components::bodies::OrbitalSystem::push_back
void push_back(const entt::entity &entity)
Definition:
bodies.h:100
cqsp::common::components::bodies::Planet
Definition:
bodies.h:117
cqsp::common::components::bodies::Star
Definition:
bodies.h:115
cqsp::common::components::bodies::TerrainData
Definition:
bodies.h:110
cqsp::common::components::bodies::TerrainData::sea_level
float sea_level
Definition:
bodies.h:111
cqsp::common::components::bodies::TerrainData::data
std::map< float, std::tuple< int, int, int, int > > data
Definition:
bodies.h:112
cqsp::common::components::bodies::Terrain
Definition:
bodies.h:105
cqsp::common::components::bodies::Terrain::terrain_type
entt::entity terrain_type
Definition:
bodies.h:107
cqsp::common::components::bodies::Terrain::seed
int seed
Definition:
bodies.h:106
cqsp::common::components::bodies::TexturedTerrain
Definition:
bodies.h:86
cqsp::common::components::bodies::TexturedTerrain::terrain_name
std::string terrain_name
Definition:
bodies.h:87
cqsp::common::components::bodies::TexturedTerrain::normal_name
std::string normal_name
Definition:
bodies.h:88
cqsp::common::components::bodies::TexturedTerrain::roughness_name
std::string roughness_name
Definition:
bodies.h:89
units.h
Generated on Tue Nov 19 2024 02:58:49 for Conquer Space by
1.9.2