18 #include <Qt3DRender/QGeometryRenderer> 19 #include <Qt3DExtras/QPlaneGeometry> 30 class FlatTerrainChunkLoader :
public QgsTerrainTileLoader
34 FlatTerrainChunkLoader( QgsTerrainEntity *terrain, QgsChunkNode *mNode );
36 Qt3DCore::QEntity *createEntity( Qt3DCore::QEntity *parent )
override;
39 Qt3DExtras::QPlaneGeometry *mTileGeometry =
nullptr;
46 FlatTerrainChunkLoader::FlatTerrainChunkLoader( QgsTerrainEntity *terrain, QgsChunkNode *node )
47 : QgsTerrainTileLoader( terrain, node )
53 Qt3DCore::QEntity *FlatTerrainChunkLoader::createEntity( Qt3DCore::QEntity *parent )
55 QgsTerrainTileEntity *entity =
new QgsTerrainTileEntity;
62 mTileGeometry =
new Qt3DExtras::QPlaneGeometry;
64 Qt3DRender::QGeometryRenderer *mesh =
new Qt3DRender::QGeometryRenderer;
65 mesh->setGeometry( mTileGeometry );
66 entity->addComponent( mesh );
70 createTextureComponent( entity );
74 Qt3DCore::QTransform *transform =
nullptr;
75 transform =
new Qt3DCore::QTransform();
76 entity->addComponent( transform );
81 double half = side / 2;
83 transform->setScale( side );
84 transform->setTranslation( QVector3D( bbox.
xMin + half, 0, bbox.
zMin + half ) );
86 entity->setEnabled(
false );
87 entity->setParent( parent );
97 return new FlatTerrainChunkLoader(
mTerrain, node );
104 cloned->mExtent = mExtent;
105 cloned->updateTilingScheme();
128 QDomElement elemExtent = elem.ownerDocument().createElement(
"extent" );
129 elemExtent.setAttribute(
"xmin", QString::number( r.
xMinimum() ) );
130 elemExtent.setAttribute(
"xmax", QString::number( r.
xMaximum() ) );
131 elemExtent.setAttribute(
"ymin", QString::number( r.
yMinimum() ) );
132 elemExtent.setAttribute(
"ymax", QString::number( r.
yMaximum() ) );
139 QDomElement elemExtent = elem.firstChildElement(
"extent" );
140 double xmin = elemExtent.attribute(
"xmin" ).toDouble();
141 double xmax = elemExtent.attribute(
"xmax" ).toDouble();
142 double ymin = elemExtent.attribute(
"ymin" ).toDouble();
143 double ymax = elemExtent.attribute(
"ymax" ).toDouble();
153 updateTilingScheme();
159 updateTilingScheme();
162 void QgsFlatTerrainGenerator::updateTilingScheme()
164 if ( mExtent.isNull() )
3 Axis-aligned bounding box - in world coords.
void rootChunkHeightRange(float &hMin, float &hMax) const override
Returns height range of the root chunk in world coordinates.
3 Terrain generator that creates a simple square flat area.
A rectangle specified with double values.
void writeXml(QDomElement &elem) const override
Write terrain generator's configuration to XML.
QgsCoordinateReferenceSystem crs() const
Returns CRS of the terrain.
void readXml(const QDomElement &elem) override
Read terrain generator's configuration from XML.
QgsChunkLoader * createChunkLoader(QgsChunkNode *node) const override SIP_FACTORY
QgsRectangle extent() const override
extent of the terrain in terrain's CRS
QgsTerrainEntity * mTerrain
QgsTerrainGenerator * clone() const override SIP_FACTORY
Makes a copy of the current instance.
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
double xMaximum() const
Returns the x maximum value (right side of rectangle).
Type type() const override
What texture generator implementation is this.
Type
Enumeration of the available terrain generators.
QgsTilingScheme mTerrainTilingScheme
Tiling scheme of the terrain.
3 Base class for generators of terrain.
This class represents a coordinate reference system (CRS).
double xMinimum() const
Returns the x minimum value (left side of rectangle).
void setCrs(const QgsCoordinateReferenceSystem &crs)
Sets CRS of the terrain.
double yMaximum() const
Returns the y maximum value (top side of rectangle).
3 The class encapsulates tiling scheme (just like with WMTS / TMS / XYZ layers).
QgsRectangle tileToExtent(int x, int y, int z) const
Returns map coordinates of the extent of a tile.
The whole terrain is flat area.
void setExtent(const QgsRectangle &extent)
Sets extent of the terrain.
QgsRectangle extent() const override
extent of the terrain in terrain's CRS