QGIS API Documentation  3.17.0-Master (a035f434f4)
qgsskyboxentity.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsskyboxentity.h
3  --------------------------------------
4  Date : August 2020
5  Copyright : (C) 2020 by Belgacem Nedjima
6  Email : gb uderscore nedjima at esi dot dz
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 QGSSKYBOXENTITY_H
17 #define QGSSKYBOXENTITY_H
18 
19 #include <Qt3DCore/QEntity>
20 #include <QVector3D>
21 #include <Qt3DRender/QTexture>
22 #include <Qt3DExtras/QCuboidMesh>
23 #include <Qt3DRender/QEffect>
24 #include <Qt3DRender/QMaterial>
25 #include <Qt3DRender/QShaderProgram>
26 #include <Qt3DRender/QFilterKey>
27 #include <Qt3DRender/QRenderPass>
28 #include <Qt3DExtras/QPlaneMesh>
29 #include <Qt3DRender/QParameter>
30 
31 #include "qgis_3d.h"
32 
33 class QgsImageTexture;
34 
35 #define SIP_NO_FILE
36 
43 class _3D_EXPORT QgsSkyboxEntity : public Qt3DCore::QEntity
44 {
45  Q_OBJECT
46  public:
49  {
51  DistinctTexturesSkybox
52  };
53  public:
55  QgsSkyboxEntity( QNode *parent = nullptr );
56 
58  virtual SkyboxType type() const = 0;
59 
60  protected:
61  Qt3DRender::QEffect *mEffect = nullptr;
62  Qt3DRender::QMaterial *mMaterial = nullptr;
63  Qt3DRender::QTechnique *mGl3Technique = nullptr;
64  Qt3DRender::QFilterKey *mFilterKey = nullptr;
65  Qt3DRender::QRenderPass *mGl3RenderPass = nullptr;
66  Qt3DExtras::QCuboidMesh *mMesh = nullptr;
67  Qt3DRender::QParameter *mGammaStrengthParameter = nullptr;
68  Qt3DRender::QParameter *mTextureParameter = nullptr;
69 };
70 
76 class _3D_EXPORT QgsPanoramicSkyboxEntity : public QgsSkyboxEntity
77 {
78  public:
80  QgsPanoramicSkyboxEntity( const QString &texturePath, Qt3DCore::QNode *parent = nullptr );
81 
83  QString texturePath() const { return mTexturePath; }
85  SkyboxType type() const override { return SkyboxType::PanoramicSkybox; }
86 
87  private:
88  void reloadTexture();
89  private:
90  QString mTexturePath;
91  Qt3DRender::QTextureLoader *mLoadedTexture = nullptr;
92  Qt3DRender::QShaderProgram *mGlShader = nullptr;
93 };
94 
100 class _3D_EXPORT QgsCubeFacesSkyboxEntity : public QgsSkyboxEntity
101 {
102  public:
104  QgsCubeFacesSkyboxEntity( const QString &posX, const QString &posY, const QString &posZ, const QString &negX, const QString &negY, const QString &negZ, Qt3DCore::QNode *parent = nullptr );
105 
107  SkyboxType type() const override { return SkyboxType::DistinctTexturesSkybox; }
108 
109  private:
110  void init();
111  void reloadTexture();
112  private:
113  QMap<Qt3DRender::QTextureCubeMap::CubeMapFace, QString> mCubeFacesPaths;
114  Qt3DRender::QShaderProgram *mGlShader = nullptr;
115  QVector<Qt3DRender::QTextureImage *> mFacesTextureImages;
116  Qt3DRender::QTextureCubeMap *mCubeMap = nullptr;
117 };
118 
119 #endif // QGSSKYBOXENTITY_H
base class for all skybox types It holds the common member data between different skybox entity types...
SkyboxType type() const override
Returns the type of the current skybox.
QString texturePath() const
Returns the path of the current texture in use.
The QgsImageTexture class Holds an image that can be used as a texture in the 3D view.
a skybox constructed from a panoramic image 3
SkyboxType
Skybox type enumeration.
SkyboxType type() const override
Returns the type of the current skybox.
a skybox constructed from a 6 cube faces 3