QGIS API Documentation  3.14.0-Pi (9f7028fd23)
quantizedmeshgeometry.h
Go to the documentation of this file.
1 /***************************************************************************
2  quantizedmeshgeometry.h
3  ---------------------
4  begin : July 2017
5  copyright : (C) 2017 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 #ifndef QUANTIZEDMESHGEOMETRY_H
16 #define QUANTIZEDMESHGEOMETRY_H
17 
18 #include <QtGui/QTransform>
19 
20 #include <Qt3DRender/QGeometry>
21 #include <Qt3DRender/QBuffer>
22 #include <Qt3DRender/QAttribute>
23 
24 
25 
27 {
28  // The center of the tile in Earth-centered Fixed coordinates.
29  double CenterX;
30  double CenterY;
31  double CenterZ;
32 
33  // The minimum and maximum heights in the area covered by this tile.
34  // The minimum may be lower and the maximum may be higher than
35  // the height of any vertex in this tile in the case that the min/max vertex
36  // was removed during mesh simplification, but these are the appropriate
37  // values to use for analysis or visualization.
38  float MinimumHeight;
39  float MaximumHeight;
40 
41  // The tile’s bounding sphere. The X,Y,Z coordinates are again expressed
42  // in Earth-centered Fixed coordinates, and the radius is in meters.
45  double BoundingSphereCenterZ;
46  double BoundingSphereRadius;
47 
48  // The horizon occlusion point, expressed in the ellipsoid-scaled Earth-centered Fixed frame.
49  // If this point is below the horizon, the entire tile is below the horizon.
50  // See http://cesiumjs.org/2013/04/25/Horizon-culling/ for more information.
54 };
55 
56 #include "qgsrectangle.h"
57 
59 {
60  QgsRectangle extent; // extent in WGS coordinates
62  QVector<qint16> uvh; // each coordinate 0-32767. u=lon, v=lat (within tile). not interleaved: first u, then v, then h
63  QVector<quint16> indices; // indices of triangles (length = 3*triangle count)
64 };
65 
67 class QgsMapToPixel;
68 
69 class Map3D;
70 
76 class QuantizedMeshGeometry : public Qt3DRender::QGeometry
77 {
78  public:
80  QuantizedMeshGeometry( QuantizedMeshTile *t, const Map3D &map, const QgsMapToPixel &mapToPixel, const QgsCoordinateTransform &terrainToMap, QNode *parent = nullptr );
81 
83  static QuantizedMeshTile *readTile( int tx, int ty, int tz, const QgsRectangle &extent );
85  static void downloadTileIfMissing( int tx, int ty, int tz );
86 
87  private:
88  Qt3DRender::QBuffer *mVertexBuffer = nullptr;
89  Qt3DRender::QBuffer *mIndexBuffer = nullptr;
90  Qt3DRender::QAttribute *mPositionAttribute = nullptr;
91  Qt3DRender::QAttribute *mTexCoordAttribute = nullptr;
92  Qt3DRender::QAttribute *mIndexAttribute = nullptr;
93 };
94 
95 #endif // QUANTIZEDMESHGEOMETRY_H
QuantizedMeshGeometry::downloadTileIfMissing
static void downloadTileIfMissing(int tx, int ty, int tz)
Downloads a tile to to a file in the local disk cache.
Definition: quantizedmeshgeometry.cpp:238
qgsrectangle.h
QuantizedMeshHeader::CenterY
double CenterY
Definition: quantizedmeshgeometry.h:43
QuantizedMeshHeader::BoundingSphereRadius
double BoundingSphereRadius
Definition: quantizedmeshgeometry.h:59
QuantizedMeshHeader::HorizonOcclusionPointY
double HorizonOcclusionPointY
Definition: quantizedmeshgeometry.h:65
QuantizedMeshGeometry::QuantizedMeshGeometry
QuantizedMeshGeometry(QuantizedMeshTile *t, const Map3D &map, const QgsMapToPixel &mapToPixel, const QgsCoordinateTransform &terrainToMap, QNode *parent=nullptr)
Constructs geometry based on the loaded tile data.
Definition: quantizedmeshgeometry.cpp:276
QgsRectangle
Definition: qgsrectangle.h:41
QuantizedMeshHeader::CenterZ
double CenterZ
Definition: quantizedmeshgeometry.h:44
QuantizedMeshTile::uvh
QVector< qint16 > uvh
Definition: quantizedmeshgeometry.h:62
QuantizedMeshHeader::BoundingSphereCenterX
double BoundingSphereCenterX
Definition: quantizedmeshgeometry.h:56
QuantizedMeshGeometry
Definition: quantizedmeshgeometry.h:76
QuantizedMeshHeader::BoundingSphereCenterZ
double BoundingSphereCenterZ
Definition: quantizedmeshgeometry.h:58
QuantizedMeshTile::extent
QgsRectangle extent
Definition: quantizedmeshgeometry.h:60
QuantizedMeshHeader::HorizonOcclusionPointZ
double HorizonOcclusionPointZ
Definition: quantizedmeshgeometry.h:66
QuantizedMeshHeader::CenterX
double CenterX
Definition: quantizedmeshgeometry.h:42
QuantizedMeshHeader
Definition: quantizedmeshgeometry.h:26
QuantizedMeshTile::indices
QVector< quint16 > indices
Definition: quantizedmeshgeometry.h:63
QuantizedMeshHeader::MaximumHeight
float MaximumHeight
Definition: quantizedmeshgeometry.h:52
QuantizedMeshHeader::MinimumHeight
float MinimumHeight
Definition: quantizedmeshgeometry.h:51
QuantizedMeshTile::header
QuantizedMeshHeader header
Definition: quantizedmeshgeometry.h:61
QgsMapToPixel
Definition: qgsmaptopixel.h:37
QuantizedMeshTile
Definition: quantizedmeshgeometry.h:58
QuantizedMeshHeader::BoundingSphereCenterY
double BoundingSphereCenterY
Definition: quantizedmeshgeometry.h:57
QuantizedMeshHeader::HorizonOcclusionPointX
double HorizonOcclusionPointX
Definition: quantizedmeshgeometry.h:64
QgsCoordinateTransform
Definition: qgscoordinatetransform.h:52
QuantizedMeshGeometry::readTile
static QuantizedMeshTile * readTile(int tx, int ty, int tz, const QgsRectangle &extent)
Reads a tile from a file in the local disk cache.
Definition: quantizedmeshgeometry.cpp:146