GlobeEngine
Universe.h
Go to the documentation of this file.
1 #ifndef exoViewer_Universe_h
2 #define exoViewer_Universe_h
3 
4 #include <iostream>
5 #include <stdio.h>
6 #include <stack>
7 #include "tinyxml2.h"
8 #include "XMLGetter.h"
9 
10 #include "AstroCommon.h"
11 #include "System.h"
12 #include "Body.h"
13 #include "Star.h"
14 #include "Planet.h"
15 #include "SmallBody.h"
16 #include "Moon.h"
18 #include "OverviewPointCloud.h"
19 
20 namespace geAstro{
21 
22  //struct to hold all info for a body that is relevant for UI drawing
23  struct UIBodyInfo{
24 
25  std::string name;
26  vmml::Vector2d screenPosition;
28  bool isVisible;
29 
30  UIBodyInfo(std::string _name, vmml::Vector2d _screenPosition, SystemSelection _selectionInfo, bool _isVisible) :
31  name(_name), screenPosition(_screenPosition), selectionInfo(_selectionInfo), isVisible(_isVisible)
32  {}
33 
35  name = "";
36  screenPosition = vmml::Vector2d::ZERO;
37  SystemSelection selectionInfo = SystemSelection();
38  isVisible = false;
39  }
40  };
41 
42  class Universe
43  {
44  public:
45  Universe();
46  ~Universe();
47  void clear();
48  void create(std::string _path);
49 
50  void Universe::loadShaders(std::string _shaderpath);
52  void createExoSystems();
53 
54  void createSSsmallBodies(std::shared_ptr<System> _system);
55 
56  void updateAllOrbits(double _currentDate);
57  void updateOrbitsOfCurrentSystem(double _currentDate);
58  void updatePositions();
59 
60  void isRealScaled(bool _in);
61  bool isRealScaled() const;
62  //void applyScaling();
63 
64  int getSystemCount();
65 
66  std::shared_ptr<System> const& getSystemAtIdx(int _idx) const;
67 
68  const std::shared_ptr<System> getSystemByName(std::string _name);
69 
70  void setModelsVisibleForSelection(UniverseSelection _sel, bool _isVisible);
71 
72  const std::vector<std::shared_ptr<System>>& getSystems();
73 
74  void showHabitableZones();
75 
76  // draw objects
77  void drawObjectsOfSystemAtIdx(int _idx, System::BodyType _type, std::shared_ptr<ge::Camera> _cam);
78  void drawOrbitsOfSystemAtIdx(int _idx, System::BodyType _type, std::shared_ptr<ge::Camera> _cam);
79 
80  std::shared_ptr<OverviewPointCloud> overviewPointCloud;
81 
82  void collectAllBodyNames();
83  const std::vector<std::string>& getAllBodyNames() const;
84  const std::vector<std::string>& getSystemAndPlanetNames() const;
85  UniverseSelection findSelectionByName(std::string _name);
86 
87  // Object selection
88  bool getCurrentlySelectedVisibilty() const;
89  std::shared_ptr<Body> getCurrentlySelectedBody() const;
90  vmml::Vector3d getCurrentlySelectedPosition() const;
91  vmml::Matrix4d getCurrentlySelectedModelMatrix() const;
92  std::shared_ptr<Body> getBodyForSelection(UniverseSelection _selection) const;
93  std::shared_ptr<System> getSystemForSelection(UniverseSelection _selection) const;
94  std::shared_ptr<Planet> getPlanetForSelection(UniverseSelection _selection) const;
95  void setCurrentSelection(UniverseSelection _selection);
97  void navigateBackInHistory();
98 
99  private:
100  std::shared_ptr<ge::DrawableComponent> getCurrentlySelectedDrawable() const;
101 
102  std::shared_ptr<Moon> getMoonFromXMLElement(tinyxml2::XMLElement* _element, vmml::Vector3d _systemPos);
103  std::shared_ptr<Planet> getPlanetFromXMLElement(tinyxml2::XMLElement* _element, vmml::Vector3d _systemPos, bool _isSolarSystem);
104  std::shared_ptr<Star> getStarFromXMLElement(tinyxml2::XMLElement* _element, vmml::Vector3d _systemPos);
105  bool getSystemFromXML(std::string _path, bool _isSolarSystem = false);
106  void createSSBodiesA(tinyxml2::XMLElement* _root, std::shared_ptr<System> _system);
107 
108  OrbitInfo getOrbitInfoFromXMLElement(tinyxml2::XMLElement* _XMLsuperordinateElement);
109 
110  void createTestSun();
111 
112  std::string trim(std::string& _str, char _c);
113 
114  std::shared_ptr<ge::Shader> programForOrbits;
115  std::shared_ptr<ge::Shader> programForSpheres;
116  std::shared_ptr<ge::Shader> programForPlanets;
117  std::shared_ptr<ge::Shader> programForStars;
118  std::shared_ptr<ge::Shader> programForHabitableZones;
119  std::shared_ptr<ge::Shader> programForOverviewPointCloud;
120  std::shared_ptr<ge::Shader> programForSmallBodyPointClouds;
121 
122  XMLGetter *xmlGetter;
123 
124  std::vector<std::shared_ptr<System>> systems;
125  std::stack<UniverseSelection> selectionStack;
126 
127  bool isRealScale;
128  bool showMoons;
129  bool localSBDatabase;
130  bool localOpenExoplanetCatalogue;
131  bool smallBodiesAsPointCloud;
132 
133  std::string solarSystemXMLName;
134  std::string solarSystemMoonsPath;
135  std::string jplSmallBodiesPath;
136  std::string openExoplanetCataloguePath;
137 
138  unsigned int numberOfSystemsToDisplay;
139  std::vector<std::string> interestingSystems;
140  std::vector<std::string> allBodyNames;
141  std::vector<std::string> systemAndPlanetNames;
142 
143  unsigned int numberOfSmallBodiesPerCategoryToDisplay;
144 
145  std::string texturePath;
146  std::string habZonePath;
147 
148  std::shared_ptr<ge::Texture2Drgba> standardSuntex;
149  std::shared_ptr<ge::Texture2Drgba> standardJupitertex;
150  std::shared_ptr<ge::Texture2Drgba> standardMoontex;
151  std::shared_ptr<ge::Texture2Drgba> standardEarthtex;
152  std::shared_ptr<HabitableZoneClassification> hzClassification;
153 
154  vmml::Vector3f orbitColorForPlanets;
155  vmml::Vector3f orbitColorForMoons;
156  vmml::Vector3f orbitColorForSmallbodies;
157  };
158 
159 }
160 #endif
std::shared_ptr< OverviewPointCloud > overviewPointCloud
Definition: Universe.h:80
void drawOrbitsOfSystemAtIdx(int _idx, System::BodyType _type, std::shared_ptr< ge::Camera > _cam)
Definition: Universe.cpp:582
void createSolarSystemBodies()
Definition: Universe.cpp:81
UniverseSelection findSelectionByName(std::string _name)
Definition: Universe.cpp:688
void createSSsmallBodies(std::shared_ptr< System > _system)
Definition: Universe.cpp:488
UniverseSelection getCurrentSelection() const
Definition: Universe.cpp:891
void clear()
Definition: Universe.cpp:19
const std::vector< std::string > & getSystemAndPlanetNames() const
Definition: Universe.cpp:665
~Universe()
Definition: Universe.cpp:15
std::shared_ptr< Body > getBodyForSelection(UniverseSelection _selection) const
Definition: Universe.cpp:815
Definition: AstroCommon.h:50
void drawObjectsOfSystemAtIdx(int _idx, System::BodyType _type, std::shared_ptr< ge::Camera > _cam)
Definition: Universe.cpp:578
void create(std::string _path)
Definition: Universe.cpp:24
const std::vector< std::string > & getAllBodyNames() const
Definition: Universe.cpp:661
Definition: AstroCommon.h:18
void createExoSystems()
Definition: Universe.cpp:116
Definition: Universe.h:23
void collectAllBodyNames()
Definition: Universe.cpp:669
Definition: Universe.h:42
std::string name
Definition: Universe.h:25
bool getCurrentlySelectedVisibilty() const
Definition: Universe.cpp:807
Universe()
Definition: Universe.cpp:10
BodyType
Definition: System.h:23
bool isVisible
Definition: Universe.h:28
UIBodyInfo(std::string _name, vmml::Vector2d _screenPosition, SystemSelection _selectionInfo, bool _isVisible)
Definition: Universe.h:30
void showHabitableZones()
Definition: Universe.cpp:628
void updatePositions()
Definition: Universe.cpp:596
void navigateBackInHistory()
Definition: Universe.cpp:895
const std::vector< std::shared_ptr< System > > & getSystems()
Definition: Universe.cpp:634
void updateAllOrbits(double _currentDate)
Definition: Universe.cpp:586
vmml::Vector3d getCurrentlySelectedPosition() const
Definition: Universe.cpp:801
vmml::Matrix4d getCurrentlySelectedModelMatrix() const
Definition: Universe.cpp:795
std::shared_ptr< Body > getCurrentlySelectedBody() const
Definition: Universe.cpp:811
bool isRealScaled() const
Definition: Universe.cpp:657
vmml::Vector2d screenPosition
Definition: Universe.h:26
std::shared_ptr< System > const & getSystemAtIdx(int _idx) const
Definition: Universe.cpp:638
void Universe::loadShaders(std::string _shaderpath)
void setModelsVisibleForSelection(UniverseSelection _sel, bool _isVisible)
Definition: Universe.cpp:726
Definition: Orbit.h:14
const std::shared_ptr< System > getSystemByName(std::string _name)
Definition: Universe.cpp:619
UIBodyInfo()
Definition: Universe.h:34
void updateOrbitsOfCurrentSystem(double _currentDate)
Definition: Universe.cpp:592
std::shared_ptr< System > getSystemForSelection(UniverseSelection _selection) const
Definition: Universe.cpp:838
void setCurrentSelection(UniverseSelection _selection)
Definition: Universe.cpp:846
std::shared_ptr< Planet > getPlanetForSelection(UniverseSelection _selection) const
Definition: Universe.cpp:842
Definition: XMLGetter.h:10
int getSystemCount()
Definition: Universe.cpp:642
SystemSelection selectionInfo
Definition: Universe.h:27
Definition: AstroCommon.h:35