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(
const tinygltf::Model &model,
int accessorIndex,
const QgsMatrix4x4 &tileTransform,
const QgsCoordinateTransform *ecefToTargetCrs,
const QgsVector3D &tileTranslationEcef,
const QMatrix4x4 *nodeTransform,
Qgis::Axis gltfUpAxis, QVector<double> &vx, QVector<double> &vy, QVector<double> &vz )
55 const tinygltf::Accessor &accessor = model.accessors[accessorIndex];
56 const tinygltf::BufferView &bv = model.bufferViews[accessor.bufferView];
57 const tinygltf::Buffer &b = model.buffers[bv.buffer];
59 if ( accessor.componentType != TINYGLTF_PARAMETER_TYPE_FLOAT || accessor.type != TINYGLTF_TYPE_VEC3 )
65 const unsigned char *ptr = b.data.data() + bv.byteOffset + accessor.byteOffset;
67 vx.resize( accessor.count );
68 vy.resize( accessor.count );
69 vz.resize( accessor.count );
70 double *vxOut = vx.data();
71 double *vyOut = vy.data();
72 double *vzOut = vz.data();
73 for (
int i = 0; i < static_cast<int>( accessor.count ); ++i )
75 const float *fptr =
reinterpret_cast<const float *
>( ptr );
76 QVector3D vOrig( fptr[0], fptr[1], fptr[2] );
79 vOrig = nodeTransform->map( vOrig );
87 v = tileTransform.
map( tileTranslationEcef );
94 QVector3D vFlip( vOrig.x(), -vOrig.z(), vOrig.y() );
95 v = tileTransform.
map(
QgsVector3D( vFlip ) + tileTranslationEcef );
101 v = tileTransform.
map(
QgsVector3D( vOrig ) + tileTranslationEcef );
111 ptr += bv.byteStride;
113 ptr += 3 *
sizeof( float );
116 if ( ecefToTargetCrs )
120 ecefToTargetCrs->
transformCoords( accessor.count, vx.data(), vy.data(), vz.data() );
131bool QgsGltfUtils::extractTextureCoordinates(
const tinygltf::Model &model,
int accessorIndex, QVector<float> &x, QVector<float> &y )
133 const tinygltf::Accessor &accessor = model.accessors[accessorIndex];
134 const tinygltf::BufferView &bv = model.bufferViews[accessor.bufferView];
135 const tinygltf::Buffer &b = model.buffers[bv.buffer];
137 if ( accessor.componentType != TINYGLTF_PARAMETER_TYPE_FLOAT || accessor.type != TINYGLTF_TYPE_VEC2 )
142 const unsigned char *ptr = b.data.data() + bv.byteOffset + accessor.byteOffset;
143 x.resize( accessor.count );
144 y.resize( accessor.count );
146 float *xOut = x.data();
147 float *yOut = y.data();
149 for ( std::size_t i = 0; i < accessor.count; i++ )
151 const float *fptr =
reinterpret_cast< const float *
>( ptr );
157 ptr += bv.byteStride;
159 ptr += 2 *
sizeof( float );
164QgsGltfUtils::ResourceType QgsGltfUtils::imageResourceType(
const tinygltf::Model &model,
int index )
166 const tinygltf::Image &img = model.images[index];
168 if ( !img.image.empty() )
170 return ResourceType::Embedded;
174 return ResourceType::Linked;
178QImage QgsGltfUtils::extractEmbeddedImage(
const tinygltf::Model &model,
int index )
180 const tinygltf::Image &img = model.images[index];
181 if ( !img.image.empty() )
182 return QImage( img.image.data(), img.width, img.height, QImage::Format_ARGB32 );
187QString QgsGltfUtils::linkedImagePath(
const tinygltf::Model &model,
int index )
189 const tinygltf::Image &img = model.images[index];
190 return QString::fromStdString( img.uri );
193std::unique_ptr<QMatrix4x4> QgsGltfUtils::parseNodeTransform(
const tinygltf::Node &node )
197 std::unique_ptr<QMatrix4x4> matrix;
198 if ( !node.matrix.empty() )
200 matrix = std::make_unique<QMatrix4x4>( );
201 float *mdata = matrix->data();
202 for (
int i = 0; i < 16; ++i )
203 mdata[i] =
static_cast< float >( node.matrix[i] );
205 else if ( node.translation.size() || node.rotation.size() || node.scale.size() )
207 matrix = std::make_unique<QMatrix4x4>( );
208 if ( node.scale.size() )
210 matrix->scale(
static_cast< float >( node.scale[0] ),
static_cast< float >( node.scale[1] ),
static_cast< float >( node.scale[2] ) );
212 if ( node.rotation.size() )
214 matrix->rotate( 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] ) ) );
216 if ( node.translation.size() )
218 matrix->translate(
static_cast< float >( node.translation[0] ),
static_cast< float >( node.translation[1] ),
static_cast< float >( node.translation[2] ) );
227 bool sceneOk =
false;
228 const std::size_t sceneIndex = QgsGltfUtils::sourceSceneForModel( model, sceneOk );
234 const tinygltf::Scene &scene = model.scenes[sceneIndex];
237 auto it = model.extensions.find(
"CESIUM_RTC" );
238 if ( it != model.extensions.end() )
240 const tinygltf::Value v = it->second;
241 if ( v.IsObject() && v.Has(
"center" ) )
243 const tinygltf::Value center = v.Get(
"center" );
244 if ( center.IsArray() && center.Size() == 3 )
246 tileTranslationEcef =
QgsVector3D( center.Get( 0 ).GetNumberAsDouble(), center.Get( 1 ).GetNumberAsDouble(), center.Get( 2 ).GetNumberAsDouble() );
251 if ( scene.nodes.size() == 0 )
254 int rootNodeIndex = scene.nodes[0];
255 tinygltf::Node &rootNode = model.nodes[rootNodeIndex];
257 if ( tileTranslationEcef.
isNull() && rootNode.translation.size() )
259 QgsVector3D rootTranslation( rootNode.translation[0], rootNode.translation[1], rootNode.translation[2] );
263 if ( rootTranslation.length() > 1e6 )
273 tileTranslationEcef =
QgsVector3D( rootTranslation.x(), -rootTranslation.z(), rootTranslation.y() );
274 rootNode.translation[0] = rootNode.translation[1] = rootNode.translation[2] = 0;
279 tileTranslationEcef =
QgsVector3D( rootTranslation.x(), rootTranslation.y(), rootTranslation.z() );
280 rootNode.translation[0] = rootNode.translation[1] = rootNode.translation[2] = 0;
287 return tileTranslationEcef;
291bool QgsGltfUtils::loadImageDataWithQImage(
292 tinygltf::Image *image,
const int image_idx, std::string *err,
293 std::string *warn,
int req_width,
int req_height,
294 const unsigned char *bytes,
int size,
void *user_data )
297 if ( req_width != 0 || req_height != 0 )
301 ( *err ) +=
"Expecting zero req_width/req_height.\n";
310 if ( !img.loadFromData( bytes, size ) )
315 "Unknown image format. QImage cannot decode image data for image[" +
316 std::to_string( image_idx ) +
"] name = \"" + image->name +
"\".\n";
321 if ( img.format() != QImage::Format_RGB32 && img.format() != QImage::Format_ARGB32 )
324 img.convertTo( QImage::Format_RGB32 );
327 image->width = img.width();
328 image->height = img.height();
329 image->component = 4;
331 image->pixel_type = TINYGLTF_COMPONENT_TYPE_UNSIGNED_BYTE;
333 image->image.resize(
static_cast<size_t>( image->width * image->height * image->component ) *
size_t( image->bits / 8 ) );
334 std::copy( img.constBits(), img.constBits() +
static_cast< std::size_t
>( image->width ) * image->height * image->component * ( image->bits / 8 ), image->image.begin() );
339bool QgsGltfUtils::loadGltfModel(
const QByteArray &data, tinygltf::Model &model, QString *errors, QString *warnings )
341 tinygltf::TinyGLTF loader;
343 loader.SetImageLoader( QgsGltfUtils::loadImageDataWithQImage,
nullptr );
349 loader.SetParseStrictness( tinygltf::ParseStrictness::Permissive );
352 std::string err, warn;
355 if ( data.startsWith(
"glTF" ) )
357 if ( data.at( 4 ) == 1 )
359 *errors = QObject::tr(
"GLTF version 1 tiles cannot be loaded" );
362 res = loader.LoadBinaryFromMemory( &model, &err, &warn,
363 (
const unsigned char * )data.constData(), data.size(), baseDir );
367 res = loader.LoadASCIIFromString( &model, &err, &warn,
368 data.constData(), data.size(), baseDir );
372 *errors = QString::fromStdString( err );
375 *warnings = QString::fromStdString( warn );
378 const thread_local QRegularExpression rxFailedToLoadExternalUriForImage( u
"Failed to load external 'uri' for image\\[\\d+\\] name = \".*?\"\\n?"_s );
379 warnings->replace( rxFailedToLoadExternalUriForImage, QString() );
380 const thread_local QRegularExpression rxFileNotFound( u
"File not found : .*?\\n"_s );
381 warnings->replace( rxFileNotFound, QString() );
387std::size_t QgsGltfUtils::sourceSceneForModel(
const tinygltf::Model &model,
bool &ok )
390 if ( model.scenes.empty() )
396 int index = model.defaultScene;
397 if ( index >= 0 &&
static_cast< std::size_t
>( index ) < model.scenes.size() )
409void dumpDracoModelInfo( draco::Mesh *dracoMesh )
411 std::cout <<
"Decoded Draco Mesh:" << dracoMesh->num_points() <<
" points / " << dracoMesh->num_faces() <<
" faces" << std::endl;
412 draco::GeometryMetadata *geometryMetadata = dracoMesh->metadata();
414 std::cout <<
"Global Geometry Metadata:" << std::endl;
415 for (
const auto &entry : geometryMetadata->entries() )
417 std::cout <<
" Key: " << entry.first <<
", Value: " << entry.second.data().size() << std::endl;
420 std::cout <<
"\nAttribute Metadata:" << std::endl;
421 for ( int32_t i = 0; i < dracoMesh->num_attributes(); ++i )
423 const draco::PointAttribute *attribute = dracoMesh->attribute( i );
427 std::cout <<
" Attribute ID: " << attribute->unique_id() <<
" / " << draco::PointAttribute::TypeToString( attribute->attribute_type() ) << std::endl;
428 if (
const draco::AttributeMetadata *attributeMetadata = geometryMetadata->attribute_metadata( attribute->unique_id() ) )
430 for (
const auto &entry : attributeMetadata->entries() )
432 std::cout <<
" Key: " << entry.first <<
", Length: " << entry.second.data().size() << std::endl;
439bool QgsGltfUtils::loadDracoModel(
const QByteArray &data,
const I3SNodeContext &context, tinygltf::Model &model, QString *errors )
445 QByteArray dataExtracted;
446 if ( data.startsWith( QByteArray(
"\x1f\x8b", 2 ) ) )
451 *errors =
"Failed to decode gzipped model";
457 dataExtracted = data;
464 draco::Decoder decoder;
465 draco::DecoderBuffer decoderBuffer;
466 decoderBuffer.Init( dataExtracted.constData(), dataExtracted.size() );
468 draco::StatusOr<draco::EncodedGeometryType> geometryTypeStatus = decoder.GetEncodedGeometryType( &decoderBuffer );
469 if ( !geometryTypeStatus.ok() )
472 *errors =
"Failed to get geometry type: " + QString( geometryTypeStatus.status().error_msg() );
475 if ( geometryTypeStatus.value() != draco::EncodedGeometryType::TRIANGULAR_MESH )
478 *errors =
"Not a triangular mesh";
482 draco::StatusOr<std::unique_ptr<draco::Mesh>> meshStatus = decoder.DecodeMeshFromBuffer( &decoderBuffer );
483 if ( !meshStatus.ok() )
486 *errors =
"Failed to decode mesh: " + QString( meshStatus.status().error_msg() );
490 std::unique_ptr<draco::Mesh> dracoMesh = std::move( meshStatus ).value();
492 draco::GeometryMetadata *geometryMetadata = dracoMesh->metadata();
493 if ( !geometryMetadata )
496 *errors =
"Geometry metadata missing";
500 int posAccessorIndex = -1;
501 int normalAccessorIndex = -1;
502 int uvAccessorIndex = -1;
503 int indicesAccessorIndex = -1;
509 const draco::PointAttribute *posAttribute = dracoMesh->GetNamedAttribute( draco::GeometryAttribute::POSITION );
512 double scaleX = 1, scaleY = 1;
513 const draco::AttributeMetadata *posMetadata = geometryMetadata->attribute_metadata( posAttribute->unique_id() );
516 posMetadata->GetEntryDouble(
"i3s-scale_x", &scaleX );
517 posMetadata->GetEntryDouble(
"i3s-scale_y", &scaleY );
522 std::vector<unsigned char> posData( dracoMesh->num_points() * 3 *
sizeof(
float ) );
523 float *posPtr =
reinterpret_cast<float *
>( posData.data() );
526 for ( draco::PointIndex i( 0 ); i < dracoMesh->num_points(); ++i )
528 posAttribute->ConvertValue<
float>( posAttribute->mapped_index( i ), posAttribute->num_components(), values );
534 if ( context.isGlobalMode )
536 double lonDeg = double( values[0] ) * scaleX + nodeCenterLonLat.
x();
537 double latDeg = double( values[1] ) * scaleY + nodeCenterLonLat.
y();
538 double alt = double( values[2] ) + nodeCenterLonLat.
z();
540 QgsVector3D localPos = ecef - context.nodeCenterEcef;
542 values[0] =
static_cast<float>( localPos.
x() );
543 values[1] =
static_cast<float>( localPos.
y() );
544 values[2] =
static_cast<float>( localPos.
z() );
547 posPtr[i.value() * 3 + 0] = values[0];
548 posPtr[i.value() * 3 + 1] = values[1];
549 posPtr[i.value() * 3 + 2] = values[2];
552 tinygltf::Buffer posBuffer;
553 posBuffer.data = posData;
554 model.buffers.emplace_back( std::move( posBuffer ) );
556 tinygltf::BufferView posBufferView;
557 posBufferView.buffer =
static_cast<int>( model.buffers.size() ) - 1;
558 posBufferView.byteOffset = 0;
559 posBufferView.byteLength = posData.size();
560 posBufferView.target = TINYGLTF_TARGET_ARRAY_BUFFER;
561 model.bufferViews.emplace_back( std::move( posBufferView ) );
563 tinygltf::Accessor posAccessor;
564 posAccessor.bufferView =
static_cast<int>( model.bufferViews.size() ) - 1;
565 posAccessor.byteOffset = 0;
566 posAccessor.componentType = TINYGLTF_COMPONENT_TYPE_FLOAT;
567 posAccessor.count = dracoMesh->num_points();
568 posAccessor.type = TINYGLTF_TYPE_VEC3;
569 model.accessors.emplace_back( std::move( posAccessor ) );
571 posAccessorIndex =
static_cast<int>( model.accessors.size() ) - 1;
578 const draco::PointAttribute *normalAttribute = dracoMesh->GetNamedAttribute( draco::GeometryAttribute::NORMAL );
579 if ( normalAttribute )
581 std::vector<unsigned char> normalData( dracoMesh->num_points() * 3 *
sizeof(
float ) );
582 float *normalPtr =
reinterpret_cast<float *
>( normalData.data() );
585 for ( draco::PointIndex i( 0 ); i < dracoMesh->num_points(); ++i )
587 normalAttribute->ConvertValue<
float>( normalAttribute->mapped_index( i ), normalAttribute->num_components(), values );
589 normalPtr[i.value() * 3 + 0] = values[0];
590 normalPtr[i.value() * 3 + 1] = values[1];
591 normalPtr[i.value() * 3 + 2] = values[2];
594 tinygltf::Buffer normalBuffer;
595 normalBuffer.data = normalData;
596 model.buffers.emplace_back( std::move( normalBuffer ) );
598 tinygltf::BufferView normalBufferView;
599 normalBufferView.buffer =
static_cast<int>( model.buffers.size() ) - 1;
600 normalBufferView.byteOffset = 0;
601 normalBufferView.byteLength = normalData.size();
602 normalBufferView.target = TINYGLTF_TARGET_ARRAY_BUFFER;
603 model.bufferViews.emplace_back( std::move( normalBufferView ) );
605 tinygltf::Accessor normalAccessor;
606 normalAccessor.bufferView =
static_cast<int>( model.bufferViews.size() ) - 1;
607 normalAccessor.byteOffset = 0;
608 normalAccessor.componentType = TINYGLTF_COMPONENT_TYPE_FLOAT;
609 normalAccessor.count = dracoMesh->num_points();
610 normalAccessor.type = TINYGLTF_TYPE_VEC3;
611 model.accessors.emplace_back( std::move( normalAccessor ) );
613 normalAccessorIndex =
static_cast<int>( model.accessors.size() ) - 1;
620 const draco::PointAttribute *uvAttribute = dracoMesh->GetNamedAttribute( draco::GeometryAttribute::TEX_COORD );
623 std::vector<unsigned char> uvData( dracoMesh->num_points() * 2 *
sizeof(
float ) );
624 float *uvPtr =
reinterpret_cast<float *
>( uvData.data() );
628 const draco::PointAttribute *uvRegionAttribute =
nullptr;
629 for ( int32_t i = 0; i < dracoMesh->num_attributes(); ++i )
631 const draco::PointAttribute *attribute = dracoMesh->attribute( i );
635 draco::AttributeMetadata *attributeMetadata = geometryMetadata->attribute_metadata( attribute->unique_id() );
636 if ( !attributeMetadata )
639 std::string i3sAttributeType;
640 if ( attributeMetadata->GetEntryString(
"i3s-attribute-type", &i3sAttributeType ) && i3sAttributeType ==
"uv-region" )
642 uvRegionAttribute = attribute;
647 for ( draco::PointIndex i( 0 ); i < dracoMesh->num_points(); ++i )
649 uvAttribute->ConvertValue<
float>( uvAttribute->mapped_index( i ), uvAttribute->num_components(), values );
651 if ( uvRegionAttribute )
657 uint16_t uvRegion[4];
658 uvRegionAttribute->ConvertValue<uint16_t>( uvRegionAttribute->mapped_index( i ), uvRegionAttribute->num_components(), uvRegion );
659 float uMin =
static_cast<float>( uvRegion[0] ) / 65535.f;
660 float vMin =
static_cast<float>( uvRegion[1] ) / 65535.f;
661 float uMax =
static_cast<float>( uvRegion[2] ) / 65535.f;
662 float vMax =
static_cast<float>( uvRegion[3] ) / 65535.f;
663 values[0] = uMin + values[0] * ( uMax - uMin );
664 values[1] = vMin + values[1] * ( vMax - vMin );
667 uvPtr[i.value() * 2 + 0] = values[0];
668 uvPtr[i.value() * 2 + 1] = values[1];
671 tinygltf::Buffer uvBuffer;
672 uvBuffer.data = uvData;
673 model.buffers.emplace_back( std::move( uvBuffer ) );
675 tinygltf::BufferView uvBufferView;
676 uvBufferView.buffer =
static_cast<int>( model.buffers.size() ) - 1;
677 uvBufferView.byteOffset = 0;
678 uvBufferView.byteLength = uvData.size();
679 uvBufferView.target = TINYGLTF_TARGET_ARRAY_BUFFER;
680 model.bufferViews.emplace_back( std::move( uvBufferView ) ) ;
682 tinygltf::Accessor uvAccessor;
683 uvAccessor.bufferView =
static_cast<int>( model.bufferViews.size() ) - 1;
684 uvAccessor.byteOffset = 0;
685 uvAccessor.componentType = TINYGLTF_COMPONENT_TYPE_FLOAT;
686 uvAccessor.count = dracoMesh->num_points();
687 uvAccessor.type = TINYGLTF_TYPE_VEC2;
688 model.accessors.emplace_back( std::move( uvAccessor ) );
690 uvAccessorIndex =
static_cast<int>( model.accessors.size() ) - 1;
698 std::vector<unsigned char> indexData;
699 indexData.resize( dracoMesh->num_faces() * 3 *
sizeof( quint32 ) );
700 Q_ASSERT(
sizeof( dracoMesh->face( draco::FaceIndex( 0 ) )[0] ) ==
sizeof( quint32 ) );
701 memcpy( indexData.data(), &dracoMesh->face( draco::FaceIndex( 0 ) )[0], indexData.size() );
703 tinygltf::Buffer gltfIndexBuffer;
704 gltfIndexBuffer.data = indexData;
705 model.buffers.emplace_back( std::move( gltfIndexBuffer ) );
707 tinygltf::BufferView indexBufferView;
708 indexBufferView.buffer =
static_cast<int>( model.buffers.size() ) - 1;
709 indexBufferView.byteLength = dracoMesh->num_faces() * 3 *
sizeof( quint32 );
710 indexBufferView.byteOffset = 0;
711 indexBufferView.byteStride = 0;
712 indexBufferView.target = TINYGLTF_TARGET_ELEMENT_ARRAY_BUFFER;
713 model.bufferViews.emplace_back( std::move( indexBufferView ) );
715 tinygltf::Accessor indicesAccessor;
716 indicesAccessor.bufferView =
static_cast<int>( model.bufferViews.size() ) - 1;
717 indicesAccessor.byteOffset = 0;
718 indicesAccessor.count = dracoMesh->num_faces() * 3;
719 indicesAccessor.type = TINYGLTF_TYPE_SCALAR;
720 indicesAccessor.componentType = TINYGLTF_COMPONENT_TYPE_UNSIGNED_INT;
721 model.accessors.emplace_back( std::move( indicesAccessor ) );
723 indicesAccessorIndex =
static_cast<int>( model.accessors.size() ) - 1;
729 tinygltf::Material material;
730 int materialIndex = loadMaterialFromMetadata( context.materialInfo, model );
732 tinygltf::Primitive primitive;
733 primitive.mode = TINYGLTF_MODE_TRIANGLES;
734 primitive.material = materialIndex;
735 primitive.indices = indicesAccessorIndex;
736 if ( posAccessorIndex != -1 )
737 primitive.attributes[
"POSITION"] = posAccessorIndex;
738 if ( normalAccessorIndex != -1 )
739 primitive.attributes[
"NORMAL"] = normalAccessorIndex;
740 if ( uvAccessorIndex != -1 )
741 primitive.attributes[
"TEXCOORD_0"] = uvAccessorIndex;
743 tinygltf::Mesh tiny_mesh;
744 tiny_mesh.primitives.emplace_back( std::move( primitive ) );
745 model.meshes.emplace_back( std::move( tiny_mesh ) );
749 model.nodes.emplace_back( std::move( node ) );
751 tinygltf::Scene scene;
752 scene.nodes.push_back( 0 );
753 model.scenes.emplace_back( std::move( scene ) );
755 model.defaultScene = 0;
756 model.asset.version =
"2.0";
762bool QgsGltfUtils::loadDracoModel(
const QByteArray &data,
const I3SNodeContext &context, tinygltf::Model &model, QString *errors )
768 *errors =
"Cannot load geometry - QGIS was built without Draco library.";
774int QgsGltfUtils::loadMaterialFromMetadata(
const QVariantMap &materialInfo, tinygltf::Model &model )
776 tinygltf::Material material;
777 material.name =
"DefaultMaterial";
779 QVariantList colorList = materialInfo[
"pbrBaseColorFactor"].toList();
780 material.pbrMetallicRoughness.baseColorFactor = { colorList[0].toDouble(), colorList[1].toDouble(), colorList[2].toDouble(), colorList[3].toDouble() };
782 if ( materialInfo.contains(
"pbrBaseColorTexture" ) )
784 QString baseColorTextureUri = materialInfo[
"pbrBaseColorTexture"].toString();
787 img.uri = baseColorTextureUri.toStdString();
788 model.images.emplace_back( std::move( img ) );
790 tinygltf::Texture tex;
791 tex.source =
static_cast<int>( model.images.size() ) - 1;
792 model.textures.emplace_back( std::move( tex ) );
794 material.pbrMetallicRoughness.baseColorTexture.index =
static_cast<int>( model.textures.size() ) - 1;
797 if ( materialInfo.contains(
"doubleSided" ) )
799 material.doubleSided = materialInfo[
"doubleSided"].toInt();
803 model.materials.emplace_back( std::move( material ) );
805 return static_cast<int>( model.materials.size() ) - 1;
808bool QgsGltfUtils::writeGltfModel(
const tinygltf::Model &model,
const QString &outputFilename )
810 tinygltf::TinyGLTF gltf;
811 bool res = gltf.WriteGltfSceneToFile( &model,
812 outputFilename.toStdString(),
822 const QVariantMap tileMetadata = tile.
metadata();
824 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)