GlobeEngine
GlobeEngine.h
Go to the documentation of this file.
1 
8 #ifndef GlobeEngine_GlobeEngine_h
9 #define GlobeEngine_GlobeEngine_h
10 
11 #include <math.h>
12 #include <ctime>
13 #include <iostream>
14 #include <stdio.h>
15 #include <vector>
16 #include "OpenGL_Includes.h"
17 #include "Engine.h"
18 #include "FrameBufferObject.h"
19 #include "Shader.h"
20 #include "FlightCamera.h"
21 #include "OrthographicMapCamera.h"
22 #include "Common.h"
23 #include "CoordinateSystem.h"
24 #include "ArcBallCamera.h"
25 #include "Globe.h"
26 #include "SceneStateSet.h"
27 #include "DebugMap.h"
28 #include "SceneBluePrint.h"
29 #include "Cube.h"
30 #include "DrawableComponent.h"
31 #include "ColorisationTable.h"
32 #include "GlobeComposition.h"
33 #include "Skybox.h"
34 #include "Cube.h"
35 #include "Plane.h"
36 #include "DebugLogger.h"
37 #include "Timer.h"
38 #include "StyleCollection.h"
39 #include "AnimationPath.h"
40 #include "VolumeRenderer.h"
41 
42 namespace geGIS {
43 
44  class ModelLayer;
45 
46 
48  {
50  GLint pickResultGroup; // ID of the type of vector data
51  GLint pickResultID; // ID of the vector data set
52  GLint entityID; // ID of the picked entity of a vector data set
53  };
54 
56  {
57  GLuint colorChannel1;
58  GLuint colorChannel2;
59  GLuint depthChannel;
60  };
61 
62  class GlobeEngine : public ge::Engine
63  {
64  public:
65  GlobeEngine();
66  ~GlobeEngine();
67 
68  void clear();
69  void destroy();
70  void create(const std::shared_ptr<geGIS::SceneBlueprint>& _scene);
71  void setModelAndBluePrintReference(std::shared_ptr<geGIS::ModelLayer> _modelLayer);
72 
73  void initializeScene(std::string _pathFile = 0);
74  void drawScene();
75  void resize(int _w, int _h);
76  void update();
77 
78  void drawUtilities(std::shared_ptr<ge::Camera> _cam);
79  void drawDecals(std::shared_ptr<ge::Camera> _cam);
80  void selectPixel(int x, int y);
81  void showCameraFrustums(bool _in);
82  void setEditortable(geData::HeightColorTable _colortable);
83 
84  void requestOcclusionQuery();
85  void setAAWeight(float _in);
86  void setAAActive(bool _in) ;
87  void setBackgroundColor(vmml::Vector3f _color);
88 
89  void setPickingColor(vmml::Vector3f _color){
90  this->pickingColor = _color;
91  }
92 
93  void setPickingOffset(vmml::Vector2f _offset){
94  this->pickingOffset = _offset;
95  }
96 
97  //void setColortableIndex(int _value);
98  //void setStencilInDepth(bool _in);
99  void saveScreenshot(std::string _filePath, int _bufferID = 0);
100 
101  void showSkybox(bool _in);
102  //std::vector<std::string> getColortableNames();
103 
104  // composition property
105  void setSceneCompositionHandleForStencilTexture(std::shared_ptr<ge::TextureHandle> _in);
106 
107  // other rendering effects
108  void isShadowMappingEnabled(bool _in);
109  bool isShadowMappingEnabled();
110 
111  void isAmbientOcclusionEnabled(bool _in);
113 
115  /* void setSSAOCompositionTotalStrength(double _in);
116  void setSSAOCompositionStrength(double _in);
117  void setSSAOCompositionOffset(double _in);
118  void setSSAOCompositionFalloff(double _in);
119  void setSSAOCompositionRadius(double _in);*/
120  void setSuperSamplingMultiplicator(double _in);
121  double getSuperSamplingMultiplicator(double _in);
122 
124 
125  void moveCameraToPosition(vmml::Vector3d _pos);
126 
127  vmml::Vector2d get2dPoint(vmml::Vector3d _p, vmml::Matrix4d _modelMatrix = vmml::Matrix4d::IDENTITY);
128 
129  void enableEdgeHightlighting(bool _in);
130  void setEdgeHightlightingThreshold(float _in);
131 
133 
134  // GPU Feature drawing
135  bool isClusteredShadingEnabled() const;
136  bool isMortonOrderShadingEnabled() const;
137 
139  void setGPUBufferHandle(GLuint _in, GLuint _inBound, unsigned int _maxDepth, GLuint _attrHandle=0);
140  void setGPUFeatureLineRadius(double _rad, double _maxRad);
141  void setGPUMouseLensRadius(float _in);
142  void setGPUMouseLensCategory(int _in);
143  void setRenderingWithTerrain(bool _terrainVis);
144  void setRenderingWithVolume(bool _volumeVis);
145 
147  void setMouseCoordForGPUFeature(vmml::Vector2f _mouseCoord);
148  std::shared_ptr<ge::Shader> getActiveCompositionShader();
149 
150  // other functions
152 
153  // Camera animation
154  void startCameraAnimation();
155 
156  void setReportActive(bool _in);
157  void enableVolumeRenderer(vmml::Vector3d _scale, vmml::Vector3d _position);
158  void disableVolumeRenderer();
159 
160  std::shared_ptr<geFlow::VolumeRenderer> getVolumeRenderer();
161  std::shared_ptr<geFlow::VolumeComposition> getVolumeComposition();
162  void setTFforVolumeRendering(unsigned char* _transferFunctionData);
163  void applyVolumeInfo();
164 
165  private:
166  using ge::Engine::create; // implicitly hidden
167 
168  void paintAccumulatedLines();
169  void drawOcclusionQueryPass();
170  void drawScreenshot(bool _ssaoActive);
171  void drawAmbientOcclusionPass();
172  void drawMainPass();
173  void drawShadowMapPass();
174  void drawStencilBuffer(std::shared_ptr<ge::Camera> _cam);
175  void drawFeatures(std::shared_ptr<ge::Camera> _cam);
176  void drawClusteredVectorMaps();
177  void setupSceneCameras();
178  void pickFromFramebuffer(int _AASizeMultiplicator = 1);
179  void drawDebugMaps();
180 
181  GLfloat renderModeValue;
182  std::shared_ptr<ge::Shader> programForDebug;
183  std::shared_ptr<ge::Shader> programForDebugDepth;
184  std::shared_ptr<ge::Shader> programForDebugStencil;
185  std::shared_ptr<ge::Shader> programForDebugInt;
186  std::shared_ptr<ge::Shader> programForUtilities;
187  std::shared_ptr<ge::Shader> programForSkybox;
188  std::shared_ptr<ge::Shader> programForColoredGeometry;
189  std::shared_ptr<ge::Shader> programForCubes;
190  std::shared_ptr<ge::Shader> computeProgramForClusteredShading;
191 
192  // CoordinateCross
193  ge::CoordinateSystem coordinateSystem;
194 
195  // Scenegraph Scalable objects
196  std::shared_ptr<geGIS::ModelLayer> modellayer;
197  std::shared_ptr<SceneBlueprint> sceneBlueprint;
198  ge::SceneStateSet sceneStates[5];
199 
200  GlobeComposition sceneComposition;
201  ResampleComposition resampleComposition;
202 
203  Globe globe;
204  ge::Skybox* skybox;
205  ge::Plane* plane;
206 
207  std::shared_ptr<geData::AnimationPath> cameraFlight;
208  float elapsedTime;
209  float maxTime;
210  bool animationInProgress;
211 
212  ge::FrameBufferObject gBuffer;
213  ge::FrameBufferObject occlusionFBO;
214  ge::FrameBufferObject stencilFBO;
215  ge::FrameBufferObject stencilColorFBO;
216  ge::FrameBufferObject shadowMap;
217  ge::FrameBufferObject accumulatedLineInfo;
218  ge::FrameBufferObject decalpass;
219 
220  enum ge::DrawableComponent::RENDERSTATE renderstate;
221  enum ge::Camera::CAMERATYPE cameratype;
222 
223  // camera properties
224  int cameraIdxOcclusions;
225  int cameraIdxShadows;
226 
227  // planes for occlusion queries
228  ge::Plane scanplanes[3];
229 
230 
231  // Picking result
232  PickingResult toPick;
233  PickingResult previous;
234  vmml::Vector3f pickingColor;
235  vmml::Vector2f pickingOffset;
236 
237  // Debug
238  ge::Timer timer;
239  geUtil::DebugMap debugmaps[9];
240  geUtil::DebugLogger openglDebugLogger;
241 
242  ge::DrawableComponent::RENDERSTATE occlusionState;
243  ge::DrawableComponent::RENDERSTATE occlusionRequestState;
244  bool inOcclusionQueryProcess;
245 
246  // Antialiasing
247  float antialiasingWeight;
248  bool activeAA;
249  double superSamplingSizeMultiplicator;
250  bool superSamplingActive;
251 
252  // Stencil colorisation
253  //std::vector< std::shared_ptr<geData::ColorisationTable> > colorisationTables;
254  //int tableIndex;
255  //bool stencilColorInDepth;
256 
257  // hi res screenshot
258  int screenShot;
259  std::string screenShotFilePath;
260 
261  // shadow mapping
262  bool shadowMappingEnabled;
263  vmml::Matrix4d invViewMatrix;
264  vmml::Matrix4d depthTextureMatrix;
265  vmml::Matrix4d biasMatrix;
266 
267  // Ambient occlusion
268  SSAOComposition ssaoComposition;
269 
270  std::shared_ptr<geGIS::SceneBlueprint> earthscene;
271 
272  // GBuffer information
273  GBufferHandles gbufferInfo;
274 
275  // Clustered Shading on
276  bool clusteredShadingActive;
277  bool mortonOrderShadingActive;
278  bool mouseLensForGPUFeaturesActive;
279 
280  // Shader recompiler
281  bool recompileShaders;
282 
283  // Texture
284  std::shared_ptr<ge::Texture2Drgba> computeTexture;
285 
286  // Volume Rendering
287  std::shared_ptr<geFlow::VolumeRenderer> volumeRenderer;
288  std::string volumeShaderPath;
289 
290  bool reportActive;
291  bool reportCommandApplied;
292  };
293 }
294 #endif
void startCameraAnimation()
Definition: GlobeEngine.cpp:1365
void saveScreenshot(std::string _filePath, int _bufferID=0)
Definition: GlobeEngine.cpp:1158
vmml::Vector2d get2dPoint(vmml::Vector3d _p, vmml::Matrix4d _modelMatrix=vmml::Matrix4d::IDENTITY)
Definition: GlobeEngine.cpp:1205
void setAAWeight(float _in)
Definition: GlobeEngine.cpp:1143
~GlobeEngine()
Definition: GlobeEngine.cpp:48
void showSkybox(bool _in)
Definition: GlobeEngine.cpp:1173
GLint entityID
Definition: GlobeEngine.h:52
void setPickingColor(vmml::Vector3f _color)
Definition: GlobeEngine.h:89
void selectPixel(int x, int y)
Definition: GlobeEngine.cpp:1133
void setRenderingWithVolume(bool _volumeVis)
Definition: GlobeEngine.cpp:1201
void setRenderingWithTerrain(bool _terrainVis)
Definition: GlobeEngine.cpp:1197
void drawDecals(std::shared_ptr< ge::Camera > _cam)
Definition: GlobeEngine.cpp:689
GLuint colorChannel2
Definition: GlobeEngine.h:58
Definition: ClusterGrid.h:17
int pickCoordinates[2]
Definition: GlobeEngine.h:49
Definition: StyleCollection.h:45
void updateFramebufferStandardID()
Definition: GlobeEngine.cpp:1090
Definition: DebugMap.h:18
Definition: Plane.h:26
void setGPUFeatureLineRadius(double _rad, double _maxRad)
Definition: GlobeEngine.cpp:1279
Definition: Skybox.h:19
void moveCameraToPosition(vmml::Vector3d _pos)
Definition: GlobeEngine.cpp:1118
Definition: DebugLogger.h:22
void setSceneCompositionHandleForStencilTexture(std::shared_ptr< ge::TextureHandle > _in)
Definition: GlobeEngine.cpp:1210
Definition: FrameBufferObject.h:20
Definition: GlobeEngine.h:47
Definition: GlobeEngine.h:62
std::shared_ptr< geFlow::VolumeRenderer > getVolumeRenderer()
Definition: GlobeEngine.cpp:1346
void showCameraFrustums(bool _in)
Definition: GlobeEngine.cpp:1110
Definition: GlobeComposition.h:161
virtual void create()
Definition: Engine.cpp:61
double getSuperSamplingMultiplicator(double _in)
Definition: GlobeEngine.cpp:1247
void drawScene()
Definition: GlobeEngine.cpp:558
void resize(int _w, int _h)
Definition: GlobeEngine.cpp:1057
Definition: GlobeComposition.h:201
GLint pickResultID
Definition: GlobeEngine.h:51
bool isMortonOrderShadingEnabled() const
Definition: GlobeEngine.cpp:1255
RENDERSTATE
Definition: DrawableComponent.h:28
GLint pickResultGroup
Definition: GlobeEngine.h:50
Definition: ColorisationTable.h:20
Definition: Globe.h:17
void setSSAOParameter(SSAOParameter _in)
Definition: GlobeEngine.cpp:1231
void setSuperSamplingMultiplicator(double _in)
Definition: GlobeEngine.cpp:1243
Definition: Engine.h:20
void setGPUMouseLensCategory(int _in)
Definition: GlobeEngine.cpp:1287
void setBackgroundColor(vmml::Vector3f _color)
Definition: GlobeEngine.cpp:1164
GBufferHandles getGBufferHandles() const
Definition: GlobeEngine.cpp:700
void clear()
Definition: GlobeEngine.cpp:54
bool isShadowMappingEnabled()
Definition: GlobeEngine.cpp:1219
Definition: GlobeComposition.h:48
void setGPUStyleBufferHandles(geGIS::StyleCollectionUniformHandles _in)
Definition: GlobeEngine.cpp:1275
void setModelAndBluePrintReference(std::shared_ptr< geGIS::ModelLayer > _modelLayer)
Definition: GlobeEngine.cpp:85
void initializeScene(std::string _pathFile=0)
Definition: GlobeEngine.cpp:91
std::shared_ptr< geFlow::VolumeComposition > getVolumeComposition()
Definition: GlobeEngine.cpp:1341
void setEditortable(geData::HeightColorTable _colortable)
void setEdgeHightlightingThreshold(float _in)
Definition: GlobeEngine.cpp:1239
bool isAmbientOcclusionEnabled()
Definition: GlobeEngine.cpp:1227
void enableEdgeHightlighting(bool _in)
Definition: GlobeEngine.cpp:1235
void setReportActive(bool _in)
Definition: GlobeEngine.cpp:1291
void disableVolumeRenderer()
Definition: GlobeEngine.cpp:1336
GlobeEngine()
Definition: GlobeEngine.cpp:27
GLuint depthChannel
Definition: GlobeEngine.h:59
void setGPUMouseLensRadius(float _in)
Definition: GlobeEngine.cpp:1283
void enableVolumeRenderer(vmml::Vector3d _scale, vmml::Vector3d _position)
Definition: GlobeEngine.cpp:1296
void setPickingOffset(vmml::Vector2f _offset)
Definition: GlobeEngine.h:93
std::shared_ptr< ge::Shader > getActiveCompositionShader()
Definition: GlobeEngine.cpp:1350
void drawUtilities(std::shared_ptr< ge::Camera > _cam)
Definition: GlobeEngine.cpp:865
Definition: SceneStateSet.h:41
void requestOcclusionQuery()
Definition: GlobeEngine.cpp:1128
void setMouseCoordForGPUFeature(vmml::Vector2f _mouseCoord)
Definition: GlobeEngine.cpp:1358
void update()
Definition: GlobeEngine.cpp:383
CAMERATYPE
Definition: Camera.h:21
void setAAActive(bool _in)
Definition: GlobeEngine.cpp:1148
void enableGPUFeatures(geGIS::GPUFeatureFlags _in)
Definition: GlobeEngine.cpp:1259
GLuint colorChannel1
Definition: GlobeEngine.h:57
void applyVolumeInfo()
Definition: GlobeEngine.cpp:1324
void setTFforVolumeRendering(unsigned char *_transferFunctionData)
Definition: GlobeEngine.cpp:1370
void recompileShadersAfterNextUpdate()
Definition: GlobeEngine.cpp:1354
Definition: Timer.h:17
bool isClusteredShadingEnabled() const
Definition: GlobeEngine.cpp:1251
Definition: GlobeComposition.h:92
void destroy()
Definition: GlobeEngine.cpp:74
Definition: CoordinateSystem.h:17
void setGPUBufferHandle(GLuint _in, GLuint _inBound, unsigned int _maxDepth, GLuint _attrHandle=0)
Definition: GlobeEngine.cpp:1269
Definition: GlobeComposition.h:17
Definition: GlobeEngine.h:55