QGIS API Documentation 3.99.0-Master (c22de0620c0)
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
31#include <memory>
32
33#include "qgis.h"
34#include "qgis_core.h"
36
37#include <QVector>
38
39#define SIP_NO_FILE
40
41class QMatrix4x4;
42class QImage;
43
44class QgsMatrix4x4;
46class QgsVector3D;
47
48namespace tinygltf
49{
50 struct Image;
51 class Model;
52 class Node;
53 class TinyGLTF;
54}
55
56
64class CORE_EXPORT QgsGltfUtils
65{
66 public:
67
82 static bool accessorToMapCoordinates( const tinygltf::Model &model,
83 int accessorIndex,
84 const QgsMatrix4x4 &tileTransform,
85 const QgsCoordinateTransform *ecefToTargetCrs,
86 const QgsVector3D &tileTranslationEcef,
87 const QMatrix4x4 *nodeTransform,
88 Qgis::Axis gltfUpAxis,
89 QVector<double> &vx, QVector<double> &vy, QVector<double> &vz );
90
94 enum class ResourceType
95 {
96 Embedded,
97 Linked,
98 };
99
106 static ResourceType imageResourceType( const tinygltf::Model &model, int index );
107
116 static QImage extractEmbeddedImage( const tinygltf::Model &model, int index );
117
126 static QString linkedImagePath( const tinygltf::Model &model, int index );
127
133 static std::unique_ptr<QMatrix4x4> parseNodeTransform( const tinygltf::Node &node );
134
140 static QgsVector3D extractTileTranslation( tinygltf::Model &model, Qgis::Axis upAxis = Qgis::Axis::Y );
141
145 static bool loadImageDataWithQImage(
146 tinygltf::Image *image, const int image_idx, std::string *err,
147 std::string *warn, int req_width, int req_height,
148 const unsigned char *bytes, int size, void *user_data );
149
153 static bool extractTextureCoordinates( const tinygltf::Model &model, int accessorIndex,
154 QVector<float> &x, QVector<float> &y );
155
161 static bool loadGltfModel( const QByteArray &data, tinygltf::Model &model, QString *errors, QString *warnings );
162
171 static std::size_t sourceSceneForModel( const tinygltf::Model &model, bool &ok );
172
178 struct CORE_EXPORT I3SNodeContext
179 {
181 void initFromTile( const QgsTiledSceneTile &tile,
182 const QgsCoordinateReferenceSystem &layerCrs,
183 const QgsCoordinateReferenceSystem &sceneCrs,
184 const QgsCoordinateTransformContext &transformContext );
185
190 QVariantMap materialInfo;
191
197 bool isGlobalMode = false;
198
203 QgsCoordinateTransform datasetToSceneTransform;
204
209 QgsVector3D nodeCenterEcef;
210 };
211
226 static bool loadDracoModel( const QByteArray &data, const I3SNodeContext &context, tinygltf::Model &model, QString *errors = nullptr );
227
239 static int loadMaterialFromMetadata( const QVariantMap &materialInfo, tinygltf::Model &model );
240
245 static bool writeGltfModel( const tinygltf::Model &model, const QString &outputFilename );
246};
247
249
250#endif // QGSGLTFUTILS_H
Axis
Cartesian axes.
Definition qgis.h:2524
@ Y
Y-axis.
Definition qgis.h:2526
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:33