QGIS API Documentation 4.1.0-Master (9af12b5a203)
Loading...
Searching...
No Matches
qgs3d.h
Go to the documentation of this file.
1/***************************************************************************
2 qgs3d.h
3 --------
4 begin : July 2020
5 copyright : (C) 2020 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGS3D_H
19#define QGS3D_H
20
21#include <memory>
22
23#include "qgis.h"
24#include "qgis_3d.h"
25#include "qgis_sip.h"
26
31class QgsMaterial;
35template<class T> class QgsSettingsEntryEnumFlag;
36
37#ifndef SIP_RUN
38namespace Qt3DCore
39{
40 class QGeometry;
41}
42
43namespace Qt3DRender
44{
45 class QEffect;
46}
47#endif
48
55class _3D_EXPORT Qgs3D
56{
57 public:
61
62 Qgs3D( const Qgs3D &other ) = delete;
63 Qgs3D &operator=( const Qgs3D &other ) = delete;
64
68 static Qgs3D *instance();
69
70 ~Qgs3D();
71
75 static void initialize();
76
81
86
87#ifndef SIP_RUN
96
101 static QMap<QString, QString> toMaterialExportParameters( const QgsAbstractMaterialSettings *settings );
102
107 static void addMaterialParametersToEffect( Qt3DRender::QEffect *effect, const QgsAbstractMaterialSettings *settings, const QgsMaterialContext &materialContext );
108
113 static void applyMaterialDataDefinedToGeometry( const QgsAbstractMaterialSettings *settings, Qt3DCore::QGeometry *geometry, int vertexCount, const QByteArray &dataDefinedBytes );
114
120 static QByteArray materialDataDefinedVertexColorsAsByte( const QgsAbstractMaterialSettings *settings, const QgsExpressionContext &expressionContext );
121
127
132
133 // if you change this, also update the corresponding constant in shadows.inc.frag!
135 static constexpr int NUM_SHADOW_CASCADES = 4;
136
137#endif
138
139 private:
140 Qgs3D();
141
142#ifdef SIP_RUN
143 Qgs3D( const Qgs3D &other );
144#endif
145
146 bool mInitialized = false;
147
148 Qgs3DTerrainRegistry *mTerrainRegistry = nullptr;
149 std::unique_ptr< QgsAbstractMaterial3DHandler > mNullMaterialHandler;
150 std::unique_ptr< QgsAbstractMaterial3DHandler > mPhongMaterialHandler;
151 std::unique_ptr< QgsAbstractMaterial3DHandler > mPhongTexturedMaterialHandler;
152 std::unique_ptr< QgsAbstractMaterial3DHandler > mSimpleLineMaterialHandler;
153 std::unique_ptr< QgsAbstractMaterial3DHandler > mGoochMaterialHandler;
154 std::unique_ptr< QgsAbstractMaterial3DHandler > mMetalRoughMaterialHandler;
155 std::unique_ptr< QgsAbstractMaterial3DHandler > mMetalRoughTexturedMaterialHandler;
156};
157
158#endif // QGS3D_H
MaterialRenderingTechnique
Material rendering techniques.
Definition qgis.h:4342
Registry of available 3d terrain classes.
static void initialize()
Initializes the 3D framework.
Definition qgs3d.cpp:77
static QMap< QString, QString > toMaterialExportParameters(const QgsAbstractMaterialSettings *settings)
Returns the parameters to be exported to .mtl file.
Definition qgs3d.cpp:161
static Qgs3DTerrainRegistry * terrainRegistry()
Returns the terrain registry, used for managing 3D terrains.
Definition qgs3d.cpp:130
static const QgsSettingsEntryEnumFlag< Qgis::TextureFilterQuality > * settingTextureFilterQuality
Definition qgs3d.h:59
static QgsMaterial * toMaterial(const QgsAbstractMaterialSettings *settings, Qgis::MaterialRenderingTechnique technique, const QgsMaterialContext &context)
Creates a new QgsMaterial object representing the material settings.
Definition qgs3d.cpp:152
static void addMaterialParametersToEffect(Qt3DRender::QEffect *effect, const QgsAbstractMaterialSettings *settings, const QgsMaterialContext &materialContext)
Adds parameters from the material settings to a destination effect.
Definition qgs3d.cpp:170
static const QgsSettingsEntryBool * settingMsaaEnabled
Definition qgs3d.h:58
static QgsMaterialRegistry * materialRegistry()
Returns the material registry, used for managing 3D materials.
Definition qgs3d.cpp:125
static Qgs3D * instance()
Returns a pointer to the singleton instance.
Definition qgs3d.cpp:60
static const QgsAbstractMaterial3DHandler * handlerForMaterialSettings(const QgsAbstractMaterialSettings *settings)
Returns the handler to use for a material settings.
Definition qgs3d.cpp:135
Qgs3D & operator=(const Qgs3D &other)=delete
static constexpr int NUM_SHADOW_CASCADES
Number of shadow map cascades.
Definition qgs3d.h:135
Qgs3D(const Qgs3D &other)=delete
static QByteArray materialDataDefinedVertexColorsAsByte(const QgsAbstractMaterialSettings *settings, const QgsExpressionContext &expressionContext)
Returns byte array corresponding to the data defined colors depending of the expressionContext,...
Definition qgs3d.cpp:186
static const QgsSettingsEntryEnumFlag< Qgis::ShadowQuality > * settingShadowQuality
Definition qgs3d.h:60
static int materialDataDefinedByteStride(const QgsAbstractMaterialSettings *settings)
Returns byte stride of the data defined colors,used to fill the vertex colors data defined buffer for...
Definition qgs3d.cpp:195
static void applyMaterialDataDefinedToGeometry(const QgsAbstractMaterialSettings *settings, Qt3DCore::QGeometry *geometry, int vertexCount, const QByteArray &dataDefinedBytes)
Applies the data defined bytes, dataDefinedBytes, on the geometry by filling a specific vertex buffer...
Definition qgs3d.cpp:178
Abstract base class for material 3D handlers.
Abstract base class for material settings.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Context settings for a material.
Registry of available 3d material settings classes.
Base class for all materials used within QGIS 3D views.
Definition qgsmaterial.h:40
A boolean settings entry.
A template class for enum and flag settings entry.
#define SIP_SKIP
Definition qgis_sip.h:133