首页 > 代码库 > ArcEngine下SceneControl叠加影像数据(构建三维地形)

ArcEngine下SceneControl叠加影像数据(构建三维地形)

加载完TIN数据后,需要在三维物体上描绘细节,即纹理;建立DEM表面点与纹理空间点的关系,即纹理映射。叠加影像数据就是把影像看作纹理,将其贴在地形表面,让其具有地形起伏的三维效果。

这里与GlobeControl下三维场景的构建有所不同,在前面的博文中我们提到过,globe下图层主要有三种类型:Floating、Draped、Elevation(浮动、叠加和高程图层),即只需要设置图层的属性即可,叠加图层与浮动图层从高程图层获取高程值。SceneControl中实现影像的叠加,参照ArcScene中的操作:“右键”——>“属性”——>“基本高度”——>“从表面获取的高程”,设置为浮动在自定义表面。


这里主要使用I3DProperties接口,代码如下:

                ISceneGraph pSceneGraph = axSceneControl1.SceneGraph;
                IScene pScene = pSceneGraph.Scene;
                ITinLayer pTinLayer = null;
                IRasterLayer pRasterlayer = null;
                //获取TIN、DOM
                for (int i = 0;i < pScene.LayerCount;i++)
                {
                    ILayer pLayer = pScene.get_Layer(i);
                    if (pLayer is ITinLayer)
                    {
                        pTinLayer = pLayer as ITinLayer;
                    }
                    if (pLayer is IRasterLayer)
                    {
                        pRasterlayer = pLayer as IRasterLayer;
                    }

                }
                //设置3D属性
                ITinAdvanced tinAdvanced = pTinLayer.Dataset as ITinAdvanced;
                ISurface surface = tinAdvanced.Surface;

                ILayerExtensions layerExtensions = pRasterlayer as ILayerExtensions;
                I3DProperties p3DProperties = null;

                for (int i = 0;i < layerExtensions.ExtensionCount;i++)
                {
                    if (layerExtensions.get_Extension(i) is I3DProperties)
                    {
                        p3DProperties = layerExtensions.get_Extension(i) as I3DProperties;
                    }
                }
                p3DProperties.BaseOption = esriBaseOption.esriBaseSurface;
                p3DProperties.BaseSurface = surface;
                p3DProperties.Apply3DProperties(pRasterlayer);