GIS的积累
It is never to late to learn

导航

 

VRMapBlock 对象

楼快对象


接口

IVRMapNode

    IVRMapObject

        VRMapBlock

IVRMapBlockDisp


说明

楼快对象是以地形上的二维多边形区域为底座,给以一定高度,拉起来的三维棱柱,用来描述标准形状的建筑物。

 使用AddPoint,AddPolygon方法创建面区域对象,须要注意的是在使用AddPolygon方法后,使用AddPoint方法才能增加Polygon的顶点。Point方法返回当前对象的所有的顶点,Polygon方法返回当前对象的区域个数,PolygonPoint方法配合使用可以取得相应的顶点。RemoveAll方法可以清除当前对象的所有的区域及顶点。。用户可以即时设置颜色(Color),可视范围(ViewRange),楼层数(FloorCount),纹理(TextureFileName),纹理参数(AlignAngle,TextureUDist,TextureVDist)

 VBA示例

创建楼块对象,并加入到场景中

Private Sub DrawBlock()

    Dim vrTerrain As VRMapTerrain

    Dim ivObject As IVRMapObject

    Dim ivNode As IVRMapNode

    Dim vrBlock As New VRMapBlock

    Dim sImageFile As String

    Dim fs

    Dim pt As S_Vec2

   

    If Application.Document.Scene.TypeNodeCount("Terrain") = 0 Then Exit Sub

    Set vrTerrain = Application.Document.Scene.TypeNode("Terrain", 0)

    Set ivObject = vrTerrain

   

    sImageFile = InputBox("请输入贴图文件的路径及文件名。比如:C:\Image\Texture.bmp")

    If IsNull(sImageFile) = True Or Len(sImageFile) = 0 Then Exit Sub

    Set fs = CreateObject("Scripting.FileSystemObject")

    If fs.FileExists(sImageFile) = False Then

        MsgBox "文件不存在", vbCritical

        Exit Sub

    End If

   

    vrBlock.AddPolygon

    pt.x = 10

    pt.y = 10

    vrBlock.AddPoint pt

    pt.x = 40

    pt.y = 10

    vrBlock.AddPoint pt

    pt.x = 40

    pt.y = 40

    vrBlock.AddPoint pt

    pt.x = 10

    pt.y = 40

    vrBlock.AddPoint pt

   

    vrBlock.TextureFileName = sImageFile

    vrBlock.TextureUDist = 1

    vrBlock.RoofTextureVDist = 1

    vrBlock.AlignAngle = 20

    vrBlock.CollideAccurate = False

    vrBlock.FloorCount = 20

    vrBlock.Color = #ffc480

    vrBlock.ViewRange = 10000

   

    Set ivNode = vrBlock

    ivNode.ObjectName = "New Block"

    ivObject.AddChild ivNode

       

End Sub

 

 

 

 

VRMapPMObject 对象

   
渐进网格对象


接口

IVRMapNode

    IVRMapObject

        VRMapPMObject

IVRMapPMObjectDisp


说明

渐进网格用于描述复杂的几何体。

渐进网格允许对几何体做各种优化,静态优化和LOD处理。这些优化能大大的提高渲染效率。通过CreateProgressiveMesh可以创建网格的LOD信息,可以用LODThreshold调整LOD误差参数。而ChgTransformMatrixStatic则用于静态优化。

 

渐进网格可以直接从3DS文件中调入(通过VRMapX2对象的CreatePMObjectFrom3DS)。

 

通过AddTriangle,AddVertex,AddMaterial,AddMaterialBlock,UpdateContents方法可以构建网格。

 

示例

下面的范例从3DS文件中调入模型,并生成LOD信息。

Dim pmObject as VRMapPMObject

Set pmObject = vrmapX.CreatePMObjectFrom3DS "1.3ds"

Dim i as New VNodeIterator

i.IteratedObject = pmObject

Dim p as VRMapPMObject

Dim n as IVRMapNode

Set n = i.FirstNode

while not n is Nothing

    Set p = n

    if not p is Nothing then

        p.CreateProgressiveMesh 0.06,0.01

    endif

    Set n = i.NextNode

wend

 

posted on 2009-09-10 19:10  GIS的学习  阅读(182)  评论(0编辑  收藏  举报