23 #include <Qt3DCore/QTransform>
24 #include <Qt3DRender/QEffect>
25 #include <Qt3DRender/QTechnique>
26 #include <Qt3DRender/QCullFace>
47 Qt3DCore::QNode *parent )
51 Qt3DRender::QMaterial *mat =
material( symbol );
54 Qt3DCore::QTransform *tform =
new Qt3DCore::QTransform;
55 tform->setTranslation( QVector3D( 0, 0, 0 ) );
58 QgsMesh3DSymbolEntityNode *entity =
new QgsMesh3DSymbolEntityNode( map, layer, symbol );
59 entity->findChild<Qt3DRender::QGeometryRenderer *>()->setObjectName( QStringLiteral(
"main" ) );
60 entity->addComponent( mat );
61 entity->addComponent( tform );
62 entity->setParent(
this );
65 Qt3DRender::QMaterial *QgsMesh3DSymbolEntity::material(
const QgsMesh3DSymbol &symbol )
const
68 Qt3DRender::QMaterial *material = symbol.
material()->
toMaterial( QgsMaterialSettingsRenderingTechnique::Triangles, context );
71 auto techniques = material->effect()->techniques();
72 for (
auto tit = techniques.constBegin(); tit != techniques.constEnd(); ++tit )
74 auto renderPasses = ( *tit )->renderPasses();
75 for (
auto rpit = renderPasses.begin(); rpit != renderPasses.end(); ++rpit )
77 Qt3DRender::QCullFace *cullFace =
new Qt3DRender::QCullFace;
78 cullFace->setMode( Qt3DRender::QCullFace::Back );
79 ( *rpit )->addRenderState( cullFace );
85 QgsMesh3DSymbolEntityNode::QgsMesh3DSymbolEntityNode(
const Qgs3DMapSettings &map,
88 Qt3DCore::QNode *parent ) :
Qt3DCore::QEntity( parent )
90 addComponent( renderer( map, symbol, layer ) );
93 Qt3DRender::QGeometryRenderer *QgsMesh3DSymbolEntityNode::renderer(
const Qgs3DMapSettings &map,
98 QList<QgsPolygon *> polygons;
99 QList<QgsFeatureId> fids;
104 float height = symbol.
height();
109 static_cast<double>( height )
117 const QVector<QgsMeshFace> &triangles = mesh->
triangles();
118 const QVector<QgsMeshVertex> &vertices = mesh->
vertices();
119 for (
int i = 0; i < triangles.size(); ++i )
122 Q_ASSERT( triangle.size() == 3 );
126 Qgs3DTypes::AltitudeBinding::AltBindVertex,
129 polygons.append( polygon.release() );
141 QList<float> extrusionHeightPerPolygon;
142 mGeometry->setPolygons( polygons, fids, origin, 0.0, extrusionHeightPerPolygon );
144 Qt3DRender::QGeometryRenderer *renderer =
new Qt3DRender::QGeometryRenderer;
145 renderer->setGeometry( mGeometry );