NCF参数化建筑论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
楼主: panhao1
打印 上一主题 下一主题

[VB & C#] 长啊长的树

[复制链接]
跳转到指定楼层
1m
发表于 2010-3-28 18:57:35 | 显示全部楼层 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 panhao1 于 2010-3-28 18:59 编辑

原来是rs(参见《101》)脚本 后来被我改写为gh脚本(当然是原创的啦)

为了说明gh脚本能取代rs(理论上的)
我做了个对比 (两颗树都是gh输出) 第二个加了实时bake脚本(我以前帖子中提到过关键性代码)  看起来像rs吧


还有视屏 大家看看吧

好了先看图

长草.part001.rar

400 KB, 下载次数: 212, 下载积分: 照度 -1 lux

长草.part002.rar

327.07 KB, 下载次数: 181, 下载积分: 照度 -1 lux

评分

参与人数 3强度 +10 照度 +120 收起 理由
dizon + 2 + 40
skywoolf + 4 + 40
f(x) + 4 + 40

查看全部评分

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享
2m
 楼主| 发表于 2010-3-28 19:03:30 | 显示全部楼层
本帖最后由 panhao1 于 2010-3-28 19:06 编辑

《101》中的rs代码
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
3m
 楼主| 发表于 2010-3-28 19:07:47 | 显示全部楼层
我的关键性代码

If isnothing(pt) Then Exit Sub
    Dim Svector As New On3dPoint(0, 0, 1)
    Dim props2 As Integer = 0
    Dim arcs As New List(Of OnArc)
    Call Start(pt, svector, props0, props1, props2, gen, max1, min1, max2, min2, arcs)
    a = arcs

Public  Sub start(ByVal pt As On3dPoint, ByVal dir As on3dvector, ByVal  props0 As Integer, ByVal props1 As Integer, ByVal props2 As Integer, ByVal gen As Integer, ByVal max1 As Double, ByVal min1 As Double, ByVal max2 As Double, ByVal min2 As Double, ByRef arcs As list(Of onarc))
    If props2 >gen Then Exit Sub
    'randomize
    For i As int32=1 To (rnd() * props1 + props0)
      Dim randpt As New on3dpoint
      randpt = randompoint(pt, max1, min1, max2, min2, dir)
      Dim wing As New OnArc
      wing = addarc(pt, randpt, dir)
      If isnothing(wing) Then Exit Sub
      Dim direction As New on3dvector
      direction = wing.TangentAt(wing.Domain(1))
      arcs.add(wing)
      Call Start(randpt, direction, props0, props1, props2 + 1, gen, max1, min1, max2, min2, arcs)
    Next
  End Sub
4m
 楼主| 发表于 2010-3-28 23:29:52 | 显示全部楼层
本帖最后由 panhao1 于 2010-3-29 12:18 编辑

6# odys
不是共同语言..
5m
 楼主| 发表于 2010-5-13 18:16:01 | 显示全部楼层
23# jasonbb88

你转一下格式就变小了 大概1M左右

小黑屋|手机版|NCF参数化建筑论坛 ( 浙ICP备2020044100号-2 )    辽公网安备21021102000973号

GMT+8, 2024-5-11 18:52 , Processed in 0.061667 second(s), 22 queries , Gzip On.

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表