QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
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} //namespace tinygltf
55
56
64class CORE_EXPORT QgsGltfUtils
65{
66 public:
81 static bool accessorToMapCoordinates(
82 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,
90 QVector<double> &vy,
91 QVector<double> &vz
92 );
93
97 enum class ResourceType
98 {
99 Embedded,
100 Linked,
101 };
102
109 static ResourceType imageResourceType( const tinygltf::Model &model, int index );
110
119 static QImage extractEmbeddedImage( const tinygltf::Model &model, int index );
120
129 static QString linkedImagePath( const tinygltf::Model &model, int index );
130
136 static std::unique_ptr<QMatrix4x4> parseNodeTransform( const tinygltf::Node &node );
137
143 static QgsVector3D extractTileTranslation( tinygltf::Model &model, Qgis::Axis upAxis = Qgis::Axis::Y );
144
148 static bool loadImageDataWithQImage(
149 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
150 );
151
155 static bool extractTextureCoordinates( const tinygltf::Model &model, int accessorIndex, QVector<float> &x, QVector<float> &y );
156
162 static bool loadGltfModel( const QByteArray &data, tinygltf::Model &model, QString *errors, QString *warnings );
163
172 static std::size_t sourceSceneForModel( const tinygltf::Model &model, bool &ok );
173
179 struct CORE_EXPORT I3SNodeContext
180 {
182 void initFromTile( const QgsTiledSceneTile &tile, const QgsCoordinateReferenceSystem &layerCrs, const QgsCoordinateReferenceSystem &sceneCrs, const QgsCoordinateTransformContext &transformContext );
183
188 QVariantMap materialInfo;
189
195 bool isGlobalMode = false;
196
201 QgsCoordinateTransform datasetToSceneTransform;
202
207 QgsVector3D nodeCenterEcef;
208 };
209
224 static bool loadDracoModel( const QByteArray &data, const I3SNodeContext &context, tinygltf::Model &model, QString *errors = nullptr );
225
237 static int loadMaterialFromMetadata( const QVariantMap &materialInfo, tinygltf::Model &model );
238
243 static bool writeGltfModel( const tinygltf::Model &model, const QString &outputFilename );
244};
245
247
248#endif // QGSGLTFUTILS_H
Axis
Cartesian axes.
Definition qgis.h:2540
@ Y
Y-axis.
Definition qgis.h:2542
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