QGIS API Documentation 4.1.0-Master (64dc32379c2)
Loading...
Searching...
No Matches
qgsmetalroughtexturedmaterialsettings.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsmetalroughtexturedmaterialsettings.cpp
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
17
18#include "qgssymbollayerutils.h"
19
20#include <QString>
21
22using namespace Qt::StringLiterals;
23
25{
26 return u"metalroughtextured"_s;
27}
28
47
52
57
59{
60 const QgsMetalRoughTexturedMaterialSettings *otherMetal = dynamic_cast<const QgsMetalRoughTexturedMaterialSettings *>( other );
61 if ( !otherMetal )
62 return false;
63
64 return *this == *otherMetal;
65}
66
71
73{
74 return !mNormalTexturePath.isEmpty() || !mHeightTexturePath.isEmpty();
75}
76
77void QgsMetalRoughTexturedMaterialSettings::readXml( const QDomElement &elem, const QgsReadWriteContext &context )
78{
79 mBaseColorTexturePath = elem.attribute( u"base_color_texture_path"_s, QString() );
80 mMetalnessTexturePath = elem.attribute( u"metalness_texture_path"_s, QString() );
81 mRoughnessTexturePath = elem.attribute( u"roughness_texture_path"_s, QString() );
82 mNormalTexturePath = elem.attribute( u"normal_texture_path"_s, QString() );
83 mHeightTexturePath = elem.attribute( u"height_texture_path"_s, QString() );
84 mAmbientOcclusionTexturePath = elem.attribute( u"ambient_occlusion_texture_path"_s, QString() );
85 mEmissionTexturePath = elem.attribute( u"emission_texture_path"_s, QString() );
86 mEmissionFactor = elem.attribute( u"emission_factor"_s, QString( "1.0" ) ).toDouble();
87 mParallaxScale = elem.attribute( u"parallax_scale"_s, QString( "0.1" ) ).toDouble();
88 mTextureScale = elem.attribute( u"texture_scale"_s, QString( "1.0" ) ).toDouble();
89 mTextureRotation = elem.attribute( u"texture_rotation"_s, QString( "0.0" ) ).toDouble();
90 mOpacity = elem.attribute( u"opacity"_s, u"1.0"_s ).toDouble();
91
93}
94
95void QgsMetalRoughTexturedMaterialSettings::writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const
96{
97 elem.setAttribute( u"base_color_texture_path"_s, mBaseColorTexturePath );
98 elem.setAttribute( u"metalness_texture_path"_s, mMetalnessTexturePath );
99 elem.setAttribute( u"roughness_texture_path"_s, mRoughnessTexturePath );
100 elem.setAttribute( u"normal_texture_path"_s, mNormalTexturePath );
101 elem.setAttribute( u"parallax_scale"_s, mParallaxScale );
102 elem.setAttribute( u"height_texture_path"_s, mHeightTexturePath );
103 elem.setAttribute( u"emission_texture_path"_s, mEmissionTexturePath );
104 elem.setAttribute( u"ambient_occlusion_texture_path"_s, mAmbientOcclusionTexturePath );
105 if ( !qgsDoubleNear( mEmissionFactor, 1.0 ) )
106 elem.setAttribute( u"emission_factor"_s, mEmissionFactor );
107 elem.setAttribute( u"texture_scale"_s, mTextureScale );
108 elem.setAttribute( u"texture_rotation"_s, mTextureRotation );
109 if ( !qgsDoubleNear( mOpacity, 1 ) )
110 elem.setAttribute( u"opacity"_s, mOpacity );
111
113}
MaterialRenderingTechnique
Material rendering techniques.
Definition qgis.h:4342
@ Points
Point based rendering, requires point data.
Definition qgis.h:4346
@ Triangles
Triangle based rendering (default).
Definition qgis.h:4343
@ TrianglesFromModel
Triangle based rendering, using a model object source.
Definition qgis.h:4348
@ Lines
Line based rendering, requires line data.
Definition qgis.h:4344
@ Billboards
Flat billboard rendering.
Definition qgis.h:4350
@ TrianglesDataDefined
Triangle based rendering with possibility of datadefined color.
Definition qgis.h:4349
@ InstancedPoints
Instanced based rendering, requiring triangles and point data.
Definition qgis.h:4345
@ TrianglesWithFixedTexture
Triangle based rendering, using a fixed, non-user-configurable texture (e.g. for terrain rendering).
Definition qgis.h:4347
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.
bool requiresTangents() const override
Returns true if the material requires tangents generated during triangulation.
QString type() const override
Returns the unique type name for the material.
QgsMetalRoughTexturedMaterialSettings * clone() const override
Clones the material settings.
static QgsAbstractMaterialSettings * create()
Returns a new instance of QgsMetalRoughTexturedMaterialSettings.
void writeXml(QDomElement &elem, const QgsReadWriteContext &context) const override
Writes settings to a DOM element.
void readXml(const QDomElement &elem, const QgsReadWriteContext &context) override
Reads settings from a DOM element.
bool equals(const QgsAbstractMaterialSettings *other) const override
Returns true if this settings exactly matches an other settings.
bool requiresTextureCoordinates() const override
Returns true if the material requires texture coordinates to be generated during triangulation.
static bool supportsTechnique(Qgis::MaterialRenderingTechnique technique)
Returns true if the specified technique is supported by the metal rough material.
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:7148