-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqgsabstract3dengine.h
149 lines (127 loc) · 4.84 KB
/
qgsabstract3dengine.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/***************************************************************************
qgsabstract3dengine.h
--------------------------------------
Date : July 2018
Copyright : (C) 2018 by Martin Dobias
Email : wonder dot sk at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSABSTRACT3DENGINE_H
#define QGSABSTRACT3DENGINE_H
#include "qgis_3d.h"
#include <QObject>
#include <QElapsedTimer>
#define SIP_NO_FILE
class QColor;
class QRect;
class QSurface;
namespace Qt3DCore
{
class QEntity;
}
namespace Qt3DRender
{
class QRenderSettings;
class QCamera;
class QFrameGraphNode;
}
class QgsShadowRenderingFrameGraph;
/**
* \ingroup 3d
* \brief Base class for 3D engine implementation. A 3D engine is responsible for setting up
* rendering with Qt3D. This means mainly:
*
* - creating Qt3D aspect engine and registering rendering aspect
* - setting up a camera, render settings and frame graph
*
* We have two implementations:
*
* - QgsWindow3DEngine - used for rendering on display (has a QWindow that can be embedded into QWidget)
* - QgsOffscreen3DEngine - renders scene to images
*
* \note Not available in Python bindings
* \since QGIS 3.4
*/
class _3D_EXPORT QgsAbstract3DEngine : public QObject
{
Q_OBJECT
public:
/**
* Constructor for QgsAbstract3DEngine with the specified \a parent object.
*/
QgsAbstract3DEngine( QObject *parent = nullptr );
//! Sets background color of the scene
virtual void setClearColor( const QColor &color ) = 0;
//! Sets whether frustum culling is enabled (this should make rendering faster by not rendering entities outside of camera's view)
virtual void setFrustumCullingEnabled( bool enabled ) = 0;
//! Sets root entity of the 3D scene
virtual void setRootEntity( Qt3DCore::QEntity *root ) = 0;
//! Returns access to the engine's render settings (the frame graph can be accessed from here)
virtual Qt3DRender::QRenderSettings *renderSettings() = 0;
//! Returns pointer to the engine's camera entity
virtual Qt3DRender::QCamera *camera() = 0;
//! Returns size of the engine's rendering area in pixels
virtual QSize size() const = 0;
//! Sets the size of the rendering area (in pixels)
virtual void setSize( QSize s ) = 0;
/**
* Starts a request for an image containing the depth buffer data of the engine.
* The function does not block - when the depth buffer image is captured, it is returned in depthBufferCaptured() signal.
* Only one image request can be active at a time.
*/
void requestDepthBufferCapture();
/**
* Starts a request for an image rendered by the engine.
* The function does not block - when the rendered image is captured, it is returned in imageCaptured() signal.
* Only one image request can be active at a time.
*/
void requestCaptureImage();
/**
* Returns the surface of the engine
*
* \since QGIS 3.14
*/
virtual QSurface *surface() const = 0;
/**
* Returns the shadow rendering frame graph object used to render the scene
*
* \since QGIS 3.18
*/
QgsShadowRenderingFrameGraph *frameGraph() { return mFrameGraph; }
/**
* Sets whether it will be possible to render to an image
*
* \note for QgsWindow3DEngine render capture will be disabled by default
* and for QgsOffscreen3DEngine it is enabled by default
* \since QGIS 3.18
*/
void setRenderCaptureEnabled( bool enabled );
/**
* Returns whether it will be possible to render to an image
* \since QGIS 3.18
*/
bool renderCaptureEnabled() const;
signals:
//! Emitted after a call to requestCaptureImage() to return the captured image.
void imageCaptured( const QImage &image );
/**
* Emitted after a call to requestDepthBufferCapture() to return the captured depth buffer.
* \note The depth buffer values are encoded into RGB channels and should be decoded with Qgs3DUtils::decodeDepth()
* \since QGIS 3.24
*/
void depthBufferCaptured( const QImage &image );
/**
* Emitted after a call to setSize()
* \since QGIS 3.30
*/
void sizeChanged();
protected:
QgsShadowRenderingFrameGraph *mFrameGraph = nullptr;
};
#endif // QGSABSTRACT3DENGINE_H