19#include <QDomDocument> 
   20#include <Qt3DRender/QDirectionalLight> 
   21#include <Qt3DCore/QEntity> 
   35  Qt3DCore::QEntity *lightEntity = 
new Qt3DCore::QEntity( parent );
 
   36  Qt3DCore::QTransform *lightTransform = 
new Qt3DCore::QTransform;
 
   38  Qt3DRender::QDirectionalLight *light = 
new Qt3DRender::QDirectionalLight;
 
   39  light->setColor( 
color() );
 
   44  lightEntity->addComponent( light );
 
   45  lightEntity->addComponent( lightTransform );
 
   52  QDomElement elemLight = doc.createElement( QStringLiteral( 
"directional-light" ) );
 
   53  elemLight.setAttribute( QStringLiteral( 
"x" ), mDirection.
x() );
 
   54  elemLight.setAttribute( QStringLiteral( 
"y" ), mDirection.
y() );
 
   55  elemLight.setAttribute( QStringLiteral( 
"z" ), mDirection.
z() );
 
   57  elemLight.setAttribute( QStringLiteral( 
"intensity" ), mIntensity );
 
   63  mDirection.
set( elem.attribute( QStringLiteral( 
"x" ) ).toFloat(),
 
   64                  elem.attribute( QStringLiteral( 
"y" ) ).toFloat(),
 
   65                  elem.attribute( QStringLiteral( 
"z" ) ).toFloat() );
 
   67  mIntensity = elem.attribute( QStringLiteral( 
"intensity" ) ).toFloat();
 
   72  return mDirection == other.mDirection && mColor == other.mColor && mIntensity == other.mIntensity;
 
LightSourceType
Light source types for 3D scenes.
 
@ Directional
Directional light source.
 
bool operator==(const QgsDirectionalLightSettings &other)
 
QgsDirectionalLightSettings * clone() const override
Returns a copy of the light source.
 
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.
 
The class is used as a container of context for various read/write operations on other objects.
 
static QColor decodeColor(const QString &str)
 
static QString encodeColor(const QColor &color)
 
double y() const
Returns Y coordinate.
 
double z() const
Returns Z coordinate.
 
double x() const
Returns X coordinate.
 
void set(double x, double y, double z)
Sets vector coordinates.