AE学习笔记(三)——ArcScene下设置图层BaseHeight
public partial class MainForm : Form
{
public I3DProperties Get3DPropsFromLayer(ILayer pLyr)
{
ILayerExtensions pLyrExts = (ILayerExtensions)pLyr;
I3DProperties p3DProp = null;
for (int i = 0; i < pLyrExts.ExtensionCount; i++)
if (pLyrExts.get_Extension(i) is I3DProperties)
p3DProp = (I3DProperties)pLyrExts.get_Extension(i);
return p3DProp;
}
public void SetlayerSurface()
{
ISceneGraph scenegraph = this.axSceneControl1.SceneGraph;
IScene scene = scenegraph.Scene;
ILayer layer;
layer = scene.get_Layer(0);
IRasterLayer rlayer;
rlayer = layer as IRasterLayer;
IRaster raster;
IRasterSurface rsurface = new RasterSurface();
ISurface surface;
raster = (IRaster)rlayer.Raster;
IRasterBandCollection rasterbands = raster as IRasterBandCollection;
IRasterBand rasterband = rasterbands.Item(0);
rsurface.RasterBand = rasterband;
surface = rsurface as ISurface;
ILayerExtensions layerextensions = layer as ILayerExtensions;
I3DProperties properties = new Raster3DPropertiesClass();
int i;
object p3d;
for (i = 0; i < layerextensions.ExtensionCount; i++)
{
p3d = layerextensions.get_Extension(i);
if (p3d != null)
{
properties = (I3DProperties)p3d;
break;
}
}
properties.BaseOption = esriBaseOption.esriBaseSurface;
properties.BaseSurface = surface;
properties.Apply3DProperties(layer);
properties.ZFactor = 20;
scenegraph = scene.SceneGraph;
scenegraph.RefreshViewers();
}
}