I like to create a cube on a graphicsOverlay in a sceneView (3D) - but without success.
I just can see the plane area drapped on the surface.
I don´t use QML but widget based approach.
What i did:
Create a scene, sceneView connect them and so...
d->m_graphicsLayer->setSceneProperties(Esri::ArcGISRuntime::LayerSceneProperties(Esri::ArcGISRuntime::SurfacePlacement::Draped)); const Esri::ArcGISRuntime::SpatialReference &sr = d->m_mapImpl->getEsriSpatialReference(); // create 4 point for rectangle const Esri::ArcGISRuntime::Viewpoint &vp = d->m_mapGeoView->currentViewpoint(Esri::ArcGISRuntime::ViewpointType::CenterAndScale); const Esri::ArcGISRuntime::Point &mapCenter = static_cast<Esri::ArcGISRuntime::Point>(vp.targetGeometry()); ... SituationMap::PositionCont posContTrans = ...; Esri::ArcGISRuntime::PolygonBuilder builder(sr, this); int z = 1000; builder.addPoint(Esri::ArcGISRuntime::Point(posContTrans[0].x(), posContTrans[0].y(), z, sr)); builder.addPoint(Esri::ArcGISRuntime::Point(posContTrans[1].x(), posContTrans[1].y(), z, sr)); builder.addPoint(Esri::ArcGISRuntime::Point(posContTrans[2].x(), posContTrans[2].y(), z, sr)); builder.addPoint(Esri::ArcGISRuntime::Point(posContTrans[3].x(), posContTrans[3].y(), z, sr)); qCritical() << " posContTrans=" << posContTrans[0]; qCritical() << " posContTrans=" << posContTrans[1]; qCritical() << " posContTrans=" << posContTrans[2]; qCritical() << " posContTrans=" << posContTrans[3]; Esri::ArcGISRuntime::SimpleFillSymbol* sls = new Esri::ArcGISRuntime::SimpleFillSymbol(Esri::ArcGISRuntime::SimpleFillSymbolStyle::Solid, Qt::red, this); Esri::ArcGISRuntime::SimpleRenderer *renderer = new Esri::ArcGISRuntime::SimpleRenderer(sls, this); Esri::ArcGISRuntime::RendererSceneProperties props = renderer->sceneProperties(); props.setExtrusionMode(Esri::ArcGISRuntime::ExtrusionMode::BaseHeight); props.setExtrusionExpression(QLatin1String("height")); renderer->setSceneProperties(props); d->m_graphicsLayer->setRenderer(renderer); Esri::ArcGISRuntime::Graphic *graphic = new Esri::ArcGISRuntime::Graphic( Esri::ArcGISRuntime::Polygon(builder.toGeometry())Create , this); QVariantMap att = graphic->attributes()->attributesMap(); att[QLatin1String("height")] = 1000000; d->m_graphicsLayer->graphics()->append(graphic);
I tried the RenderingMode::Static and also Dynamic.. No height is visible.
What is missing?
Can someone help me?
Thx
Norbert
Solved! Go to Solution.
Hi Luke!
My mistake:
I assumed that i have to apply a QString to the attributeMap. So i wrote:
QString heightStr = QString(QLatin1Literal("%1")).arg(m_height.value());
heightStr.replace(QLatin1Char(','), QLatin1Char('.')); // required???
att[QLatin1String("height")] = heightStr;
But motivated by your comment i re-thought what i was doing and simplify it to:
QVariantMap att = m_graphic->attributes()->attributesMap();
att[QLatin1String("height")] = QVariant(m_height.value());
Or even smaller:
m_graphic->attributes()->insertAttribute(QLatin1String("height"), QVariant(m_height.value()));
Thanks a lot!
That's great Norbert - I'm glad its working now