26 #include <Qt3DRender/QTexture> 28 #if QT_VERSION >= 0x050900 29 #include <Qt3DExtras/QTextureMaterial> 31 #include <Qt3DExtras/QDiffuseMapMaterial> 38 QgsTerrainTileLoader::QgsTerrainTileLoader( QgsTerrainEntity *terrain, QgsChunkNode *node )
39 : QgsChunkLoader( node )
60 mExtentMapCrs = terrain->terrainToMapTransform().transformBoundingBox( extentTerrainCrs );
61 mTileDebugText = QStringLiteral(
"%1 | %2 | %3" ).arg( tx ).arg( ty ).arg( tz );
64 void QgsTerrainTileLoader::loadTexture()
66 connect(
mTerrain->textureGenerator(), &QgsTerrainTextureGenerator::tileReady,
this, &QgsTerrainTileLoader::onImageReady );
67 mTextureJobId =
mTerrain->textureGenerator()->render( mExtentMapCrs, mTileDebugText );
70 void QgsTerrainTileLoader::createTextureComponent( QgsTerrainTileEntity *entity )
72 Qt3DRender::QTexture2D *texture =
new Qt3DRender::QTexture2D( entity );
73 QgsTerrainTextureImage *textureImage =
new QgsTerrainTextureImage( mTextureImage, mExtentMapCrs, mTileDebugText );
74 texture->addTextureImage( textureImage );
75 texture->setMinificationFilter( Qt3DRender::QTexture2D::Linear );
76 texture->setMagnificationFilter( Qt3DRender::QTexture2D::Linear );
77 Qt3DExtras::QTextureMaterial *material =
nullptr;
78 #if QT_VERSION >= 0x050900 79 material =
new Qt3DExtras::QTextureMaterial;
80 material->setTexture( texture );
82 material =
new Qt3DExtras::QDiffuseMapMaterial;
83 material->setDiffuse( texture );
84 material->setShininess( 1 );
85 material->setAmbient( Qt::white );
87 entity->setTextureImage( textureImage );
88 entity->addComponent( material );
91 void QgsTerrainTileLoader::onImageReady(
int jobId,
const QImage &image )
93 if ( mTextureJobId == jobId )
95 mTextureImage = image;
A rectangle specified with double values.
virtual Type type() const =0
What texture generator implementation is this.
const QgsTilingScheme & tilingScheme() const
Returns tiling scheme of the terrain.
3 Definition of the world
3 Terrain generator using downloaded terrain tiles using quantized mesh specification ...
QgsRectangle tileToExtent(int x, int y, int z) const
Returns map coordinates of the extent of a tile.
QgsTerrainEntity * mTerrain
void quadTreeTileToBaseTile(int x, int y, int z, int &tx, int &ty, int &tz) const
Converts tile coordinates (x,y,z) in our quadtree to tile coordinates of quantized mesh tree...
QgsTerrainGenerator * terrainGenerator() const
Returns terrain generator. It takes care of producing terrain tiles from the input data...