GlobeEngine
ExoEngine.h
Go to the documentation of this file.
1 #ifndef exoViewer_ExoEngine_h
2 #define exoViewer_ExoEngine_h
3 
4 #include <math.h>
5 #include <ctime>
6 #include <iostream>
7 #include <stdio.h>
8 #include <vector>
9 #include <vmmlib/vmmlib.hpp>
10 #include "OpenGL_Includes.h"
11 #include "Engine.h"
12 #include "Shader.h"
13 #include "Common.h"
14 #include "AstroCoordinateSystem.h"
15 #include "SceneStateSet.h"
16 #include "DrawableComponent.h"
17 #include "System.h"
18 #include "tinyxml2.h"
19 #include "Texture.h"
20 #include "FrameBufferObject.h"
21 #include "Skybox.h"
22 #include "ExoComposition.h"
23 #include "Ring.h"
24 #include "UnitCircles.h"
25 #include "ArcBallCamera.h"
26 #include "OrthographicMapCamera.h"
27 #include "FlightCamera.h"
28 //#include "DebugMap.h"
29 #include "PassiveCamera.h"
30 #include "DebugLogger.h"
31 #include "XMLGetter.h"
32 #include "Universe.h"
33 #include "OrbitJob.h"
34 #include "DebugMapProvider.h"
35 #include "ComparisonGrid.h"
36 #include "CoordinateSystem.h"
37 #include "OverviewPointCloud.h"
39 #include "BloomComposition.h"
40 #include "ComparisonComposition.h"
41 #include "Comparisoner.h"
42 
43 
44 namespace geAstro{
45 
47 
49 
50  class ExoEngine : public ge::Engine
51  {
52  public:
53  ExoEngine();
54  ~ExoEngine();
55 
56  void clear();
57  void destroy();
58  void create();
59  void initializeScene(std::string path);
60 
61  void drawScene();
62  void resize(int _w, int _h);
63  void update();
64 
65  void toggleAnimation();
66  void toggleOrbits();
67  void toggleHabitableZone();
68  void toggleCoordinateAxes();
69  void toggleUnitCircles();
70  void toggleScaled();
71  void toggleSkybox();
72  void setDate(double _julianDay);
73  void setSpeed(double _daysPerUpdate);
74  void setUnitCircles(double _unitSize, int _unit, int _numberOfRings);
75  void setIsCoreView(bool _isCoreView);
76  void setIsMapView(bool _isMapView);
77 
78  //comparison stuff
79  void setSceneToDisplay(geAstro::SceneType _sceneToDisplay);
80  void repositionDrawables(geAstro::SceneType _sceneToDisplay);
81 
82  double getSpeed() const;
83 
84  void setSelectedHasChanged(bool _selectedHasChanged);
85  bool getSelectedHasChanged();
86  void setSystemInFocus(int _systemIndex);
87 
88  const std::shared_ptr<System> getSystemByName(std::string _name);
89  const std::shared_ptr<Universe> getUniverse();
90 
91  vmml::Vector3i getDate();
92  vmml::Vector2d get2dPoint(vmml::Vector3d _p);
93  vmml::Vector2d get2dPoint(vmml::Vector3d _p, vmml::Matrix4d _modelMatrix);
94 
95  /*void isUsingPassiveCamera(bool _value);
96  bool isUsingPassiveCamera();
97  */
98  void toggleDebugMap();
99 
100  void setPickingEvent(PickingEvent pe);
101  void setPickingCoordinates(vmml::Vector2i _coord);
102 
103  const std::vector<std::shared_ptr<System>>& getSystems();
104 
105  std::shared_ptr<System> getSystemInFocus();
106 
107 
108  void setMousePosition(int x, int y);
109  vmml::Vector2i getMousePosition();
110 
114  void navigateBack();
115 
116  void reloadShaders();
117 
119 
120  const std::vector<UIBodyInfo>& getSystemsUIInfo() const;
121  const std::vector<UIBodyInfo>& getSunsUIInfo() const;
122  const std::vector<UIBodyInfo>& getPlanetUIInfo() const;
123  const std::vector<UIBodyInfo>& getMoonUIInfo() const;
124  const std::vector<UIBodyInfo>& getSmallBodyObjectUIInfo() const;
125  const UIBodyInfo& getSelectedUIInfo() const;
126  const std::vector<int>& getUIInfoSizes() const;
127 
129 
131 
132  private:
133  void updateFramebufferStandardID();
134  void setUpUpdateJobs();
135 
136  void setupCameras();
137  void setCamerasForResize();
138  vmml::Vector4d calculateOrthoCamCoordinates();
139 
140  vmml::Vector2d calculateLightPositionOnScreen();
141 
142  void drawVisualizationScene();
143  void drawOverviewMapScene();
144  void drawPlanetComparisonScene();
145 
146  void drawBodies();
147  void evaluatePickingEvent();
148  void drawOrbits();
149  void drawHabitableZone();
150  void drawSkybox();
151  void drawDebugMap();
152 
153  XMLGetter* xmlGetter;
154 
155  std::shared_ptr<ge::Shader> programForUnitCircles;
156  std::shared_ptr<ge::Shader> programForSkybox;
157  std::shared_ptr<ge::Shader> programForUtilities;
158  std::shared_ptr<ge::Shader> programForDebug;
159  std::shared_ptr<ge::Shader> programForCoordinateSystem;
160 
161  // The universe
162  std::shared_ptr<Universe> universe;
163  // CoordinateCross
164  AstroCoordinateSystem coordinateSystem;
165  // grid for comparison view
166  ComparisonGrid comparisonGrid;
167  // unit circles to draw
168  std::shared_ptr<UnitCircles> unitCircles;
169  // Basic scene state
170  ge::SceneStateSet sceneStates[2];
171 
172  double initialDate;
173  double currentDate;
174  double daysPerUpdate;
175 
176  std::string shaderPath;
177  std::string skyboxPath;
178 
179  bool pauseAnimation;
180  bool showOrbits;
181  bool showSkybox;
182  bool smallBodiesAsPointCloud;
183  bool isCoreView;
184  bool isMapView;
185 
186  SceneType sceneToDisplay;
187 
188  ge::FrameBufferObject bodiesFbo;
189  ge::FrameBufferObject orbitsFbo;
190  ge::FrameBufferObject habZoneAndSkyboxFbo;
191 
192  //FBOs for sun rendering
193  ge::FrameBufferObject sunBuffer;
194 
195  bool selectedHasChanged;
196  int systemInFocus;
197 
198  //composition for sun rendering blur
199  geExoViewer::GaussianBlurComposition gaussianBlurPassHorizontal;
200  geExoViewer::GaussianBlurComposition gaussianBlurPassVertical;
201 
202  //composition for bloom
203  geExoViewer::BloomComposition bloomComposition;
204 
205  //composition for planet comparison
206  geExoViewer::ComparisonComposition comparisonComposition;
207 
208  //sun rendering rotation
209  float sunRotation;
210  float sunOverlayRotation;
211 
212  bool usingEQCamera;
213 
214  geExoViewer::ExoComposition outlineComposition;
215  std::shared_ptr<ge::Skybox> skybox;
216 
218  ge::ViewFrustumProperties vfpropOrtho;
219 
220  vmml::Vector2i screenExtent;
221  PickingEvent pickingevent;
222  vmml::Vector2i pickCoord;
223  vmml::Vector2i mousePosition;
224 
225  geUtil::DebugMapProvider* debugMapProvider;
226  geUtil::DebugLogger openglDebugLogger;
227 
228  std::vector<OrbitJob*> runnables;
229  std::vector<UIBodyInfo> systemsUIInfo;
230  std::vector<UIBodyInfo> sunsUIInfo;
231  std::vector<UIBodyInfo> planetUIInfo;
232  std::vector<UIBodyInfo> moonUIInfo;
233  std::vector<UIBodyInfo> smallBodyObjectUIInfo;
234  UIBodyInfo selectedUIInfo;
235  std::vector<int> uiInfoSizeSums;
236 
237  //comparison stuff
238  Comparisoner comparisoner;
239  };
240 
241 }
242 #endif
void setSpeed(double _daysPerUpdate)
Definition: ExoEngine.cpp:780
double getSpeed() const
Definition: ExoEngine.cpp:453
~ExoEngine()
Definition: ExoEngine.cpp:13
void reloadShaders()
Definition: ExoEngine.cpp:1032
void setSceneToDisplay(geAstro::SceneType _sceneToDisplay)
Definition: ExoEngine.cpp:985
Definition: GaussianBlurComposition.h:8
const UIBodyInfo & getSelectedUIInfo() const
Definition: ExoEngine.cpp:1226
void setIsMapView(bool _isMapView)
Definition: ExoEngine.cpp:981
void setMousePosition(int x, int y)
Definition: ExoEngine.cpp:953
void toggleAnimation()
Definition: ExoEngine.cpp:726
void navigateToNewSelectionInSystem(UniverseSelection _sel)
Definition: DebugLogger.h:22
void navigateBack()
Definition: ExoEngine.cpp:972
vmml::Vector2d get2dPoint(vmml::Vector3d _p)
Definition: ExoEngine.cpp:863
void setDate(double _julianDay)
Definition: ExoEngine.cpp:937
Definition: Comparisoner.h:55
Definition: FrameBufferObject.h:20
void setUnitCircles(double _unitSize, int _unit, int _numberOfRings)
Definition: ExoEngine.cpp:785
const std::shared_ptr< System > getSystemByName(std::string _name)
Definition: ExoEngine.cpp:762
void navigateToCurrentSelection()
Definition: ExoEngine.cpp:967
Definition: AstroCommon.h:50
void toggleOrbits()
Definition: ExoEngine.cpp:730
const std::shared_ptr< Universe > getUniverse()
Definition: ExoEngine.cpp:1289
void update()
Definition: ExoEngine.cpp:457
vmml::Vector3i getDate()
Definition: ExoEngine.cpp:501
Definition: AstroCommon.h:18
const std::vector< std::shared_ptr< System > > & getSystems()
Definition: ExoEngine.cpp:758
void sortUIInfoForSystemInFocus()
Definition: ExoEngine.cpp:1036
void toggleUnitCircles()
Definition: ExoEngine.cpp:746
Definition: Universe.h:23
Definition: ComparisonGrid.h:10
void initializeScene(std::string path)
Definition: ExoEngine.cpp:88
void toggleScaled()
Definition: ExoEngine.cpp:750
SceneType
Definition: ExoEngine.h:48
Definition: ExoEngine.h:46
Definition: ComparisonComposition.h:9
Definition: ExoEngine.h:46
Definition: Engine.h:20
void navigateToNewSelection(UniverseSelection _sel)
Definition: ExoEngine.cpp:960
void setPickingEvent(PickingEvent pe)
Definition: ExoEngine.cpp:718
ExoEngine()
Definition: ExoEngine.cpp:8
void destroy()
Definition: ExoEngine.cpp:82
void drawScene()
Definition: ExoEngine.cpp:506
void setSystemInFocus(int _systemIndex)
Definition: ExoEngine.cpp:770
const std::vector< int > & getUIInfoSizes() const
Definition: ExoEngine.cpp:1230
void resize(int _w, int _h)
Definition: ExoEngine.cpp:272
std::shared_ptr< System > getSystemInFocus()
Definition: ExoEngine.cpp:766
void setPickingCoordinates(vmml::Vector2i _coord)
Definition: ExoEngine.cpp:722
void setIsCoreView(bool _isCoreView)
Definition: ExoEngine.cpp:977
Definition: AstroCoordinateSystem.h:13
void toggleCoordinateAxes()
Definition: ExoEngine.cpp:742
Definition: ExoEngine.h:46
Definition: BloomComposition.h:8
Definition: ViewFrustum.h:18
Definition: SceneStateSet.h:41
const std::vector< UIBodyInfo > & getSystemsUIInfo() const
Definition: ExoEngine.cpp:1206
const std::vector< UIBodyInfo > & getSmallBodyObjectUIInfo() const
Definition: ExoEngine.cpp:1222
vmml::Vector2i getMousePosition()
Definition: ExoEngine.cpp:956
Comparisoner & getComparisoner()
Definition: ExoEngine.cpp:1293
Definition: ExoEngine.h:48
Definition: ExoEngine.h:48
const std::vector< UIBodyInfo > & getSunsUIInfo() const
Definition: ExoEngine.cpp:1210
UniverseSelection getSelectionForUIInfoID(int _idx) const
Definition: ExoEngine.cpp:1234
Definition: DebugMapProvider.h:11
void toggleHabitableZone()
Definition: ExoEngine.cpp:738
PickingEvent
Definition: ExoEngine.h:46
Definition: ExoComposition.h:16
const std::vector< UIBodyInfo > & getPlanetUIInfo() const
Definition: ExoEngine.cpp:1214
const std::vector< UIBodyInfo > & getMoonUIInfo() const
Definition: ExoEngine.cpp:1218
void setSelectedHasChanged(bool _selectedHasChanged)
Definition: ExoEngine.cpp:859
void create()
Definition: ExoEngine.cpp:85
Definition: ExoEngine.h:50
void repositionDrawables(geAstro::SceneType _sceneToDisplay)
Definition: ExoEngine.cpp:1004
Definition: XMLGetter.h:10
Definition: ExoEngine.h:48
void toggleSkybox()
Definition: ExoEngine.cpp:734
bool getSelectedHasChanged()
Definition: ExoEngine.cpp:855
void clear()
Definition: ExoEngine.cpp:18
Definition: ExoEngine.h:46
void toggleDebugMap()
Definition: ExoEngine.cpp:949