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,
const QString &baseDir )
350 tinygltf::TinyGLTF loader;
352 loader.SetImageLoader( QgsGltfUtils::loadImageDataWithQImage,
nullptr );
358 loader.SetParseStrictness( tinygltf::ParseStrictness::Permissive );
360 std::string err, warn;
363 if ( data.startsWith(
"glTF" ) )
365 if ( data.at( 4 ) == 1 )
367 *errors = QObject::tr(
"GLTF version 1 tiles cannot be loaded" );
370 res = loader.LoadBinaryFromMemory( &model, &err, &warn, (
const unsigned char * ) data.constData(), data.size(), baseDir.toStdString() );
374 res = loader.LoadASCIIFromString( &model, &err, &warn, data.constData(), data.size(), baseDir.toStdString() );
378 *errors = QString::fromStdString( err );
381 *warnings = QString::fromStdString( warn );
384 const thread_local QRegularExpression rxFailedToLoadExternalUriForImage( u
"Failed to load external 'uri' for image\\[\\d+\\] name = \".*?\"\\n?"_s );
385 warnings->replace( rxFailedToLoadExternalUriForImage, QString() );
386 const thread_local QRegularExpression rxFileNotFound( u
"File not found : .*?\\n"_s );
387 warnings->replace( rxFileNotFound, QString() );
393std::size_t QgsGltfUtils::sourceSceneForModel(
const tinygltf::Model &model,
bool &ok )
396 if ( model.scenes.empty() )
402 int index = model.defaultScene;
403 if ( index >= 0 &&
static_cast< std::size_t
>( index ) < model.scenes.size() )
414void dumpDracoModelInfo( draco::Mesh *dracoMesh )
416 std::cout <<
"Decoded Draco Mesh:" << dracoMesh->num_points() <<
" points / " << dracoMesh->num_faces() <<
" faces" << std::endl;
417 draco::GeometryMetadata *geometryMetadata = dracoMesh->metadata();
419 std::cout <<
"Global Geometry Metadata:" << std::endl;
420 for (
const auto &entry : geometryMetadata->entries() )
422 std::cout <<
" Key: " << entry.first <<
", Value: " << entry.second.data().size() << std::endl;
425 std::cout <<
"\nAttribute Metadata:" << std::endl;
426 for ( int32_t i = 0; i < dracoMesh->num_attributes(); ++i )
428 const draco::PointAttribute *attribute = dracoMesh->attribute( i );
432 std::cout <<
" Attribute ID: " << attribute->unique_id() <<
" / " << draco::PointAttribute::TypeToString( attribute->attribute_type() ) << std::endl;
433 if (
const draco::AttributeMetadata *attributeMetadata = geometryMetadata->attribute_metadata( attribute->unique_id() ) )
435 for (
const auto &entry : attributeMetadata->entries() )
437 std::cout <<
" Key: " << entry.first <<
", Length: " << entry.second.data().size() << std::endl;
444bool QgsGltfUtils::loadDracoModel(
const QByteArray &data,
const I3SNodeContext &context, tinygltf::Model &model, QString *errors )
450 QByteArray dataExtracted;
451 if ( data.startsWith( QByteArray(
"\x1f\x8b", 2 ) ) )
456 *errors =
"Failed to decode gzipped model";
462 dataExtracted = data;
469 draco::Decoder decoder;
470 draco::DecoderBuffer decoderBuffer;
471 decoderBuffer.Init( dataExtracted.constData(), dataExtracted.size() );
473 draco::StatusOr<draco::EncodedGeometryType> geometryTypeStatus = decoder.GetEncodedGeometryType( &decoderBuffer );
474 if ( !geometryTypeStatus.ok() )
477 *errors =
"Failed to get geometry type: " + QString( geometryTypeStatus.status().error_msg() );
480 if ( geometryTypeStatus.value() != draco::EncodedGeometryType::TRIANGULAR_MESH )
483 *errors =
"Not a triangular mesh";
487 draco::StatusOr<std::unique_ptr<draco::Mesh>> meshStatus = decoder.DecodeMeshFromBuffer( &decoderBuffer );
488 if ( !meshStatus.ok() )
491 *errors =
"Failed to decode mesh: " + QString( meshStatus.status().error_msg() );
495 std::unique_ptr<draco::Mesh> dracoMesh = std::move( meshStatus ).value();
497 draco::GeometryMetadata *geometryMetadata = dracoMesh->metadata();
498 if ( !geometryMetadata )
501 *errors =
"Geometry metadata missing";
505 int posAccessorIndex = -1;
506 int normalAccessorIndex = -1;
507 int uvAccessorIndex = -1;
508 int indicesAccessorIndex = -1;
514 const draco::PointAttribute *posAttribute = dracoMesh->GetNamedAttribute( draco::GeometryAttribute::POSITION );
517 double scaleX = 1, scaleY = 1;
518 const draco::AttributeMetadata *posMetadata = geometryMetadata->attribute_metadata( posAttribute->unique_id() );
521 posMetadata->GetEntryDouble(
"i3s-scale_x", &scaleX );
522 posMetadata->GetEntryDouble(
"i3s-scale_y", &scaleY );
527 std::vector<unsigned char> posData( dracoMesh->num_points() * 3 *
sizeof(
float ) );
528 float *posPtr =
reinterpret_cast<float *
>( posData.data() );
531 for ( draco::PointIndex i( 0 ); i < dracoMesh->num_points(); ++i )
533 posAttribute->ConvertValue<
float>( posAttribute->mapped_index( i ), posAttribute->num_components(), values );
539 if ( context.isGlobalMode )
541 double lonDeg = double( values[0] ) * scaleX + nodeCenterLonLat.
x();
542 double latDeg = double( values[1] ) * scaleY + nodeCenterLonLat.
y();
543 double alt = double( values[2] ) + nodeCenterLonLat.
z();
545 QgsVector3D localPos = ecef - context.nodeCenterEcef;
547 values[0] =
static_cast<float>( localPos.
x() );
548 values[1] =
static_cast<float>( localPos.
y() );
549 values[2] =
static_cast<float>( localPos.
z() );
552 posPtr[i.value() * 3 + 0] = values[0];
553 posPtr[i.value() * 3 + 1] = values[1];
554 posPtr[i.value() * 3 + 2] = values[2];
557 tinygltf::Buffer posBuffer;
558 posBuffer.data = posData;
559 model.buffers.emplace_back( std::move( posBuffer ) );
561 tinygltf::BufferView posBufferView;
562 posBufferView.buffer =
static_cast<int>( model.buffers.size() ) - 1;
563 posBufferView.byteOffset = 0;
564 posBufferView.byteLength = posData.size();
565 posBufferView.target = TINYGLTF_TARGET_ARRAY_BUFFER;
566 model.bufferViews.emplace_back( std::move( posBufferView ) );
568 tinygltf::Accessor posAccessor;
569 posAccessor.bufferView =
static_cast<int>( model.bufferViews.size() ) - 1;
570 posAccessor.byteOffset = 0;
571 posAccessor.componentType = TINYGLTF_COMPONENT_TYPE_FLOAT;
572 posAccessor.count = dracoMesh->num_points();
573 posAccessor.type = TINYGLTF_TYPE_VEC3;
574 model.accessors.emplace_back( std::move( posAccessor ) );
576 posAccessorIndex =
static_cast<int>( model.accessors.size() ) - 1;
583 const draco::PointAttribute *normalAttribute = dracoMesh->GetNamedAttribute( draco::GeometryAttribute::NORMAL );
584 if ( normalAttribute )
586 std::vector<unsigned char> normalData( dracoMesh->num_points() * 3 *
sizeof(
float ) );
587 float *normalPtr =
reinterpret_cast<float *
>( normalData.data() );
590 for ( draco::PointIndex i( 0 ); i < dracoMesh->num_points(); ++i )
592 normalAttribute->ConvertValue<
float>( normalAttribute->mapped_index( i ), normalAttribute->num_components(), values );
594 normalPtr[i.value() * 3 + 0] = values[0];
595 normalPtr[i.value() * 3 + 1] = values[1];
596 normalPtr[i.value() * 3 + 2] = values[2];
599 tinygltf::Buffer normalBuffer;
600 normalBuffer.data = normalData;
601 model.buffers.emplace_back( std::move( normalBuffer ) );
603 tinygltf::BufferView normalBufferView;
604 normalBufferView.buffer =
static_cast<int>( model.buffers.size() ) - 1;
605 normalBufferView.byteOffset = 0;
606 normalBufferView.byteLength = normalData.size();
607 normalBufferView.target = TINYGLTF_TARGET_ARRAY_BUFFER;
608 model.bufferViews.emplace_back( std::move( normalBufferView ) );
610 tinygltf::Accessor normalAccessor;
611 normalAccessor.bufferView =
static_cast<int>( model.bufferViews.size() ) - 1;
612 normalAccessor.byteOffset = 0;
613 normalAccessor.componentType = TINYGLTF_COMPONENT_TYPE_FLOAT;
614 normalAccessor.count = dracoMesh->num_points();
615 normalAccessor.type = TINYGLTF_TYPE_VEC3;
616 model.accessors.emplace_back( std::move( normalAccessor ) );
618 normalAccessorIndex =
static_cast<int>( model.accessors.size() ) - 1;
625 const draco::PointAttribute *uvAttribute = dracoMesh->GetNamedAttribute( draco::GeometryAttribute::TEX_COORD );
628 std::vector<unsigned char> uvData( dracoMesh->num_points() * 2 *
sizeof(
float ) );
629 float *uvPtr =
reinterpret_cast<float *
>( uvData.data() );
633 const draco::PointAttribute *uvRegionAttribute =
nullptr;
634 for ( int32_t i = 0; i < dracoMesh->num_attributes(); ++i )
636 const draco::PointAttribute *attribute = dracoMesh->attribute( i );
640 draco::AttributeMetadata *attributeMetadata = geometryMetadata->attribute_metadata( attribute->unique_id() );
641 if ( !attributeMetadata )
644 std::string i3sAttributeType;
645 if ( attributeMetadata->GetEntryString(
"i3s-attribute-type", &i3sAttributeType ) && i3sAttributeType ==
"uv-region" )
647 uvRegionAttribute = attribute;
652 for ( draco::PointIndex i( 0 ); i < dracoMesh->num_points(); ++i )
654 uvAttribute->ConvertValue<
float>( uvAttribute->mapped_index( i ), uvAttribute->num_components(), values );
656 if ( uvRegionAttribute )
662 uint16_t uvRegion[4];
663 uvRegionAttribute->ConvertValue<uint16_t>( uvRegionAttribute->mapped_index( i ), uvRegionAttribute->num_components(), uvRegion );
664 float uMin =
static_cast<float>( uvRegion[0] ) / 65535.f;
665 float vMin =
static_cast<float>( uvRegion[1] ) / 65535.f;
666 float uMax =
static_cast<float>( uvRegion[2] ) / 65535.f;
667 float vMax =
static_cast<float>( uvRegion[3] ) / 65535.f;
668 values[0] = uMin + values[0] * ( uMax - uMin );
669 values[1] = vMin + values[1] * ( vMax - vMin );
672 uvPtr[i.value() * 2 + 0] = values[0];
673 uvPtr[i.value() * 2 + 1] = values[1];
676 tinygltf::Buffer uvBuffer;
677 uvBuffer.data = uvData;
678 model.buffers.emplace_back( std::move( uvBuffer ) );
680 tinygltf::BufferView uvBufferView;
681 uvBufferView.buffer =
static_cast<int>( model.buffers.size() ) - 1;
682 uvBufferView.byteOffset = 0;
683 uvBufferView.byteLength = uvData.size();
684 uvBufferView.target = TINYGLTF_TARGET_ARRAY_BUFFER;
685 model.bufferViews.emplace_back( std::move( uvBufferView ) );
687 tinygltf::Accessor uvAccessor;
688 uvAccessor.bufferView =
static_cast<int>( model.bufferViews.size() ) - 1;
689 uvAccessor.byteOffset = 0;
690 uvAccessor.componentType = TINYGLTF_COMPONENT_TYPE_FLOAT;
691 uvAccessor.count = dracoMesh->num_points();
692 uvAccessor.type = TINYGLTF_TYPE_VEC2;
693 model.accessors.emplace_back( std::move( uvAccessor ) );
695 uvAccessorIndex =
static_cast<int>( model.accessors.size() ) - 1;
703 std::vector<unsigned char> indexData;
704 indexData.resize( dracoMesh->num_faces() * 3 *
sizeof( quint32 ) );
705 Q_ASSERT(
sizeof( dracoMesh->face( draco::FaceIndex( 0 ) )[0] ) ==
sizeof( quint32 ) );
706 memcpy( indexData.data(), &dracoMesh->face( draco::FaceIndex( 0 ) )[0], indexData.size() );
708 tinygltf::Buffer gltfIndexBuffer;
709 gltfIndexBuffer.data = indexData;
710 model.buffers.emplace_back( std::move( gltfIndexBuffer ) );
712 tinygltf::BufferView indexBufferView;
713 indexBufferView.buffer =
static_cast<int>( model.buffers.size() ) - 1;
714 indexBufferView.byteLength = dracoMesh->num_faces() * 3 *
sizeof( quint32 );
715 indexBufferView.byteOffset = 0;
716 indexBufferView.byteStride = 0;
717 indexBufferView.target = TINYGLTF_TARGET_ELEMENT_ARRAY_BUFFER;
718 model.bufferViews.emplace_back( std::move( indexBufferView ) );
720 tinygltf::Accessor indicesAccessor;
721 indicesAccessor.bufferView =
static_cast<int>( model.bufferViews.size() ) - 1;
722 indicesAccessor.byteOffset = 0;
723 indicesAccessor.count = dracoMesh->num_faces() * 3;
724 indicesAccessor.type = TINYGLTF_TYPE_SCALAR;
725 indicesAccessor.componentType = TINYGLTF_COMPONENT_TYPE_UNSIGNED_INT;
726 model.accessors.emplace_back( std::move( indicesAccessor ) );
728 indicesAccessorIndex =
static_cast<int>( model.accessors.size() ) - 1;
734 tinygltf::Material material;
735 int materialIndex = loadMaterialFromMetadata( context.materialInfo, model );
737 tinygltf::Primitive primitive;
738 primitive.mode = TINYGLTF_MODE_TRIANGLES;
739 primitive.material = materialIndex;
740 primitive.indices = indicesAccessorIndex;
741 if ( posAccessorIndex != -1 )
742 primitive.attributes[
"POSITION"] = posAccessorIndex;
743 if ( normalAccessorIndex != -1 )
744 primitive.attributes[
"NORMAL"] = normalAccessorIndex;
745 if ( uvAccessorIndex != -1 )
746 primitive.attributes[
"TEXCOORD_0"] = uvAccessorIndex;
748 tinygltf::Mesh tiny_mesh;
749 tiny_mesh.primitives.emplace_back( std::move( primitive ) );
750 model.meshes.emplace_back( std::move( tiny_mesh ) );
754 model.nodes.emplace_back( std::move( node ) );
756 tinygltf::Scene scene;
757 scene.nodes.push_back( 0 );
758 model.scenes.emplace_back( std::move( scene ) );
760 model.defaultScene = 0;
761 model.asset.version =
"2.0";
767bool QgsGltfUtils::loadDracoModel(
const QByteArray &data,
const I3SNodeContext &context, tinygltf::Model &model, QString *errors )
773 *errors =
"Cannot load geometry - QGIS was built without Draco library.";
779int QgsGltfUtils::loadMaterialFromMetadata(
const QVariantMap &materialInfo, tinygltf::Model &model )
781 tinygltf::Material material;
782 material.name =
"DefaultMaterial";
784 QVariantList colorList = materialInfo[
"pbrBaseColorFactor"].toList();
785 material.pbrMetallicRoughness.baseColorFactor = { colorList[0].toDouble(), colorList[1].toDouble(), colorList[2].toDouble(), colorList[3].toDouble() };
787 if ( materialInfo.contains(
"pbrBaseColorTexture" ) )
789 QString baseColorTextureUri = materialInfo[
"pbrBaseColorTexture"].toString();
792 img.uri = baseColorTextureUri.toStdString();
793 model.images.emplace_back( std::move( img ) );
795 tinygltf::Texture tex;
796 tex.source =
static_cast<int>( model.images.size() ) - 1;
797 model.textures.emplace_back( std::move( tex ) );
799 material.pbrMetallicRoughness.baseColorTexture.index =
static_cast<int>( model.textures.size() ) - 1;
802 if ( materialInfo.contains(
"doubleSided" ) )
804 material.doubleSided = materialInfo[
"doubleSided"].toInt();
808 model.materials.emplace_back( std::move( material ) );
810 return static_cast<int>( model.materials.size() ) - 1;
813bool QgsGltfUtils::writeGltfModel(
const tinygltf::Model &model,
const QString &outputFilename )
815 tinygltf::TinyGLTF gltf;
816 bool res = gltf.WriteGltfSceneToFile(
818 outputFilename.toStdString(),
827void QgsGltfUtils::I3SNodeContext::initFromTile(
831 const QVariantMap tileMetadata = tile.
metadata();
833 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)