QGIS API Documentation 3.39.0-Master (3aed037ce22)
Loading...
Searching...
No Matches
qgsphongtexturedmaterialsettings.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsphongtexturedmaterialsettings.h
3 --------------------------------------
4 Date : August 2020
5 Copyright : (C) 2020 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 QGSPHONGTEXTUREDMATERIALSETTINGS_H
17#define QGSPHONGTEXTUREDMATERIALSETTINGS_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 QgsPhongTexturedMaterialSettings *clone() const override SIP_FACTORY;
54
56 QColor ambient() const { return mAmbient; }
58 QColor specular() const { return mSpecular; }
60 float shininess() const { return mShininess; }
61
62 QMap<QString, QString> toExportParameters() const override;
63
69 QString diffuseTexturePath() const { return mDiffuseTexturePath; }
70
76 float textureScale() const { return mTextureScale; }
77
82 bool requiresTextureCoordinates() const { return !mDiffuseTexturePath.isEmpty(); }
83
87 float textureRotation() const;
88
93 float opacity() const { return mOpacity; }
94
96 void setAmbient( const QColor &ambient ) { mAmbient = ambient; }
97
99 void setSpecular( const QColor &specular ) { mSpecular = specular; }
101 void setShininess( float shininess ) { mShininess = shininess; }
102
107 void setDiffuseTexturePath( const QString &path ) { mDiffuseTexturePath = path; }
108
114 void setTextureScale( float scale ) { mTextureScale = scale; }
115
117 void setTextureRotation( float rotation ) { mTextureRotation = rotation; }
118
123 void setOpacity( float opacity ) { mOpacity = opacity; }
124
125 void readXml( const QDomElement &elem, const QgsReadWriteContext &context ) override;
126 void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const override;
127#ifndef SIP_RUN
128 Qt3DRender::QMaterial *toMaterial( QgsMaterialSettingsRenderingTechnique technique, const QgsMaterialContext &context ) const override SIP_FACTORY;
129 void addParametersToEffect( Qt3DRender::QEffect *effect, const QgsMaterialContext &materialContext ) const override;
130#endif
131
132 // TODO c++20 - replace with = default
134 {
135 return mAmbient == other.mAmbient &&
136 mSpecular == other.mSpecular &&
137 mShininess == other.mShininess &&
138 mOpacity == other.mOpacity &&
139 mDiffuseTexturePath == other.mDiffuseTexturePath &&
140 mTextureScale == other.mTextureScale &&
141 mTextureRotation == other.mTextureRotation;
142 }
143
144 private:
145 QColor mAmbient{ QColor::fromRgbF( 0.1f, 0.1f, 0.1f, 1.0f ) };
146 QColor mSpecular{ QColor::fromRgbF( 1.0f, 1.0f, 1.0f, 1.0f ) };
147 float mShininess = 0.0f;
148 float mOpacity = 1.0f;
149 QString mDiffuseTexturePath;
150 float mTextureScale{ 1.0f };
151 float mTextureRotation{ 0.0f };
152};
153
154
155#endif // QGSPHONGTEXTUREDMATERIALSETTINGS_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 requiresTextureCoordinates() const
Returns true if the material requires texture coordinates to be generated during triangulation....
void setTextureScale(float scale)
Sets the texture scale The texture scale changes the size of the displayed texture in the 3D scene If...
void setSpecular(const QColor &specular)
Sets specular color component.
float textureScale() const
Returns the texture scale The texture scale changes the size of the displayed texture in the 3D scene...
float shininess() const
Returns shininess of the surface.
void setDiffuseTexturePath(const QString &path)
Sets the path of the diffuse texture.
QString diffuseTexturePath() const
Returns the diffuse texture path.
QColor specular() const
Returns specular color component.
void setShininess(float shininess)
Sets shininess of the surface.
void setAmbient(const QColor &ambient)
Sets ambient color component.
void setOpacity(float opacity)
Sets opacity of the surface.
void setTextureRotation(float rotation)
Sets the texture rotation in degrees.
bool operator==(const QgsPhongTexturedMaterialSettings &other) const
float opacity() const
Returns the opacity of the surface.
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