ラスター レイヤー・フィーチャ レイヤーの立ち上げ

Private Sub AddFeatureLayerAsSurface()

    'RasterLayerの作成
    Dim pSxDocument As ISxDocument
    Set pSxDocument = ThisDocument
    
    Dim pFLayer As IFeatureLayer
    Set pFLayer = pSxDocument.Scene.Layer(0)
    
    
    '立ち上げ設定
    Dim p3DProperties As I3DProperties
    Set p3DProperties = Get3DPropsFromLayer(pFLayer)
    
    p3DProperties.BaseOption = esriBaseSurface  'レイヤの標高をサーフェスから取得
    p3DProperties.ExtrusionExpressionString = 55500 '高さ
    p3DProperties.ExtrusionType = esriExtrusionNone '立ち上げのチェック オフ
    p3DProperties.ExtrusionType = esriExtrusionBase '立ち上げのチェック オン
    
    
    p3DProperties.Apply3DProperties pFLayer      '設定の適用
    
    Dim pSceneGraph As ISceneGraph
    Set pSceneGraph = pSxDocument.Scene.SceneGraph
    pSceneGraph.RefreshViewers                  'ビューの再描画

End Sub

'VBA
Private Sub AddRasterLayerAsSurface()

    'RasterLayerの作成
    Dim pSxDocument As ISxDocument
    Set pSxDocument = ThisDocument
    
    Dim pRasterLayer As IRasterLayer
    Set pRasterLayer = New RasterLayer
    pRasterLayer.CreateFromFilePath ("E:\SpatialData\Raster\ジオイド(ArcGIS93)\WGS84.img")
    pRasterLayer.Name = "DEM"
    pSxDocument.Scene.AddLayer pRasterLayer, False  '事前にArcSceneへレイヤを追加しないと3DPropertiesは追加されない
    
    '立ち上げ設定
    Dim p3DProperties As I3DProperties
    Set p3DProperties = Get3DPropsFromLayer(pRasterLayer)
    
    p3DProperties.BaseOption = esriBaseSurface  'レイヤの標高をサーフェスから取得
    p3DProperties.MaxRasterRows = 200           'ラスタの解像度(ロウ)
    p3DProperties.MaxRasterRows = 400           'ラスタの解像度(カラム)
    p3DProperties.ZFactor = 1                   'Z 単位変換
    p3DProperties.RenderMode = esriRenderCache  'レンダリング スピードを高速にするためにレイヤをキャッシュ
    
    p3DProperties.OffsetExpressionString = "0"  'オフセット
    p3DProperties.RenderVisibility = esriRenderAlways   '常にレイヤをレンダリング
    p3DProperties.Illuminate = True             'シーンの光源位置を考慮して地表面フィーチャを陰影表示
    p3DProperties.SmoothShading = True          'スムースな陰影処理を使用
    
    Dim pRasterSurface As IRasterSurface
    Set pRasterSurface = New RasterSurface
    
    Dim pRasterBandCollection As IRasterBandCollection
    Set pRasterBandCollection = pRasterLayer.Raster
    pRasterSurface.RasterBand = pRasterBandCollection.Item(0)
    
    Set p3DProperties.BaseSurface = pRasterSurface
    
    
    p3DProperties.Apply3DProperties pRasterLayer      '設定の適用
    
    Dim pSceneGraph As ISceneGraph
    Set pSceneGraph = pSxDocument.Scene.SceneGraph
    pSceneGraph.RefreshViewers                  'ビューの再描画

End Sub

'I3DPropertiesオブジェクトの取得
Private Function Get3DPropsFromLayer(pLayer As ILayer) As I3DProperties
    Dim i As Integer
    Dim pLayerExts As ILayerExtensions
    
    Set pLayerExts = pLayer
    For i = 0 To pLayerExts.ExtensionCount - 1
        Dim p3DProps As I3DProperties
        Set p3DProps = pLayerExts.Extension(i)
        If (Not p3DProps Is Nothing) Then
            Set Get3DPropsFromLayer = p3DProps
            Exit Function
        End If
    Next i
End Function
private void AddRasterLayerAsSurface()
{
    //RasterLayerの作成
    IRasterLayer pRasterLayer = new RasterLayerClass();
    pRasterLayer.CreateFromFilePath(@"E:\SpatialData\Raster\ジオイド(ArcGIS93)mg");
    pRasterLayer.Name = "DEM";
    axSceneControl1.Scene.AddLayer((ILayer)pRasterLayer, false);    //事前にScenへレイヤ追加しないと3DPropertiesは追加されない

    //立ち上げ設定
    I3DProperties p3DProperties = Get3DPropertiesFromLayer((ILayer)pRasterLayer);

    p3DProperties.BaseOption = esriBaseOption.esriBaseSurface;  //レイヤの標高を得
    //p3DProperties.MaxRasterRows = 200;           //ラスタの解像度(ロウ)
    //p3DProperties.MaxRasterRows = 400 ;          //ラスタの解像度(カラム)
    p3DProperties.ZFactor = 1;                   //Z 単位変換
    p3DProperties.RenderMode = esriRenderMode.esriRenderCache;  //レンダリング するためにレイヤをキャッシュ

    p3DProperties.OffsetExpressionString = "0";  //オフセット
    p3DProperties.RenderVisibility = esriRenderVisibility.esriRenderAlways;   //ダリング
    p3DProperties.Illuminate = true;             //シーンの光源位置を考慮して地陰影表示
    p3DProperties.SmoothShading = true;          //スムースな陰影処理を使用

    //サーフェスの設定
    IRasterSurface pRasterSurface = new RasterSurfaceClass();
    IRasterBandCollection pRasterBandCollection = (IRasterBandCollection)pRasterster;
    pRasterSurface.RasterBand = pRasterBandCollection.Item(0);
    p3DProperties.BaseSurface = (IFunctionalSurface)pRasterSurface;

    p3DProperties.Apply3DProperties(pRasterLayer);      //設定の適用

    //ビューの再描画
    ISceneGraph pSceneGraph = axSceneControl1.Scene.SceneGraph;
    pSceneGraph.RefreshViewers();                  
}

//I3DPropertiesオブジェクトの取得
private I3DProperties Get3DPropertiesFromLayer(ILayer pLayer)
{
    ILayerExtensions pLayerExtensions = (ILayerExtensions)pLayer;

    for (int i = 0; i <= pLayerExtensions.ExtensionCount -1 ; i++)
    {
        I3DProperties p3DProperties = (I3DProperties)pLayerExtensions.get_Extension(i);
        if( p3DProperties != null)
        {
            return p3DProperties;
        }
    }
    return null;
}