| 
    QGIS API Documentation
    3.26.3-Buenos Aires (65e4edfdad)
    
   | 
 
 
 
 
Go to the documentation of this file.
   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 
   71   const 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 );
 
  129       polygons.append( polygon.release() );
 
  141   const QList<float> extrusionHeightPerPolygon;
 
  142   mGeometry->setPolygons( polygons, fids, origin, 0.0, extrusionHeightPerPolygon );
 
  144   Qt3DRender::QGeometryRenderer *renderer = 
new Qt3DRender::QGeometryRenderer;
 
  145   renderer->setGeometry( mGeometry );
 
  
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
 
@ Vertex
Clamp every vertex of feature.
 
double valueAsDouble(int key, const QgsExpressionContext &context, double defaultValue=0.0, bool *ok=nullptr) const
Calculates the current value of the property with the specified key and interprets it as a double.
 
const QVector< QgsMeshVertex > & vertices() const
Returns vertices in map coordinate system.
 
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context.
 
double y() const
Returns Y coordinate.
 
static QgsProject * instance()
Returns the QgsProject singleton instance.
 
const QVector< QgsMeshFace > & triangles() const
Returns triangles.
 
3D symbol that draws mesh geometry as planar triangles.
 
float height() const
Returns height (altitude) of the symbol (in map units)
 
@ PropertyHeight
Height (altitude)
 
QgsAbstractMaterialSettings * material() const
Returns material used for shading of the symbol.
 
QgsTriangularMesh * triangularMesh(double minimumTriangleSize=0) const
Returns triangular mesh (nullptr before rendering or calling to updateMesh).
 
bool addBackFaces() const
Returns whether also triangles facing the other side will be created.
 
Context settings for a material.
 
static QgsExpressionContextScope * projectScope(const QgsProject *project)
Creates a new scope which contains variables and functions relating to a QGIS project.
 
CORE_EXPORT std::unique_ptr< QgsPolygon > toPolygon(const QgsMeshFace &face, const QVector< QgsMeshVertex > &vertices)
Returns face as polygon geometry, caller is responsible for delete.
 
Represents a mesh layer supporting display of data on structured or unstructured meshes.
 
@ Triangles
Triangle based rendering (default)
 
QgsVector3D origin() const
Returns coordinates in map CRS at which 3D scene has origin (0,0,0)
 
QVector< int > QgsMeshFace
List of vertex indexes.
 
A class to represent a 2D point.
 
A phong shading model with diffuse texture map.
 
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
 
virtual Qt3DRender::QMaterial * toMaterial(QgsMaterialSettingsRenderingTechnique technique, const QgsMaterialContext &context) const =0
Creates a new QMaterial object representing the material settings.
 
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the symbol layer's property collection, used for data defined overrides.
 
static void clampAltitudes(QgsLineString *lineString, Qgis::AltitudeClamping altClamp, Qgis::AltitudeBinding altBind, const QgsPoint ¢roid, float height, const Qgs3DMapSettings &map)
Clamps altitude of vertices of a linestring according to the settings.
 
Triangular/Derived Mesh is mesh with vertices in map coordinates.
 
bool isActive(int key) const override
Returns true if the collection contains an active property with the specified key.
 
double x() const
Returns X coordinate.
 
Qgis::AltitudeClamping altitudeClamping() const
Returns method that determines altitude (whether to clamp to feature to terrain)
 
Class derived from Qt3DRender::QGeometry that represents polygons tessellated into 3D geometry.
 
bool requiresTextureCoordinates() const
Returns true if the material requires texture coordinates to be generated during triangulation....