QGIS API Documentation 3.38.0-Grenoble (exported)
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
43
44 QString type() const override;
45
49 static bool supportsTechnique( QgsMaterialSettingsRenderingTechnique technique );
50
55
56 QgsMetalRoughMaterialSettings *clone() const override SIP_FACTORY;
57
63 QColor baseColor() const { return mBaseColor; }
64
70 float metalness() const { return mMetalness; }
71
77 float roughness() const { return mRoughness; }
78
79 QMap<QString, QString> toExportParameters() const override;
80
86 void setBaseColor( const QColor &color ) { mBaseColor = color; }
87
93 void setMetalness( float metalness ) { mMetalness = metalness; }
94
100 void setRoughness( float roughness ) { mRoughness = roughness; }
101
102 void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) override;
103 void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const override;
104
105#ifndef SIP_RUN
106 Qt3DRender::QMaterial *toMaterial( QgsMaterialSettingsRenderingTechnique technique, const QgsMaterialContext &context ) const override SIP_FACTORY;
107 void addParametersToEffect( Qt3DRender::QEffect *effect, const QgsMaterialContext &materialContext ) const override;
108#endif
109
110 // TODO c++20 - replace with = default
111 bool operator==( const QgsMetalRoughMaterialSettings &other ) const
112 {
113 return mBaseColor == other.mBaseColor &&
114 mMetalness == other.mMetalness &&
115 mRoughness == other.mRoughness;
116 }
117
118 private:
119 QColor mBaseColor{ QColor::fromRgbF( 0.5f, 0.5f, 0.5f, 1.0f ) };
120 float mMetalness = 0.0f;
121 float mRoughness = 0.0f;
122};
123
124
125#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 Qt3DRender::QMaterial * toMaterial(QgsMaterialSettingsRenderingTechnique technique, const QgsMaterialContext &context) const =0
Creates a new QMaterial object representing the material settings.
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.
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.
QgsMetalRoughMaterialSettings()=default
Constructor for QgsMetalRoughMaterialSettings.
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