47 : mAltClamping( other.altitudeClamping() )
48 , mMaterial( other.material() ? other.material()->clone() : nullptr )
49 , mShape( other.shape() )
50 , mShapeProperties( other.shapeProperties() )
51 , mTransform( other.transform() )
52 , mBillboardSymbol( other.billboardSymbol() ? other.billboardSymbol()->clone() : nullptr )
54 setDataDefinedProperties( other.dataDefinedProperties() );
61 QDomDocument doc = elem.ownerDocument();
63 QDomElement elemDataProperties = doc.createElement( QStringLiteral(
"data" ) );
65 elem.appendChild( elemDataProperties );
67 elem.setAttribute( QStringLiteral(
"material_type" ), mMaterial->type() );
68 QDomElement elemMaterial = doc.createElement( QStringLiteral(
"material" ) );
69 mMaterial->writeXml( elemMaterial, context );
70 elem.appendChild( elemMaterial );
72 elem.setAttribute( QStringLiteral(
"shape" ),
shapeToString( mShape ) );
74 QVariantMap shapePropertiesCopy( mShapeProperties );
75 shapePropertiesCopy[QStringLiteral(
"model" )] = QVariant( context.
pathResolver().
writePath( shapePropertiesCopy[QStringLiteral(
"model" )].toString() ) );
77 QDomElement elemShapeProperties = doc.createElement( QStringLiteral(
"shape-properties" ) );
79 elem.appendChild( elemShapeProperties );
81 QDomElement elemTransform = doc.createElement( QStringLiteral(
"transform" ) );
83 elem.appendChild( elemTransform );
89 elem.appendChild( symbolElem );
95 const QDomElement elemDataProperties = elem.firstChildElement( QStringLiteral(
"data" ) );
98 const QDomElement elemMaterial = elem.firstChildElement( QStringLiteral(
"material" ) );
99 const QString materialType = elem.attribute( QStringLiteral(
"material_type" ), QStringLiteral(
"phong" ) );
103 mMaterial->readXml( elemMaterial, context );
105 mShape =
shapeFromString( elem.attribute( QStringLiteral(
"shape" ) ) );
107 const QDomElement elemShapeProperties = elem.firstChildElement( QStringLiteral(
"shape-properties" ) );
109 mShapeProperties[QStringLiteral(
"model" )] = QVariant( context.
pathResolver().
readPath( mShapeProperties[QStringLiteral(
"model" )].toString() ) );
111 const QDomElement elemTransform = elem.firstChildElement( QStringLiteral(
"transform" ) );
114 const QDomElement symbolElem = elem.firstChildElement( QStringLiteral(
"symbol" ) );
116 setBillboardSymbol( QgsSymbolLayerUtils::loadSymbol< QgsMarkerSymbol >( symbolElem, context ) );
129 mTransform.data()[13] =
static_cast< float >( props->
zOffset() );
135 if (
shape == QStringLiteral(
"sphere" ) )
137 else if (
shape == QLatin1String(
"cone" ) )
139 else if (
shape == QLatin1String(
"cube" ) )
141 else if (
shape == QLatin1String(
"torus" ) )
143 else if (
shape == QLatin1String(
"plane" ) )
145 else if (
shape == QLatin1String(
"extruded-text" ) )
147 else if (
shape == QLatin1String(
"model" ) )
149 else if (
shape == QLatin1String(
"billboard" ) )
159 case Cylinder:
return QStringLiteral(
"cylinder" );
160 case Sphere:
return QStringLiteral(
"sphere" );
161 case Cone:
return QStringLiteral(
"cone" );
162 case Cube:
return QStringLiteral(
"cube" );
163 case Torus:
return QStringLiteral(
"torus" );
164 case Plane:
return QStringLiteral(
"plane" );
165 case ExtrudedText:
return QStringLiteral(
"extruded-text" );
166 case Model:
return QStringLiteral(
"model" );
167 case Billboard:
return QStringLiteral(
"billboard" );
168 default: Q_ASSERT(
false );
return QString();
174 QMatrix4x4 billboardTransformMatrix;
175 billboardTransformMatrix.translate( QVector3D( 0, mTransform.data()[13], 0 ) );
177 return billboardTransformMatrix;
182 return mMaterial.get();
197 Qt3DRender::QSceneLoader *sceneLoader = entity->findChild<Qt3DRender::QSceneLoader *>();
198 if ( sceneLoader !=
nullptr )
200 const QVector<Qgs3DExportObject *> objects = exporter->processSceneLoaderGeometries( sceneLoader, objectNamePrefix );
206 exporter->mObjects << objects;
210 const QList<Qt3DRender::QMesh *> meshes = entity->findChildren<Qt3DRender::QMesh *>();
211 for ( Qt3DRender::QMesh *mesh : meshes )
213 Qgs3DExportObject *
object = exporter->processGeometryRenderer( mesh, objectNamePrefix );
214 if (
object ==
nullptr )
continue;
216 object->setupMaterial(
material() );
217 exporter->mObjects << object;
225 if ( obj !=
nullptr )
227 exporter->mObjects << obj;
233 const QVector<Qgs3DExportObject *> objects = exporter->processInstancedPointGeometry( entity, objectNamePrefix );
237 exporter->mObjects << obj;
246 return mBillboardSymbol.get();
251 mBillboardSymbol.reset( symbol );