39 Qt3DCore::QEntity *lightEntity =
new Qt3DCore::QEntity();
40 Qt3DCore::QTransform *lightTransform =
new Qt3DCore::QTransform;
41 lightTransform->setTranslation( QVector3D(
position().x(),
45 Qt3DRender::QPointLight *light =
new Qt3DRender::QPointLight;
46 light->setColor(
color() );
53 lightEntity->addComponent( light );
54 lightEntity->addComponent( lightTransform );
58 lightEntity->setParent( parent );
63 Qt3DCore::QEntity *originEntity =
new Qt3DCore::QEntity();
65 Qt3DCore::QTransform *trLightOriginCenter =
new Qt3DCore::QTransform;
66 trLightOriginCenter->setTranslation( lightTransform->translation() );
67 originEntity->addComponent( trLightOriginCenter );
69 Qt3DExtras::QPhongMaterial *materialLightOriginCenter =
new Qt3DExtras::QPhongMaterial;
70 materialLightOriginCenter->setAmbient(
color() );
71 originEntity->addComponent( materialLightOriginCenter );
73 Qt3DExtras::QSphereMesh *rendererLightOriginCenter =
new Qt3DExtras::QSphereMesh;
74 rendererLightOriginCenter->setRadius( 20 );
75 originEntity->addComponent( rendererLightOriginCenter );
77 originEntity->setEnabled(
true );
79 Qt3DCore::QEntity *groupEntity =
new Qt3DCore::QEntity( parent );
80 lightEntity->setParent( groupEntity );
81 originEntity->setParent( groupEntity );
82 groupEntity->setEnabled(
true );
89 QDomElement elemLight = doc.createElement( QStringLiteral(
"point-light" ) );
90 elemLight.setAttribute( QStringLiteral(
"x" ), mPosition.
x() );
91 elemLight.setAttribute( QStringLiteral(
"y" ), mPosition.
y() );
92 elemLight.setAttribute( QStringLiteral(
"z" ), mPosition.
z() );
94 elemLight.setAttribute( QStringLiteral(
"intensity" ), mIntensity );
95 elemLight.setAttribute( QStringLiteral(
"attenuation-0" ), mConstantAttenuation );
96 elemLight.setAttribute( QStringLiteral(
"attenuation-1" ), mLinearAttenuation );
97 elemLight.setAttribute( QStringLiteral(
"attenuation-2" ), mQuadraticAttenuation );
103 mPosition.
set( elem.attribute( QStringLiteral(
"x" ) ).toDouble(),
104 elem.attribute( QStringLiteral(
"y" ) ).toDouble(),
105 elem.attribute( QStringLiteral(
"z" ) ).toDouble() );
107 mIntensity = elem.attribute( QStringLiteral(
"intensity" ) ).toFloat();
108 mConstantAttenuation = elem.attribute( QStringLiteral(
"attenuation-0" ) ).toDouble();
109 mLinearAttenuation = elem.attribute( QStringLiteral(
"attenuation-1" ) ).toDouble();
110 mQuadraticAttenuation = elem.attribute( QStringLiteral(
"attenuation-2" ) ).toDouble();
The class is used as a container of context for various read/write operations on other objects.