QGIS API Documentation 4.1.0-Master (ca2ac17535b)
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
31
32namespace Qt3DExtras
33{
34 class QCuboidMesh;
35}
36
37namespace Qt3DRender
38{
39 class QEffect;
40 class QFilterKey;
41 class QMaterial;
42 class QParameter;
43 class QRenderPass;
44 class QShaderProgram;
45 class QTechnique;
46 class QTexture;
47} //namespace Qt3DRender
48
49class QgsImageTexture;
50
51// this is broken for z-up coordinate system
52#define ENABLE_PANORAMIC_SKYBOX 0
53
61class _3D_EXPORT QgsSkyboxEntity : public Qt3DCore::QEntity
62{
63 Q_OBJECT
64
65 public:
67 QgsSkyboxEntity( QNode *parent = nullptr );
68
70 virtual Qgis::Map3DBackgroundType type() const = 0;
71
77 virtual void updateEnvironmentLight( QgsEnvironmentLight *light ) const = 0;
78
79 protected:
80 Qt3DRender::QEffect *mEffect = nullptr;
81 Qt3DRender::QMaterial *mMaterial = nullptr;
82 Qt3DRender::QTechnique *mGl3Technique = nullptr;
83 Qt3DRender::QFilterKey *mFilterKey = nullptr;
84 Qt3DRender::QRenderPass *mGl3RenderPass = nullptr;
85 Qt3DExtras::QCuboidMesh *mMesh = nullptr;
86 Qt3DRender::QParameter *mGammaStrengthParameter = nullptr;
87 Qt3DRender::QParameter *mTextureParameter = nullptr;
88};
89
90
91#if ENABLE_PANORAMIC_SKYBOX
92
99class _3D_EXPORT QgsPanoramicSkyboxEntity : public QgsSkyboxEntity
100{
101 Q_OBJECT
102
103 public:
105 QgsPanoramicSkyboxEntity( const QString &texturePath, Qt3DCore::QNode *parent = nullptr );
106
108 QString texturePath() const { return mTexturePath; }
109 Qgis::Map3DBackgroundType type() const override { return Qgis::Map3DBackgroundType::NoBackground; } // this will have to be changed if panoramic skybox is fixed
110
111 private:
112 void reloadTexture();
113
114 private:
115 QString mTexturePath;
116 Qt3DRender::QTextureLoader *mLoadedTexture = nullptr;
117 Qt3DRender::QShaderProgram *mGlShader = nullptr;
118};
119#endif
120
121
129{
130 Q_OBJECT
131
132 public:
136 const QString &posX,
137 const QString &posY,
138 const QString &posZ,
139 const QString &negX,
140 const QString &negY,
141 const QString &negZ,
142 bool enableEnvironmentalLighting,
143 Qt3DCore::QNode *parent = nullptr
144 );
146 void updateEnvironmentLight( QgsEnvironmentLight *light ) const override;
147
148 private:
149 void init();
150 void reloadTexture();
151
152 private:
153 struct FaceTransformation
154 {
155 QString path;
156 bool mirrorHorizontal = false;
157 bool mirrorVertical = false;
158 };
159
160 QMap<Qt3DRender::QTextureCubeMap::CubeMapFace, FaceTransformation> generateFaceTransformation() const;
161
163 QString mSourcePosX;
164 QString mSourcePosY;
165 QString mSourcePosZ;
166 QString mSourceNegX;
167 QString mSourceNegY;
168 QString mSourceNegZ;
169 bool mEnableEnvironmentalLighting = true;
170
171 Qt3DRender::QShaderProgram *mGlShader = nullptr;
172 QVector<Qt3DRender::QAbstractTextureImage *> mFacesTextureImages;
173 Qt3DRender::QTextureCubeMap *mCubeMap = nullptr;
174};
175
176#endif // QGSSKYBOXENTITY_H
Map3DBackgroundType
Background types for 3D map view.
Definition qgis.h:4416
@ DistinctTextureSkybox
Skybox with 6 distinct textures for different faces.
Definition qgis.h:4419
@ NoBackground
No background.
Definition qgis.h:4417
SkyboxCubeMapping
Skybox texture cube mapping for distinct texture skyboxes.
Definition qgis.h:4429
@ NativeZUp
Textures exported for Z-up (+X Right, +Y Forward, +Z Up).
Definition qgis.h:4430
QgsCubeFacesSkyboxEntity(Qgis::SkyboxCubeMapping mapping, const QString &posX, const QString &posY, const QString &posZ, const QString &negX, const QString &negY, const QString &negZ, bool enableEnvironmentalLighting, Qt3DCore::QNode *parent=nullptr)
Constructs a skybox from 6 different images.
Qgis::Map3DBackgroundType type() const override
Returns the background type of skybox entity.
An environment light entity.
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 void updateEnvironmentLight(QgsEnvironmentLight *light) const =0
Updates the specified environment light to match the skybox settings.
virtual Qgis::Map3DBackgroundType type() const =0
Returns the background type of skybox entity.
Qt3DExtras::QCuboidMesh * mMesh
Qt3DRender::QParameter * mTextureParameter
Qt3DRender::QMaterial * mMaterial
Qt3DRender::QTechnique * mGl3Technique