27#include <Qt3DRender/QGeometryRenderer>
29#include "moc_qgsflatterraingenerator.cpp"
39 return QgsChunkLoaderResult { std::bind_front( &QgsFlatTerrainGenerator::createEntity,
this, node, resources ) };
46 QgsTerrainTileEntity *entity =
new QgsTerrainTileEntity( node->tileId() );
53 Qt3DExtras::QPlaneGeometry *tileGeometry =
new Qt3DExtras::QPlaneGeometry;
55 Qt3DRender::QGeometryRenderer *mesh =
new Qt3DRender::QGeometryRenderer;
56 mesh->setGeometry( tileGeometry );
57 entity->addComponent( mesh );
65 QgsGeoTransform *transform =
nullptr;
66 transform =
new QgsGeoTransform();
67 entity->addComponent( transform );
70 const QgsBox3D box3D = node->box3D();
74 std::max( box3D.
xMinimum(), mapFullBox3D.xMinimum() ),
75 std::max( box3D.
yMinimum(), mapFullBox3D.yMinimum() ),
77 std::min( box3D.
xMaximum(), mapFullBox3D.xMaximum() ),
78 std::min( box3D.
yMaximum(), mapFullBox3D.yMaximum() ),
81 const double xSide = commonExtent.width();
82 const double ySide = commonExtent.height();
83 const double xMin = commonExtent.xMinimum();
84 const double yMin = commonExtent.yMinimum();
86 transform->setRotation( QQuaternion::fromAxisAndAngle( QVector3D( 1, 0, 0 ), 90 ) );
87 transform->setScale3D( QVector3D(
static_cast<float>( xSide ), 1,
static_cast<float>( ySide ) ) );
88 transform->setGeoTranslation(
QgsVector3D( xMin + xSide / 2, yMin + ySide / 2, 0 ) );
92 entity->setParent( parent );
101 cloned->updateTilingScheme();
124 updateTilingScheme();
133 updateTilingScheme();
144void 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.
Rendering context for preparation of 3D entities.
static Qgs3DRenderContext fromMapSettings(const Qgs3DMapSettings *mapSettings)
Creates an initialized Qgs3DRenderContext instance from given Qgs3DMapSettings.
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.
Represents a coordinate reference system (CRS).
Contains information about the context in which a coordinate transform is executed.
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.
static QgsTerrainGenerator * create()
Creates a new instance of a QgsFlatTerrainGenerator object.
QFuture< QgsChunkLoaderResult > loadChunk(QgsChunkNode *node) override
float heightAt(double x, double y, const Qgs3DRenderContext &context) const override
Returns height at (x,y) in map's CRS.
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.
QgsTerrainGenerator * clone() const override
Makes a copy of the current instance.
void setCrs(const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context) override
Sets the CRS associated with the terrain.
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.
QgsTerrainGenerator()
Create new terrain generator.
void applyMaterial(const TerrainTextureResources &resources, QgsTerrainTileEntity *entity, bool isShadingEnabled, const QgsPhongMaterialSettings &shadingMaterial, bool useTexture, const Qgs3DRenderContext &context)
Creates material component for the entity with the rendered map as a texture.
QgsTerrainEntity * mTerrain
QFuture< TerrainTextureResources > loadTextureResources(QgsChunkNode *node)
Asynchronously loads resources for creating texture.
Encapsulates tiling schemes (just like with WMTS / TMS / XYZ layers).
A 3D vector (similar to QVector3D) with the difference that it uses double precision instead of singl...
#define QGIS_CHECK_MAIN_THREAD_ACCESS