QGIS API Documentation  3.20.0-Odense (decaadbb31)
qgsdemterraintilegeometry_p.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsdemterraintilegeometry_p.h
3  --------------------------------------
4  Date : 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 
16 #ifndef QGSDEMTERRAINTILEGEOMETRY_P_H
17 #define QGSDEMTERRAINTILEGEOMETRY_P_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 <Qt3DExtras/qt3dextras_global.h>
33 #include <Qt3DRender/qgeometry.h>
34 #include <QSize>
35 
36 #include <QImage>
37 
38 namespace Qt3DRender
39 {
40 
41  class QAttribute;
42  class QBuffer;
43 
44 } // Qt3DRender
45 
46 namespace QgsRayCastingUtils
47 {
48  class Ray3D;
49 }
50 
56 class DemTerrainTileGeometry : public Qt3DRender::QGeometry
57 {
58  Q_OBJECT
59 
60  public:
61 
66  explicit DemTerrainTileGeometry( int resolution, float side, float vertScale, float skirtHeight, const QByteArray &heightMap, QNode *parent = nullptr );
67 
68  bool rayIntersection( const QgsRayCastingUtils::Ray3D &ray, const QMatrix4x4 &worldTransform, QVector3D &intersectionPoint );
69 
70  Qt3DRender::QAttribute *positionAttribute() { return mPositionAttribute; }
71  Qt3DRender::QAttribute *normalAttribute() { return mNormalAttribute; }
72  Qt3DRender::QAttribute *texCoordsAttribute() { return mTexCoordAttribute; }
73  Qt3DRender::QAttribute *indexAttribute() { return mIndexAttribute; }
74 
75  private:
76  void init();
77 
78  int mResolution;
79  float mSide;
80  float mVertScale;
81  float mSkirtHeight;
82  QByteArray mHeightMap;
83  Qt3DRender::QAttribute *mPositionAttribute = nullptr;
84  Qt3DRender::QAttribute *mNormalAttribute = nullptr;
85  Qt3DRender::QAttribute *mTexCoordAttribute = nullptr;
86  Qt3DRender::QAttribute *mIndexAttribute = nullptr;
87  Qt3DRender::QBuffer *mVertexBuffer = nullptr;
88  Qt3DRender::QBuffer *mIndexBuffer = nullptr;
89 };
90 
92 
93 #endif // QGSDEMTERRAINTILEGEOMETRY_P_H