colaboration / flying surface

Bookmark and Share

This is a small colaboration with Mary ann busby, from chile.
the aim was generate surface from other surfaces, and create some kind movement.
the code works under recursion: analizing, generating and deleting every surface.
is very abstract and also is very simple how it’s works.

This movie requires Flash Player 9

Some Images from the complete generation, saving every “child”:

113
27
2-a-despues-del-crecimiento
35
r22
r12
r3-seccion-de-un-crecimiento
r21

And here the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
Option Explicit
'some functions from Marius Watz
'Script written by carlos de la b.
'Script copyrighted by designemergente.org
'Script version miƩrcoles, 24 de junio de 2009 18:17:12

Call Main()
Sub Main()
 
'//we need a Surface to grow and grow
Dim Idsrf
Idsrf = Rhino.GetObject("sel srf", 8)
If IsNull(Idsrf) Then Exit Sub
 
Call rec(Idsrf, 0)
 
End Sub
 
Function rec(Idsrf, counter) '//recursion under your own Risk!!!

'domain of the curve
Dim Udom, Vdom
Udom = Rhino.SurfaceDomain(Idsrf, 0)
Vdom = Rhino.SurfaceDomain(Idsrf, 1)
 
'parameters, divisions, counters and a point
Dim Up, Vp, divU, divV, i, j, k, pt, l
k = 0
divU = 6
divV = 6
 
Dim arrPoints(35)
 
For i = 0 To divU - 1
For j = 0 To divV - 1
 
Up = Udom(0) + i * ((Udom(1) - Udom(0)) / divU)
Vp = Vdom(0) + j * ((Vdom(1) - Vdom(0)) / divV)
 
pt = Rhino.SurfaceCurvature(Idsrf, Array(Up, Vp))
 
'Randomize
' If 0.5 < rnd Then
' pt(1) = Rhino.VectorScale(pt(1), rnd * 5)
' l = Rhino.PointAdd(pt(1), pt(0))

' Else
l = Rhino.PointAdd(pt(1), pt(0))
 
' End If

arrPoints(k) = l
k = k + 1
 
Next
Next
 
Call Rhino.DeleteObject(IDsrf)
Dim n: n = Rhino.AddSrfPtGrid (Array(divU, divV), arrPoints)
 
Call Rhino.sleep(3000)
 
renderView()
 
Call rec(n, counter + 1)
 
End Function
 
' Render current viewport
'this function from Marius Watz, a very little modification by me.
Function renderView()
Dim view,filename
 
view = Rhino.CurrentView
Rhino.Command "_-Render"
filename=getRenderFileName("GrowSurface")
Dim cmd : cmd="_-SaveRenderWindowAs " & Chr(34) & filename & Chr(34)
Rhino.Command cmd
Rhino.Command "_-CloseRenderWindow"
Rhino.Sleep(3000)
End Function
 
' Get auto-incremented filename
Function getRenderFileName(scriptName) 'this function from Marius Watz
Dim index,done, doc, file, temp,imgNum
 
done=-1
index=0
Do While done=-1
doc=Rhino.WorkingFolder & "\" & scriptName & padStr(scriptName,index) & ".jpg"
file=Rhino.FindFile(doc)
If IsNull(file)=True Then
done=1
Else
index=index+1
End If
Loop
 
getRenderFileName=doc
End Function
 
Function padStr(prefix,val) 'this function from Marius Watz
Dim l : l=Len(val)
If l<1 Then
padStr="000" & val
ElseIf l<2 Then
padStr="00" & val
ElseIf l<3 Then
padStr="0" & val
Else
padStr="" & val
End If
End Function

Leave a Reply