import maya.cmds as c
try:
if c.window(window, exists = True):
c.deleteUI(window)
except NameError:
print 'error'
window = c.window(t = "Add Root Bone Plugin_ver.0 by_oyx",w= 300, h=150,sizeable = False)
c.columnLayout()
c.separator(h = 10,w = 300, style = 'out')
name_root = c.textFieldGrp(label = "Root Name",editable = True,text = 'Root',ct2 = ('left','left'),co2 = (10,-50))
c.separator(h = 10, w = 300,style = 'out')
create_RootY_button = c.button(label = "Create Root_XZ",w = 300,c = "Create_Root_XZ()")
c.separator(h = 10,w = 300, style = 'out')
create_RootXYZ_button = c.button(label = "Create Root_XYZ",w = 300,c = "Create_Root_XYZ()")
c.showWindow(window)
def Create_Root_XZ():
root_name = c.textFieldGrp(name_root,q = True,tx = True)
text = c.ls(selection = True)
c.currentTime(0)
HipsPosition = c.xform(text,q = True, t = True)
c.select(clear = True)
root = c.joint(p = (HipsPosition[0],0,HipsPosition[2]),n = root_name)
c.connectJoint(text,root_name,parentMode = True)
c.copyKey(text,at = 'translateX',option = 'keys')
c.pasteKey(root_name,at = "translateX",option = "merge")
c.cutKey(text,attribute = "translateX",option = "keys")
c.copyKey(text,at = 'translateZ',option = 'keys')
c.pasteKey(root_name,at = "translateZ",option = "merge")
c.cutKey(text,attribute = "translateZ",option = "keys")
def Create_Root_XYZ():
root_name = c.textFieldGrp(name_root,q = True,tx = True)
text = c.ls(selection = True)
c.currentTime(0)
HipsPosition = c.xform(text,q = True, t = True)
c.select(clear = True)
root = c.joint(p = (HipsPosition[0],0,HipsPosition[2]),n = root_name)
c.connectJoint(text,root_name,parentMode = True)
c.copyKey(text,at = 'translateX',option = 'keys')
c.pasteKey(root_name,at = "translateX",option = "merge")
c.cutKey(text,attribute = "translateX",option = "keys")
c.copyKey(text,at = 'translateY',option = 'keys')
c.pasteKey(root_name,at = "translateY",option = "merge")
c.cutKey(text,attribute = "translateY",option = "keys")
c.copyKey(text,at = 'translateZ',option = 'keys')
c.pasteKey(root_name,at = "translateZ",option = "merge")
c.cutKey(text,attribute = "translateZ",option = "keys")
c.keyframe(root_name,at = 'translateY',option = "move",relative = True,valueChange = (HipsPosition[1]*-1))
ADD ROOT BONE TO UE4
最新推荐文章于 2023-02-27 14:25:45 发布
这段代码在Maya中创建了一个名为'Root'的关节,并根据用户选择的对象复制了其XZ或XYZ轴的平移关键帧。通过'CreateRoot_XZ'和'CreateRoot_XYZ'按钮,用户可以为选定的物体添加一个根关节,同时保留原有的平移动画。
摘要由CSDN通过智能技术生成