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)
评论列表
文章目录