18 #include <Qt3DRender/QGeometryRenderer> 31 FlatTerrainChunkLoader::FlatTerrainChunkLoader( QgsTerrainEntity *terrain, QgsChunkNode *node )
32 : QgsTerrainTileLoader( terrain, node )
38 Qt3DCore::QEntity *FlatTerrainChunkLoader::createEntity( Qt3DCore::QEntity *parent )
40 QgsTerrainTileEntity *entity =
new QgsTerrainTileEntity;
47 mTileGeometry =
new Qt3DExtras::QPlaneGeometry;
49 Qt3DRender::QGeometryRenderer *mesh =
new Qt3DRender::QGeometryRenderer;
50 mesh->setGeometry( mTileGeometry );
51 entity->addComponent( mesh );
55 createTextureComponent( entity );
59 Qt3DCore::QTransform *transform =
nullptr;
60 transform =
new Qt3DCore::QTransform();
61 entity->addComponent( transform );
66 double half = side / 2;
68 transform->setScale( side );
69 transform->setTranslation( QVector3D( bbox.
xMin + half, 0, bbox.
zMin + half ) );
71 entity->setEnabled(
false );
72 entity->setParent( parent );
82 return new FlatTerrainChunkLoader(
mTerrain, node );
89 cloned->mExtent = mExtent;
90 cloned->updateTilingScheme();
113 QDomElement elemExtent = elem.ownerDocument().createElement( QStringLiteral(
"extent" ) );
114 elemExtent.setAttribute( QStringLiteral(
"xmin" ), QString::number( r.
xMinimum() ) );
115 elemExtent.setAttribute( QStringLiteral(
"xmax" ), QString::number( r.
xMaximum() ) );
116 elemExtent.setAttribute( QStringLiteral(
"ymin" ), QString::number( r.
yMinimum() ) );
117 elemExtent.setAttribute( QStringLiteral(
"ymax" ), QString::number( r.
yMaximum() ) );
124 QDomElement elemExtent = elem.firstChildElement( QStringLiteral(
"extent" ) );
125 double xmin = elemExtent.attribute( QStringLiteral(
"xmin" ) ).toDouble();
126 double xmax = elemExtent.attribute( QStringLiteral(
"xmax" ) ).toDouble();
127 double ymin = elemExtent.attribute( QStringLiteral(
"ymin" ) ).toDouble();
128 double ymax = elemExtent.attribute( QStringLiteral(
"ymax" ) ).toDouble();
138 updateTilingScheme();
144 updateTilingScheme();
147 void QgsFlatTerrainGenerator::updateTilingScheme()
149 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.
double yMaximum() const
Returns the y maximum value (top side of rectangle).
void readXml(const QDomElement &elem) override
Read terrain generator's configuration from XML.
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
double xMaximum() const
Returns the x maximum value (right side of rectangle).
QgsChunkLoader * createChunkLoader(QgsChunkNode *node) const override SIP_FACTORY
QgsCoordinateReferenceSystem crs() const
Returns CRS of the terrain.
QgsRectangle tileToExtent(int x, int y, int z) const
Returns map coordinates of the extent of a tile.
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.
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).
void setCrs(const QgsCoordinateReferenceSystem &crs)
Sets CRS of the terrain.
3 The class encapsulates tiling scheme (just like with WMTS / TMS / XYZ layers).
double xMinimum() const
Returns the x minimum value (left side of rectangle).
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