def curve_to_hair(curve_shape, hair_system):
curve = cmds.listRelatives(curve_shape, parent=True, f=True)[0]
curve_name = curve.split('|')[-1]
# Create follicle
follicle_shape = cmds.createNode('follicle')
follicle = cmds.listRelatives(follicle_shape, parent=True, f=True)[0]
follicle = cmds.rename(follicle, curve_name + '_follicle#')
follicle_shape = cmds.listRelatives(follicle, shapes=True, f=True)[0]
cmds.connectAttr(curve + '.worldMatrix', follicle_shape + '.startPositionMatrix')
cmds.connectAttr(curve_shape + '.local', follicle_shape + '.startPosition')
# # Create output curve
out_curve_shape = cmds.createNode('nurbsCurve')
out_curve = cmds.listRelatives(out_curve_shape, parent=True, f=True)[0]
out_curve = cmds.rename(out_curve, curve_name + '_out#')
out_curve_shape = cmds.listRelatives(out_curve, shapes=True, f=True)[0]
cmds.connectAttr(follicle + '.outCurve', out_curve_shape + '.create')
# Add follicle to hair system
add_follicle(follicle_shape, hair_system)
return [[follicle, follicle_shape], [out_curve, out_curve_shape]]
评论列表
文章目录