21 #include <Qt3DExtras/QDiffuseMapMaterial>
22 #include <Qt3DExtras/QPhongMaterial>
23 #include <Qt3DRender/QParameter>
24 #include <Qt3DRender/QEffect>
30 return QStringLiteral(
"phong" );
37 case QgsMaterialSettingsRenderingTechnique::Triangles:
38 case QgsMaterialSettingsRenderingTechnique::InstancedPoints:
43 case QgsMaterialSettingsRenderingTechnique::Lines:
64 mShininess = elem.attribute( QStringLiteral(
"shininess" ) ).toFloat();
72 elem.setAttribute( QStringLiteral(
"shininess" ), mShininess );
80 case QgsMaterialSettingsRenderingTechnique::Triangles:
81 case QgsMaterialSettingsRenderingTechnique::InstancedPoints:
85 Qt3DExtras::QPhongMaterial *material =
new Qt3DExtras::QPhongMaterial;
86 material->setDiffuse( mDiffuse );
87 material->setAmbient( mAmbient );
88 material->setSpecular( mSpecular );
89 material->setShininess( mShininess );
100 case QgsMaterialSettingsRenderingTechnique::Lines:
109 QMap<QString, QString> parameters;
110 parameters[ QStringLiteral(
"Kd" ) ] = QStringLiteral(
"%1 %2 %3" ).arg( mDiffuse.redF() ).arg( mDiffuse.greenF() ).arg( mDiffuse.blueF() );
111 parameters[ QStringLiteral(
"Ka" ) ] = QStringLiteral(
"%1 %2 %3" ).arg( mAmbient.redF() ).arg( mAmbient.greenF() ).arg( mAmbient.blueF() );
112 parameters[ QStringLiteral(
"Ks" ) ] = QStringLiteral(
"%1 %2 %3" ).arg( mSpecular.redF() ).arg( mSpecular.greenF() ).arg( mSpecular.blueF() );
113 parameters[ QStringLiteral(
"Ns" ) ] = QString::number( mShininess );
119 Qt3DRender::QParameter *ambientParameter =
new Qt3DRender::QParameter( QStringLiteral(
"ka" ), QColor::fromRgbF( 0.05f, 0.05f, 0.05f, 1.0f ) );
120 Qt3DRender::QParameter *diffuseParameter =
new Qt3DRender::QParameter( QStringLiteral(
"kd" ), QColor::fromRgbF( 0.7f, 0.7f, 0.7f, 1.0f ) );
121 Qt3DRender::QParameter *specularParameter =
new Qt3DRender::QParameter( QStringLiteral(
"ks" ), QColor::fromRgbF( 0.01f, 0.01f, 0.01f, 1.0f ) );
122 Qt3DRender::QParameter *shininessParameter =
new Qt3DRender::QParameter( QStringLiteral(
"shininess" ), 150.0f );
124 diffuseParameter->setValue( mDiffuse );
125 ambientParameter->setValue( mAmbient );
126 specularParameter->setValue( mSpecular );
127 shininessParameter->setValue( mShininess );
129 effect->addParameter( ambientParameter );
130 effect->addParameter( diffuseParameter );
131 effect->addParameter( specularParameter );
132 effect->addParameter( shininessParameter );