QGIS API Documentation 4.1.0-Master (9af12b5a203)
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::Map3DBackgroundType 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; }
100 Qgis::Map3DBackgroundType type() const override { return Qgis::Map3DBackgroundType::NoBackground; } // this will have to be changed if panoramic skybox is fixed
101
102 private:
103 void reloadTexture();
104
105 private:
106 QString mTexturePath;
107 Qt3DRender::QTextureLoader *mLoadedTexture = nullptr;
108 Qt3DRender::QShaderProgram *mGlShader = nullptr;
109};
110#endif
111
112
120{
121 Q_OBJECT
122
123 public:
126 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
127 );
129
130 private:
131 void init();
132 void reloadTexture();
133
134 private:
135 struct FaceTransformation
136 {
137 QString path;
138 bool mirrorHorizontal = false;
139 bool mirrorVertical = false;
140 };
141
142 QMap<Qt3DRender::QTextureCubeMap::CubeMapFace, FaceTransformation> generateFaceTransformation() const;
143
145 QString mSourcePosX;
146 QString mSourcePosY;
147 QString mSourcePosZ;
148 QString mSourceNegX;
149 QString mSourceNegY;
150 QString mSourceNegZ;
151
152 Qt3DRender::QShaderProgram *mGlShader = nullptr;
153 QVector<Qt3DRender::QAbstractTextureImage *> mFacesTextureImages;
154 Qt3DRender::QTextureCubeMap *mCubeMap = nullptr;
155};
156
157#endif // QGSSKYBOXENTITY_H
Map3DBackgroundType
Background types for 3D map view.
Definition qgis.h:4415
@ DistinctTextureSkybox
Skybox with 6 distinct textures for different faces.
Definition qgis.h:4418
@ NoBackground
No background.
Definition qgis.h:4416
SkyboxCubeMapping
Skybox texture cube mapping for distinct texture skyboxes.
Definition qgis.h:4428
@ NativeZUp
Textures exported for Z-up (+X Right, +Y Forward, +Z Up).
Definition qgis.h:4429
Qgis::Map3DBackgroundType type() const override
Returns the background type of skybox entity.
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::Map3DBackgroundType type() const =0
Returns the background type of skybox entity.
Qt3DExtras::QCuboidMesh * mMesh
Qt3DRender::QParameter * mTextureParameter
Qt3DRender::QMaterial * mMaterial
Qt3DRender::QTechnique * mGl3Technique