18 #include <Qt3DCore/QEntity>
36 std::unique_ptr< QgsPolygon3DSymbol > result = qgis::make_unique< QgsPolygon3DSymbol >();
37 result->mAltClamping = mAltClamping;
38 result->mAltBinding = mAltBinding;
39 result->mHeight = mHeight;
40 result->mExtrusionHeight = mExtrusionHeight;
41 result->mMaterial.reset( mMaterial->clone() );
42 result->mCullingMode = mCullingMode;
43 result->mInvertNormals = mInvertNormals;
44 result->mAddBackFaces = mAddBackFaces;
45 result->mRenderedFacade = mRenderedFacade;
46 result->mEdgesEnabled = mEdgesEnabled;
47 result->mEdgeWidth = mEdgeWidth;
48 result->mEdgeColor = mEdgeColor;
49 copyBaseSettings( result.get() );
50 return result.release();
57 QDomDocument doc = elem.ownerDocument();
59 QDomElement elemDataProperties = doc.createElement( QStringLiteral(
"data" ) );
62 elemDataProperties.setAttribute( QStringLiteral(
"height" ), mHeight );
63 elemDataProperties.setAttribute( QStringLiteral(
"extrusion-height" ), mExtrusionHeight );
65 elemDataProperties.setAttribute( QStringLiteral(
"invert-normals" ), mInvertNormals ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
66 elemDataProperties.setAttribute( QStringLiteral(
"add-back-faces" ), mAddBackFaces ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
67 elemDataProperties.setAttribute( QStringLiteral(
"rendered-facade" ), mRenderedFacade );
68 elem.appendChild( elemDataProperties );
70 elem.setAttribute( QStringLiteral(
"material_type" ), mMaterial->type() );
71 QDomElement elemMaterial = doc.createElement( QStringLiteral(
"material" ) );
72 mMaterial->writeXml( elemMaterial, context );
73 elem.appendChild( elemMaterial );
75 QDomElement elemDDP = doc.createElement( QStringLiteral(
"data-defined-properties" ) );
76 mDataDefinedProperties.writeXml( elemDDP, propertyDefinitions() );
77 elem.appendChild( elemDDP );
79 QDomElement elemEdges = doc.createElement( QStringLiteral(
"edges" ) );
80 elemEdges.setAttribute( QStringLiteral(
"enabled" ), mEdgesEnabled ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
81 elemEdges.setAttribute( QStringLiteral(
"width" ), mEdgeWidth );
83 elem.appendChild( elemEdges );
90 QDomElement elemDataProperties = elem.firstChildElement( QStringLiteral(
"data" ) );
93 mHeight = elemDataProperties.attribute( QStringLiteral(
"height" ) ).toFloat();
94 mExtrusionHeight = elemDataProperties.attribute( QStringLiteral(
"extrusion-height" ) ).toFloat();
96 mInvertNormals = elemDataProperties.attribute( QStringLiteral(
"invert-normals" ) ).toInt();
97 mAddBackFaces = elemDataProperties.attribute( QStringLiteral(
"add-back-faces" ) ).toInt();
98 mRenderedFacade = elemDataProperties.attribute( QStringLiteral(
"rendered-facade" ),
"3" ).toInt();
100 const QDomElement elemMaterial = elem.firstChildElement( QStringLiteral(
"material" ) );
101 const QString materialType = elem.attribute( QStringLiteral(
"material_type" ), QStringLiteral(
"phong" ) );
105 mMaterial->readXml( elemMaterial, context );
107 QDomElement elemDDP = elem.firstChildElement( QStringLiteral(
"data-defined-properties" ) );
108 if ( !elemDDP.isNull() )
109 mDataDefinedProperties.readXml( elemDDP, propertyDefinitions() );
111 QDomElement elemEdges = elem.firstChildElement( QStringLiteral(
"edges" ) );
112 if ( !elemEdges.isNull() )
114 mEdgesEnabled = elemEdges.attribute( QStringLiteral(
"enabled" ) ).toInt();
115 mEdgeWidth = elemEdges.attribute( QStringLiteral(
"width" ) ).toFloat();
132 return mMaterial.get();
145 QList<Qt3DRender::QGeometryRenderer *> renderers = entity->findChildren<Qt3DRender::QGeometryRenderer *>();
146 for ( Qt3DRender::QGeometryRenderer *r : renderers )
148 Qgs3DExportObject *
object = exporter->processGeometryRenderer( r, objectNamePrefix );
149 if (
object ==
nullptr )
continue;
150 exporter->processEntityMaterial( entity,
object );
151 exporter->mObjects.push_back(
object );
153 return renderers.size() != 0;