SceneControl中如何设置矢量图层按DEM起伏显示?

ArcScene中若将矢量图层按DEM起伏显示,可以设置矢量图层右键->Layer Properties->Base Heights->Floating on a custom surface 选则该DEM,Engine中如何实现该功能?
已邀请:

朱新颖

赞同来自:

【解决办法】:
Engine中首先要获取该矢量图层的I3DProperties接口,然后设置I3DProperties.BaseOption为esriBaseSurface,并且I3DProperties.BaseSurface指定为该DEM即可,参考代码:


ISceneGraph scenegraph = axSceneControl1.SceneGraph;
             IScene scene = scenegraph.Scene;
             ILayer layer = scene.get_Layer(0);
             IRasterLayer rasterLayer = scene.get_Layer(1) as IRasterLayer;
             IRaster raster = (IRaster)rasterLayer.Raster;

             IRasterBandCollection rasterbands = raster as IRasterBandCollection;
             IRasterBand rasterband = rasterbands.Item(0);

             IRasterSurface rasterSurface = new RasterSurface();
             rasterSurface.RasterBand = rasterband;          

             I3DProperties p3DProps = Get3DPropsFromLayer(layer) as I3DProperties;
             if (p3DProps != null)
             {
                                
                 p3DProps.BaseOption = esriBaseOption.esriBaseSurface;
                 p3DProps.BaseSurface = rasterSurface as IFunctionalSurface;
                 p3DProps.ZFactor = 2;
                 p3DProps.Apply3DProperties(layer);
                 axSceneControl1.SceneGraph.RefreshViewers();
             }

public I3DProperties Get3DPropsFromLayer(ILayer pLayer)
{
I3DProperties p3DProps = null;
try
{
ILayerExtensions pExt = pLayer as ILayerExtensions;

for (int i = 0; i < pExt.ExtensionCount; i++)
{
if (pExt.get_Extension(i) is I3DProperties)
{
p3DProps = (I3DProperties)pExt.get_Extension(i);
}

}
if (p3DProps == null) Trace.WriteLine(未能获取图层的I3DProperties接口。);
return p3DProps;
}
catch (Exception ex)
{
Trace.WriteLine(获取图层的I3DProperties接口时发生异常 + ex.ToString());
return null;
}
}

要回复问题请先登录注册