×

工业设计互动平台

手机短信,快捷登录

微信登录,快人一步

QQ登录

只需一步,快速开始

关于Voronoi 的一个程序.进来看看.

发布于 2012-3-16 0 点赞 3 评论 3083 浏览

Option Explicit

' 3d Voronoi AKA Project Cell
' (c) Gabe Smedresman 2005
' All Rights Reserved.


''' global naming variables

Dim XX: XX = 0
Dim YY: YY = 1
Dim ZZ: ZZ = 2

GenerateVoronoiCells

Sub GenerateVoronoiCells()
    Randomize

    Dim arrBoundingVolume ' array of polysurfaces indicating bounding volume
    Dim arrPoints ' array of string references to voronoi points

    Dim i,j

    Dim startTime : startTime = Now

    ' select objects

    arrBoundingVolume = Rhino.GetObjects("Select a Bounding Volume",16+8,vbTrue,vbTrue)
    If IsNull(arrBoundingVolume) Then Exit Sub
    HideObjects arrBoundingVolume

    arrPoints = Rhino.GetObjects("Select Cell Points",1,vbFalse,vbFalse)

    ShowObjects arrBoundingVolume

    If IsNull(arrPoints) Then Exit Sub

    ' go through each point in the list, and create a cell, name it, color it, And update the progress report.

    Dim strCell, strName
    Rhino.Print "Beginning cell divisions: " & UBound(arrPoints)+1 & " cells total."
    For i = 0 To UBound(arrPoints) ' for each point to make a cell around  ' one point at a time

        strCell = GenerateCell(arrPoints(i),arrPoints,arrBoundingVolume)
        Dim value : value = Int(Rnd()*255)
        Rhino.objectColor strCell, RGB(255,255,value)
        strName = "Cell #" & i
        Rhino.objectname strCell, strName

        Dim strTime : strTime = GetTimeDescription(startTime, (i+1) * 1.0 / (UBound(arrPoints)+1) )

        Rhino.Print i+1 & " of " & UBound(arrPoints)+1 & " cells ("& Int((i+1) * 100 / (UBound(arrPoints)+1)) & "%) completed. " & strTime

    Next 'i

    ' hide source geometry to reveal the cells
    HideObjects arrPoints
    HideObjects arrBoundingVolume


End Sub
'麻烦大虾帮忙解释下从Rhino.Print那里给我讲讲每行都是什么意思.比如UBound就是一个VB的方法名?&符号代表什么'

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

精彩回复

文明上网理性发言、请文明用语

qq771031883 | 设计助理 | 发表于 2012-9-27 23:48:00
你写的?
0 回复

举报

moplee | 实习生 | 发表于 2012-9-28 00:06:42
难道不是and吗
0 回复

举报