Created
May 8, 2014 07:03
-
-
Save zeffii/62f55c9b59b83d8ca883 to your computer and use it in GitHub Desktop.
vectorized ScriptNode script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sv_main(height=[], tail_len=[], tail_width=[], head_len=[]): | |
in_sockets = [ | |
['s', 'height', height], | |
['s', 'tail_len', tail_len], | |
['s', 'tail_width', tail_width], | |
['s', 'head_len', head_len]] | |
def make_arrow(a=1.0, b=1.0, c=0.4, d=0.5): | |
full_arrow = [[a,0],[0,b],[0,c],[-d,c],[-d,-c],[0,-c],[0,-b]] | |
if 0.0 in (c, d): | |
full_arrow = [[a,0],[0,b],[0,-b]] | |
faces = [[0,1,2]] | |
else: | |
faces = [[0,6,1],[2,3,4,5]] | |
verts = [(x,y,0) for x, y in full_arrow] | |
return verts, faces | |
multi_vert_objects = [] | |
multi_face_objects = [] | |
# this assumes that all zipped parameters | |
# are of equal number, ie: the length of the incoming lists | |
# are all the same. | |
for params in zip(height, tail_len, tail_width, head_len): | |
pheight, ptail_len, ptail_width, phead_len = params | |
a = phead_len | |
b = pheight/2 | |
c = ptail_width/2 | |
d = ptail_len | |
v, f = make_arrow(a, b, c, d) | |
multi_vert_objects.append(v) | |
multi_face_objects.append(f) | |
out_sockets = [ | |
['v', 'Verts', multi_vert_objects], | |
['s', 'Faces', multi_face_objects] | |
] | |
return in_sockets, out_sockets |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment