QGIS API Documentation 4.1.0-Master (3fcefe620d1)
Loading...
Searching...
No Matches
qgsmetalroughtexturedmaterialsettings.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsmetalroughtexturedmaterialsettings.h
3 --------------------------------------
4 Date : April 2026
5 Copyright : (C) 2026 by Nyall Dawson
6 Email : nyall dot dawson at gmail dot com
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 QGSMETALROUGHTEXTUREDMATERIALSETTINGS_H
17#define QGSMETALROUGHTEXTUREDMATERIALSETTINGS_H
18
19#include "qgis_core.h"
21
22#include <QColor>
23
24class QDomElement;
25
36{
37 public:
39
40 QString type() const override;
41
46
51
53 bool equals( const QgsAbstractMaterialSettings *other ) const override;
55
61 QString baseColorTexturePath() const { return mBaseColorTexturePath; }
62
68 QString metalnessTexturePath() const { return mMetalnessTexturePath; }
69
75 QString roughnessTexturePath() const { return mRoughnessTexturePath; }
76
82 QString normalTexturePath() const { return mNormalTexturePath; }
83
89 QString heightTexturePath() const { return mHeightTexturePath; }
90
97 double parallaxScale() const { return mParallaxScale; }
98
105 QString emissionTexturePath() const { return mEmissionTexturePath; }
106
116 double emissionFactor() const { return mEmissionFactor; }
117
123 QString ambientOcclusionTexturePath() const { return mAmbientOcclusionTexturePath; }
124
134 double textureScale() const { return mTextureScale; }
135
141 double textureRotation() const { return mTextureRotation; }
142
149 QPointF textureOffset() const { return mTextureOffset; }
150
157 double opacity() const { return mOpacity; }
158
164 void setBaseColorTexturePath( const QString &path ) { mBaseColorTexturePath = path; }
165
171 void setMetalnessTexturePath( const QString &path ) { mMetalnessTexturePath = path; }
172
178 void setRoughnessTexturePath( const QString &path ) { mRoughnessTexturePath = path; }
179
185 void setNormalTexturePath( const QString &path ) { mNormalTexturePath = path; }
186
192 void setHeightTexturePath( const QString &path ) { mHeightTexturePath = path; }
193
200 void setParallaxScale( double scale ) { mParallaxScale = scale; }
201
207 void setAmbientOcclusionTexturePath( const QString &path ) { mAmbientOcclusionTexturePath = path; }
208
215 void setEmissionTexturePath( const QString &path ) { mEmissionTexturePath = path; }
216
226 void setEmissionFactor( double factor ) { mEmissionFactor = factor; }
227
236 void setTextureScale( double scale ) { mTextureScale = scale; }
237
243 void setTextureRotation( double rotation ) { mTextureRotation = rotation; }
244
250 void setTextureOffset( QPointF offset ) { mTextureOffset = offset; }
251
258 void setOpacity( double opacity ) { mOpacity = opacity; }
259
260 bool requiresTextureCoordinates() const override;
261 bool requiresTangents() const override;
262 void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) override;
263 void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const override;
264
273 QColor averageColor() const override;
274
285 void setColorsFromBase( const QColor &baseColor ) override;
286
288 {
289 return mBaseColorTexturePath == other.mBaseColorTexturePath
290 && mMetalnessTexturePath == other.mMetalnessTexturePath
291 && mRoughnessTexturePath == other.mRoughnessTexturePath
292 && mNormalTexturePath == other.mNormalTexturePath
293 && mAmbientOcclusionTexturePath == other.mAmbientOcclusionTexturePath
294 && mHeightTexturePath == other.mHeightTexturePath
295 && mEmissionTexturePath == other.mEmissionTexturePath
296 && qgsDoubleNear( mTextureScale, other.mTextureScale )
297 && qgsDoubleNear( mTextureRotation, other.mTextureRotation )
298 && qgsDoubleNear( mEmissionFactor, other.mEmissionFactor )
299 && qgsDoubleNear( mParallaxScale, other.mParallaxScale )
300 && qgsDoubleNear( mTextureOffset.x(), other.mTextureOffset.x() )
301 && qgsDoubleNear( mTextureOffset.y(), other.mTextureOffset.y() )
302 && qgsDoubleNear( mOpacity, other.mOpacity )
304 }
305
306 private:
307 QColor textureAverageColor( const QString &texturePath ) const;
308
309 private:
310 QString mBaseColorTexturePath;
311 QString mMetalnessTexturePath;
312 QString mRoughnessTexturePath;
313 QString mNormalTexturePath;
314 QString mHeightTexturePath;
315 double mParallaxScale { 0.1 };
316
317 QString mAmbientOcclusionTexturePath;
318
319 QString mEmissionTexturePath;
320 double mEmissionFactor { 1.0 };
321
322 double mTextureScale { 1.0 };
323 double mTextureRotation { 0.0 };
324 QPointF mTextureOffset { 0.0, 0.0 };
325 double mOpacity { 1.0 };
326
327 mutable std::optional<QColor> mAverageColor;
328};
329
330
331#endif // QGSMETALROUGHTEXTUREDMATERIALSETTINGS_H
MaterialRenderingTechnique
Material rendering techniques.
Definition qgis.h:4375
Abstract base class for material settings.
virtual void writeXml(QDomElement &element, const QgsReadWriteContext &) const
Writes settings to a DOM element.
virtual void readXml(const QDomElement &element, const QgsReadWriteContext &)
Reads settings from a DOM element.
virtual bool requiresTangents() const
Returns true if the material requires tangents generated during triangulation.
virtual QColor averageColor() const =0
Returns an approximate color representing the blended material color.
virtual QString type() const =0
Returns the unique type name for the material.
virtual void setColorsFromBase(const QColor &baseColor)=0
Decomposes a base color into the material's color components, and sets the material's colors accordin...
QgsPropertyCollection dataDefinedProperties() const
Returns the symbol material property collection, used for data defined overrides.
virtual bool requiresTextureCoordinates() const
Returns true if the material requires texture coordinates to be generated during triangulation.
double emissionFactor() const
Returns the emission factor, which dictates the strength of the emission effect.
void setTextureScale(double scale)
Sets the texture scale.
QgsMetalRoughTexturedMaterialSettings * clone() const override
Clones the material settings.
static QgsAbstractMaterialSettings * create()
Returns a new instance of QgsMetalRoughTexturedMaterialSettings.
QString roughnessTexturePath() const
Returns the path to the roughness texture map.
double textureRotation() const
Returns the texture rotation, in degrees.
double textureScale() const
Returns the texture scale.
double opacity() const
Returns the opacity of the surface.
void setTextureRotation(double rotation)
Sets the texture rotation, in degrees.
void setMetalnessTexturePath(const QString &path)
Sets the path to the metalness texture map.
QPointF textureOffset() const
Returns the texture offset.
void setEmissionTexturePath(const QString &path)
Sets the path to the emission/luminosity texture map.
QString normalTexturePath() const
Returns the path to the normal texture map.
QString ambientOcclusionTexturePath() const
Returns the path to the ambient occlusion texture map.
void setHeightTexturePath(const QString &path)
Sets the path to the height texture map.
void setAmbientOcclusionTexturePath(const QString &path)
Sets the path to the ambient occlusion texture map.
QString metalnessTexturePath() const
Returns the path to the metalness texture map.
void setNormalTexturePath(const QString &path)
Sets the path to the normal texture map.
QSet< QgsAbstractMaterialSettings::Property > supportedProperties() const override
Returns the set of data-defined properties supported by this material.
bool equals(const QgsAbstractMaterialSettings *other) const override
Returns true if this settings exactly matches an other settings.
QString baseColorTexturePath() const
Returns the path to the base color texture map.
void setEmissionFactor(double factor)
Sets the emission factor, which dictates the strength of the emission effect.
static bool supportsTechnique(Qgis::MaterialRenderingTechnique technique)
Returns true if the specified technique is supported by the metal rough material.
QString heightTexturePath() const
Returns the path to the height texture map.
QString emissionTexturePath() const
Returns the path to the emission/luminosity texture map.
void setBaseColorTexturePath(const QString &path)
Sets the path to the base color texture map.
void setOpacity(double opacity)
Sets the opacity of the surface.
bool operator==(const QgsMetalRoughTexturedMaterialSettings &other) const
void setTextureOffset(QPointF offset)
Sets the texture offset.
void setRoughnessTexturePath(const QString &path)
Sets the path to the roughness texture map.
void setParallaxScale(double scale)
Sets the parallax scale, which dictates the strength of the height displacement effect.
double parallaxScale() const
Returns the parallax scale, which dictates the strength of the height displacement effect.
A container for the context for various read/write operations on objects.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference).
Definition qgis.h:7340
#define SIP_FACTORY
Definition qgis_sip.h:83