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() )
415void dumpDracoModelInfo( draco::Mesh *dracoMesh )
417 std::cout <<
"Decoded Draco Mesh:" << dracoMesh->num_points() <<
" points / " << dracoMesh->num_faces() <<
" faces" << std::endl;
418 draco::GeometryMetadata *geometryMetadata = dracoMesh->metadata();
420 std::cout <<
"Global Geometry Metadata:" << std::endl;
421 for (
const auto &entry : geometryMetadata->entries() )
423 std::cout <<
" Key: " << entry.first <<
", Value: " << entry.second.data().size() << std::endl;
426 std::cout <<
"\nAttribute Metadata:" << std::endl;
427 for ( int32_t i = 0; i < dracoMesh->num_attributes(); ++i )
429 const draco::PointAttribute *attribute = dracoMesh->attribute( i );
433 std::cout <<
" Attribute ID: " << attribute->unique_id() <<
" / " << draco::PointAttribute::TypeToString( attribute->attribute_type() ) << std::endl;
434 if (
const draco::AttributeMetadata *attributeMetadata = geometryMetadata->attribute_metadata( attribute->unique_id() ) )
436 for (
const auto &entry : attributeMetadata->entries() )
438 std::cout <<
" Key: " << entry.first <<
", Length: " << entry.second.data().size() << std::endl;
445bool QgsGltfUtils::loadDracoModel(
const QByteArray &data,
const I3SNodeContext &context, tinygltf::Model &model, QString *errors )
451 QByteArray dataExtracted;
452 if ( data.startsWith( QByteArray(
"\x1f\x8b", 2 ) ) )
457 *errors =
"Failed to decode gzipped model";
463 dataExtracted = data;
470 draco::Decoder decoder;
471 draco::DecoderBuffer decoderBuffer;
472 decoderBuffer.Init( dataExtracted.constData(), dataExtracted.size() );
474 draco::StatusOr<draco::EncodedGeometryType> geometryTypeStatus = decoder.GetEncodedGeometryType( &decoderBuffer );
475 if ( !geometryTypeStatus.ok() )
478 *errors =
"Failed to get geometry type: " + QString( geometryTypeStatus.status().error_msg() );
481 if ( geometryTypeStatus.value() != draco::EncodedGeometryType::TRIANGULAR_MESH )
484 *errors =
"Not a triangular mesh";
488 draco::StatusOr<std::unique_ptr<draco::Mesh>> meshStatus = decoder.DecodeMeshFromBuffer( &decoderBuffer );
489 if ( !meshStatus.ok() )
492 *errors =
"Failed to decode mesh: " + QString( meshStatus.status().error_msg() );
496 std::unique_ptr<draco::Mesh> dracoMesh = std::move( meshStatus ).value();
498 draco::GeometryMetadata *geometryMetadata = dracoMesh->metadata();
499 if ( !geometryMetadata )
502 *errors =
"Geometry metadata missing";
506 int posAccessorIndex = -1;
507 int normalAccessorIndex = -1;
508 int uvAccessorIndex = -1;
509 int indicesAccessorIndex = -1;
515 const draco::PointAttribute *posAttribute = dracoMesh->GetNamedAttribute( draco::GeometryAttribute::POSITION );
518 double scaleX = 1, scaleY = 1;
519 const draco::AttributeMetadata *posMetadata = geometryMetadata->attribute_metadata( posAttribute->unique_id() );
522 posMetadata->GetEntryDouble(
"i3s-scale_x", &scaleX );
523 posMetadata->GetEntryDouble(
"i3s-scale_y", &scaleY );
528 std::vector<unsigned char> posData( dracoMesh->num_points() * 3 *
sizeof(
float ) );
529 float *posPtr =
reinterpret_cast<float *
>( posData.data() );
532 for ( draco::PointIndex i( 0 ); i < dracoMesh->num_points(); ++i )
534 posAttribute->ConvertValue<
float>( posAttribute->mapped_index( i ), posAttribute->num_components(), values );
540 if ( context.isGlobalMode )
542 double lonDeg = double( values[0] ) * scaleX + nodeCenterLonLat.
x();
543 double latDeg = double( values[1] ) * scaleY + nodeCenterLonLat.
y();
544 double alt = double( values[2] ) + nodeCenterLonLat.
z();
546 QgsVector3D localPos = ecef - context.nodeCenterEcef;
548 values[0] =
static_cast<float>( localPos.
x() );
549 values[1] =
static_cast<float>( localPos.
y() );
550 values[2] =
static_cast<float>( localPos.
z() );
553 posPtr[i.value() * 3 + 0] = values[0];
554 posPtr[i.value() * 3 + 1] = values[1];
555 posPtr[i.value() * 3 + 2] = values[2];
558 tinygltf::Buffer posBuffer;
559 posBuffer.data = posData;
560 model.buffers.emplace_back( std::move( posBuffer ) );
562 tinygltf::BufferView posBufferView;
563 posBufferView.buffer =
static_cast<int>( model.buffers.size() ) - 1;
564 posBufferView.byteOffset = 0;
565 posBufferView.byteLength = posData.size();
566 posBufferView.target = TINYGLTF_TARGET_ARRAY_BUFFER;
567 model.bufferViews.emplace_back( std::move( posBufferView ) );
569 tinygltf::Accessor posAccessor;
570 posAccessor.bufferView =
static_cast<int>( model.bufferViews.size() ) - 1;
571 posAccessor.byteOffset = 0;
572 posAccessor.componentType = TINYGLTF_COMPONENT_TYPE_FLOAT;
573 posAccessor.count = dracoMesh->num_points();
574 posAccessor.type = TINYGLTF_TYPE_VEC3;
575 model.accessors.emplace_back( std::move( posAccessor ) );
577 posAccessorIndex =
static_cast<int>( model.accessors.size() ) - 1;
584 const draco::PointAttribute *normalAttribute = dracoMesh->GetNamedAttribute( draco::GeometryAttribute::NORMAL );
585 if ( normalAttribute )
587 std::vector<unsigned char> normalData( dracoMesh->num_points() * 3 *
sizeof(
float ) );
588 float *normalPtr =
reinterpret_cast<float *
>( normalData.data() );
591 for ( draco::PointIndex i( 0 ); i < dracoMesh->num_points(); ++i )
593 normalAttribute->ConvertValue<
float>( normalAttribute->mapped_index( i ), normalAttribute->num_components(), values );
595 normalPtr[i.value() * 3 + 0] = values[0];
596 normalPtr[i.value() * 3 + 1] = values[1];
597 normalPtr[i.value() * 3 + 2] = values[2];
600 tinygltf::Buffer normalBuffer;
601 normalBuffer.data = normalData;
602 model.buffers.emplace_back( std::move( normalBuffer ) );
604 tinygltf::BufferView normalBufferView;
605 normalBufferView.buffer =
static_cast<int>( model.buffers.size() ) - 1;
606 normalBufferView.byteOffset = 0;
607 normalBufferView.byteLength = normalData.size();
608 normalBufferView.target = TINYGLTF_TARGET_ARRAY_BUFFER;
609 model.bufferViews.emplace_back( std::move( normalBufferView ) );
611 tinygltf::Accessor normalAccessor;
612 normalAccessor.bufferView =
static_cast<int>( model.bufferViews.size() ) - 1;
613 normalAccessor.byteOffset = 0;
614 normalAccessor.componentType = TINYGLTF_COMPONENT_TYPE_FLOAT;
615 normalAccessor.count = dracoMesh->num_points();
616 normalAccessor.type = TINYGLTF_TYPE_VEC3;
617 model.accessors.emplace_back( std::move( normalAccessor ) );
619 normalAccessorIndex =
static_cast<int>( model.accessors.size() ) - 1;
626 const draco::PointAttribute *uvAttribute = dracoMesh->GetNamedAttribute( draco::GeometryAttribute::TEX_COORD );
629 std::vector<unsigned char> uvData( dracoMesh->num_points() * 2 *
sizeof(
float ) );
630 float *uvPtr =
reinterpret_cast<float *
>( uvData.data() );
634 const draco::PointAttribute *uvRegionAttribute =
nullptr;
635 for ( int32_t i = 0; i < dracoMesh->num_attributes(); ++i )
637 const draco::PointAttribute *attribute = dracoMesh->attribute( i );
641 draco::AttributeMetadata *attributeMetadata = geometryMetadata->attribute_metadata( attribute->unique_id() );
642 if ( !attributeMetadata )
645 std::string i3sAttributeType;
646 if ( attributeMetadata->GetEntryString(
"i3s-attribute-type", &i3sAttributeType ) && i3sAttributeType ==
"uv-region" )
648 uvRegionAttribute = attribute;
653 for ( draco::PointIndex i( 0 ); i < dracoMesh->num_points(); ++i )
655 uvAttribute->ConvertValue<
float>( uvAttribute->mapped_index( i ), uvAttribute->num_components(), values );
657 if ( uvRegionAttribute )
663 uint16_t uvRegion[4];
664 uvRegionAttribute->ConvertValue<uint16_t>( uvRegionAttribute->mapped_index( i ), uvRegionAttribute->num_components(), uvRegion );
665 float uMin =
static_cast<float>( uvRegion[0] ) / 65535.f;
666 float vMin =
static_cast<float>( uvRegion[1] ) / 65535.f;
667 float uMax =
static_cast<float>( uvRegion[2] ) / 65535.f;
668 float vMax =
static_cast<float>( uvRegion[3] ) / 65535.f;
669 values[0] = uMin + values[0] * ( uMax - uMin );
670 values[1] = vMin + values[1] * ( vMax - vMin );
673 uvPtr[i.value() * 2 + 0] = values[0];
674 uvPtr[i.value() * 2 + 1] = values[1];
677 tinygltf::Buffer uvBuffer;
678 uvBuffer.data = uvData;
679 model.buffers.emplace_back( std::move( uvBuffer ) );
681 tinygltf::BufferView uvBufferView;
682 uvBufferView.buffer =
static_cast<int>( model.buffers.size() ) - 1;
683 uvBufferView.byteOffset = 0;
684 uvBufferView.byteLength = uvData.size();
685 uvBufferView.target = TINYGLTF_TARGET_ARRAY_BUFFER;
686 model.bufferViews.emplace_back( std::move( uvBufferView ) );
688 tinygltf::Accessor uvAccessor;
689 uvAccessor.bufferView =
static_cast<int>( model.bufferViews.size() ) - 1;
690 uvAccessor.byteOffset = 0;
691 uvAccessor.componentType = TINYGLTF_COMPONENT_TYPE_FLOAT;
692 uvAccessor.count = dracoMesh->num_points();
693 uvAccessor.type = TINYGLTF_TYPE_VEC2;
694 model.accessors.emplace_back( std::move( uvAccessor ) );
696 uvAccessorIndex =
static_cast<int>( model.accessors.size() ) - 1;
704 std::vector<unsigned char> indexData;
705 indexData.resize( dracoMesh->num_faces() * 3 *
sizeof( quint32 ) );
706 Q_ASSERT(
sizeof( dracoMesh->face( draco::FaceIndex( 0 ) )[0] ) ==
sizeof( quint32 ) );
707 memcpy( indexData.data(), &dracoMesh->face( draco::FaceIndex( 0 ) )[0], indexData.size() );
709 tinygltf::Buffer gltfIndexBuffer;
710 gltfIndexBuffer.data = indexData;
711 model.buffers.emplace_back( std::move( gltfIndexBuffer ) );
713 tinygltf::BufferView indexBufferView;
714 indexBufferView.buffer =
static_cast<int>( model.buffers.size() ) - 1;
715 indexBufferView.byteLength = dracoMesh->num_faces() * 3 *
sizeof( quint32 );
716 indexBufferView.byteOffset = 0;
717 indexBufferView.byteStride = 0;
718 indexBufferView.target = TINYGLTF_TARGET_ELEMENT_ARRAY_BUFFER;
719 model.bufferViews.emplace_back( std::move( indexBufferView ) );
721 tinygltf::Accessor indicesAccessor;
722 indicesAccessor.bufferView =
static_cast<int>( model.bufferViews.size() ) - 1;
723 indicesAccessor.byteOffset = 0;
724 indicesAccessor.count = dracoMesh->num_faces() * 3;
725 indicesAccessor.type = TINYGLTF_TYPE_SCALAR;
726 indicesAccessor.componentType = TINYGLTF_COMPONENT_TYPE_UNSIGNED_INT;
727 model.accessors.emplace_back( std::move( indicesAccessor ) );
729 indicesAccessorIndex =
static_cast<int>( model.accessors.size() ) - 1;
735 tinygltf::Material material;
736 int materialIndex = loadMaterialFromMetadata( context.materialInfo, model );
738 tinygltf::Primitive primitive;
739 primitive.mode = TINYGLTF_MODE_TRIANGLES;
740 primitive.material = materialIndex;
741 primitive.indices = indicesAccessorIndex;
742 if ( posAccessorIndex != -1 )
743 primitive.attributes[
"POSITION"] = posAccessorIndex;
744 if ( normalAccessorIndex != -1 )
745 primitive.attributes[
"NORMAL"] = normalAccessorIndex;
746 if ( uvAccessorIndex != -1 )
747 primitive.attributes[
"TEXCOORD_0"] = uvAccessorIndex;
749 tinygltf::Mesh tiny_mesh;
750 tiny_mesh.primitives.emplace_back( std::move( primitive ) );
751 model.meshes.emplace_back( std::move( tiny_mesh ) );
755 model.nodes.emplace_back( std::move( node ) );
757 tinygltf::Scene scene;
758 scene.nodes.push_back( 0 );
759 model.scenes.emplace_back( std::move( scene ) );
761 model.defaultScene = 0;
762 model.asset.version =
"2.0";
768bool QgsGltfUtils::loadDracoModel(
const QByteArray &data,
const I3SNodeContext &context, tinygltf::Model &model, QString *errors )
774 *errors =
"Cannot load geometry - QGIS was built without Draco library.";
780int QgsGltfUtils::loadMaterialFromMetadata(
const QVariantMap &materialInfo, tinygltf::Model &model )
782 tinygltf::Material material;
783 material.name =
"DefaultMaterial";
785 QVariantList colorList = materialInfo[
"pbrBaseColorFactor"].toList();
786 material.pbrMetallicRoughness.baseColorFactor = { colorList[0].toDouble(), colorList[1].toDouble(), colorList[2].toDouble(), colorList[3].toDouble() };
788 if ( materialInfo.contains(
"pbrBaseColorTexture" ) )
790 QString baseColorTextureUri = materialInfo[
"pbrBaseColorTexture"].toString();
793 img.uri = baseColorTextureUri.toStdString();
794 model.images.emplace_back( std::move( img ) );
796 tinygltf::Texture tex;
797 tex.source =
static_cast<int>( model.images.size() ) - 1;
798 model.textures.emplace_back( std::move( tex ) );
800 material.pbrMetallicRoughness.baseColorTexture.index =
static_cast<int>( model.textures.size() ) - 1;
803 if ( materialInfo.contains(
"doubleSided" ) )
805 material.doubleSided = materialInfo[
"doubleSided"].toInt();
809 model.materials.emplace_back( std::move( material ) );
811 return static_cast<int>( model.materials.size() ) - 1;
814bool QgsGltfUtils::writeGltfModel(
const tinygltf::Model &model,
const QString &outputFilename )
816 tinygltf::TinyGLTF gltf;
817 bool res = gltf.WriteGltfSceneToFile(
819 outputFilename.toStdString(),
828void QgsGltfUtils::I3SNodeContext::initFromTile(
832 const QVariantMap tileMetadata = tile.
metadata();
834 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)