17#include "moc_qgsflatterraingenerator.cpp"
19#include <Qt3DRender/QGeometryRenderer>
33FlatTerrainChunkLoader::FlatTerrainChunkLoader( QgsTerrainEntity *terrain, QgsChunkNode *node )
34 : QgsTerrainTileLoader( terrain, node )
40Qt3DCore::QEntity *FlatTerrainChunkLoader::createEntity( Qt3DCore::QEntity *parent )
42 QgsTerrainTileEntity *entity =
new QgsTerrainTileEntity( mNode->tileId() );
49 mTileGeometry =
new Qt3DExtras::QPlaneGeometry;
51 Qt3DRender::QGeometryRenderer *mesh =
new Qt3DRender::QGeometryRenderer;
52 mesh->setGeometry( mTileGeometry );
53 entity->addComponent( mesh );
61 QgsGeoTransform *transform =
nullptr;
62 transform =
new QgsGeoTransform();
63 entity->addComponent( transform );
66 const QgsBox3D box3D = mNode->box3D();
69 const QgsBox3D commonExtent( std::max( box3D.
xMinimum(), mapFullBox3D.xMinimum() ), std::max( box3D.
yMinimum(), mapFullBox3D.yMinimum() ), box3D.
zMinimum(), std::min( box3D.
xMaximum(), mapFullBox3D.xMaximum() ), std::min( box3D.
yMaximum(), mapFullBox3D.yMaximum() ), box3D.
zMaximum() );
70 const double xSide = commonExtent.width();
71 const double ySide = commonExtent.height();
72 const double xMin = commonExtent.xMinimum();
73 const double yMin = commonExtent.yMinimum();
75 transform->setRotation( QQuaternion::fromAxisAndAngle( QVector3D( 1, 0, 0 ), 90 ) );
76 transform->setScale3D( QVector3D(
static_cast<float>( xSide ), 1,
static_cast<float>( ySide ) ) );
77 transform->setGeoTranslation(
QgsVector3D( xMin + xSide / 2, yMin + ySide / 2, 0 ) );
81 entity->setParent( parent );
96 return new FlatTerrainChunkLoader(
mTerrain, node );
104 cloned->updateTilingScheme();
127 updateTilingScheme();
136 updateTilingScheme();
139void QgsFlatTerrainGenerator::updateTilingScheme()
QgsRectangle extent() const
Returns the 3D scene's 2D extent in the 3D scene'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.
A 3-dimensional box composed of x, y, z coordinates.
double yMaximum() const
Returns the maximum y value.
double xMinimum() const
Returns the minimum x value.
double zMaximum() const
Returns the maximum z value.
double xMaximum() const
Returns the maximum x value.
double zMinimum() const
Returns the minimum z value.
double yMinimum() const
Returns the minimum y value.
This class represents a coordinate reference system (CRS).
Contains information about the context in which a coordinate transform is executed.
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 rootChunkHeightRange(float &hMin, float &hMax) const override
Returns height range of the root chunk in world coordinates.
QgsTerrainGenerator * clone() const override SIP_FACTORY
Makes a copy of the current instance.
QgsFlatTerrainGenerator()=default
void setExtent(const QgsRectangle &extent) override
sets the extent of the terrain in terrain's CRS
QgsCoordinateReferenceSystem crs() const override
Returns CRS of the terrain.
void setCrs(const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context) override
Sets the CRS associated with the terrain.
static QgsTerrainGenerator * create() SIP_FACTORY
Creates a new instance of a QgsFlatTerrainGenerator object.
A rectangle specified with double values.
Type
Enumeration of the available terrain generators.
@ Flat
The whole terrain is flat area.
QgsTilingScheme mTerrainTilingScheme
Tiling scheme of the terrain.
QgsTerrainEntity * mTerrain
QgsRectangle tileToExtent(int x, int y, int z) const
Returns map coordinates of the extent of a tile.
Class for storage of 3D vectors similar to QVector3D, with the difference that it uses double precisi...
const QgsCoordinateReferenceSystem & crs