X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fworld%2FBody.hpp;h=3db5e37e362b3de7352dac22ee6a4a848dac5652;hb=bcf776b6d51aeb9147bde32da8dd0768b10db993;hp=2f87d22723cd2239575355bf5153c006ef8d13af;hpb=0453d6da05d4b29d953f00857d743310d9344ce0;p=blobs.git diff --git a/src/world/Body.hpp b/src/world/Body.hpp index 2f87d22..3db5e37 100644 --- a/src/world/Body.hpp +++ b/src/world/Body.hpp @@ -1,6 +1,7 @@ #ifndef BLOBS_WORLD_BODY_HPP_ #define BLOBS_WORLD_BODY_HPP_ +#include "Orbit.hpp" #include "../graphics/glm.hpp" #include @@ -10,6 +11,9 @@ namespace blobs { namespace app { class Assets; } +namespace creature { + class Creature; +} namespace graphics { class Viewport; } @@ -40,38 +44,59 @@ public: void SetParent(Body &); void UnsetParent(); - double Mass() const noexcept; - void Mass(double) noexcept; + const std::vector &Children() const noexcept { return children; } + + double Mass() const noexcept { return mass; } + void Mass(double m) noexcept { mass = m; } - double Radius() const noexcept; - void Radius(double) noexcept; + double Radius() const noexcept { return radius; } + void Radius(double r) noexcept { radius = r; } - double SemiMajorAxis() const noexcept; - void SemiMajorAxis(double) noexcept; + Orbit &GetOrbit() noexcept { return orbit; } + const Orbit &GetOrbit() const noexcept { return orbit; } - double Eccentricity() const noexcept; - void Eccentricity(double) noexcept; + const glm::dvec2 &SurfaceTilt() const noexcept { return surface_tilt; } + void SurfaceTilt(const glm::dvec2 &t) noexcept { surface_tilt = t; } - double Inclination() const noexcept; - void Inclination(double) noexcept; + const glm::dvec2 &AxialTilt() const noexcept { return axis_tilt; } + void AxialTilt(const glm::dvec2 &t) noexcept { axis_tilt = t; } - double LongitudeAscending() const noexcept; - void LongitudeAscending(double) noexcept; + double Rotation() const noexcept { return rotation; } + void Rotation(double r) noexcept { rotation = r; } - double ArgumentPeriapsis() const noexcept; - void ArgumentPeriapsis(double) noexcept; + double AngularMomentum() const noexcept { return angular; } + void AngularMomentum(double m) noexcept { angular = m; } - double MeanAnomaly() const noexcept; - void MeanAnomaly(double) noexcept; + double Inertia() const noexcept; double GravitationalParameter() const noexcept; double OrbitalPeriod() const noexcept; + double RotationalPeriod() const noexcept; + + const glm::dmat4 &LocalTransform() const noexcept { return local; } + const glm::dmat4 &InverseTransform() const noexcept { return inverse_local; } + + const glm::dmat4 &ToParent() const noexcept { return inverse_orbital; } + const glm::dmat4 &FromParent() const noexcept { return orbital; } - glm::mat4 ToParent() const noexcept; - glm::mat4 FromParent() const noexcept; + glm::dmat4 ToUniverse() const noexcept; + glm::dmat4 FromUniverse() const noexcept; virtual void Draw(app::Assets &, graphics::Viewport &) { } + void Tick(double dt); + void Cache() noexcept; + + // body takes over ownership of given pointer + void AddCreature(creature::Creature *); + void RemoveCreature(creature::Creature *); + std::vector &Creatures() noexcept { return creatures; } + const std::vector &Creatures() const noexcept { return creatures; } + + void Atmosphere(int a) noexcept { atmosphere = a; } + int Atmosphere() const noexcept { return atmosphere; } + bool HasAtmosphere() const noexcept { return atmosphere >= 0; } + private: void AddChild(Body &); void RemoveChild(Body &); @@ -82,14 +107,19 @@ private: std::vector children; double mass; double radius; - - // Orbit - double sma; // semi-major axis - double ecc; // eccentricity - double inc; // inclination - double asc; // longitude of ascending node - double arg; // argument of periapsis - double mna; // mean anomaly (at t=0) + Orbit orbit; + glm::dvec2 surface_tilt; + glm::dvec2 axis_tilt; + double rotation; + double angular; + + glm::dmat4 orbital; + glm::dmat4 inverse_orbital; + glm::dmat4 local; + glm::dmat4 inverse_local; + + std::vector creatures; + int atmosphere; };