hello everybody,
i'm trying to make a windows application using arcgis engine in .Net environment.
the program have a 2d map control (main view) and 3d globe control (helper view),
user can add graphics to the 2d map then view the scene in 3d view.
during the transmission to 3d view, i'm looping through the elements in the 2d graphics container, and add every element to a new globeGraphicsLayer
then drape this layer in globe control
ESRI.ArcGIS.GlobeCore.IGlobe globe = axGlobeControl1.Globe;
if (layer is IGraphicsLayer) // "layer" is the graphics layer in the 2d map
{
ESRI.ArcGIS.GlobeCore.IGlobeGraphicsLayer globeGraphicsLayer = null;
globeGraphicsLayer = new ESRI.ArcGIS.GlobeCore.GlobeGraphicsLayerClass();
((ILayer)globeGraphicsLayer).Name = "GraphicsObjects";
((ILayer)globeGraphicsLayer).SpatialReference = ((ESRI.ArcGIS.Analyst3D.IScene)globe).SpatialReference;
IGraphicsContainer graphicsContainer = layer as IGraphicsContainer;
IElement currentElement = null;
graphicsContainer.Reset();
currentElement = graphicsContainer.Next();
int i = 0;
while (currentElement != null)
{
AddGraphicsLayerToGlobe(globeGraphicsLayer, currentElement);
currentElement = graphicsContainer.Next();
i++;
}
if (i > 0)
{
// tis line does not work what expected
globe.AddLayerType((ILayer)globeGraphicsLayer, ESRI.ArcGIS.GlobeCore.esriGlobeLayerType.esriGlobeLayerTypeDraped, false);
}
}
private void AddGraphicsLayerToGlobe(ESRI.ArcGIS.GlobeCore.IGlobeGraphicsLayer globeGraphicsLayer, IElement element)
{
ESRI.ArcGIS.GlobeCore.IGlobe globe = axGlobeControl1.Globe;
if (element.Geometry.GeometryType == esriGeometryType.esriGeometryLine ||
element.Geometry.GeometryType == esriGeometryType.esriGeometryPolyline
)
{
ILineElement elementObject = element as ILineElement;
// Add a line graphics element to the graphics layer
ESRI.ArcGIS.Carto.IElement lineElement = new ESRI.ArcGIS.Carto.LineElementClass();
ESRI.ArcGIS.Analyst3D.ISimpleLine3DSymbol simpleLineSymbol3D = new ESRI.ArcGIS.Analyst3D.SimpleLine3DSymbolClass();
simpleLineSymbol3D.Style = ESRI.ArcGIS.Analyst3D.esriSimple3DLineStyle.esriS3DLSStrip;
// Set symbol color and size
ESRI.ArcGIS.Display.IColor rgbColor = new ESRI.ArcGIS.Display.RgbColorClass();
simpleLineSymbol3D.ResolutionQuality = 1;
rgbColor.RGB = elementObject.Symbol.Color.RGB;
ESRI.ArcGIS.Display.ILineSymbol lineSymbol = (ESRI.ArcGIS.Display.ILineSymbol)simpleLineSymbol3D; //Explicit cast
lineSymbol.Color = rgbColor;
lineSymbol.Width = elementObject.Symbol.Width;
// Set the geometry
ESRI.ArcGIS.Geometry.IPolyline polyline = new ESRI.ArcGIS.Geometry.PolylineClass();
IPointCollection srcPointCollection = ((IPolyline)element.Geometry) as IPointCollection;
IPointCollection dstPointCollection = polyline as IPointCollection;
int count = srcPointCollection.PointCount;
for (int i = 0 ; i < count ; i++)
{
IPoint point = srcPointCollection.get_Point(i);
object missing = Type.Missing;
dstPointCollection.AddPoint(point, ref missing, ref missing);
}
lineElement.Geometry = polyline;
// Add to the graphics layer
ESRI.ArcGIS.Carto.ILineElement lineElement_2 = (ESRI.ArcGIS.Carto.ILineElement)lineElement; // Explicit cast
lineElement_2.Symbol = lineSymbol;
ESRI.ArcGIS.GlobeCore.IGlobeGraphicsElementProperties props = new ESRI.ArcGIS.GlobeCore.GlobeGraphicsElementProperties();
props.Rasterize = true;
props.DrapeElement = false;
int x;
globeGraphicsLayer.AddElement(lineElement, props, out x);
}
else if (element.Geometry.GeometryType == esriGeometryType.esriGeometryPoint)
{
/// eqevelant code
}
}
i can add data to the globe control, but draping graphics layer on terrain does not work, the elements (lines and polygons) appear flat not draped.
any help please 😞