Last active
August 29, 2015 14:06
-
-
Save zeffii/3d95247dbbc4a171e33a to your computer and use it in GitHub Desktop.
tiebinder_realtime_curve.py
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 bake_n_shake(out): | |
curves = bpy.data.curves | |
objects = bpy.data.objects | |
scene = bpy.context.scene | |
curve_name = 'tie_binding' | |
cu = curves.get(curve_name, curves.new(name=curve_name, type='CURVE')) | |
tie = cu.splines.new('POLY') | |
obj = objects.get(curve_name, objects.new(curve_name, cu)) | |
out2 = [] | |
[out2.extend(list(i)+[0.0]) for i in out] # flattens the list for foreach_set | |
tie.points.add(len(out)-1) | |
tie.points.foreach_set('co', out2) | |
cu.extrude = 0.3 | |
if not curve_name in scene.objects: | |
scene.objects.link(obj) | |
def sv_main(n=[]): | |
'''use note node to define toe | |
l - left, r - right, t - top, | |
bake, convert to curve and | |
extrude 0.3' | |
'Nikitron, 2014''' | |
in_sockets = [ | |
['s', 'n', n]] | |
out = [ | |
(0, 0.2, -5), | |
(0, 0.2, -3), | |
(0, 0.2, 0), | |
(1, 0.2, 1), | |
(3, 5, 2), | |
(0, 7, 2), | |
(-3, 5, 2), | |
(-1, 0.5, 1) ] | |
front = True | |
vecs = [(0.8660254037844386, 0.0, -0.5), | |
(0,0,1), | |
(-0.8660254037844386, 0.0, -0.5)] | |
if n: | |
for k, i in enumerate(n[0][0]): | |
if i[0] == 'l': | |
i = 0 | |
elif i[0] == 't': | |
i = 1 | |
elif i[0] == 'r': | |
i = 2 | |
v = vecs[i] | |
if front: | |
front = False | |
y1 = -0.015 | |
y2 = 0.015 | |
else: | |
front = True | |
y1 = 0.015 | |
y2 = -0.015 | |
out.append((v[0]*k*0.05+v[0], | |
y1*(k+1), | |
v[2]*k*0.05+v[2])) | |
out.append((v[0]*k*0.05+v[0], | |
y2*(k+1), | |
v[2]*k*0.05+v[2])) | |
out.extend([ | |
(0, -0.4,-1), | |
(0, -0.2,-3), | |
(0, 0,-10)]) | |
out_sockets = [ | |
['v', 'out', [out]]] | |
if n: | |
bake_n_shake(out) | |
return in_sockets, out_sockets |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment