附上图片作者: panhao1 时间: 2010-10-14 02:30
这个脚本书上好像缺几行代码 我记得坛子创立初期好像发过完整的代码作者: panhao1 时间: 2010-10-14 02:32
Option Explicit
'Script written by <insert name>
'Script copyrighted by <insert company name>
'Script version 2009年3月11日 22:13:15
Call Main()
Sub Main()
Dim ptStart: ptStart = Array(0,0,0)
Dim vecDir: vecDir = Array(0,0,1)
Dim Props: Props = Array(3,4,6,5,0.8,30,0.7)
Dim Generation: Generation = 2
Call RecursiveGrowth(ptStart, vecDir, Props, Generation)
End Sub
Sub RecursiveGrowth(ByVal ptStart, ByVal vecDir, ByVal Props(), ByVal Generation)
If Generation > Props(2) Then Exit Sub
Dim ptGrow, vecGrow, newTwig
Dim newProps : newProps = Props
newProps(3) = Props(3) * Props(4)
newProps(5) = Props(5) * Props(6)
If newProps(5) > 90 Then newProps(5) = 90
Dim N, maxN
maxN = CInt(Props(0) + Rnd() * (Props(1) - Props(0)))
For N = 1 To maxN
ptGrow = RandomPointInCone(ptStart, vecDir, 0.25*Props(3), Props(3), Props(5))
newTwig = AddArcDir(ptStart, ptGrow, vecDir)
If Not IsNull(newTwig) Then
vecGrow = CurveTangent(newTwig, CurveDomain(newTwig)(1))
Call RecursiveGrowth(ptGrow, vecGrow, newProps, Generation+1)
End If
Next
End Sub