zbw_jointsOnCurveSetup.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:zTools 作者: zethwillie 项目源码 文件源码
def create_joint(cvs, wts):
    tform = cvs[0].partition(".")[0]
    curve = cmds.listRelatives(tform, f=True, s=True)[0]

    ps = []
    center = []
    for cv in cvs:
        ps.append(cmds.pointPosition(cv))
        center = [sum(y)/len(y) for y in zip(*ps)]

    #create joint at location
    # ----------- should get closest point on surface   
    cmds.select(cl=True)    
    jnt = cmds.joint()
    cmds.xform(jnt, ws=True, t=center)

#---------------- orient the joint along the curve?
#---------------- here create the ctrl set up for the joint

    ctrl = rig.createControl(name="{0}Ctrl".format(jnt), type="sphere", color="red")
    grp = cmds.group(name="{0}Grp".format(ctrl), em=True)
    cmds.parent(ctrl, grp)
    cmds.xform(grp, ws=True, t=center)
    cmds.parent(jnt, ctrl)

    # scale the control
    comps = cmds.ls("{0}.cv[*]".format(ctrl))
    cmds.select(comps, r=True)
    cmds.scale(.2,.2,.2)

    #add influence to skin Cluster
    cmds.select(tform, r=True)
    cmds.skinCluster(e=True, ai=jnt, wt=0)

    cmds.setAttr("{0}.v".format(jnt), 0)

    #apply weights to that joint
    cls = mel.eval("findRelatedSkinCluster " + tform)
    for v in range(len(cvs)):
        cmds.skinPercent(cls, cvs[v], transformValue=[jnt, wts[v]])

    return(jnt, ctrl, grp)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号