python数据动画_[转载]Maya使用Python获取动画每帧的rotation数据
··············
import?maya.cmds as
mc
import?os
#添加一個(gè)"Maya動(dòng)畫收集數(shù)據(jù)"窗口設(shè)置動(dòng)畫開始播放
#win = mc.window(title = "Maya動(dòng)畫收集數(shù)據(jù)", w = 400, h = 40)
#mc.frameLayout( lv=False )
#mc.playbackOptions( minTime=0, maxTime=20 )
mc.select("jamie_arm_R",?"jamie_elbow_R")#輸入模型骨骼,最后輸出的就是這些骨骼對(duì)應(yīng)的數(shù)據(jù)
sel?=?mc.ls(sl?=?1)
maxT?=?mc.playbackOptions(query?=?True,
maxTime?=?True)
minT?=?mc.playbackOptions(query?=?True,
minTime?=?True)
os.remove("D:\RotationInfo.txt")#在添加數(shù)據(jù)之前刪除原存數(shù)據(jù)的txt
#定義GetRot方法
def?GetRot(time):
info?=?[]
#t
= mc.currentTime(query = True)
t?=?mc.currentTime(time)
for?i?in?sel:
rotx?=?mc.getAttr(i?+?".rx")
roty?=?mc.getAttr(i?+?".ry")
rotz?=?mc.getAttr(i?+?".rz")
iposInfo?=?[i,
rotx, roty, rotz]
info.append(iposInfo)
info_str?=?""
for?i?in?info:
info_str?=?info_str?+?"rn"?+?str(i[1])?+?"rn"?+?str(i[2])?+?"rn"?+?str(i[3])
#info_str
= info_str + i[0] + "rnrotX:" + str(i[1]) + "?rotY:" + str(i[2]) + "?rotZ:" + str(i[3]) +
"rnrn"
#info_str
= str(t) + "rnrn" + info_str
f?=?open("D:\RotationInfo.txt"?,?"a")#打開要存數(shù)據(jù)的txt,若不存在則新建一個(gè)
f.write(info_str)
f.close
for?i?in?range(int(minT),?int(maxT?+?1)):
GetRot(i)
#mc.showWindow(win)
#mc.text(label = "選擇動(dòng)畫的其中一幀,然后點(diǎn)擊“收集數(shù)據(jù)”執(zhí)行數(shù)據(jù)統(tǒng)計(jì)", h = 50)
#mc.button(label = "播放動(dòng)畫", command = "mc.play(state = 1)")
#mc.button(label = "收集數(shù)據(jù)", command = "GetRot()")
#mc.button(label = "結(jié)束播放", command = "mc.play(state = 0)")
總結(jié)
以上是生活随笔為你收集整理的python数据动画_[转载]Maya使用Python获取动画每帧的rotation数据的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 超好用的 Windows 效率工具推荐
- 下一篇: python3装饰器例子_python