23 #include <Qt3DCore/QTransform>
24 #include <Qt3DRender/QEffect>
25 #include <Qt3DRender/QTechnique>
26 #include <Qt3DRender/QCullFace>
46 Qt3DCore::QNode *parent )
50 Qt3DExtras::QPhongMaterial *mat =
material( symbol );
53 Qt3DCore::QTransform *tform =
new Qt3DCore::QTransform;
54 tform->setTranslation( QVector3D( 0, 0, 0 ) );
57 QgsMesh3DSymbolEntityNode *entity =
new QgsMesh3DSymbolEntityNode( map, layer, symbol );
58 entity->findChild<Qt3DRender::QGeometryRenderer *>()->setObjectName( QStringLiteral(
"main" ) );
59 entity->addComponent( mat );
60 entity->addComponent( tform );
61 entity->setParent(
this );
64 Qt3DExtras::QPhongMaterial *QgsMesh3DSymbolEntity::material(
const QgsMesh3DSymbol &symbol )
const
66 Qt3DExtras::QPhongMaterial *material =
new Qt3DExtras::QPhongMaterial;
69 auto techniques = material->effect()->techniques();
70 for (
auto tit = techniques.constBegin(); tit != techniques.constEnd(); ++tit )
72 auto renderPasses = ( *tit )->renderPasses();
73 for (
auto rpit = renderPasses.begin(); rpit != renderPasses.end(); ++rpit )
75 Qt3DRender::QCullFace *cullFace =
new Qt3DRender::QCullFace;
76 cullFace->setMode( Qt3DRender::QCullFace::Back );
77 ( *rpit )->addRenderState( cullFace );
88 QgsMesh3DSymbolEntityNode::QgsMesh3DSymbolEntityNode(
const Qgs3DMapSettings &map,
91 Qt3DCore::QNode *parent ) :
Qt3DCore::QEntity( parent )
93 addComponent( renderer( map, symbol, layer ) );
96 Qt3DRender::QGeometryRenderer *QgsMesh3DSymbolEntityNode::renderer(
const Qgs3DMapSettings &map,
101 QList<QgsPolygon *> polygons;
102 QList<QgsFeatureId> fids;
107 float height = symbol.
height();
112 static_cast<double>( height )
120 const QVector<QgsMeshFace> &triangles = mesh->
triangles();
121 const QVector<QgsMeshVertex> &vertices = mesh->
vertices();
122 for (
int i = 0; i < triangles.size(); ++i )
125 Q_ASSERT( triangle.size() == 3 );
129 Qgs3DTypes::AltitudeBinding::AltBindVertex,
132 polygons.append( polygon.release() );
143 QList<float> extrusionHeightPerPolygon;
144 mGeometry->setPolygons( polygons, fids, origin, 0.0, extrusionHeightPerPolygon );
146 Qt3DRender::QGeometryRenderer *renderer =
new Qt3DRender::QGeometryRenderer;
147 renderer->setGeometry( mGeometry );