GlobeEngine
Body.h
Go to the documentation of this file.
1 #ifndef ExoViewer_Body_h
2 #define ExoViewer_Body_h
3 
4 #include "OpenGL_Includes.h"
5 #include <math.h>
6 #include <vector>
7 #include <vmmlib/vmmlib.hpp>
8 
9 #include "Sphere.h"
10 #include "Camera.h"
11 #include "Orbit.h"
12 #include "Texture.h"
13 
14 #include "AstroCommon.h"
15 
16 
17 namespace geAstro{
18 
20  double crustDepth; //starting depth of the crust in % of the radius
21  double mantleDepth; //starting depth of the mantle in % of the radius
22  double coreDepth; //starting depth of the core in % of the radius
23  };
24 
25  struct BodyInfo
26  {
27  std::string name;
28  double radius; //radius in AU
29  double mass; //mass in kg
30  double rotationPeriod; //time to rotate 360 degrees in d
31  double axisTilt; //axis tilt in degrees
32  double transittime;
33  double temperature;
34  double age;
36 
38  radius = -1.0;
39  mass = -1.0;
40  rotationPeriod = -1.0;
41  axisTilt = -1.0;
42  transittime = -1.0;
43  temperature = -1.0;
44  age = -1.0;
45  structure.crustDepth = -1;
46  structure.mantleDepth = -1;
47  structure.coreDepth = -1;
48  };
49 
50  // copy constructor
51  BodyInfo(const std::shared_ptr<BodyInfo> copy){
52  name = copy->name;
53  radius = copy->radius;
54  mass = copy->mass;
55  rotationPeriod = copy->rotationPeriod;
56  axisTilt = copy->axisTilt;
57  transittime = copy->transittime;
58  temperature = copy->temperature;
59  age = copy->age;
60  structure.crustDepth = copy->structure.crustDepth;
61  structure.mantleDepth = copy->structure.mantleDepth;
62  structure.coreDepth = copy->structure.coreDepth;
63  }
64  };
65 
66  class Body
67  {
68  public:
69  Body();
70  ~Body();
71  void clear();
72  void updateRotation(double _currentDateInDays);
73 
74  void setBodyAttributes(BodyInfo _data, double _scaleSize);
75  void setBodyAttributes(BodyInfo _data, double _scaleSize, BodyCompositionInfo _crust);
76  void setBodyAttributes(BodyInfo _data, double _scaleSize, std::shared_ptr<Body> _parent);
77 
78  // satellite handling
79  bool hasSatellites();
80  std::vector<std::shared_ptr<Body> > getSatellites() const;
81  void addSatellite(std::shared_ptr<Body> _satellite);
82  void setParent(std::shared_ptr<Body> _parent);
83 
84  // Orbit handling
85  void createOrbit(OrbitInfo orbitInfo, vmml::Vector3d _center, std::shared_ptr<ge::Shader> _programForOrbits, vmml::Vector3f _orbitColor
86  , unsigned int _id, unsigned int _groupuid);
87  void createOrbit(OrbitInfo orbitInfo, vmml::Vector3d _center, std::shared_ptr<ge::Shader> _programForOrbits, vmml::Vector3f _orbitColor,
88  unsigned int _id, unsigned int _groupuid, bool _smallBodiesAsPointCloud, bool _isRealScale);
89  void updateOrbit(double _date);
90  void drawOrbit(std::shared_ptr<ge::Camera> _cam);
91  bool hasOrbit() const;
92  const OrbitInfo& getOrbitData();
93  std::shared_ptr<Orbit> const& getOrbit() const;
94 
95  double scaleBody(double _value) const;
96  //void isRealScaled(bool _isRealScaled);
97 
98  double getRadiusScaled(bool _scaled = false) const;
99 
100  bool hasCoreView();
101  const BodyCompositionInfo& getCrustInfo() const;
102  double getCrustDepthInKm();
103  double getMantleDepthInKm();
104  double getCoreDepthInKm();
105  double getRadiusInKm();
106 
107  void setBodyInfo(BodyInfo _info);
108  const BodyInfo& getBodyInfo() const;
109  const vmml::Vector3d& getCurrentRotation() const;
110 
111  private:
112  BodyInfo data;
113  std::shared_ptr<Orbit> orbit;
114  std::shared_ptr<Body> parent;
115  std::vector<std::shared_ptr<Body>> satellites;
116  bool isRealScale;
117 
118  vmml::Vector3d currentRotation;
119  double rotationAngle;
120  double dateOfLastRotationUpdate;
121  double scaleSize;
122  };
123 
124 }
125 
126 #endif
double getRadiusInKm()
Definition: Body.cpp:159
~Body()
Definition: Body.cpp:10
bool hasSatellites()
Definition: Body.cpp:122
double age
Definition: Body.h:34
void addSatellite(std::shared_ptr< Body > _satellite)
Definition: Body.cpp:118
double mantleDepth
Definition: Body.h:21
Definition: Body.h:19
double transittime
Definition: Body.h:32
double getCrustDepthInKm()
Definition: Body.cpp:147
double scaleBody(double _value) const
Definition: Body.cpp:126
double radius
Definition: Body.h:28
void createOrbit(OrbitInfo orbitInfo, vmml::Vector3d _center, std::shared_ptr< ge::Shader > _programForOrbits, vmml::Vector3f _orbitColor, unsigned int _id, unsigned int _groupuid)
Definition: Body.cpp:69
void updateOrbit(double _date)
Definition: Body.cpp:81
bool hasCoreView()
Definition: Body.cpp:139
void setBodyInfo(BodyInfo _info)
Definition: Body.cpp:163
const BodyInfo & getBodyInfo() const
Definition: Body.cpp:167
double axisTilt
Definition: Body.h:31
const OrbitInfo & getOrbitData()
Definition: Body.cpp:106
double rotationPeriod
Definition: Body.h:30
std::vector< std::shared_ptr< Body > > getSatellites() const
Definition: Body.cpp:114
void setBodyAttributes(BodyInfo _data, double _scaleSize)
Definition: Body.cpp:31
const BodyCompositionInfo & getCrustInfo() const
Definition: Body.cpp:143
void drawOrbit(std::shared_ptr< ge::Camera > _cam)
Definition: Body.cpp:93
Definition: AstroCommon.h:18
Body()
Definition: Body.cpp:5
bool hasOrbit() const
Definition: Body.cpp:99
BodyInfo(const std::shared_ptr< BodyInfo > copy)
Definition: Body.h:51
double getRadiusScaled(bool _scaled=false) const
Definition: Body.cpp:135
double coreDepth
Definition: Body.h:22
BodyInfo()
Definition: Body.h:37
Definition: Body.h:66
void updateRotation(double _currentDateInDays)
Definition: Body.cpp:44
Definition: Orbit.h:14
double temperature
Definition: Body.h:33
double getCoreDepthInKm()
Definition: Body.cpp:155
void setParent(std::shared_ptr< Body > _parent)
Definition: Body.cpp:171
double getMantleDepthInKm()
Definition: Body.cpp:151
std::string name
Definition: Body.h:27
void clear()
Definition: Body.cpp:14
BodyCompositionInfo structure
Definition: Body.h:35
double crustDepth
Definition: Body.h:20
const vmml::Vector3d & getCurrentRotation() const
Definition: Body.cpp:175
Definition: Body.h:25
double mass
Definition: Body.h:29
std::shared_ptr< Orbit > const & getOrbit() const
Definition: Body.cpp:110