ADD ROOT BONE TO UE4

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))

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值