ml_centerOfMass.py 文件源码

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

项目:ml_tools 作者: morganloomis 项目源码 文件源码
def bakeCenterOfMass(*args):
    '''
    Bake root animation to center of mass.
    '''

    sel = mc.ls(sl=True)

    if not len(sel) == 1:
        raise RuntimeError('Please select the root control of your puppet.') 

    root, com = getRootAndCOM(sel[0])

    if not root:
        root = sel[0]
    if not com:
        com = createCenterOfMass()

    start, end = utl.frameRange()
    with utl.IsolateViews():
        mc.bakeResults(com, time=(start,end), sampleBy=1, attribute=['tx','ty','tz'], simulation=True)

    rootOffset = mc.group(em=True, name='rootOffset')
    rootOffset = mc.parent(rootOffset, com)[0]

    #bake
    utl.matchBake(source=[root], 
                  destination=[rootOffset], 
                  bakeOnOnes=True, 
                  maintainOffset=False, 
                  preserveTangentWeight=False, 
                  translate=True, 
                  rotate=True)

    mc.cutKey(root, attribute=['tx','ty','tz','rx','ry','rz'])
    mc.parentConstraint(rootOffset, root)

    mc.select(com)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号