QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
qgsgltfutils.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsgltfutils.h
3 --------------------------------------
4 Date : July 2023
5 Copyright : (C) 2023 by Martin Dobias
6 Email : wonder dot sk at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSGLTFUTILS_H
17#define QGSGLTFUTILS_H
18
20
21//
22// W A R N I N G
23// -------------
24//
25// This file is not part of the QGIS API. It exists purely as an
26// implementation detail. This header file may change from version to
27// version without notice, or even be removed.
28//
29
30#define SIP_NO_FILE
31
32#include <memory>
33
34#include "qgis.h"
35#include "qgis_core.h"
37
38#include <QVector>
39
40class QMatrix4x4;
41class QImage;
42
43class QgsMatrix4x4;
45class QgsVector3D;
46
47namespace tinygltf
48{
49 struct Image;
50 class Model;
51 class Node;
52 class TinyGLTF;
53}
54
55
63class CORE_EXPORT QgsGltfUtils
64{
65 public:
66
81 static bool accessorToMapCoordinates( const tinygltf::Model &model,
82 int accessorIndex,
83 const QgsMatrix4x4 &tileTransform,
84 const QgsCoordinateTransform *ecefToTargetCrs,
85 const QgsVector3D &tileTranslationEcef,
86 const QMatrix4x4 *nodeTransform,
87 Qgis::Axis gltfUpAxis,
88 QVector<double> &vx, QVector<double> &vy, QVector<double> &vz );
89
93 enum class ResourceType
94 {
95 Embedded,
96 Linked,
97 };
98
105 static ResourceType imageResourceType( const tinygltf::Model &model, int index );
106
115 static QImage extractEmbeddedImage( const tinygltf::Model &model, int index );
116
125 static QString linkedImagePath( const tinygltf::Model &model, int index );
126
132 static std::unique_ptr<QMatrix4x4> parseNodeTransform( const tinygltf::Node &node );
133
139 static QgsVector3D extractTileTranslation( tinygltf::Model &model, Qgis::Axis upAxis = Qgis::Axis::Y );
140
144 static bool loadImageDataWithQImage(
145 tinygltf::Image *image, const int image_idx, std::string *err,
146 std::string *warn, int req_width, int req_height,
147 const unsigned char *bytes, int size, void *user_data );
148
152 static bool extractTextureCoordinates( const tinygltf::Model &model, int accessorIndex,
153 QVector<float> &x, QVector<float> &y );
154
160 static bool loadGltfModel( const QByteArray &data, tinygltf::Model &model, QString *errors, QString *warnings );
161
170 static std::size_t sourceSceneForModel( const tinygltf::Model &model, bool &ok );
171
177 struct CORE_EXPORT I3SNodeContext
178 {
180 void initFromTile( const QgsTiledSceneTile &tile,
181 const QgsCoordinateReferenceSystem &layerCrs,
182 const QgsCoordinateReferenceSystem &sceneCrs,
183 const QgsCoordinateTransformContext &transformContext );
184
189 QVariantMap materialInfo;
190
196 bool isGlobalMode = false;
197
202 QgsCoordinateTransform datasetToSceneTransform;
203
208 QgsVector3D nodeCenterEcef;
209 };
210
225 static bool loadDracoModel( const QByteArray &data, const I3SNodeContext &context, tinygltf::Model &model, QString *errors = nullptr );
226
238 static int loadMaterialFromMetadata( const QVariantMap &materialInfo, tinygltf::Model &model );
239
244 static bool writeGltfModel( const tinygltf::Model &model, const QString &outputFilename );
245};
246
248
249#endif // QGSGLTFUTILS_H
Axis
Cartesian axes.
Definition qgis.h:2451
@ Y
Y-axis.
Definition qgis.h:2453
A simple 4x4 matrix implementation useful for transformation in 3D space.
Represents an individual tile from a tiled scene data source.
A 3D vector (similar to QVector3D) with the difference that it uses double precision instead of singl...
Definition qgsvector3d.h:30