python 从http://www.conghal.com/blog/烘焙quadruped动画到定位器以使用枢轴控制(步骤1)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 从http://www.conghal.com/blog/烘焙quadruped动画到定位器以使用枢轴控制(步骤1)相关的知识,希望对你有一定的参考价值。

# create a locator for each selected control
# bake worldspace matrix to locator for each key in range

import maya.cmds as cmds

sel = cmds.ls (sl=True)
objLocList = []
ctrlSet = cmds.sets(em=True, n="bakedWsCtrlsSet")
locSet = cmds.sets(em=True, n="bakedWsLocsSet")

for obj in sel:
    objXform = cmds.xform (obj, q=True, m=True, ws=True)
    loc = "|" + cmds.spaceLocator (n = (obj + "_locator"))[0]
    cmds.xform (loc, m=objXform, ws=True)
    objLocList.append((obj,loc))
    cmds.sets(obj, add=ctrlSet)
    cmds.sets(loc, add=locSet)

rangeMin = int(cmds.playbackOptions(q=True, min=True))
rangeMax = int(cmds.playbackOptions(q=True,max=True))

initTime = cmds.currentTime(q=True)
autoKeyState = cmds.autoKeyframe(q=True, st=True)
cmds.autoKeyframe(st=False)

for t in range(rangeMin, rangeMax + 1):
    cmds.currentTime (t)
    for (trgtObj, loc) in objLocList:
        trgtXform = cmds.xform (trgtObj, q=True, m=True, ws=True)
        cmds.xform (loc, m=trgtXform, ws=True)
        cmds.setKeyframe(loc, at=["t","r","s"], rk=True)

cmds.currentTime(initTime) 
cmds.select(sel)

cmds.autoKeyframe(st=autoKeyState)

以上是关于python 从http://www.conghal.com/blog/烘焙quadruped动画到定位器以使用枢轴控制(步骤1)的主要内容,如果未能解决你的问题,请参考以下文章

Python从入门到精通— 初识Python

Python从入门到精通— 初识Python

Python从入门到精通— 初识Python

Python 绑定:从 Python 调用 C 或 C++

Python 从入门到精通推荐看哪些书籍呢?

《Python从入门基础到实践》