Last active
August 29, 2015 14:17
-
-
Save petfactory/93acdbdac2aa38740718 to your computer and use it in GitHub Desktop.
Curve SkinPercent
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
pm.system.openFile('/Users/johan/Documents/Projects/python_dev/scenes/spring_jnts.mb', f=True) | |
ik_jnt_list = [pm.PyNode('joint{0}'.format(j+1)) for j in range(5)] | |
pos_list = [j.getTranslation(ws=True) for j in ik_jnt_list] | |
crv = pm.curve(d=1, p=pos_list) | |
crv_shape = crv.getShape() | |
crv_shape.overrideEnabled.set(1) | |
crv_shape.overrideColor.set(17) | |
pm.toggle(crv, controlVertex=True) | |
skin_cluster = pm.skinCluster(ik_jnt_list[0], crv) | |
pm.skinPercent(skin_cluster, 'curve1.cv[0]', transformValue=('joint1', 1.0)) | |
pm.skinPercent(skin_cluster, 'curve1.cv[1]', transformValue=('joint2', 1.0)) | |
pm.skinPercent(skin_cluster, 'curve1.cv[2]', transformValue=('joint3', 1.0)) | |
pm.skinPercent(skin_cluster, 'curve1.cv[3]', transformValue=('joint4', 1.0)) | |
pm.skinPercent(skin_cluster, 'curve1.cv[4]', transformValue=('joint5', 1.0)) | |
############################################# | |
def set_curve_skin_percent(crv, jnt_list, num_div): | |
num_jnt = len(jnt_list) | |
cv_index = 0 | |
u_inc = 1.0 / (num_div + 1) | |
for index in range(num_jnt-1): | |
start = jnt_list[index] | |
end = jnt_list[index+1] | |
for n in range(num_div+1): | |
u = u_inc * n | |
#print(cv_index) | |
print('') | |
#print('{0} ({1}) > {2} ({3})'.format(start, 1.0-u, end, u)) | |
print('{0}.cv[{1}], transformValue=({2}, {3})').format(crv, cv_index, start, 1.0-u) | |
print('{0}.cv[{1}], transformValue=({2}, {3})').format(crv, cv_index, end, u) | |
cv_index +=1 | |
print('') | |
print('{0}.cv[{1}], transformValue=({2}, {3})').format(crv, cv_index, jnt_list[-1], 1.0) | |
print('') | |
jnt_list = ['joint{0}'.format(j+1) for j in range(4)] | |
num_div = 1 | |
crv = 'curve1' | |
set_curve_skin_percent(crv=crv, jnt_list=jnt_list, num_div=num_div) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment