python数据动画_[转载]Maya使用Python获取动画每帧的rotation数据
··············
import?maya.cmds as
mc
import?os
#添加一個"Maya動畫收集數據"窗口設置動畫開始播放
#win = mc.window(title = "Maya動畫收集數據", w = 400, h = 40)
#mc.frameLayout( lv=False )
#mc.playbackOptions( minTime=0, maxTime=20 )
mc.select("jamie_arm_R",?"jamie_elbow_R")#輸入模型骨骼,最后輸出的就是這些骨骼對應的數據
sel?=?mc.ls(sl?=?1)
maxT?=?mc.playbackOptions(query?=?True,
maxTime?=?True)
minT?=?mc.playbackOptions(query?=?True,
minTime?=?True)
os.remove("D:\RotationInfo.txt")#在添加數據之前刪除原存數據的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")#打開要存數據的txt,若不存在則新建一個
f.write(info_str)
f.close
for?i?in?range(int(minT),?int(maxT?+?1)):
GetRot(i)
#mc.showWindow(win)
#mc.text(label = "選擇動畫的其中一幀,然后點擊“收集數據”執行數據統計", h = 50)
#mc.button(label = "播放動畫", command = "mc.play(state = 1)")
#mc.button(label = "收集數據", command = "GetRot()")
#mc.button(label = "結束播放", command = "mc.play(state = 0)")
總結
以上是生活随笔為你收集整理的python数据动画_[转载]Maya使用Python获取动画每帧的rotation数据的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 超好用的 Windows 效率工具推荐
- 下一篇: 模糊查询与字符串的操作