30#include <QRegularExpression>
33using namespace Qt::StringLiterals;
35#define TINYGLTF_IMPLEMENTATION
40#define TINYGLTF_ENABLE_DRACO
43#define TINYGLTF_NO_STB_IMAGE
44#define TINYGLTF_NO_STB_IMAGE_WRITE
53bool QgsGltfUtils::accessorToMapCoordinates(
54 const tinygltf::Model &model,
59 const QMatrix4x4 *nodeTransform,
66 const tinygltf::Accessor &accessor = model.accessors[accessorIndex];
67 const tinygltf::BufferView &bv = model.bufferViews[accessor.bufferView];
68 const tinygltf::Buffer &b = model.buffers[bv.buffer];
70 if ( accessor.componentType != TINYGLTF_PARAMETER_TYPE_FLOAT || accessor.type != TINYGLTF_TYPE_VEC3 )
76 const unsigned char *ptr = b.data.data() + bv.byteOffset + accessor.byteOffset;
78 vx.resize( accessor.count );
79 vy.resize( accessor.count );
80 vz.resize( accessor.count );
81 double *vxOut = vx.data();
82 double *vyOut = vy.data();
83 double *vzOut = vz.data();
84 for (
int i = 0; i < static_cast<int>( accessor.count ); ++i )
86 const float *fptr =
reinterpret_cast<const float *
>( ptr );
87 QVector3D vOrig( fptr[0], fptr[1], fptr[2] );
90 vOrig = nodeTransform->map( vOrig );
98 v = tileTransform.
map( tileTranslationEcef );
105 QVector3D vFlip( vOrig.x(), -vOrig.z(), vOrig.y() );
106 v = tileTransform.
map(
QgsVector3D( vFlip ) + tileTranslationEcef );
112 v = tileTransform.
map(
QgsVector3D( vOrig ) + tileTranslationEcef );
122 ptr += bv.byteStride;
124 ptr += 3 *
sizeof( float );
127 if ( ecefToTargetCrs )
131 ecefToTargetCrs->
transformCoords( accessor.count, vx.data(), vy.data(), vz.data() );
142bool QgsGltfUtils::extractTextureCoordinates(
const tinygltf::Model &model,
int accessorIndex, QVector<float> &x, QVector<float> &y )
144 const tinygltf::Accessor &accessor = model.accessors[accessorIndex];
145 const tinygltf::BufferView &bv = model.bufferViews[accessor.bufferView];
146 const tinygltf::Buffer &b = model.buffers[bv.buffer];
148 if ( accessor.componentType != TINYGLTF_PARAMETER_TYPE_FLOAT || accessor.type != TINYGLTF_TYPE_VEC2 )
153 const unsigned char *ptr = b.data.data() + bv.byteOffset + accessor.byteOffset;
154 x.resize( accessor.count );
155 y.resize( accessor.count );
157 float *xOut = x.data();
158 float *yOut = y.data();
160 for ( std::size_t i = 0; i < accessor.count; i++ )
162 const float *fptr =
reinterpret_cast< const float *
>( ptr );
168 ptr += bv.byteStride;
170 ptr += 2 *
sizeof( float );
175QgsGltfUtils::ResourceType QgsGltfUtils::imageResourceType(
const tinygltf::Model &model,
int index )
177 const tinygltf::Image &img = model.images[index];
179 if ( !img.image.empty() )
181 return ResourceType::Embedded;
185 return ResourceType::Linked;
189QImage QgsGltfUtils::extractEmbeddedImage(
const tinygltf::Model &model,
int index )
191 const tinygltf::Image &img = model.images[index];
192 if ( !img.image.empty() )
193 return QImage( img.image.data(), img.width, img.height, QImage::Format_ARGB32 );
198QString QgsGltfUtils::linkedImagePath(
const tinygltf::Model &model,
int index )
200 const tinygltf::Image &img = model.images[index];
201 return QString::fromStdString( img.uri );
204std::unique_ptr<QMatrix4x4> QgsGltfUtils::parseNodeTransform(
const tinygltf::Node &node )
208 std::unique_ptr<QMatrix4x4> matrix;
209 if ( !node.matrix.empty() )
211 matrix = std::make_unique<QMatrix4x4>();
212 float *mdata = matrix->data();
213 for (
int i = 0; i < 16; ++i )
214 mdata[i] =
static_cast< float >( node.matrix[i] );
216 else if ( node.translation.size() || node.rotation.size() || node.scale.size() )
218 matrix = std::make_unique<QMatrix4x4>();
219 if ( node.scale.size() )
221 matrix->scale(
static_cast< float >( node.scale[0] ),
static_cast< float >( node.scale[1] ),
static_cast< float >( node.scale[2] ) );
223 if ( node.rotation.size() )
226 QQuaternion(
static_cast< float >( node.rotation[3] ),
static_cast< float >( node.rotation[0] ),
static_cast< float >( node.rotation[1] ),
static_cast< float >( node.rotation[2] ) )
229 if ( node.translation.size() )
231 matrix->translate(
static_cast< float >( node.translation[0] ),
static_cast< float >( node.translation[1] ),
static_cast< float >( node.translation[2] ) );
240 bool sceneOk =
false;
241 const std::size_t sceneIndex = QgsGltfUtils::sourceSceneForModel( model, sceneOk );
247 const tinygltf::Scene &scene = model.scenes[sceneIndex];
250 auto it = model.extensions.find(
"CESIUM_RTC" );
251 if ( it != model.extensions.end() )
253 const tinygltf::Value v = it->second;
254 if ( v.IsObject() && v.Has(
"center" ) )
256 const tinygltf::Value center = v.Get(
"center" );
257 if ( center.IsArray() && center.Size() == 3 )
259 tileTranslationEcef =
QgsVector3D( center.Get( 0 ).GetNumberAsDouble(), center.Get( 1 ).GetNumberAsDouble(), center.Get( 2 ).GetNumberAsDouble() );
264 if ( scene.nodes.size() == 0 )
267 int rootNodeIndex = scene.nodes[0];
268 tinygltf::Node &rootNode = model.nodes[rootNodeIndex];
270 if ( tileTranslationEcef.
isNull() && rootNode.translation.size() )
272 QgsVector3D rootTranslation( rootNode.translation[0], rootNode.translation[1], rootNode.translation[2] );
276 if ( rootTranslation.length() > 1e6 )
286 tileTranslationEcef =
QgsVector3D( rootTranslation.x(), -rootTranslation.z(), rootTranslation.y() );
287 rootNode.translation[0] = rootNode.translation[1] = rootNode.translation[2] = 0;
292 tileTranslationEcef =
QgsVector3D( rootTranslation.x(), rootTranslation.y(), rootTranslation.z() );
293 rootNode.translation[0] = rootNode.translation[1] = rootNode.translation[2] = 0;
300 return tileTranslationEcef;
304bool QgsGltfUtils::loadImageDataWithQImage(
305 tinygltf::Image *image,
const int image_idx, std::string *err, std::string *warn,
int req_width,
int req_height,
const unsigned char *bytes,
int size,
void *user_data
308 if ( req_width != 0 || req_height != 0 )
312 ( *err ) +=
"Expecting zero req_width/req_height.\n";
321 if ( !img.loadFromData( bytes, size ) )
325 ( *err ) +=
"Unknown image format. QImage cannot decode image data for image[" + std::to_string( image_idx ) +
"] name = \"" + image->name +
"\".\n";
330 if ( img.format() != QImage::Format_RGB32 && img.format() != QImage::Format_ARGB32 )
333 img.convertTo( QImage::Format_RGB32 );
336 image->width = img.width();
337 image->height = img.height();
338 image->component = 4;
340 image->pixel_type = TINYGLTF_COMPONENT_TYPE_UNSIGNED_BYTE;
342 image->image.resize(
static_cast<size_t>( image->width * image->height * image->component ) *
size_t( image->bits / 8 ) );
343 std::copy( img.constBits(), img.constBits() +
static_cast< std::size_t
>( image->width ) * image->height * image->component * ( image->bits / 8 ), image->image.begin() );
348bool QgsGltfUtils::loadGltfModel(
const QByteArray &data, tinygltf::Model &model, QString *errors, QString *warnings )
350 tinygltf::TinyGLTF loader;
352 loader.SetImageLoader( QgsGltfUtils::loadImageDataWithQImage,
nullptr );
358 loader.SetParseStrictness( tinygltf::ParseStrictness::Permissive );
361 std::string err, warn;
364 if ( data.startsWith(
"glTF" ) )
366 if ( data.at( 4 ) == 1 )
368 *errors = QObject::tr(
"GLTF version 1 tiles cannot be loaded" );
371 res = loader.LoadBinaryFromMemory( &model, &err, &warn, (
const unsigned char * ) data.constData(), data.size(), baseDir );
375 res = loader.LoadASCIIFromString( &model, &err, &warn, data.constData(), data.size(), baseDir );
379 *errors = QString::fromStdString( err );
382 *warnings = QString::fromStdString( warn );
385 const thread_local QRegularExpression rxFailedToLoadExternalUriForImage( u
"Failed to load external 'uri' for image\\[\\d+\\] name = \".*?\"\\n?"_s );
386 warnings->replace( rxFailedToLoadExternalUriForImage, QString() );
387 const thread_local QRegularExpression rxFileNotFound( u
"File not found : .*?\\n"_s );
388 warnings->replace( rxFileNotFound, QString() );
394std::size_t QgsGltfUtils::sourceSceneForModel(
const tinygltf::Model &model,
bool &ok )
397 if ( model.scenes.empty() )
403 int index = model.defaultScene;
404 if ( index >= 0 &&
static_cast< std::size_t
>( index ) < model.scenes.size() )
416void dumpDracoModelInfo( draco::Mesh *dracoMesh )
418 std::cout <<
"Decoded Draco Mesh:" << dracoMesh->num_points() <<
" points / " << dracoMesh->num_faces() <<
" faces" << std::endl;
419 draco::GeometryMetadata *geometryMetadata = dracoMesh->metadata();
421 std::cout <<
"Global Geometry Metadata:" << std::endl;
422 for (
const auto &entry : geometryMetadata->entries() )
424 std::cout <<
" Key: " << entry.first <<
", Value: " << entry.second.data().size() << std::endl;
427 std::cout <<
"\nAttribute Metadata:" << std::endl;
428 for ( int32_t i = 0; i < dracoMesh->num_attributes(); ++i )
430 const draco::PointAttribute *attribute = dracoMesh->attribute( i );
434 std::cout <<
" Attribute ID: " << attribute->unique_id() <<
" / " << draco::PointAttribute::TypeToString( attribute->attribute_type() ) << std::endl;
435 if (
const draco::AttributeMetadata *attributeMetadata = geometryMetadata->attribute_metadata( attribute->unique_id() ) )
437 for (
const auto &entry : attributeMetadata->entries() )
439 std::cout <<
" Key: " << entry.first <<
", Length: " << entry.second.data().size() << std::endl;
446bool QgsGltfUtils::loadDracoModel(
const QByteArray &data,
const I3SNodeContext &context, tinygltf::Model &model, QString *errors )
452 QByteArray dataExtracted;
453 if ( data.startsWith( QByteArray(
"\x1f\x8b", 2 ) ) )
458 *errors =
"Failed to decode gzipped model";
464 dataExtracted = data;
471 draco::Decoder decoder;
472 draco::DecoderBuffer decoderBuffer;
473 decoderBuffer.Init( dataExtracted.constData(), dataExtracted.size() );
475 draco::StatusOr<draco::EncodedGeometryType> geometryTypeStatus = decoder.GetEncodedGeometryType( &decoderBuffer );
476 if ( !geometryTypeStatus.ok() )
479 *errors =
"Failed to get geometry type: " + QString( geometryTypeStatus.status().error_msg() );
482 if ( geometryTypeStatus.value() != draco::EncodedGeometryType::TRIANGULAR_MESH )
485 *errors =
"Not a triangular mesh";
489 draco::StatusOr<std::unique_ptr<draco::Mesh>> meshStatus = decoder.DecodeMeshFromBuffer( &decoderBuffer );
490 if ( !meshStatus.ok() )
493 *errors =
"Failed to decode mesh: " + QString( meshStatus.status().error_msg() );
497 std::unique_ptr<draco::Mesh> dracoMesh = std::move( meshStatus ).value();
499 draco::GeometryMetadata *geometryMetadata = dracoMesh->metadata();
500 if ( !geometryMetadata )
503 *errors =
"Geometry metadata missing";
507 int posAccessorIndex = -1;
508 int normalAccessorIndex = -1;
509 int uvAccessorIndex = -1;
510 int indicesAccessorIndex = -1;
516 const draco::PointAttribute *posAttribute = dracoMesh->GetNamedAttribute( draco::GeometryAttribute::POSITION );
519 double scaleX = 1, scaleY = 1;
520 const draco::AttributeMetadata *posMetadata = geometryMetadata->attribute_metadata( posAttribute->unique_id() );
523 posMetadata->GetEntryDouble(
"i3s-scale_x", &scaleX );
524 posMetadata->GetEntryDouble(
"i3s-scale_y", &scaleY );
529 std::vector<unsigned char> posData( dracoMesh->num_points() * 3 *
sizeof(
float ) );
530 float *posPtr =
reinterpret_cast<float *
>( posData.data() );
533 for ( draco::PointIndex i( 0 ); i < dracoMesh->num_points(); ++i )
535 posAttribute->ConvertValue<
float>( posAttribute->mapped_index( i ), posAttribute->num_components(), values );
541 if ( context.isGlobalMode )
543 double lonDeg = double( values[0] ) * scaleX + nodeCenterLonLat.
x();
544 double latDeg = double( values[1] ) * scaleY + nodeCenterLonLat.
y();
545 double alt = double( values[2] ) + nodeCenterLonLat.
z();
547 QgsVector3D localPos = ecef - context.nodeCenterEcef;
549 values[0] =
static_cast<float>( localPos.
x() );
550 values[1] =
static_cast<float>( localPos.
y() );
551 values[2] =
static_cast<float>( localPos.
z() );
554 posPtr[i.value() * 3 + 0] = values[0];
555 posPtr[i.value() * 3 + 1] = values[1];
556 posPtr[i.value() * 3 + 2] = values[2];
559 tinygltf::Buffer posBuffer;
560 posBuffer.data = posData;
561 model.buffers.emplace_back( std::move( posBuffer ) );
563 tinygltf::BufferView posBufferView;
564 posBufferView.buffer =
static_cast<int>( model.buffers.size() ) - 1;
565 posBufferView.byteOffset = 0;
566 posBufferView.byteLength = posData.size();
567 posBufferView.target = TINYGLTF_TARGET_ARRAY_BUFFER;
568 model.bufferViews.emplace_back( std::move( posBufferView ) );
570 tinygltf::Accessor posAccessor;
571 posAccessor.bufferView =
static_cast<int>( model.bufferViews.size() ) - 1;
572 posAccessor.byteOffset = 0;
573 posAccessor.componentType = TINYGLTF_COMPONENT_TYPE_FLOAT;
574 posAccessor.count = dracoMesh->num_points();
575 posAccessor.type = TINYGLTF_TYPE_VEC3;
576 model.accessors.emplace_back( std::move( posAccessor ) );
578 posAccessorIndex =
static_cast<int>( model.accessors.size() ) - 1;
585 const draco::PointAttribute *normalAttribute = dracoMesh->GetNamedAttribute( draco::GeometryAttribute::NORMAL );
586 if ( normalAttribute )
588 std::vector<unsigned char> normalData( dracoMesh->num_points() * 3 *
sizeof(
float ) );
589 float *normalPtr =
reinterpret_cast<float *
>( normalData.data() );
592 for ( draco::PointIndex i( 0 ); i < dracoMesh->num_points(); ++i )
594 normalAttribute->ConvertValue<
float>( normalAttribute->mapped_index( i ), normalAttribute->num_components(), values );
596 normalPtr[i.value() * 3 + 0] = values[0];
597 normalPtr[i.value() * 3 + 1] = values[1];
598 normalPtr[i.value() * 3 + 2] = values[2];
601 tinygltf::Buffer normalBuffer;
602 normalBuffer.data = normalData;
603 model.buffers.emplace_back( std::move( normalBuffer ) );
605 tinygltf::BufferView normalBufferView;
606 normalBufferView.buffer =
static_cast<int>( model.buffers.size() ) - 1;
607 normalBufferView.byteOffset = 0;
608 normalBufferView.byteLength = normalData.size();
609 normalBufferView.target = TINYGLTF_TARGET_ARRAY_BUFFER;
610 model.bufferViews.emplace_back( std::move( normalBufferView ) );
612 tinygltf::Accessor normalAccessor;
613 normalAccessor.bufferView =
static_cast<int>( model.bufferViews.size() ) - 1;
614 normalAccessor.byteOffset = 0;
615 normalAccessor.componentType = TINYGLTF_COMPONENT_TYPE_FLOAT;
616 normalAccessor.count = dracoMesh->num_points();
617 normalAccessor.type = TINYGLTF_TYPE_VEC3;
618 model.accessors.emplace_back( std::move( normalAccessor ) );
620 normalAccessorIndex =
static_cast<int>( model.accessors.size() ) - 1;
627 const draco::PointAttribute *uvAttribute = dracoMesh->GetNamedAttribute( draco::GeometryAttribute::TEX_COORD );
630 std::vector<unsigned char> uvData( dracoMesh->num_points() * 2 *
sizeof(
float ) );
631 float *uvPtr =
reinterpret_cast<float *
>( uvData.data() );
635 const draco::PointAttribute *uvRegionAttribute =
nullptr;
636 for ( int32_t i = 0; i < dracoMesh->num_attributes(); ++i )
638 const draco::PointAttribute *attribute = dracoMesh->attribute( i );
642 draco::AttributeMetadata *attributeMetadata = geometryMetadata->attribute_metadata( attribute->unique_id() );
643 if ( !attributeMetadata )
646 std::string i3sAttributeType;
647 if ( attributeMetadata->GetEntryString(
"i3s-attribute-type", &i3sAttributeType ) && i3sAttributeType ==
"uv-region" )
649 uvRegionAttribute = attribute;
654 for ( draco::PointIndex i( 0 ); i < dracoMesh->num_points(); ++i )
656 uvAttribute->ConvertValue<
float>( uvAttribute->mapped_index( i ), uvAttribute->num_components(), values );
658 if ( uvRegionAttribute )
664 uint16_t uvRegion[4];
665 uvRegionAttribute->ConvertValue<uint16_t>( uvRegionAttribute->mapped_index( i ), uvRegionAttribute->num_components(), uvRegion );
666 float uMin =
static_cast<float>( uvRegion[0] ) / 65535.f;
667 float vMin =
static_cast<float>( uvRegion[1] ) / 65535.f;
668 float uMax =
static_cast<float>( uvRegion[2] ) / 65535.f;
669 float vMax =
static_cast<float>( uvRegion[3] ) / 65535.f;
670 values[0] = uMin + values[0] * ( uMax - uMin );
671 values[1] = vMin + values[1] * ( vMax - vMin );
674 uvPtr[i.value() * 2 + 0] = values[0];
675 uvPtr[i.value() * 2 + 1] = values[1];
678 tinygltf::Buffer uvBuffer;
679 uvBuffer.data = uvData;
680 model.buffers.emplace_back( std::move( uvBuffer ) );
682 tinygltf::BufferView uvBufferView;
683 uvBufferView.buffer =
static_cast<int>( model.buffers.size() ) - 1;
684 uvBufferView.byteOffset = 0;
685 uvBufferView.byteLength = uvData.size();
686 uvBufferView.target = TINYGLTF_TARGET_ARRAY_BUFFER;
687 model.bufferViews.emplace_back( std::move( uvBufferView ) );
689 tinygltf::Accessor uvAccessor;
690 uvAccessor.bufferView =
static_cast<int>( model.bufferViews.size() ) - 1;
691 uvAccessor.byteOffset = 0;
692 uvAccessor.componentType = TINYGLTF_COMPONENT_TYPE_FLOAT;
693 uvAccessor.count = dracoMesh->num_points();
694 uvAccessor.type = TINYGLTF_TYPE_VEC2;
695 model.accessors.emplace_back( std::move( uvAccessor ) );
697 uvAccessorIndex =
static_cast<int>( model.accessors.size() ) - 1;
705 std::vector<unsigned char> indexData;
706 indexData.resize( dracoMesh->num_faces() * 3 *
sizeof( quint32 ) );
707 Q_ASSERT(
sizeof( dracoMesh->face( draco::FaceIndex( 0 ) )[0] ) ==
sizeof( quint32 ) );
708 memcpy( indexData.data(), &dracoMesh->face( draco::FaceIndex( 0 ) )[0], indexData.size() );
710 tinygltf::Buffer gltfIndexBuffer;
711 gltfIndexBuffer.data = indexData;
712 model.buffers.emplace_back( std::move( gltfIndexBuffer ) );
714 tinygltf::BufferView indexBufferView;
715 indexBufferView.buffer =
static_cast<int>( model.buffers.size() ) - 1;
716 indexBufferView.byteLength = dracoMesh->num_faces() * 3 *
sizeof( quint32 );
717 indexBufferView.byteOffset = 0;
718 indexBufferView.byteStride = 0;
719 indexBufferView.target = TINYGLTF_TARGET_ELEMENT_ARRAY_BUFFER;
720 model.bufferViews.emplace_back( std::move( indexBufferView ) );
722 tinygltf::Accessor indicesAccessor;
723 indicesAccessor.bufferView =
static_cast<int>( model.bufferViews.size() ) - 1;
724 indicesAccessor.byteOffset = 0;
725 indicesAccessor.count = dracoMesh->num_faces() * 3;
726 indicesAccessor.type = TINYGLTF_TYPE_SCALAR;
727 indicesAccessor.componentType = TINYGLTF_COMPONENT_TYPE_UNSIGNED_INT;
728 model.accessors.emplace_back( std::move( indicesAccessor ) );
730 indicesAccessorIndex =
static_cast<int>( model.accessors.size() ) - 1;
736 tinygltf::Material material;
737 int materialIndex = loadMaterialFromMetadata( context.materialInfo, model );
739 tinygltf::Primitive primitive;
740 primitive.mode = TINYGLTF_MODE_TRIANGLES;
741 primitive.material = materialIndex;
742 primitive.indices = indicesAccessorIndex;
743 if ( posAccessorIndex != -1 )
744 primitive.attributes[
"POSITION"] = posAccessorIndex;
745 if ( normalAccessorIndex != -1 )
746 primitive.attributes[
"NORMAL"] = normalAccessorIndex;
747 if ( uvAccessorIndex != -1 )
748 primitive.attributes[
"TEXCOORD_0"] = uvAccessorIndex;
750 tinygltf::Mesh tiny_mesh;
751 tiny_mesh.primitives.emplace_back( std::move( primitive ) );
752 model.meshes.emplace_back( std::move( tiny_mesh ) );
756 model.nodes.emplace_back( std::move( node ) );
758 tinygltf::Scene scene;
759 scene.nodes.push_back( 0 );
760 model.scenes.emplace_back( std::move( scene ) );
762 model.defaultScene = 0;
763 model.asset.version =
"2.0";
769bool QgsGltfUtils::loadDracoModel(
const QByteArray &data,
const I3SNodeContext &context, tinygltf::Model &model, QString *errors )
775 *errors =
"Cannot load geometry - QGIS was built without Draco library.";
781int QgsGltfUtils::loadMaterialFromMetadata(
const QVariantMap &materialInfo, tinygltf::Model &model )
783 tinygltf::Material material;
784 material.name =
"DefaultMaterial";
786 QVariantList colorList = materialInfo[
"pbrBaseColorFactor"].toList();
787 material.pbrMetallicRoughness.baseColorFactor = { colorList[0].toDouble(), colorList[1].toDouble(), colorList[2].toDouble(), colorList[3].toDouble() };
789 if ( materialInfo.contains(
"pbrBaseColorTexture" ) )
791 QString baseColorTextureUri = materialInfo[
"pbrBaseColorTexture"].toString();
794 img.uri = baseColorTextureUri.toStdString();
795 model.images.emplace_back( std::move( img ) );
797 tinygltf::Texture tex;
798 tex.source =
static_cast<int>( model.images.size() ) - 1;
799 model.textures.emplace_back( std::move( tex ) );
801 material.pbrMetallicRoughness.baseColorTexture.index =
static_cast<int>( model.textures.size() ) - 1;
804 if ( materialInfo.contains(
"doubleSided" ) )
806 material.doubleSided = materialInfo[
"doubleSided"].toInt();
810 model.materials.emplace_back( std::move( material ) );
812 return static_cast<int>( model.materials.size() ) - 1;
815bool QgsGltfUtils::writeGltfModel(
const tinygltf::Model &model,
const QString &outputFilename )
817 tinygltf::TinyGLTF gltf;
818 bool res = gltf.WriteGltfSceneToFile(
820 outputFilename.toStdString(),
829void QgsGltfUtils::I3SNodeContext::initFromTile(
833 const QVariantMap tileMetadata = tile.
metadata();
835 materialInfo = tileMetadata[u
"material"_s].toMap();
@ Geocentric
Geocentric CRS.
@ Reverse
Reverse/inverse transform (from destination to source).
Represents a coordinate reference system (CRS).
Qgis::CrsType type() const
Returns the type of the CRS.
Contains information about the context in which a coordinate transform is executed.
Custom exception class for Coordinate Reference System related exceptions.
A simple 4x4 matrix implementation useful for transformation in 3D space.
QgsVector3D map(const QgsVector3D &vector) const
Matrix-vector multiplication (vector is converted to homogeneous coordinates [X,Y,...
QgsVector3D center() const
Returns the vector to the center of the box.
QgsOrientedBox3D box() const
Returns the volume's oriented box.
Represents an individual tile from a tiled scene data source.
const QgsTiledSceneBoundingVolume & boundingVolume() const
Returns the bounding volume for the tile.
QVariantMap metadata() const
Returns additional metadata attached to the tile.
A 3D vector (similar to QVector3D) with the difference that it uses double precision instead of singl...
double y() const
Returns Y coordinate.
double z() const
Returns Z coordinate.
bool isNull() const
Returns true if all three coordinates are zero.
double x() const
Returns X coordinate.
static bool decodeGzip(const QByteArray &bytesIn, QByteArray &bytesOut)
Decodes gzip byte stream, returns true on success.
#define QgsDebugError(str)