QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
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
27#include "qgs3dexportobject.h"
28#include "qgsfeatureid.h"
29
31class QgsTerrainTileEntity;
32class QgsTerrainEntity;
36class QgsChunkNode;
38class QgsTerrainTextureGenerator;
39class QgsVectorLayer;
41class QgsLine3DSymbol;
43class QgsMeshEntity;
44class TestQgs3DRendering;
45
46#define SIP_NO_FILE
47
56class _3D_EXPORT Qgs3DSceneExporter : public Qt3DCore::QEntity
57{
58 Q_OBJECT
59
60 public:
62
64 {
65 for ( Qgs3DExportObject *obj : mObjects )
66 delete obj;
67 }
68
73 bool parseVectorLayerEntity( Qt3DCore::QEntity *entity, QgsVectorLayer *layer );
74
76 void parseTerrain( QgsTerrainEntity *terrain, const QString &layer );
77
79 void save( const QString &sceneName, const QString &sceneFolderPath, int precision = 6 );
80
82 void setSmoothEdges( bool smoothEdges ) { mSmoothEdges = smoothEdges; }
84 bool smoothEdges() const { return mSmoothEdges; }
85
87 void setExportNormals( bool exportNormals ) { mExportNormals = exportNormals; }
89 bool exportNormals() const { return mExportNormals; }
90
92 void setExportTextures( bool exportTextures ) { mExportTextures = exportTextures; }
94 bool exportTextures() const { return mExportTextures; }
95
97 void setTerrainResolution( int resolution ) { mTerrainResolution = resolution; }
99 int terrainResolution() const { return mTerrainResolution; }
100
102 void setTerrainTextureResolution( int resolution ) { mTerrainTextureResolution = resolution; }
104 int terrainTextureResolution() const { return mTerrainTextureResolution; }
106 void setScale( float scale ) { mScale = scale; }
108 float scale() const { return mScale; }
109
110 private:
112 QVector<Qgs3DExportObject *> processInstancedPointGeometry( Qt3DCore::QEntity *entity, const QString &objectNamePrefix );
114 QVector<Qgs3DExportObject *> processSceneLoaderGeometries( Qt3DRender::QSceneLoader *sceneLoader, const QString &objectNamePrefix );
116 Qgs3DExportObject *processGeometryRenderer( Qt3DRender::QGeometryRenderer *mesh, const QString &objectNamePrefix, float sceneScale = 1.0f, QVector3D sceneTranslation = QVector3D( 0.0f, 0.0f, 0.0f ) );
118 void processEntityMaterial( Qt3DCore::QEntity *entity, Qgs3DExportObject *object );
120 QVector<Qgs3DExportObject *> processLines( Qt3DCore::QEntity *entity, const QString &objectNamePrefix );
122 Qgs3DExportObject *processPoints( Qt3DCore::QEntity *entity, const QString &objectNamePrefix );
123
125 QgsTerrainTileEntity *getFlatTerrainEntity( QgsTerrainEntity *terrain, QgsChunkNode *node );
127 QgsTerrainTileEntity *getDemTerrainEntity( QgsTerrainEntity *terrain, QgsChunkNode *node );
129 QgsTerrainTileEntity *getMeshTerrainEntity( QgsTerrainEntity *terrain, QgsChunkNode *node );
130
132 void parseDemTile( QgsTerrainTileEntity *tileEntity, const QString &layerName );
134 void parseFlatTile( QgsTerrainTileEntity *tileEntity, const QString &layerName );
136 void parseMeshTile( QgsTerrainTileEntity *meshEntity, const QString &layerName );
137
138 QString getObjectName( const QString &name );
139 private:
140 QMap<QString, int> usedObjectNamesCounter;
141 QVector<Qgs3DExportObject *> mObjects;
142
143 bool mSmoothEdges = false;
144 int mTerrainResolution = 128;
145 bool mExportNormals = true;
146 bool mExportTextures = false;
147 int mTerrainTextureResolution = 512;
148 float mScale = 1.0f;
149
150 QSet<QgsFeatureId> mExportedFeatureIds;
151
152 friend QgsPolygon3DSymbol;
153 friend QgsLine3DSymbol;
154 friend QgsPoint3DSymbol;
155 friend TestQgs3DRendering;
156};
157
158#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