Dim pApp as IApplicaiton
Set pApp = Application

Implements ICommand
Private m_pApp as esriCore.Iapplication
Private Sub ICommand_OnCreate(ByVal Hook As Object)
Set m_pApp = Hook
End Sub

3D模型可以包括两种：矢量模型和表面模型，表面模型包括TIN和Raster，有关表面模型的创建、数据结构访问和分析在本文中不做介绍。在此只介绍三维矢量模型的生成和访问等。3D矢量模型包括所有含有Z值的几何对象：点、线、面，以及MultiPatch（多片）。其中多片又可以分为：三角条带（Triangle Strip）、三角扇（Triangle Fan）和环（Ring）。

Dim pMultiPatch As esriCore.IMultiPatch
Set pMultiPatch = New MultiPatch
Dim pGeoCol As esriCore.IGeometryCollection
Set pGeoCol = pMultiPatch
Dim pPoints As esriCore.IPointCollection
Dim pPoint As IPoint
‘创建屋顶
Set pPoints = New esriCore.TriangleFan
Set pPoint = New Point
pPoint.PutCoords 5, 4
pPoint.Z = 10
Set pPoint = New Point
pPoint.PutCoords 0, 0
pPoint.Z = 5
‘屋顶的其它顶点:
. . . (10, 0, 5); (10, 8, 5); ( 0, 8, 5); ( 0, 0, 5)
‘将扇加到MultiPatch
‘为没有窗户的墙创建条带
Set pPoints = New esriCore.TriangleStrip
‘添加条带顶点:
. . . (10, 0, 5); (10, 0, 0); (10, 8, 5)
. . . (10, 8, 0); ( 0, 8, 5); ( 0, 8, 0)
. . . ( 0, 0, 5); ( 0, 0, 0)
‘将条带添加到MultiPatch
‘为前面的墙创建外环
Set pPoints = New esriCore.Ring
‘添加外环顶点:
. . . (10, 0, 5); (10, 0, 0); (10, 8, 5)
. . . (10, 8, 0); ( 0, 8, 5); ( 0, 8, 0)
. . . ( 0, 0, 5); ( 0, 0, 0)
‘将外环添加到MultiPatch
pMultiPatch.PutRingType pPoints, esriMultiPatchOuterRing
‘为前面的墙创建内环
Set pPoints = New esriCore.Ring
‘添加内环顶点:
. . .(1, 0, 2);(3, 0, 2);(3, 0, 4);(1, 0, 4);(1, 0, 2)
pMultiPatch.PutRingType pPoints, esriMultiPatchInnerRing
Set pPoints = New esriCore.Ring
‘添加内环顶点:
. . .(7, 0, 2);(9, 0, 2);(9, 0, 4);(7, 0, 4);(7, 0, 2)
pMultiPatch.PutRingType pPoints, esriMultiPatchInnerRing
‘设置Z和M坐标awareness
Dim pZAware As esriCore.IZAware
Set pZAware = pMultiPatch
pZAware.ZAware = True
Dim pMAware As esriCore.IMAware
Set pMAware = pMultiPatch
pMAware.MAware = False

Dim pNormal As esriCore.IVector3D
Dim pVertex As esriCore.Ipoint
Dim m As Double
m = 0
. . .
Dim pEncoder As IEncode3DProperties
Set pEncoder = New GeometryEnvironment
pEncoder.PackNormal vNormal, m
pEncoder.PackTexture2D s, t, m
pVertex.M = m

‘ 引用ArcScene文档
SceneViewerCtrl1.DocName = “c:\temp\myscene.sxd”

‘ 添加一个图层