18 #include <Qt3DCore/QEntity>
38 std::unique_ptr< QgsPolygon3DSymbol > result = std::make_unique< QgsPolygon3DSymbol >();
39 result->mAltClamping = mAltClamping;
40 result->mAltBinding = mAltBinding;
41 result->mHeight = mHeight;
42 result->mExtrusionHeight = mExtrusionHeight;
43 result->mMaterial.reset( mMaterial->clone() );
44 result->mCullingMode = mCullingMode;
45 result->mInvertNormals = mInvertNormals;
46 result->mAddBackFaces = mAddBackFaces;
47 result->mRenderedFacade = mRenderedFacade;
48 result->mEdgesEnabled = mEdgesEnabled;
49 result->mEdgeWidth = mEdgeWidth;
50 result->mEdgeColor = mEdgeColor;
51 copyBaseSettings( result.get() );
52 return result.release();
59 QDomDocument doc = elem.ownerDocument();
61 QDomElement elemDataProperties = doc.createElement( QStringLiteral(
"data" ) );
64 elemDataProperties.setAttribute( QStringLiteral(
"height" ), mHeight );
65 elemDataProperties.setAttribute( QStringLiteral(
"extrusion-height" ), mExtrusionHeight );
67 elemDataProperties.setAttribute( QStringLiteral(
"invert-normals" ), mInvertNormals ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
68 elemDataProperties.setAttribute( QStringLiteral(
"add-back-faces" ), mAddBackFaces ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
69 elemDataProperties.setAttribute( QStringLiteral(
"rendered-facade" ), mRenderedFacade );
70 elem.appendChild( elemDataProperties );
72 elem.setAttribute( QStringLiteral(
"material_type" ), mMaterial->type() );
73 QDomElement elemMaterial = doc.createElement( QStringLiteral(
"material" ) );
74 mMaterial->writeXml( elemMaterial, context );
75 elem.appendChild( elemMaterial );
77 QDomElement elemDDP = doc.createElement( QStringLiteral(
"data-defined-properties" ) );
78 mDataDefinedProperties.writeXml( elemDDP, propertyDefinitions() );
79 elem.appendChild( elemDDP );
81 QDomElement elemEdges = doc.createElement( QStringLiteral(
"edges" ) );
82 elemEdges.setAttribute( QStringLiteral(
"enabled" ), mEdgesEnabled ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
83 elemEdges.setAttribute( QStringLiteral(
"width" ), mEdgeWidth );
85 elem.appendChild( elemEdges );
92 const QDomElement elemDataProperties = elem.firstChildElement( QStringLiteral(
"data" ) );
95 mHeight = elemDataProperties.attribute( QStringLiteral(
"height" ) ).toFloat();
96 mExtrusionHeight = elemDataProperties.attribute( QStringLiteral(
"extrusion-height" ) ).toFloat();
98 mInvertNormals = elemDataProperties.attribute( QStringLiteral(
"invert-normals" ) ).toInt();
99 mAddBackFaces = elemDataProperties.attribute( QStringLiteral(
"add-back-faces" ) ).toInt();
100 mRenderedFacade = elemDataProperties.attribute( QStringLiteral(
"rendered-facade" ),
"3" ).toInt();
102 const QDomElement elemMaterial = elem.firstChildElement( QStringLiteral(
"material" ) );
103 const QString materialType = elem.attribute( QStringLiteral(
"material_type" ), QStringLiteral(
"phong" ) );
107 mMaterial->readXml( elemMaterial, context );
109 const QDomElement elemDDP = elem.firstChildElement( QStringLiteral(
"data-defined-properties" ) );
110 if ( !elemDDP.isNull() )
111 mDataDefinedProperties.readXml( elemDDP, propertyDefinitions() );
113 const QDomElement elemEdges = elem.firstChildElement( QStringLiteral(
"edges" ) );
114 if ( !elemEdges.isNull() )
116 mEdgesEnabled = elemEdges.attribute( QStringLiteral(
"enabled" ) ).toInt();
117 mEdgeWidth = elemEdges.attribute( QStringLiteral(
"width" ) ).toFloat();
132 mAltBinding = props->
binding();
140 mDataDefinedProperties.setProperty( PropertyExtrusionHeight,
QgsProperty() );
148 mDataDefinedProperties.setProperty( PropertyHeight,
QgsProperty() );
150 mHeight =
static_cast< float >( props->
zOffset() );
160 return mMaterial.get();
173 const QList<Qt3DRender::QGeometryRenderer *> renderers = entity->findChildren<Qt3DRender::QGeometryRenderer *>();
174 for ( Qt3DRender::QGeometryRenderer *r : renderers )
176 Qgs3DExportObject *
object = exporter->processGeometryRenderer( r, objectNamePrefix );
177 if (
object ==
nullptr )
continue;
178 exporter->processEntityMaterial( entity,
object );
179 exporter->mObjects.push_back(
object );
181 return renderers.size() != 0;