CG_Labs 2021.2
Loading...
Searching...
No Matches
CelestialBody.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "core/helpers.hpp"
4#include "core/node.hpp"
5
6#include <glm/mat4x4.hpp>
7#include <glm/vec3.hpp>
8
10{
11 float axial_tilt{0.0f};
12 float speed{0.0f};
13};
14
16{
17 float radius{0.0f};
18 float inclination{0.0f};
19 float speed{0.0f};
20};
21
24{
25public:
34 CelestialBody(bonobo::mesh_data const& shape, GLuint const* program,
35 GLuint diffuse_texture_id);
36
49 glm::mat4 render(std::chrono::microseconds elapsed_time,
50 glm::mat4 const& view_projection,
51 glm::mat4 const& parent_transform = glm::mat4(1.0f),
52 bool show_basis = false);
53
55 void add_child(CelestialBody* child);
56
58 std::vector<CelestialBody*> const& get_children() const;
59
61 void set_orbit(OrbitConfiguration const& configuration);
62
64 void set_scale(glm::vec3 const& scale);
65
67 void set_spin(SpinConfiguration const& configuration);
68
78 void set_ring(bonobo::mesh_data const& shape, GLuint const* program,
79 GLuint diffuse_texture_id,
80 glm::vec2 const& scale = glm::vec2(1.0f));
81
82private:
83 struct {
85 struct {
86 float radius{0.0f};
87 float inclination{0.0f};
88 float speed{0.0f};
89 float rotation_angle{0.0f};
91 glm::vec3 scale{1.0f};
92 struct {
93 float axial_tilt{0.0f};
94 float speed{0.0f};
95 float rotation_angle{0.0f};
98
99 struct {
100 Node node;
101 glm::vec2 scale{1.0f};
102 bool is_set{false};
104
105 std::vector<CelestialBody*> _children;
106};
Represents a celestial body.
Definition CelestialBody.hpp:24
float radius
Distance in metres between its centre of gravity and the centre of the orbit.
Definition CelestialBody.hpp:86
void set_scale(glm::vec3 const &scale)
Configure the scale of this celestial body.
Definition CelestialBody.cpp:67
std::vector< CelestialBody * > const & get_children() const
Return all the children of this celestial body.
Definition CelestialBody.cpp:54
float speed
Rotation speed in radians per second.
Definition CelestialBody.hpp:88
float rotation_angle
How much has it rotated around its orbital axis; in radians.
Definition CelestialBody.hpp:89
struct CelestialBody::@2::@5 spin
void add_child(CelestialBody *child)
Mark another celestial body as being “attached” to the current one.
Definition CelestialBody.cpp:49
struct CelestialBody::@2 _body
struct CelestialBody::@3 _ring
glm::vec3 scale
Definition CelestialBody.hpp:91
void set_orbit(OrbitConfiguration const &configuration)
Configure the orbit parameters for this celestial body.
Definition CelestialBody.cpp:59
std::vector< CelestialBody * > _children
Definition CelestialBody.hpp:105
struct CelestialBody::@2::@4 orbit
void set_spin(SpinConfiguration const &configuration)
Configure the spin parameters for this celestial body.
Definition CelestialBody.cpp:72
void set_ring(bonobo::mesh_data const &shape, GLuint const *program, GLuint diffuse_texture_id, glm::vec2 const &scale=glm::vec2(1.0f))
Default constructor for a celestial body.
Definition CelestialBody.cpp:79
float inclination
Angle in radians between the its orbital axis and its parent's rotational axis.
Definition CelestialBody.hpp:87
Node node
Definition CelestialBody.hpp:84
glm::mat4 render(std::chrono::microseconds elapsed_time, glm::mat4 const &view_projection, glm::mat4 const &parent_transform=glm::mat4(1.0f), bool show_basis=false)
Render this celestial body.
Definition CelestialBody.cpp:18
bool is_set
Definition CelestialBody.hpp:102
float axial_tilt
Angle in radians between the its rotational and orbital axis.
Definition CelestialBody.hpp:93
Represents a node of a scene graph.
Definition node.hpp:17
Definition CelestialBody.hpp:16
float radius
Distance in metres between the centre of the orbit and the body's centre of gravity.
Definition CelestialBody.hpp:17
float inclination
Angle in radians between the body's orbital axis and its parent's rotational axis.
Definition CelestialBody.hpp:18
float speed
Rotation speed in radians per second.
Definition CelestialBody.hpp:19
Definition CelestialBody.hpp:10
float axial_tilt
Angle in radians between the body's rotational and orbital axis.
Definition CelestialBody.hpp:11
float speed
Rotation speed in radians per second.
Definition CelestialBody.hpp:12
Contains the data for a mesh in OpenGL.
Definition helpers.hpp:42