CG_Labs  2021.2
Public Member Functions | Private Attributes | List of all members
CelestialBody Class Reference

Represents a celestial body.

#include <CelestialBody.hpp>

Public Member Functions

 CelestialBody (bonobo::mesh_data const &shape, GLuint const *program, GLuint diffuse_texture_id)
 Default constructor for a celestial body. More...
 
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. More...
 
void add_child (CelestialBody *child)
 Mark another celestial body as being “attached” to the current one. More...
 
std::vector< CelestialBody * > const & get_children () const
 Return all the children of this celestial body. More...
 
void set_orbit (OrbitConfiguration const &configuration)
 Configure the orbit parameters for this celestial body. More...
 
void set_scale (glm::vec3 const &scale)
 Configure the scale of this celestial body. More...
 
void set_spin (SpinConfiguration const &configuration)
 Configure the spin parameters for this celestial body. More...
 
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. More...
 

Private Attributes

struct {
   Node   node
 
   struct {
      float   radius {0.0f}
 Distance in metres between its centre of gravity and the centre of the orbit. More...
 
      float   inclination {0.0f}
 Angle in radians between the its orbital axis and its parent's rotational axis. More...
 
      float   speed {0.0f}
 Rotation speed in radians per second. More...
 
      float   rotation_angle {0.0f}
 How much has it rotated around its orbital axis; in radians. More...
 
   }   orbit
 
   glm::vec3   scale {1.0f}
 
   struct {
      float   axial_tilt {0.0f}
 Angle in radians between the its rotational and orbital axis. More...
 
      float   speed {0.0f}
 Rotation speed in radians per second. More...
 
      float   rotation_angle {0.0f}
 How much has it rotated around its rotational axis; in radians. More...
 
   }   spin
 
_body
 
struct {
   Node   node
 
   glm::vec2   scale {1.0f}
 
   bool   is_set {false}
 
_ring
 
std::vector< CelestialBody * > _children
 

Constructor & Destructor Documentation

◆ CelestialBody()

CelestialBody::CelestialBody ( bonobo::mesh_data const &  shape,
GLuint const *  program,
GLuint  diffuse_texture_id 
)
Parameters
[in]shapeInformation about the geometry used to model the celestial body (more details about it in assignment 2
[in]programShader program used to render the celestial body (more details about it in assignment~3)
[in]diffuse_texture_idIdentifier of the diffuse texture used (more details about it also in assignment~3)

Member Function Documentation

◆ add_child()

void CelestialBody::add_child ( CelestialBody child)

◆ get_children()

std::vector< CelestialBody * > const & CelestialBody::get_children ( ) const

◆ render()

glm::mat4 CelestialBody::render ( std::chrono::microseconds  elapsed_time,
glm::mat4 const &  view_projection,
glm::mat4 const &  parent_transform = glm::mat4(1.0f),
bool  show_basis = false 
)
Parameters
[in]elapsed_timeAmount of time (in microseconds) between two frames
[in]view_projectionMatrix transforming from world space to clip space
[in]parent_transformMatrix transforming from the parent’s local space to world space
[in]show_basisShow a 3D basis transformed by the world matrix of this celestial body
Returns
Matrix transforming from this celestial body’s local space to world space

◆ set_orbit()

void CelestialBody::set_orbit ( OrbitConfiguration const &  configuration)

◆ set_ring()

void CelestialBody::set_ring ( bonobo::mesh_data const &  shape,
GLuint const *  program,
GLuint  diffuse_texture_id,
glm::vec2 const &  scale = glm::vec2(1.0f) 
)
Parameters
[in]shapeShape used for the rings.
[in]programIdentifier of the shader program used to render the ring
[in]diffuse_texture_idIdentifier of the diffuse texture used by the ring
[in]scaleHow much to scale the ring along the x- and y-axis, assuming you are looking at it from above

◆ set_scale()

void CelestialBody::set_scale ( glm::vec3 const &  scale)

◆ set_spin()

void CelestialBody::set_spin ( SpinConfiguration const &  configuration)

Member Data Documentation

◆ 

struct { ... } CelestialBody::_body

◆ _children

std::vector<CelestialBody*> CelestialBody::_children
private

◆ 

struct { ... } CelestialBody::_ring

◆ axial_tilt

float CelestialBody::axial_tilt {0.0f}

◆ inclination

float CelestialBody::inclination {0.0f}

◆ is_set

bool CelestialBody::is_set {false}

◆ node

Node CelestialBody::node

◆ 

struct { ... } CelestialBody::orbit

◆ radius

float CelestialBody::radius {0.0f}

◆ rotation_angle

float CelestialBody::rotation_angle {0.0f}

How much has it rotated around its rotational axis; in radians.

◆ scale [1/2]

glm::vec3 CelestialBody::scale {1.0f}

◆ scale [2/2]

glm::vec2 CelestialBody::scale {1.0f}

◆ speed

float CelestialBody::speed {0.0f}

◆ 

struct { ... } CelestialBody::spin

The documentation for this class was generated from the following files: