Skip to content
Permalink
Browse files

Replace other deprecated Qt3d materials with maintained versions

  • Loading branch information
nyalldawson committed Dec 22, 2020
1 parent e4869b1 commit 14a60c1c8d18a9547f5d666ef1513d0a817be0c5
@@ -19,9 +19,6 @@

#include <Qt3DRender/QMaterial>

#include <Qt3DExtras/QDiffuseMapMaterial>
#include <Qt3DExtras/QTextureMaterial>

#include "qgsmesh3dentity_p.h"
#include "qgsmeshlayer.h"
#include "qgsmeshlayer3drenderer.h"
@@ -26,7 +26,11 @@
#include <Qt3DExtras/QPlaneGeometry>
#include <Qt3DCore/QTransform>
#include <Qt3DRender/QMaterial>
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
#include <Qt3DExtras/QDiffuseMapMaterial>
#else
#include <Qt3DExtras/QDiffuseSpecularMaterial>
#endif
#include <Qt3DExtras/QTextureMaterial>
#include <Qt3DRender/QTextureImage>
#include <Qt3DRender/QTexture>
@@ -227,10 +231,19 @@ void Qgs3DSceneExporter::processEntityMaterial( Qt3DCore::QEntity *entity, Qgs3D
QgsPhongMaterialSettings material = Qgs3DUtils::phongMaterialFromQt3DComponent( phongMaterial );
object->setupMaterial( &material );
}
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
Qt3DExtras::QDiffuseMapMaterial *diffuseMapMaterial = findTypedComponent<Qt3DExtras::QDiffuseMapMaterial>( entity );
#else
Qt3DExtras::QDiffuseSpecularMaterial *diffuseMapMaterial = findTypedComponent<Qt3DExtras::QDiffuseSpecularMaterial>( entity );
#endif

if ( diffuseMapMaterial != nullptr )
{
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
QVector<Qt3DRender::QAbstractTextureImage *> textureImages = diffuseMapMaterial->diffuse()->textureImages();
#else
QVector<Qt3DRender::QAbstractTextureImage *> textureImages = diffuseMapMaterial->diffuse().value< Qt3DRender::QTexture2D * >()->textureImages();
#endif
QgsImageTexture *imageTexture = nullptr;
for ( Qt3DRender::QAbstractTextureImage *tex : textureImages )
{
@@ -26,7 +26,11 @@
#include <Qt3DRender/QTexture>

#include <Qt3DExtras/QTextureMaterial>
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
#include <Qt3DExtras/QDiffuseMapMaterial>
#else
#include <Qt3DExtras/QDiffuseSpecularMaterial>
#endif
#include <Qt3DExtras/QPhongMaterial>

#include "quantizedmeshterraingenerator.h"
@@ -69,9 +73,15 @@ void QgsTerrainTileLoader::createTextureComponent( QgsTerrainTileEntity *entity,
{
if ( isShadingEnabled )
{
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
Qt3DExtras::QDiffuseMapMaterial *diffuseMapMaterial;
diffuseMapMaterial = new Qt3DExtras::QDiffuseMapMaterial;
diffuseMapMaterial->setDiffuse( texture );
#else
Qt3DExtras::QDiffuseSpecularMaterial *diffuseMapMaterial = new Qt3DExtras::QDiffuseSpecularMaterial;
diffuseMapMaterial->setDiffuse( QVariant::fromValue( texture ) );
material = diffuseMapMaterial;
#endif
diffuseMapMaterial->setAmbient( shadingMaterial.ambient() );
diffuseMapMaterial->setSpecular( shadingMaterial.specular() );
diffuseMapMaterial->setShininess( shadingMaterial.shininess() );

0 comments on commit 14a60c1

Please sign in to comment.
You can’t perform that action at this time.