QGIS API Documentation 3.41.0-Master (af5edcb665c)
Loading...
Searching...
No Matches
qgs3dsceneexporter.h
Go to the documentation of this file.
1/***************************************************************************
2 qgs3dsceneexporter.h
3 --------------------------------------
4 Date : June 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 QGS3DSCENEEXPORTER_H
17#define QGS3DSCENEEXPORTER_H
18
19#include <Qt3DCore/QEntity>
20#include <Qt3DExtras/QPlaneGeometry>
21#include <Qt3DRender/QSceneLoader>
22#include <Qt3DRender/QMesh>
23#include <QMap>
24#include <QFile>
25#include <QVector3D>
26#include <QMatrix4x4>
27
28#include "qgs3dexportobject.h"
29#include "qgsfeatureid.h"
30
32class QgsTerrainTileEntity;
33class QgsTerrainEntity;
37class QgsChunkNode;
39class QgsTerrainTextureGenerator;
40class QgsVectorLayer;
42class QgsLine3DSymbol;
44class QgsMeshEntity;
45class TestQgs3DRendering;
46
47#define SIP_NO_FILE
48
57class _3D_EXPORT Qgs3DSceneExporter : public Qt3DCore::QEntity
58{
59 Q_OBJECT
60
61 public:
63
65 {
66 for ( Qgs3DExportObject *obj : mObjects )
67 delete obj;
68 }
69
74 bool parseVectorLayerEntity( Qt3DCore::QEntity *entity, QgsVectorLayer *layer );
75
77 void parseTerrain( QgsTerrainEntity *terrain, const QString &layer );
78
83 bool save( const QString &sceneName, const QString &sceneFolderPath, int precision = 6 );
84
86 void setSmoothEdges( bool smoothEdges ) { mSmoothEdges = smoothEdges; }
88 bool smoothEdges() const { return mSmoothEdges; }
89
91 void setExportNormals( bool exportNormals ) { mExportNormals = exportNormals; }
93 bool exportNormals() const { return mExportNormals; }
94
96 void setExportTextures( bool exportTextures ) { mExportTextures = exportTextures; }
98 bool exportTextures() const { return mExportTextures; }
99
101 void setTerrainResolution( int resolution ) { mTerrainResolution = resolution; }
103 int terrainResolution() const { return mTerrainResolution; }
104
106 void setTerrainTextureResolution( int resolution ) { mTerrainTextureResolution = resolution; }
108 int terrainTextureResolution() const { return mTerrainTextureResolution; }
110 void setScale( float scale ) { mScale = scale; }
112 float scale() const { return mScale; }
113
114 private:
116 QVector<Qgs3DExportObject *> processInstancedPointGeometry( Qt3DCore::QEntity *entity, const QString &objectNamePrefix );
118 QVector<Qgs3DExportObject *> processSceneLoaderGeometries( Qt3DRender::QSceneLoader *sceneLoader, const QString &objectNamePrefix );
120 Qgs3DExportObject *processGeometryRenderer( Qt3DRender::QGeometryRenderer *mesh, const QString &objectNamePrefix, const QMatrix4x4 &sceneTransform = QMatrix4x4() );
122 void processEntityMaterial( Qt3DCore::QEntity *entity, Qgs3DExportObject *object );
124 QVector<Qgs3DExportObject *> processLines( Qt3DCore::QEntity *entity, const QString &objectNamePrefix );
126 Qgs3DExportObject *processPoints( Qt3DCore::QEntity *entity, const QString &objectNamePrefix );
127
129 QgsTerrainTileEntity *getFlatTerrainEntity( QgsTerrainEntity *terrain, QgsChunkNode *node );
131 QgsTerrainTileEntity *getDemTerrainEntity( QgsTerrainEntity *terrain, QgsChunkNode *node );
133 QgsTerrainTileEntity *getMeshTerrainEntity( QgsTerrainEntity *terrain, QgsChunkNode *node );
134
136 void parseDemTile( QgsTerrainTileEntity *tileEntity, const QString &layerName );
138 void parseFlatTile( QgsTerrainTileEntity *tileEntity, const QString &layerName );
140 void parseMeshTile( QgsTerrainTileEntity *meshEntity, const QString &layerName );
141
142 QString getObjectName( const QString &name );
143
144 private:
145 QMap<QString, int> usedObjectNamesCounter;
146 QVector<Qgs3DExportObject *> mObjects;
147
148 bool mSmoothEdges = false;
149 int mTerrainResolution = 128;
150 bool mExportNormals = true;
151 bool mExportTextures = false;
152 int mTerrainTextureResolution = 512;
153 float mScale = 1.0f;
154
155 QSet<QgsFeatureId> mExportedFeatureIds;
156
157 friend QgsPolygon3DSymbol;
158 friend QgsLine3DSymbol;
159 friend QgsPoint3DSymbol;
160 friend TestQgs3DRendering;
161};
162
163#endif // QGS3DSCENEEXPORTER_H
Manages the data of each object of the scene (positions, normals, texture coordinates ....
Entity that handles the exporting of 3D scene.
bool exportTextures() const
Returns whether the textures will be exported.
int terrainResolution() const
Returns the terrain resolution.
void setExportTextures(bool exportTextures)
Sets whether the textures will be exported.
void setTerrainResolution(int resolution)
Sets the terrain resolution.
bool smoothEdges() const
Returns whether the triangles will look smooth.
void setTerrainTextureResolution(int resolution)
Sets the terrain texture resolution.
bool exportNormals() const
Returns whether the normals will be exported.
float scale() const
Returns the scale of the exported 3D model.
void setScale(float scale)
Sets the scale of the exported 3D model.
void setExportNormals(bool exportNormals)
Sets whether the normals will be exported.
void setSmoothEdges(bool smoothEdges)
Sets whether the triangles will look smooth.
int terrainTextureResolution() const
Returns the terrain resolution.
Represents a vector layer which manages a vector based data sets.
int precision