QGIS API Documentation 4.1.0-Master (01362494303)
Loading...
Searching...
No Matches
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 "qgis.h"
20#include "qgis_3d.h"
21
22#include <QMap>
23#include <QString>
24#include <QVector>
25#include <Qt3DCore/QEntity>
26#include <Qt3DRender/QTexture>
27
28#define SIP_NO_FILE
29
30namespace Qt3DExtras
31{
32 class QCuboidMesh;
33}
34
35namespace Qt3DRender
36{
37 class QEffect;
38 class QFilterKey;
39 class QMaterial;
40 class QParameter;
41 class QRenderPass;
42 class QShaderProgram;
43 class QTechnique;
44 class QTexture;
45} //namespace Qt3DRender
46
47class QgsImageTexture;
48
49// this is broken for z-up coordinate system
50#define ENABLE_PANORAMIC_SKYBOX 0
51
59class _3D_EXPORT QgsSkyboxEntity : public Qt3DCore::QEntity
60{
61 Q_OBJECT
62
63 public:
65 QgsSkyboxEntity( QNode *parent = nullptr );
66
68 virtual Qgis::SkyboxType type() const = 0;
69
70 protected:
71 Qt3DRender::QEffect *mEffect = nullptr;
72 Qt3DRender::QMaterial *mMaterial = nullptr;
73 Qt3DRender::QTechnique *mGl3Technique = nullptr;
74 Qt3DRender::QFilterKey *mFilterKey = nullptr;
75 Qt3DRender::QRenderPass *mGl3RenderPass = nullptr;
76 Qt3DExtras::QCuboidMesh *mMesh = nullptr;
77 Qt3DRender::QParameter *mGammaStrengthParameter = nullptr;
78 Qt3DRender::QParameter *mTextureParameter = nullptr;
79};
80
81
82#if ENABLE_PANORAMIC_SKYBOX
83
90class _3D_EXPORT QgsPanoramicSkyboxEntity : public QgsSkyboxEntity
91{
92 Q_OBJECT
93
94 public:
96 QgsPanoramicSkyboxEntity( const QString &texturePath, Qt3DCore::QNode *parent = nullptr );
97
99 QString texturePath() const { return mTexturePath; }
101 Qgis::SkyboxType type() const override { return Qgis::SkyboxType::Panoramic; }
102
103 private:
104 void reloadTexture();
105
106 private:
107 QString mTexturePath;
108 Qt3DRender::QTextureLoader *mLoadedTexture = nullptr;
109 Qt3DRender::QShaderProgram *mGlShader = nullptr;
110};
111#endif
112
113
121{
122 Q_OBJECT
123
124 public:
127 Qgis::SkyboxCubeMapping mapping, const QString &posX, const QString &posY, const QString &posZ, const QString &negX, const QString &negY, const QString &negZ, Qt3DCore::QNode *parent = nullptr
128 );
129 Qgis::SkyboxType type() const override;
130
131 private:
132 void init();
133 void reloadTexture();
134
135 private:
136 struct FaceTransformation
137 {
138 QString path;
139 bool mirrorHorizontal = false;
140 bool mirrorVertical = false;
141 };
142
143 QMap<Qt3DRender::QTextureCubeMap::CubeMapFace, FaceTransformation> generateFaceTransformation() const;
144
146 QString mSourcePosX;
147 QString mSourcePosY;
148 QString mSourcePosZ;
149 QString mSourceNegX;
150 QString mSourceNegY;
151 QString mSourceNegZ;
152
153 Qt3DRender::QShaderProgram *mGlShader = nullptr;
154 QVector<Qt3DRender::QAbstractTextureImage *> mFacesTextureImages;
155 Qt3DRender::QTextureCubeMap *mCubeMap = nullptr;
156};
157
158#endif // QGSSKYBOXENTITY_H
SkyboxCubeMapping
Skybox texture cube mapping for distinct texture skyboxes.
Definition qgis.h:4385
@ NativeZUp
Textures exported for Z-up (+X Right, +Y Forward, +Z Up).
Definition qgis.h:4386
SkyboxType
Skybox types for 3D scenes.
Definition qgis.h:4372
Qgis::SkyboxType type() const override
Returns the type of the skybox.
QgsCubeFacesSkyboxEntity(Qgis::SkyboxCubeMapping mapping, const QString &posX, const QString &posY, const QString &posZ, const QString &negX, const QString &negY, const QString &negZ, Qt3DCore::QNode *parent=nullptr)
Constructs a skybox from 6 different images.
Holds an image that can be used as a texture in the 3D view.
Base class for all skybox types.
QgsSkyboxEntity(QNode *parent=nullptr)
Constructor.
Qt3DRender::QRenderPass * mGl3RenderPass
Qt3DRender::QParameter * mGammaStrengthParameter
Qt3DRender::QFilterKey * mFilterKey
Qt3DRender::QEffect * mEffect
virtual Qgis::SkyboxType type() const =0
Returns the type of the skybox.
Qt3DExtras::QCuboidMesh * mMesh
Qt3DRender::QParameter * mTextureParameter
Qt3DRender::QMaterial * mMaterial
Qt3DRender::QTechnique * mGl3Technique