zbw_curveTools.py 文件源码

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

项目:zTools 作者: zethwillie 项目源码 文件源码
def smoothPoints(num = 5, push = 0.05):
    """
    tries to smooth the surrounding pts around an outlier cv
    num = number of points on either side to affect
    push = amount to push out along tangent
    """
    tgtPts = cmds.ls(sl=True, fl=True)

    for tgtPt in tgtPts:

        tgtPtPos = cmds.pointPosition(tgtPt)

        tgtNum = int(tgtPt.partition("[")[2].rpartition("]")[0])
        tgtBase = tgtPt.partition("[")[0]
        #crv = tgtBase.partition(".")[0]

        tgtTan = getNormalizedTangent(tgtPt)

        for x in range(-num, num+1):

            if x != 0:
                origPt = "{0}[{1}]".format(tgtBase, tgtNum + x)
                origPtPos = cmds.pointPosition(origPt)

                perc = (float(abs(x))/(num + 1.0))
                #print origPt, perc

                newPosRaw = om.MVector(*lerp(tgtPtPos, origPtPos, math.sin(perc*3.14*0.5)))
                tan = om.MVector(tgtTan[0]*math.pow(1-perc/num, num)*push, tgtTan[1]*math.pow(1-perc/num, num)*push, tgtTan[2]*math.pow(1-perc/num, num)*push)
                #tan = om.MVector(tgtTan[0]*push, tgtTan[1]*push, tgtTan[2]*push)

                if x<0:
                    newPos = newPosRaw + tan
                if x>0:
                    newPos = newPosRaw - tan

                #print origPt, newPosRaw.x, newPosRaw.y, newPosRaw.z

                cmds.xform(origPt, ws=True, t=newPos)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号