Graphics overlay renderer

2543
17
02-23-2017 10:53 AM
KirstenStrandjord
New Contributor III

I am interested in drawing several lines using the SimpleLineSymbol. I have run into two problems. First, in the graphics scene (3D) the lines appear and disappear behind the 3D terrain when viewed from different camera angles. Even though there is no terrain obstructing the line (no terrain between camera and graphic) the lines still appear to render in incorrect order (behind terrain). Is there a setting I need to set for this to work (e.g. a depth test). My second problem is that I want each one the lines to be a different color. Does that mean I will need a new GraphicsOverlay for each line? For example, this is how I am currently setting my renderer.

SimpleLineSymbol* sls = new SimpleLineSymbol(SimpleLineSymbolStyle::Solid, lineColor, 3, thisF);

lineGraphicOverlay->setRenderer(new mn::SimpleRenderer(sls, thisF));

This makes each line the same color. Is there a way to set each line as a different color while only having one GraphicsOverlay?
Thanks for the help! 

					
				
			
			
				
			
			
				
			
			
			
			
			
			
		
17 Replies
KirstenStrandjord
New Contributor III

Yes, I do have elevation. I need the elevation mapped. I also need lines that point to the sky that don't disappear at different viewing angle. I think it might have to do with the way things are rendered. Here is a code snippet:

void addLineOfSightToMapFunc(Point myLocation, Point skyLocation,Esri::ArcGISRuntime::SceneGraphicsView* m_sceneView, QColor lineColor,mn::GraphicsOverlay* lineGraphicOverlay, MapRay *thisF )

{

// create a graphics overlay for the lines

lineGraphicOverlay->setRenderingMode(mn::GraphicsRenderingMode::Dynamic);

lineGraphicOverlay->setSceneProperties(mn::LayerSceneProperties(mn::SurfacePlacement::Absolute));

// add the overlay to the mapview

m_sceneView->graphicsOverlays()->append(lineGraphicOverlay);

// create line geometry

mn::PolygonBuilder polylineBuilder(m_sceneView->spatialReference());

// build the polyline

polylineBuilder.addPoint(myLocation);

polylineBuilder.addPoint(skyLocation);

// tells renderer what type of symbol to use.

mn::SimpleLineSymbol* sls = new mn::SimpleLineSymbol(mn::SimpleLineSymbolStyle::Solid, lineColor, 5, thisF);

// creates graphic from the polylineBuilder

mn::Graphic* lineGraphic = new mn::Graphic(polylineBuilder.toGeometry(), thisF);

// set the renderer of the graphic overlay to be the line symbol

lineGraphicOverlay->setRenderer(new mn::SimpleRenderer(sls, thisF));

// add the graphic to the overlay

lineGraphicOverlay->graphics()->append(lineGraphic);

}

0 Kudos
NorbertThoden
Occasional Contributor III

Hi
In the Known Issues i can read:

3D

  • Graphics overlays in scene views
    • Graphics overlays drawn in static mode do not render correctly. Use graphics overlays in dynamic mode.

Bases on that ou haved choosen the 'correct' RenderingMode...

I have to use the Advanced Symbology and therefore the static mode...

0 Kudos
KirstenStrandjord
New Contributor III

Hi Norbert. Thanks for the info. However, I don't want my lines to be draped. I want them pointing to the sky. 

0 Kudos
NorbertThoden
Occasional Contributor III

Hi Kirsten!

Sorry for the delay, i was busy on the SDK...

But now, i was able to spent some minutes on your problem:

That is the code i used:

d->m_graphicsLayer->setSceneProperties(Esri::ArcGISRuntime::LayerSceneProperties(Esri::ArcGISRuntime::SurfacePlacement::Absolute));

    const Esri::ArcGISRuntime::SpatialReference &sr = d->m_mapImpl->getEsriSpatialReference();

    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());

    Esri::ArcGISRuntime::Point myLocation  = Esri::ArcGISRuntime::Point(mapCenter.x(), mapCenter.y(), 10000, sr);
    Esri::ArcGISRuntime::Point skyLocation = Esri::ArcGISRuntime::Point(mapCenter.x(), mapCenter.y(), 99999, sr);

    qCritical() << " myLocation=" << myLocation << " z=" << myLocation.z();;
    qCritical() << " skyLocation=" << skyLocation << " z=" << skyLocation.z();

    Esri::ArcGISRuntime::PolygonBuilder polylineBuilder(sr, this);
    polylineBuilder.addPoint(myLocation);
    polylineBuilder.addPoint(skyLocation);

    Esri::ArcGISRuntime::SimpleLineSymbol* sls =
        new Esri::ArcGISRuntime::SimpleLineSymbol(Esri::ArcGISRuntime::SimpleLineSymbolStyle::Solid, Qt::red, 5, this);

    Esri::ArcGISRuntime::Graphic *lineGraphic = new Esri::ArcGISRuntime::Graphic(polylineBuilder.toGeometry(), this);

//#define USE_RENDERER
#ifdef USE_RENDERER
    qCritical() << " USE RENDERER";
    d->m_graphicsLayer->setRenderer(new Esri::ArcGISRuntime::SimpleRenderer(sls, this));
#else
    qCritical() << " USE no RENDERER";
    lineGraphic->setSymbol(sls);
#endif // USE_RENDERER

   d->m_graphicsLayer->graphics()->append(lineGraphic);

Independent os using the renderer or not (see #define) did not have any 'mssing' parts...

Maybe i use uncritical values to adress your problem?

Be aware: I use the RenderingMode::Dynamic and no elevation yet...

0 Kudos
LucasDanzinger
Esri Frequent Contributor

Is it possible that your lines are going through the surface of the elevation and are rendering below the basemap?

0 Kudos
KirstenStrandjord
New Contributor III

The lines should not be going through the elevation surface. The lines point to the sky and should not be passing through the surface. When you move the view around, the lines appear and disappear. You can see this in the picture I posted above.

0 Kudos
KirstenStrandjord
New Contributor III

Hi Lucas,

Thanks again for the help. I still have not been able to get the lines to render properly. Just to reiterate, the lines do not pass through the terrain. That is, they physically are defined to start and end in locations where the line will not pass through any terrain (3D elevation map). However, the lines have segments that do not render depending on the viewing angle. Do you have any other advice to figure out the issues I'm seeing?

Thanks!

0 Kudos
LucasDanzinger
Esri Frequent Contributor

Kirsten-

I'm not sure what the issue is from looking at the screenshots and code snippet. The best thing to do would be to upload a simplified project that can reproduce the issue.

- Lucas

0 Kudos