QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
Loading...
Searching...
No Matches
qgsmetalroughmaterialsettings.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsmetalroughmaterialsettings.h
3 --------------------------------------
4 Date : December 2023
5 Copyright : (C) 2023 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 QGSMETALROUGHMATERIALSETTINGS_H
17#define QGSMETALROUGHMATERIALSETTINGS_H
18
19#include "qgis_3d.h"
21
22#include <QColor>
23
24class QDomElement;
25
36{
37 public:
38
40
41 QString type() const override;
42
46 static bool supportsTechnique( QgsMaterialSettingsRenderingTechnique technique );
47
52
53 QgsMetalRoughMaterialSettings *clone() const override SIP_FACTORY;
54
60 QColor baseColor() const { return mBaseColor; }
61
67 float metalness() const { return mMetalness; }
68
74 float roughness() const { return mRoughness; }
75
76 QMap<QString, QString> toExportParameters() const override;
77
83 void setBaseColor( const QColor &color ) { mBaseColor = color; }
84
90 void setMetalness( float metalness ) { mMetalness = metalness; }
91
97 void setRoughness( float roughness ) { mRoughness = roughness; }
98
99 void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) override;
100 void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const override;
101
102#ifndef SIP_RUN
104 void addParametersToEffect( Qt3DRender::QEffect *effect, const QgsMaterialContext &materialContext ) const override;
105#endif
106
107 // TODO c++20 - replace with = default
108 bool operator==( const QgsMetalRoughMaterialSettings &other ) const
109 {
110 return mBaseColor == other.mBaseColor &&
111 mMetalness == other.mMetalness &&
112 mRoughness == other.mRoughness;
113 }
114
115 private:
116 QColor mBaseColor{ QColor::fromRgbF( 0.5f, 0.5f, 0.5f, 1.0f ) };
117 float mMetalness = 0.0f;
118 float mRoughness = 0.0f;
119};
120
121
122#endif // QGSMETALROUGHMATERIALSETTINGS_H
virtual void writeXml(QDomElement &element, const QgsReadWriteContext &) const
Writes settings to a DOM element.
virtual QMap< QString, QString > toExportParameters() const =0
Returns the parameters to be exported to .mtl file.
virtual void readXml(const QDomElement &element, const QgsReadWriteContext &)
Reads settings from a DOM element.
virtual void addParametersToEffect(Qt3DRender::QEffect *effect, const QgsMaterialContext &materialContext) const =0
Adds parameters from the material to a destination effect.
virtual QString type() const =0
Returns the unique type name for the material.
virtual QgsMaterial * toMaterial(QgsMaterialSettingsRenderingTechnique technique, const QgsMaterialContext &context) const =0
Creates a new QgsMaterial object representing the material settings.
bool operator==(const QgsMetalRoughMaterialSettings &other) const
void setRoughness(float roughness)
Returns the material's roughness.
float metalness() const
Returns the material's metalness.
float roughness() const
Returns the material's roughness.
void setBaseColor(const QColor &color)
Sets the base material color.
void setMetalness(float metalness)
Returns the material's metalness.
The class is used as a container of context for various read/write operations on other objects.
QgsMaterialSettingsRenderingTechnique
Material rendering techniques 3.
#define SIP_FACTORY
Definition qgis_sip.h:76