19#include <Qt3DCore/QEntity>
20#include <Qt3DCore/QComponent>
21#include <Qt3DCore/QNode>
23#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
24#include <Qt3DRender/QAttribute>
25#include <Qt3DRender/QBuffer>
26#include <Qt3DRender/QGeometry>
32#include <Qt3DCore/QAttribute>
33#include <Qt3DCore/QBuffer>
34#include <Qt3DCore/QGeometry>
41#include <Qt3DRender/QGeometryRenderer>
42#include <Qt3DExtras/QPlaneGeometry>
43#include <Qt3DCore/QTransform>
44#include <Qt3DRender/QMaterial>
45#include <Qt3DExtras/QDiffuseSpecularMaterial>
46#include <Qt3DExtras/QTextureMaterial>
47#include <Qt3DRender/QTextureImage>
48#include <Qt3DRender/QTexture>
49#include <Qt3DRender/QMesh>
50#include <Qt3DRender/QSceneLoader>
51#include <Qt3DRender/QAbstractTexture>
52#include <Qt3DExtras/QCylinderGeometry>
53#include <Qt3DExtras/QConeGeometry>
54#include <Qt3DExtras/QSphereGeometry>
55#include <Qt3DExtras/QCuboidGeometry>
56#include <Qt3DExtras/QTorusGeometry>
57#include <Qt3DExtras/QExtrudedTextMesh>
58#include <Qt3DExtras/QPhongMaterial>
59#include <Qt3DRender/QAbstractTextureImage>
78#include "qgsmeshterraingenerator.h"
91 const uint bytesOffset = attribute->byteOffset();
92 const uint bytesStride = attribute->byteStride();
93 const uint vertexSize = attribute->vertexSize();
96 if ( bytesStride == 0 )
98 QgsDebugMsg(
"bytesStride==0, the attribute probably was not set properly" );
102 const char *pData = data.constData();
103 for (
int i = bytesOffset; i < data.size(); i += bytesStride )
105 for (
unsigned int j = 0; j < vertexSize *
sizeof( T ); j +=
sizeof( T ) )
108 memcpy( &v, pData + i + j,
sizeof( T ) );
109 result.push_back( v );
118 QVector<uint> result;
119 const char *pData = data.constData();
120 for (
int i = 0; i < data.size(); i +=
sizeof( T ) )
123 memcpy( &v, pData + i,
sizeof( T ) );
124 result.push_back( ( uint ) v );
131 switch ( indexAttribute->vertexBaseType() )
133 case Qt3DQAttribute::VertexBaseType::Int:
134 return _getIndexDataImplementation<int>( data );
135 case Qt3DQAttribute::VertexBaseType::UnsignedInt:
136 return _getIndexDataImplementation<uint>( data );
137 case Qt3DQAttribute::VertexBaseType::Short:
138 return _getIndexDataImplementation<short>( data );
139 case Qt3DQAttribute::VertexBaseType::UnsignedShort:
140 return _getIndexDataImplementation<ushort>( data );
141 case Qt3DQAttribute::VertexBaseType::Byte:
142 return _getIndexDataImplementation<char>( data );
143 case Qt3DQAttribute::VertexBaseType::UnsignedByte:
144 return _getIndexDataImplementation<uchar>( data );
146 QgsDebugMsg(
"Probably trying to get index data using an attribute that has vertex data" );
149 return QVector<uint>();
154 QByteArray bytes = buffer->data();
155 if ( bytes.isNull() )
166 if ( attribute->attributeType() != type )
continue;
167 if ( attribute->name() == name )
return attribute;
172template<
typename Component>
175 if ( entity ==
nullptr )
return nullptr;
176 for ( Qt3DCore::QComponent *component : entity->components() )
178 Component *typedComponent = qobject_cast<Component *>( component );
179 if ( typedComponent !=
nullptr )
180 return typedComponent;
188 const QString rendererType = abstractRenderer->
type();
190 if ( rendererType ==
"mesh" )
197 if ( rendererType ==
"rulebased" )
200 const QList<Qt3DRender::QGeometryRenderer *> renderers = entity->findChildren<Qt3DRender::QGeometryRenderer *>();
201 for ( Qt3DRender::QGeometryRenderer *renderer : renderers )
203 Qt3DCore::QEntity *parentEntity = qobject_cast<Qt3DCore::QEntity *>( renderer->parent() );
206 Qgs3DExportObject *
object = processGeometryRenderer( renderer, layer->
name() + QStringLiteral(
"_" ) );
207 if (
object ==
nullptr )
continue;
208 if ( mExportTextures )
209 processEntityMaterial( parentEntity,
object );
210 mObjects.push_back(
object );
217 if ( vectorLayerRenderer )
220 const bool exported = symbol->
exportGeometries(
this, entity, layer->
name() + QStringLiteral(
"_" ) );
230void Qgs3DSceneExporter::processEntityMaterial( Qt3DCore::QEntity *entity,
Qgs3DExportObject *
object )
232 Qt3DExtras::QPhongMaterial *phongMaterial = findTypedComponent<Qt3DExtras::QPhongMaterial>( entity );
233 if ( phongMaterial !=
nullptr )
236 object->setupMaterial( &material );
238 Qt3DExtras::QDiffuseSpecularMaterial *diffuseMapMaterial = findTypedComponent<Qt3DExtras::QDiffuseSpecularMaterial>( entity );
240 if ( diffuseMapMaterial !=
nullptr )
242 const QVector<Qt3DRender::QAbstractTextureImage *> textureImages = diffuseMapMaterial->diffuse().value< Qt3DRender::QTexture2D * >()->textureImages();
244 for ( Qt3DRender::QAbstractTextureImage *tex : textureImages )
247 if ( imageTexture !=
nullptr )
break;
249 if ( imageTexture !=
nullptr )
251 const QImage image = imageTexture->
getImage();
252 object->setTextureImage( image );
263 QgsChunkNode *node = terrain->rootNode();
268 QgsTerrainTileEntity *terrainTile =
nullptr;
269 QgsTerrainTextureGenerator *textureGenerator = terrain->textureGenerator();
270 textureGenerator->waitForFinished();
271 const QSize oldResolution = textureGenerator->textureSize();
272 textureGenerator->setTextureSize( QSize( mTerrainTextureResolution, mTerrainTextureResolution ) );
273 switch ( generator->
type() )
276 terrainTile = getDemTerrainEntity( terrain, node );
277 parseDemTile( terrainTile, layerName + QStringLiteral(
"_" ) );
280 terrainTile = getFlatTerrainEntity( terrain, node );
281 parseFlatTile( terrainTile, layerName + QStringLiteral(
"_" ) );
285 terrainTile = getMeshTerrainEntity( terrain, node );
286 parseMeshTile( terrainTile, layerName + QStringLiteral(
"_" ) );
291 textureGenerator->setTextureSize( oldResolution );
294QgsTerrainTileEntity *Qgs3DSceneExporter::getFlatTerrainEntity( QgsTerrainEntity *terrain, QgsChunkNode *node )
297 FlatTerrainChunkLoader *flatTerrainLoader = qobject_cast<FlatTerrainChunkLoader *>( generator->
createChunkLoader( node ) );
298 if ( mExportTextures )
299 terrain->textureGenerator()->waitForFinished();
301 Qt3DCore::QEntity *entity = flatTerrainLoader->createEntity(
this );
302 QgsTerrainTileEntity *tileEntity = qobject_cast<QgsTerrainTileEntity *>( entity );
306QgsTerrainTileEntity *Qgs3DSceneExporter::getDemTerrainEntity( QgsTerrainEntity *terrain, QgsChunkNode *node )
312 QgsDemTerrainTileLoader *loader = qobject_cast<QgsDemTerrainTileLoader *>( generator->
createChunkLoader( node ) );
314 if ( mExportTextures )
315 terrain->textureGenerator()->waitForFinished();
316 QgsTerrainTileEntity *tileEntity = qobject_cast<QgsTerrainTileEntity *>( loader->createEntity(
this ) );
321QgsTerrainTileEntity *Qgs3DSceneExporter::getMeshTerrainEntity( QgsTerrainEntity *terrain, QgsChunkNode *node )
323 QgsMeshTerrainGenerator *generator =
dynamic_cast<QgsMeshTerrainGenerator *
>( terrain->map3D().terrainGenerator() );
324 QgsMeshTerrainTileLoader *loader = qobject_cast<QgsMeshTerrainTileLoader *>( generator->createChunkLoader( node ) );
326 QgsTerrainTileEntity *tileEntity = qobject_cast<QgsTerrainTileEntity *>( loader->createEntity(
this ) );
330void Qgs3DSceneExporter::parseFlatTile( QgsTerrainTileEntity *tileEntity,
const QString &layerName )
332 Qt3DRender::QGeometryRenderer *mesh = findTypedComponent<Qt3DRender::QGeometryRenderer>( tileEntity );
333 Qt3DCore::QTransform *transform = findTypedComponent<Qt3DCore::QTransform>( tileEntity );
336 Qt3DExtras::QPlaneGeometry *tileGeometry = qobject_cast<Qt3DExtras::QPlaneGeometry *>( geometry );
337 if ( tileGeometry ==
nullptr )
339 QgsDebugMsg(
"Qt3DExtras::QPlaneGeometry* is expected but something else was given" );
343 const float scale = transform->scale();
344 const QVector3D translation = transform->translation();
347 Qt3DQAttribute *positionAttribute = tileGeometry->positionAttribute();
348 const QByteArray verticesBytes =
getData( positionAttribute->buffer() );
349 const QVector<float> positionBuffer = getAttributeData<float>( positionAttribute, verticesBytes );
353 const QByteArray indexBytes =
getData( indexAttribute->buffer() );
354 const QVector<uint> indexesBuffer =
getIndexData( indexAttribute, indexBytes );
356 QString objectNamePrefix = layerName;
357 if ( objectNamePrefix != QString() ) objectNamePrefix += QString();
360 mObjects.push_back(
object );
362 object->setSmoothEdges( mSmoothEdges );
363 object->setupPositionCoordinates( positionBuffer,
scale, translation );
364 object->setupFaces( indexesBuffer );
366 if ( mExportNormals )
369 QVector<float> normalsBuffer;
370 for (
int i = 0; i < positionBuffer.size(); i += 3 ) normalsBuffer << 0.0f << 1.0f << 0.0f;
371 object->setupNormalCoordinates( normalsBuffer );
374 Qt3DQAttribute *texCoordsAttribute = tileGeometry->texCoordAttribute();
375 if ( mExportTextures && texCoordsAttribute !=
nullptr )
378 const QVector<float> texCoords = getAttributeData<float>( texCoordsAttribute, verticesBytes );
379 object->setupTextureCoordinates( texCoords );
381 QgsTerrainTextureImage *textureImage = tileEntity->textureImage();
382 const QImage img = textureImage->getImage();
383 object->setTextureImage( img );
387void Qgs3DSceneExporter::parseDemTile( QgsTerrainTileEntity *tileEntity,
const QString &layerName )
389 Qt3DRender::QGeometryRenderer *mesh = findTypedComponent<Qt3DRender::QGeometryRenderer>( tileEntity );
390 Qt3DCore::QTransform *transform = findTypedComponent<Qt3DCore::QTransform>( tileEntity );
393 DemTerrainTileGeometry *tileGeometry = qobject_cast<DemTerrainTileGeometry *>( geometry );
394 if ( tileGeometry ==
nullptr )
396 QgsDebugMsg(
"DemTerrainTileGeometry* is expected but something else was given" );
400 const float scale = transform->scale();
401 const QVector3D translation = transform->translation();
403 Qt3DQAttribute *positionAttribute = tileGeometry->positionAttribute();
404 const QByteArray positionBytes = positionAttribute->buffer()->data();
405 const QVector<float> positionBuffer = getAttributeData<float>( positionAttribute, positionBytes );
408 const QByteArray indexBytes = indexAttribute->buffer()->data();
409 const QVector<unsigned int> indexBuffer =
getIndexData( indexAttribute, indexBytes );
412 mObjects.push_back(
object );
414 object->setSmoothEdges( mSmoothEdges );
415 object->setupPositionCoordinates( positionBuffer,
scale, translation );
416 object->setupFaces( indexBuffer );
418 Qt3DQAttribute *normalsAttributes = tileGeometry->normalAttribute();
419 if ( mExportNormals && normalsAttributes !=
nullptr )
421 const QByteArray normalsBytes = normalsAttributes->buffer()->data();
422 const QVector<float> normalsBuffer = getAttributeData<float>( normalsAttributes, normalsBytes );
423 object->setupNormalCoordinates( normalsBuffer );
426 Qt3DQAttribute *texCoordsAttribute = tileGeometry->texCoordsAttribute();
427 if ( mExportTextures && texCoordsAttribute !=
nullptr )
429 const QByteArray texCoordsBytes = texCoordsAttribute->buffer()->data();
430 const QVector<float> texCoordsBuffer = getAttributeData<float>( texCoordsAttribute, texCoordsBytes );
431 object->setupTextureCoordinates( texCoordsBuffer );
433 QgsTerrainTextureImage *textureImage = tileEntity->textureImage();
434 const QImage img = textureImage->getImage();
435 object->setTextureImage( img );
439void Qgs3DSceneExporter::parseMeshTile( QgsTerrainTileEntity *tileEntity,
const QString &layerName )
441 QString objectNamePrefix = layerName;
442 if ( objectNamePrefix != QString() ) objectNamePrefix += QStringLiteral(
"_" );
444 const QList<Qt3DRender::QGeometryRenderer *> renderers = tileEntity->findChildren<Qt3DRender::QGeometryRenderer *>();
445 for ( Qt3DRender::QGeometryRenderer *renderer : renderers )
448 if ( obj ==
nullptr )
continue;
453QVector<Qgs3DExportObject *> Qgs3DSceneExporter::processInstancedPointGeometry( Qt3DCore::QEntity *entity,
const QString &objectNamePrefix )
455 QVector<Qgs3DExportObject *> objects;
456 const QList<Qt3DQGeometry *> geometriesList = entity->findChildren<
Qt3DQGeometry *>();
459 Qt3DQAttribute *positionAttribute =
findAttribute( geometry, Qt3DQAttribute::defaultPositionAttributeName(), Qt3DQAttribute::VertexAttribute );
463 if ( attribute->attributeType() == Qt3DQAttribute::IndexAttribute )
464 indexAttribute = attribute;
466 if ( positionAttribute ==
nullptr || indexAttribute ==
nullptr )
468 const QByteArray vertexBytes =
getData( positionAttribute->buffer() );
469 const QByteArray indexBytes =
getData( indexAttribute->buffer() );
470 const QVector<float> positionData = getAttributeData<float>( positionAttribute, vertexBytes );
471 const QVector<uint> indexData =
getIndexData( indexAttribute, indexBytes );
474 const QByteArray instancePositionBytes =
getData( instanceDataAttribute->buffer() );
475 QVector<float> instancePosition = getAttributeData<float>( instanceDataAttribute, instancePositionBytes );
476 for (
int i = 0; i < instancePosition.size(); i += 3 )
479 objects.push_back(
object );
480 object->setupPositionCoordinates( positionData, 1.0f, QVector3D( instancePosition[i], instancePosition[i + 1], instancePosition[i + 2] ) );
481 object->setupFaces( indexData );
483 object->setSmoothEdges( mSmoothEdges );
485 Qt3DQAttribute *normalsAttribute =
findAttribute( geometry, Qt3DQAttribute::defaultNormalAttributeName(), Qt3DQAttribute::VertexAttribute );
486 if ( mExportNormals && normalsAttribute !=
nullptr )
489 const QVector<float> normalsData = getAttributeData<float>( normalsAttribute, vertexBytes );
490 object->setupNormalCoordinates( normalsData );
497QVector<Qgs3DExportObject *> Qgs3DSceneExporter::processSceneLoaderGeometries( Qt3DRender::QSceneLoader *sceneLoader,
const QString &objectNamePrefix )
499 QVector<Qgs3DExportObject *> objects;
500 Qt3DCore::QEntity *sceneLoaderParent = qobject_cast<Qt3DCore::QEntity *>( sceneLoader->parent() );
501 Qt3DCore::QTransform *entityTransform = findTypedComponent<Qt3DCore::QTransform>( sceneLoaderParent );
502 float sceneScale = 1.0f;
503 QVector3D sceneTranslation( 0.0f, 0.0f, 0.0f );
504 if ( entityTransform !=
nullptr )
506 sceneScale = entityTransform->scale();
507 sceneTranslation = entityTransform->translation();
509 for (
const QString &entityName : sceneLoader->entityNames() )
511 Qt3DRender::QGeometryRenderer *mesh = qobject_cast<Qt3DRender::QGeometryRenderer *>( sceneLoader->component( entityName, Qt3DRender::QSceneLoader::GeometryRendererComponent ) );
512 Qgs3DExportObject *
object = processGeometryRenderer( mesh, objectNamePrefix, sceneScale, sceneTranslation );
513 if (
object ==
nullptr )
continue;
514 objects.push_back(
object );
519Qgs3DExportObject *Qgs3DSceneExporter::processGeometryRenderer( Qt3DRender::QGeometryRenderer *mesh,
const QString &objectNamePrefix,
float sceneScale, QVector3D sceneTranslation )
522 if ( mesh->primitiveType() != Qt3DRender::QGeometryRenderer::Triangles )
return nullptr;
525 QVector3D translation( 0.0f, 0.0f, 0.0f );
526 QObject *parent = mesh->parent();
527 while ( parent !=
nullptr )
529 Qt3DCore::QEntity *entity = qobject_cast<Qt3DCore::QEntity *>( parent );
530 Qt3DCore::QTransform *transform = findTypedComponent<Qt3DCore::QTransform>( entity );
531 if ( transform !=
nullptr )
533 scale *= transform->scale();
534 translation += transform->translation();
536 parent = parent->parent();
541 Qt3DQAttribute *positionAttribute =
findAttribute( geometry, Qt3DQAttribute::defaultPositionAttributeName(), Qt3DQAttribute::VertexAttribute );
543 QByteArray indexBytes, vertexBytes;
544 QVector<uint> indexData;
545 QVector<float> positionData;
548 if ( attribute->attributeType() == Qt3DQAttribute::IndexAttribute )
549 indexAttribute = attribute;
552 if ( indexAttribute !=
nullptr )
554 indexBytes =
getData( indexAttribute->buffer() );
558 if ( positionAttribute !=
nullptr )
560 vertexBytes =
getData( positionAttribute->buffer() );
561 positionData = getAttributeData<float>( positionAttribute, vertexBytes );
565 if ( positionAttribute !=
nullptr && indexAttribute ==
nullptr )
567 for (
int i = 0; i < positionData.size() / 3; ++i )
568 indexData.push_back( i );
571 if ( positionAttribute ==
nullptr )
573 QgsDebugMsg(
"Geometry renderer with null data was being processed" );
578 object->setupPositionCoordinates( positionData,
scale * sceneScale, translation + sceneTranslation );
579 object->setupFaces( indexData );
581 Qt3DQAttribute *normalsAttribute =
findAttribute( geometry, Qt3DQAttribute::defaultNormalAttributeName(), Qt3DQAttribute::VertexAttribute );
582 if ( mExportNormals && normalsAttribute !=
nullptr )
585 const QVector<float> normalsData = getAttributeData<float>( normalsAttribute, vertexBytes );
586 object->setupNormalCoordinates( normalsData );
589 Qt3DQAttribute *texCoordsAttribute =
findAttribute( geometry, Qt3DQAttribute::defaultTextureCoordinateAttributeName(), Qt3DQAttribute::VertexAttribute );
590 if ( mExportTextures && texCoordsAttribute !=
nullptr )
593 const QVector<float> texCoordsData = getAttributeData<float>( texCoordsAttribute, vertexBytes );
594 object->setupTextureCoordinates( texCoordsData );
600QVector<Qgs3DExportObject *> Qgs3DSceneExporter::processLines( Qt3DCore::QEntity *entity,
const QString &objectNamePrefix )
602 QVector<Qgs3DExportObject *> objs;
603 const QList<Qt3DRender::QGeometryRenderer *> renderers = entity->findChildren<Qt3DRender::QGeometryRenderer *>();
604 for ( Qt3DRender::QGeometryRenderer *renderer : renderers )
606 if ( renderer->primitiveType() != Qt3DRender::QGeometryRenderer::LineStripAdjacency )
continue;
608 Qt3DQAttribute *positionAttribute =
findAttribute( geom, Qt3DQAttribute::defaultPositionAttributeName(), Qt3DQAttribute::VertexAttribute );
612 if ( attribute->attributeType() == Qt3DQAttribute::IndexAttribute )
614 indexAttribute = attribute;
618 if ( positionAttribute ==
nullptr || indexAttribute ==
nullptr )
620 QgsDebugMsg(
"Position or index attribute was not found" );
624 const QByteArray vertexBytes =
getData( positionAttribute->buffer() );
625 const QByteArray indexBytes =
getData( indexAttribute->buffer() );
626 const QVector<float> positionData = getAttributeData<float>( positionAttribute, vertexBytes );
627 const QVector<uint> indexData =
getIndexData( indexAttribute, indexBytes );
634 objs.push_back( exportObject );
639Qgs3DExportObject *Qgs3DSceneExporter::processPoints( Qt3DCore::QEntity *entity,
const QString &objectNamePrefix )
641 QVector<float> points;
642 const QList<Qt3DRender::QGeometryRenderer *> renderers = entity->findChildren<Qt3DRender::QGeometryRenderer *>();
643 for ( Qt3DRender::QGeometryRenderer *renderer : renderers )
645 Qt3DQGeometry *geometry = qobject_cast<QgsBillboardGeometry *>( renderer->geometry() );
646 if ( geometry ==
nullptr )
648 Qt3DQAttribute *positionAttribute =
findAttribute( geometry, Qt3DQAttribute::defaultPositionAttributeName(), Qt3DQAttribute::VertexAttribute );
649 const QByteArray positionBytes =
getData( positionAttribute->buffer() );
650 if ( positionBytes.size() == 0 )
652 const QVector<float> positions = getAttributeData<float>( positionAttribute, positionBytes );
663 const QString objFilePath = QDir( sceneFolderPath ).filePath( sceneName + QStringLiteral(
".obj" ) );
664 const QString mtlFilePath = QDir( sceneFolderPath ).filePath( sceneName + QStringLiteral(
".mtl" ) );
666 QFile file( objFilePath );
667 if ( !file.open( QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate ) )
669 QFile mtlFile( mtlFilePath );
670 if ( !mtlFile.open( QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate ) )
673 float maxfloat = std::numeric_limits<float>::max(), minFloat = std::numeric_limits<float>::lowest();
674 float minX = maxfloat, minY = maxfloat, minZ = maxfloat, maxX = minFloat, maxY = minFloat, maxZ = minFloat;
677 float diffX = 1.0f, diffY = 1.0f, diffZ = 1.0f;
682 const float centerX = ( minX + maxX ) / 2.0f;
683 const float centerY = ( minY + maxY ) / 2.0f;
684 const float centerZ = ( minZ + maxZ ) / 2.0f;
686 const float scale = std::max( diffX, std::max( diffY, diffZ ) );
688 QTextStream out( &file );
690 const QString mtlLibName = sceneName +
".mtl";
691 out <<
"mtllib " << mtlLibName <<
"\n";
693 QTextStream mtlOut( &mtlFile );
696 if ( obj ==
nullptr )
continue;
698 const QString material = obj->
saveMaterial( mtlOut, sceneFolderPath );
699 out <<
"o " << obj->
name() <<
"\n";
700 if ( material != QString() )
701 out <<
"usemtl " << material <<
"\n";
702 obj->
saveTo( out,
scale / mScale, QVector3D( centerX, centerY, centerZ ) );
706QString Qgs3DSceneExporter::getObjectName(
const QString &name )
709 if ( usedObjectNamesCounter.contains( name ) )
711 ret = QStringLiteral(
"%1%2" ).arg( name ).arg( usedObjectNamesCounter[name] );
712 usedObjectNamesCounter[name]++;
715 usedObjectNamesCounter[name] = 2;
Manages the data of each object of the scene (positions, normals, texture coordinates ....
void saveTo(QTextStream &out, float scale, const QVector3D ¢er)
Saves the current object to the output stream while scaling the object and centering it to be visible...
void setType(ObjectType type)
Sets the object type.
void objectBounds(float &minX, float &minY, float &minZ, float &maxX, float &maxY, float &maxZ)
Updates the box bounds explained with the current object bounds This expands the bounding box if the ...
void setupPositionCoordinates(const QVector< float > &positionsBuffer, float scale=1.0f, const QVector3D &translation=QVector3D(0, 0, 0))
Sets positions coordinates and does the translation and scaling.
QString name() const
Returns the object name.
QString saveMaterial(QTextStream &mtlOut, const QString &folder)
saves the texture of the object and material information
void setupLine(const QVector< uint > &facesIndexes)
sets line vertex indexes
QgsTerrainGenerator * terrainGenerator() const
Returns the terrain generator.
bool terrainRenderingEnabled() const
Returns whether the 2D terrain surface will be rendered.
void parseTerrain(QgsTerrainEntity *terrain, const QString &layer)
Creates terrain export objects from the terrain entity.
void save(const QString &sceneName, const QString &sceneFolderPath)
Saves the scene to a .obj file.
float scale() const
Returns the scale of the exported 3D model.
bool parseVectorLayerEntity(Qt3DCore::QEntity *entity, QgsVectorLayer *layer)
Creates necessary export objects from entity if it represents valid vector layer entity Returns false...
static QgsPhongMaterialSettings phongMaterialFromQt3DComponent(Qt3DExtras::QPhongMaterial *material)
Returns phong material settings object based on the Qt3D material.
Base class for all renderers that may to participate in 3D view.
virtual QString type() const =0
Returns unique identifier of the renderer class (used to identify subclass)
virtual bool exportGeometries(Qgs3DSceneExporter *exporter, Qt3DCore::QEntity *entity, const QString &objectNamePrefix) const
Exports the geometries contained within the hierarchy of entity.
QgsDemHeightMapGenerator * heightMapGenerator()
Returns height map generator object - takes care of extraction of elevations from the layer)
QgsChunkLoader * createChunkLoader(QgsChunkNode *node) const override
void setResolution(int resolution)
Sets resolution of the generator (how many elevation samples on one side of a terrain tile)
QgsChunkLoader * createChunkLoader(QgsChunkNode *node) const override SIP_FACTORY
Holds an image that can be used as a texture in the 3D view.
QImage getImage() const
Returns the image.
QgsAbstract3DRenderer * renderer3D() const
Returns 3D renderer associated with the layer.
@ Dem
Terrain is built from raster layer with digital elevation model.
@ Online
Terrain is built from downloaded tiles with digital elevation model.
@ Mesh
Terrain is built from mesh layer with z value on vertices.
@ Flat
The whole terrain is flat area.
virtual Type type() const =0
What texture generator implementation is this.
3D renderer that renders all features of a vector layer with the same 3D symbol.
const QgsAbstract3DSymbol * symbol() const
Returns 3D symbol associated with the renderer.
Represents a vector layer which manages a vector based data sets.
Qt3DCore::QAttribute Qt3DQAttribute
Qt3DCore::QBuffer Qt3DQBuffer
Qt3DCore::QGeometry Qt3DQGeometry
QVector< T > getAttributeData(Qt3DQAttribute *attribute, const QByteArray &data)
Qt3DQAttribute * findAttribute(Qt3DQGeometry *geometry, const QString &name, Qt3DQAttribute::AttributeType type)
Qt3DCore::QAttribute Qt3DQAttribute
QVector< uint > getIndexData(Qt3DQAttribute *indexAttribute, const QByteArray &data)
QByteArray getData(Qt3DQBuffer *buffer)
Qt3DCore::QBuffer Qt3DQBuffer
QVector< uint > _getIndexDataImplementation(const QByteArray &data)
Component * findTypedComponent(Qt3DCore::QEntity *entity)
Qt3DCore::QGeometry Qt3DQGeometry