21#include <QDomDocument>
23#include <Qt3DCore/QEntity>
24#include <Qt3DRender/QDirectionalLight>
26using namespace Qt::StringLiterals;
40 Qt3DCore::QEntity *lightEntity =
new Qt3DCore::QEntity( parent );
42 Qt3DRender::QDirectionalLight *light =
new Qt3DRender::QDirectionalLight;
43 light->setColor(
color() );
48 lightEntity->addComponent( light );
55 QDomElement elemLight = doc.createElement( u
"directional-light"_s );
56 elemLight.setAttribute( u
"x"_s, mDirection.x() );
57 elemLight.setAttribute( u
"y"_s, mDirection.y() );
58 elemLight.setAttribute( u
"z"_s, mDirection.z() );
60 elemLight.setAttribute( u
"intensity"_s, mIntensity );
66 mDirection.set( elem.attribute( u
"x"_s ).toFloat(), elem.attribute( u
"y"_s ).toFloat(), elem.attribute( u
"z"_s ).toFloat() );
68 mIntensity = elem.attribute( u
"intensity"_s ).toFloat();
73 return mDirection == other.mDirection && mColor == other.mColor && mIntensity == other.mIntensity;
LightSourceType
Light source types for 3D scenes.
@ Directional
Directional light source.
static QColor colorFromString(const QString &string)
Decodes a string into a color value.
static QString colorToString(const QColor &color)
Encodes a color into a string value.
QgsDirectionalLightSettings * clone() const override
Returns a copy of the light source.
bool operator==(const QgsDirectionalLightSettings &other) const
float intensity() const
Returns intensity of the light.
QColor color() const
Returns color of the light.
QDomElement writeXml(QDomDocument &doc, const QgsReadWriteContext &context=QgsReadWriteContext()) const override
Writes the light source's configuration to a new DOM element and returns it.
QgsDirectionalLightSettings()=default
Construct a directional light with default values.
Qt3DCore::QEntity * createEntity(const Qgs3DMapSettings &map, Qt3DCore::QEntity *parent) const override
Creates an entity representing the light source.
void readXml(const QDomElement &elem, const QgsReadWriteContext &context=QgsReadWriteContext()) override
Reads configuration from a DOM element previously written using writeXml().
QgsVector3D direction() const
Returns the direction of the light in degrees.
Qgis::LightSourceType type() const override
Returns the light source type.
A container for the context for various read/write operations on objects.
A 3D vector (similar to QVector3D) with the difference that it uses double precision instead of singl...