]> git.localhorst.tv Git - blobs.git/blob - src/world/Body.hpp
2f87d22723cd2239575355bf5153c006ef8d13af
[blobs.git] / src / world / Body.hpp
1 #ifndef BLOBS_WORLD_BODY_HPP_
2 #define BLOBS_WORLD_BODY_HPP_
3
4 #include "../graphics/glm.hpp"
5
6 #include <vector>
7
8
9 namespace blobs {
10 namespace app {
11         class Assets;
12 }
13 namespace graphics {
14         class Viewport;
15 }
16 namespace world {
17
18 class Simulation;
19
20 class Body {
21
22 public:
23         Body();
24         ~Body();
25
26         Body(const Body &) = delete;
27         Body &operator =(const Body &) = delete;
28
29         Body(Body &&) = delete;
30         Body &operator =(Body &&) = delete;
31
32 public:
33         bool HasSimulation() const noexcept { return sim; }
34         const Simulation &GetSimulation() const noexcept { return *sim; }
35         void SetSimulation(Simulation &) noexcept;
36
37         bool HasParent() const { return parent; }
38         Body &Parent() { return *parent; }
39         const Body &Parent() const { return *parent; }
40         void SetParent(Body &);
41         void UnsetParent();
42
43         double Mass() const noexcept;
44         void Mass(double) noexcept;
45
46         double Radius() const noexcept;
47         void Radius(double) noexcept;
48
49         double SemiMajorAxis() const noexcept;
50         void SemiMajorAxis(double) noexcept;
51
52         double Eccentricity() const noexcept;
53         void Eccentricity(double) noexcept;
54
55         double Inclination() const noexcept;
56         void Inclination(double) noexcept;
57
58         double LongitudeAscending() const noexcept;
59         void LongitudeAscending(double) noexcept;
60
61         double ArgumentPeriapsis() const noexcept;
62         void ArgumentPeriapsis(double) noexcept;
63
64         double MeanAnomaly() const noexcept;
65         void MeanAnomaly(double) noexcept;
66
67         double GravitationalParameter() const noexcept;
68         double OrbitalPeriod() const noexcept;
69
70         glm::mat4 ToParent() const noexcept;
71         glm::mat4 FromParent() const noexcept;
72
73         virtual void Draw(app::Assets &, graphics::Viewport &) { }
74
75 private:
76         void AddChild(Body &);
77         void RemoveChild(Body &);
78
79 private:
80         Simulation *sim;
81         Body *parent;
82         std::vector<Body *> children;
83         double mass;
84         double radius;
85
86         // Orbit
87         double sma; // semi-major axis
88         double ecc; // eccentricity
89         double inc; // inclination
90         double asc; // longitude of ascending node
91         double arg; // argument of periapsis
92         double mna; // mean anomaly (at t=0)
93
94 };
95
96 }
97 }
98
99 #endif