18#include <Qt3DRender/QGeometryRenderer>
19#include <Qt3DCore/QTransform>
32FlatTerrainChunkLoader::FlatTerrainChunkLoader( QgsTerrainEntity *terrain, QgsChunkNode *node )
33 : QgsTerrainTileLoader( terrain, node )
39Qt3DCore::QEntity *FlatTerrainChunkLoader::createEntity( Qt3DCore::QEntity *parent )
41 QgsTerrainTileEntity *entity =
new QgsTerrainTileEntity( mNode->tileId() );
48 mTileGeometry =
new Qt3DExtras::QPlaneGeometry;
50 Qt3DRender::QGeometryRenderer *mesh =
new Qt3DRender::QGeometryRenderer;
51 mesh->setGeometry( mTileGeometry );
52 entity->addComponent( mesh );
60 Qt3DCore::QTransform *transform =
nullptr;
61 transform =
new Qt3DCore::QTransform();
62 entity->addComponent( transform );
65 const QgsAABB bbox = mNode->bbox();
71 std::max( bbox.
zMin, mapFullExtent.
zMin ),
72 std::min( bbox.
xMax, mapFullExtent.
xMax ),
74 std::min( bbox.
zMax, mapFullExtent.
zMax )
76 const double xSide = commonExtent.
xExtent();
77 const double zSide = commonExtent.
zExtent();
79 transform->setScale3D( QVector3D( xSide, 1, zSide ) );
80 transform->setTranslation( QVector3D( commonExtent.
xMin + xSide / 2, 0, commonExtent.
zMin + zSide / 2 ) );
84 entity->setParent( parent );
94 return new FlatTerrainChunkLoader(
mTerrain, node );
102 cloned->updateTilingScheme();
135 updateTilingScheme();
144 updateTilingScheme();
147void QgsFlatTerrainGenerator::updateTilingScheme()
QgsRectangle extent() const
Returns the 3D scene's 2D extent in project's CRS.
bool isTerrainShadingEnabled() const
Returns whether terrain shading is enabled.
QgsPhongMaterialSettings terrainShadingMaterial() const
Returns terrain shading material.
QList< QgsMapLayer * > layers() const
Returns the list of 3D map layers to be rendered in the scene.
QgsVector3D origin() const
Returns coordinates in map CRS at which 3D scene has origin (0,0,0)
static QgsAABB mapToWorldExtent(const QgsRectangle &extent, double zMin, double zMax, const QgsVector3D &mapOrigin)
Converts map extent to axis aligned bounding box in 3D world coordinates.
float xExtent() const
Returns box width in X axis.
float zExtent() const
Returns box width in Z axis.
This class represents a coordinate reference system (CRS).
QgsChunkLoader * createChunkLoader(QgsChunkNode *node) const override SIP_FACTORY
Type type() const override
What texture generator implementation is this.
QgsRectangle rootChunkExtent() const override
extent of the terrain's root chunk in terrain's CRS
void setCrs(const QgsCoordinateReferenceSystem &crs)
Sets CRS of the terrain.
void rootChunkHeightRange(float &hMin, float &hMax) const override
Returns height range of the root chunk in world coordinates.
QgsCoordinateReferenceSystem crs() const
Returns CRS of the terrain.
void writeXml(QDomElement &elem) const override
Write terrain generator's configuration to XML.
QgsTerrainGenerator * clone() const override SIP_FACTORY
Makes a copy of the current instance.
QgsFlatTerrainGenerator()=default
Creates flat terrain generator object.
void readXml(const QDomElement &elem) override
Read terrain generator's configuration from XML.
void setExtent(const QgsRectangle &extent) override
sets the extent of the terrain in terrain's CRS
A rectangle specified with double values.
bool isNull() const
Test if the rectangle is null (holding no spatial information).
Type
Enumeration of the available terrain generators.
@ Flat
The whole terrain is flat area.
QgsTilingScheme mTerrainTilingScheme
Tiling scheme of the terrain.
virtual QgsRectangle extent() const
extent of the terrain in terrain's CRS, might be non-square and smaller than rootChunkExtent()
QgsTerrainEntity * mTerrain
QgsRectangle tileToExtent(int x, int y, int z) const
Returns map coordinates of the extent of a tile.
const QgsCoordinateReferenceSystem & crs