/
scene.h
69 lines (57 loc) · 1.72 KB
/
scene.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
#ifndef SCENE_H
#define SCENE_H
#include "qgis_3d.h"
#include <Qt3DCore/QEntity>
namespace Qt3DRender
{
class QRenderSettings;
class QCamera;
}
namespace Qt3DLogic
{
class QFrameAction;
}
namespace Qt3DExtras
{
class QForwardRenderer;
}
class QgsMapLayer;
class CameraController;
class Map3D;
class Terrain;
class ChunkedEntity;
/**
* Entity that encapsulates our 3D scene - contains all other entities (such as terrain) as children.
*/
class _3D_EXPORT Scene : public Qt3DCore::QEntity
{
Q_OBJECT
public:
Scene( const Map3D &map, Qt3DExtras::QForwardRenderer *defaultFrameGraph, Qt3DRender::QRenderSettings *renderSettings, Qt3DRender::QCamera *camera, const QRect &viewportRect, Qt3DCore::QNode *parent = nullptr );
CameraController *cameraController() { return mCameraController; }
Terrain *terrain() { return mTerrain; }
private slots:
void onCameraChanged();
void onFrameTriggered( float dt );
void createTerrain();
void onLayerRenderer3DChanged();
void onLayersChanged();
void createTerrainDeferred();
void onBackgroundColorChanged();
private:
void addLayerEntity( QgsMapLayer *layer );
void removeLayerEntity( QgsMapLayer *layer );
private:
const Map3D &mMap;
//! Provides a way to have a synchronous function executed each frame
Qt3DLogic::QFrameAction *mFrameAction;
CameraController *mCameraController;
Terrain *mTerrain;
//! Forward renderer provided by 3D window
Qt3DExtras::QForwardRenderer *mForwardRenderer;
QList<ChunkedEntity *> chunkEntities;
//! Keeps track of entities that belong to a particular layer
QMap<QgsMapLayer *, Qt3DCore::QEntity *> mLayerEntities;
bool mTerrainUpdateScheduled = false;
};
#endif // SCENE_H