QGIS API Documentation 4.1.0-Master (01362494303)
Loading...
Searching...
No Matches
qgsframegraph.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsframegraph.h
3 --------------------------------------
4 Date : August 2020
5 Copyright : (C) 2020 by Belgacem Nedjima
6 Email : gb underscore nedjima at esi dot dz
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSFRAMEGRAPH_H
17#define QGSFRAMEGRAPH_H
18
19#include <map>
20
21#include "qgis_3d.h"
23
24#include <QWindow>
25#include <Qt3DRender/QBlitFramebuffer>
26#include <Qt3DRender/QCamera>
27#include <Qt3DRender/QCameraSelector>
28#include <Qt3DRender/QClearBuffers>
29#include <Qt3DRender/QCullFace>
30#include <Qt3DRender/QDebugOverlay>
31#include <Qt3DRender/QDepthTest>
32#include <Qt3DRender/QFrustumCulling>
33#include <Qt3DRender/QLayer>
34#include <Qt3DRender/QLayerFilter>
35#include <Qt3DRender/QParameter>
36#include <Qt3DRender/QPolygonOffset>
37#include <Qt3DRender/QRenderCapture>
38#include <Qt3DRender/QRenderStateSet>
39#include <Qt3DRender/QRenderSurfaceSelector>
40#include <Qt3DRender/QRenderTarget>
41#include <Qt3DRender/QRenderTargetSelector>
42#include <Qt3DRender/QTexture>
43#include <Qt3DRender/QViewport>
44
45#define SIP_NO_FILE
46
55class QgsLightSource;
59class QgsRectangle;
62
63
74class _3D_EXPORT QgsFrameGraph : public Qt3DCore::QEntity
75{
76 Q_OBJECT
77
78 public:
80 QgsFrameGraph( QSurface *surface, QSize s, Qt3DRender::QCamera *mainCamera, Qt3DCore::QEntity *root );
81
83 Qt3DRender::QFrameGraphNode *frameGraphRoot() { return mRenderSurfaceSelector; }
84
86 Qt3DRender::QCamera *mainCamera() { return mMainCamera; }
87
89 QgsPostprocessingEntity *postprocessingEntity() { return mPostprocessingEntity; }
90
92 Qt3DCore::QEntity *rubberBandsRootEntity() { return mRubberBandsRootEntity; }
93
95 Qt3DRender::QRenderCapture *renderCapture();
96
98 Qt3DRender::QRenderCapture *depthRenderCapture();
99
101 void setFrustumCullingEnabled( bool enabled );
102
104 void setClearColor( const QColor &clearColor );
105
107 void setSize( QSize s );
108
113 void setRenderCaptureEnabled( bool enabled );
114
119 void setDebugOverlayEnabled( bool enabled );
120
125 void setMsaaEnabled( bool enabled );
126
131 bool msaaEnabled() const { return mMsaaEnabled; }
132
134 QString dumpFrameGraph() const;
135
137 QString dumpSceneGraph() const;
138
146 void addClipPlanes( int nrClipPlanes );
147
154 void removeClipPlanes();
155
163 bool registerRenderView( std::unique_ptr<QgsAbstractRenderView> renderView, const QString &name, Qt3DRender::QFrameGraphNode *topNode = nullptr );
164
169 void unregisterRenderView( const QString &name );
170
175 void setRenderViewEnabled( const QString &name, bool enable );
176
181 bool isRenderViewEnabled( const QString &name );
182
187 QgsAbstractRenderView *renderView( const QString &name );
188
193 QgsShadowRenderView &shadowRenderView();
194
199 QgsForwardRenderView &forwardRenderView();
200
205 QgsDepthRenderView &depthRenderView();
206
211 QgsAmbientOcclusionRenderView &ambientOcclusionRenderView();
212
217 QgsOverlayTextureRenderView &overlayTextureRenderView();
218
223 QgsHighlightsRenderView &highlightsRenderView();
224
229 void updateShadowSettings( const QgsShadowSettings &shadowSettings, const QList<QgsLightSource *> &lightSources );
230
235 void updateDebugShadowMapSettings( const Qgs3DMapSettings &settings );
236
241 void updateDebugDepthMapSettings( const Qgs3DMapSettings &settings );
242
247 void updateAmbientOcclusionSettings( const QgsAmbientOcclusionSettings &settings );
248
253 void updateEyeDomeSettings( const Qgs3DMapSettings &settings );
254
255 static const QString FORWARD_RENDERVIEW;
256 static const QString SHADOW_RENDERVIEW;
257 static const QString AXIS3D_RENDERVIEW;
258 static const QString DEPTH_RENDERVIEW;
259 static const QString OVERLAY_RENDERVIEW;
261 static const QString AMBIENT_OCCLUSION_RENDERVIEW;
262 static const QString HIGHLIGHTS_RENDERVIEW;
263
264 private:
265 Qt3DRender::QRenderSurfaceSelector *mRenderSurfaceSelector = nullptr;
266 Qt3DRender::QViewport *mMainViewPort = nullptr;
267
268 Qt3DRender::QCamera *mMainCamera = nullptr;
269
270 // Post processing pass branch nodes:
271 Qt3DRender::QRenderTargetSelector *mRenderCaptureTargetSelector = nullptr;
272 Qt3DRender::QRenderCapture *mRenderCapture = nullptr;
273 // Post processing pass texture related objects:
274 Qt3DRender::QTexture2D *mRenderCaptureColorTexture = nullptr;
275 Qt3DRender::QTexture2D *mRenderCaptureDepthTexture = nullptr;
276
277 // Rubber bands pass
278 Qt3DRender::QCameraSelector *mRubberBandsCameraSelector = nullptr;
279 Qt3DRender::QLayerFilter *mRubberBandsLayerFilter = nullptr;
280 Qt3DRender::QRenderStateSet *mRubberBandsStateSet = nullptr;
281 Qt3DRender::QRenderTargetSelector *mRubberBandsRenderTargetSelector = nullptr;
282
283 QSize mSize = QSize( 1024, 768 );
284
285 QVector3D mLightDirection = QVector3D( 0.0, -1.0f, 0.0f );
286
287 Qt3DCore::QEntity *mRootEntity = nullptr;
288
289 Qt3DRender::QLayer *mRubberBandsLayer = nullptr;
290
291 QgsPostprocessingEntity *mPostprocessingEntity = nullptr;
292
293 Qt3DCore::QEntity *mRubberBandsRootEntity = nullptr;
294
296 QgsOverlayTextureEntity *mShadowTextureDebugging = nullptr;
298 QgsOverlayTextureEntity *mDepthTextureDebugging = nullptr;
299
300 void constructShadowRenderPass();
301 void constructForwardRenderPass();
302 void constructHighlightsPass();
303 void constructOverlayTexturePass( Qt3DRender::QFrameGraphNode *topNode = nullptr );
304 Qt3DRender::QFrameGraphNode *constructPostprocessingPass();
305 void constructDepthRenderPass();
306 void constructAmbientOcclusionRenderPass();
307 Qt3DRender::QFrameGraphNode *constructRubberBandsPass();
308 void constructMsaaBlitNodes();
309
310 Qt3DRender::QFrameGraphNode *constructSubPostPassForProcessing();
311 Qt3DRender::QFrameGraphNode *constructSubPostPassForRenderCapture();
312
313 bool mRenderCaptureEnabled = false;
314 bool mMsaaEnabled = false;
315 bool mMsaaBlitConfigured = false;
316 Qt3DRender::QBlitFramebuffer *mMsaaBlitNode = nullptr;
317 Qt3DRender::QBlitFramebuffer *mMsaaDepthBlitNode = nullptr;
318
319 // holds renderviews according to their name
320 std::map<QString, std::unique_ptr<QgsAbstractRenderView>> mRenderViewMap;
321
322 Q_DISABLE_COPY( QgsFrameGraph )
323};
324
325#endif // QGSFRAMEGRAPH_H
Definition of the world.
Base class for 3D render view.
Container class that holds different objects related to ambient occlusion rendering.
Contains the configuration of ambient occlusion rendering.
Object that controls camera movement based on user input.
Container class that holds different objects related to depth rendering.
Definition of a directional light in a 3D map scene.
Container class that holds different objects related to forward rendering.
bool msaaEnabled() const
Returns whether multisample anti-aliasing (MSAA) is enabled.
static const QString AMBIENT_OCCLUSION_RENDERVIEW
Ambient occlusion render view name.
Qt3DRender::QFrameGraphNode * frameGraphRoot()
Returns the root of the frame graph object.
QgsPostprocessingEntity * postprocessingEntity()
Returns the postprocessing entity.
static const QString FORWARD_RENDERVIEW
Qt3DCore::QEntity * rubberBandsRootEntity()
Returns entity for all rubber bands (to show them always on top).
static const QString SHADOW_RENDERVIEW
static const QString HIGHLIGHTS_RENDERVIEW
static const QString OVERLAY_RENDERVIEW
static const QString AXIS3D_RENDERVIEW
static const QString DEPTH_RENDERVIEW
Qt3DRender::QCamera * mainCamera()
Returns the main camera.
QgsFrameGraph(QSurface *surface, QSize s, Qt3DRender::QCamera *mainCamera, Qt3DCore::QEntity *root)
Constructor.
Container class that holds different objects related to highlighting identified features.
Base class for light sources in 3d scenes.
An entity responsible for rendering an overlay texture in 3D view.
Simple render view to preview overlay textures in 3D view.
An entity that is responsible for applying post processing effects.
A rectangle specified with double values.
Container class that holds different objects related to shadow rendering.
Contains configuration for rendering shadows.