Maya使用动力学曲线驱动骨骼

接上篇将骨骼均匀放置在曲线后,设置动力学驱动骨骼。需要说明的是,由于动力学化曲线以后,会自动创建出一条曲线作为动力学曲线。原有的曲线仅仅作为动力学曲线开始位置。由于我没有找到返回创建的曲线名称的方法。所以手动的复制了一条曲线链接到follicle上,方便后面绑定使用。

依然先选择曲线在选择根骨骼运行脚本。

import pymel.core as pm

sl = pm.ls(selection=1)
cv = sl[0]
bone = pm.listRelatives(sl[1],allDescendents=True)
bone.append(sl[1])
bone.reverse()

pm.rebuildCurve(cv,constructionHistory=False,replaceOriginal=True,
                rebuildType=0,endKnots=1,keepRange=0,keepControlPoints=True,
                keepEndPoints=True,keepTangents=False,spans=0,
                degree=3,tolerance=0)
for i in range(0,len(bone)):
    pos = py.pointOnCurve(cv,parameter=(i*(1.0/len(bone)*(len(bone)/(len(bone)-1.0)))),position=1)
    py.move(pos[0],pos[1],pos[2],bone[i])
pm.joint(bone[0],edit=True,orientJoint='xyz',secondaryAxisOrient='yup',
            children=True,zeroScaleOrient=True)
pm.setAttr(bone[len(bone)-1]+'.jointOrient',0,0,0,type='double3')

pm.select(cv)
pm.mel.makeCurvesDynamic(2, ["1", "0", "1", "1", "0"])
follicles = pm.listRelatives(cv,allParents=True,fullPath=True,shapes=True)
follicles = pm.listRelatives(follicles, children=True,shapes=True)
dyCV = pm.duplicate(cv,name=(cv+'_Dynamic'))
pm.connectAttr(follicles[0]+'.outCurve' ,dyCV[0]+'Shape.create')

ikhan = pm.ikHandle(name = bone[0]+'_ikSplineSolver',endEffector = bone[len(bone)-1],startJoint = bone[0],solver = 'ikSplineSolver', 
            curve = dyCV[0], createCurve = False)





 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值