QGIS API Documentation 3.41.0-Master (45a0abf3bec)
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 "qgis_core.h"
33#include "qgis.h"
34
35#include <memory>
36#include <QVector>
37
38class QMatrix4x4;
39class QImage;
40
42class QgsMatrix4x4;
43class QgsVector3D;
44
45namespace tinygltf
46{
47 struct Image;
48 class Model;
49 class Node;
50 class TinyGLTF;
51}
52
53
61class CORE_EXPORT QgsGltfUtils
62{
63 public:
64
79 static bool accessorToMapCoordinates( const tinygltf::Model &model,
80 int accessorIndex,
81 const QgsMatrix4x4 &tileTransform,
82 const QgsCoordinateTransform *ecefToTargetCrs,
83 const QgsVector3D &tileTranslationEcef,
84 const QMatrix4x4 *nodeTransform,
85 Qgis::Axis gltfUpAxis,
86 QVector<double> &vx, QVector<double> &vy, QVector<double> &vz );
87
91 enum class ResourceType
92 {
93 Embedded,
94 Linked,
95 };
96
103 static ResourceType imageResourceType( const tinygltf::Model &model, int index );
104
113 static QImage extractEmbeddedImage( const tinygltf::Model &model, int index );
114
123 static QString linkedImagePath( const tinygltf::Model &model, int index );
124
130 static std::unique_ptr<QMatrix4x4> parseNodeTransform( const tinygltf::Node &node );
131
137 static QgsVector3D extractTileTranslation( tinygltf::Model &model, Qgis::Axis upAxis = Qgis::Axis::Y );
138
142 static bool loadImageDataWithQImage(
143 tinygltf::Image *image, const int image_idx, std::string *err,
144 std::string *warn, int req_width, int req_height,
145 const unsigned char *bytes, int size, void *user_data );
146
150 static bool extractTextureCoordinates( const tinygltf::Model &model, int accessorIndex,
151 QVector<float> &x, QVector<float> &y );
152
158 static bool loadGltfModel( const QByteArray &data, tinygltf::Model &model, QString *errors, QString *warnings );
159
168 static std::size_t sourceSceneForModel( const tinygltf::Model &model, bool &ok );
169};
170
172
173#endif // QGSGLTFUTILS_H
Axis
Cartesian axes.
Definition qgis.h:2283
@ Y
Y-axis.
Class for doing transforms between two map coordinate systems.
A simple 4x4 matrix implementation useful for transformation in 3D space.
Class for storage of 3D vectors similar to QVector3D, with the difference that it uses double precisi...
Definition qgsvector3d.h:31