【Maya开发基础】全局缩放补偿

前言

接之前的文档留下的坑,这篇文章实现的是IK关节链stretch的功能。这篇提到,要想让Maya实时反馈,必须使用节点。还提到手臂长度total_length是常量所以可以直接python计算。but,当你一切都准备就绪,企图点击全局组整体缩放骨架时,会发生这种问题。
在这里插入图片描述
发生的原因在于total_length这些类似的量是固定值。然而这种整体缩放,total_length应该也还是要跟着一起缩放的

    # compensate for global scale
    cmds.addAttr(all_grp, attributeType='double', min=0.001, defaultValue=1,
                 keyable=True, longName='globalScale')
    [cmds.connectAttr(all_grp+'.globalScale', all_grp+',scale'+axis) for axis in 'XYZ']
    if add_stretch:
        gs_mdl = cmds.createNode('multDoubleLinear', name=base_name+'globalScale_MDL')
        cmds.setAttr(gs_mdl+'.input1', ik_stretch['total_length'])
        connectAttr(all_grp,'globalScale', gs_mdl, 'input2')
        connectAttr(gs_mdl, 'output', ik_stretch['mdn'], 'input2X')
        connectAttr(gs_mdl, 'output', ik_stretch['cnd'], 'secondTerm')

吐槽一下:这种机制设计怎么有点反直觉
PS:可以前往这个文档,查看节点具体信息。

猜你喜欢

转载自blog.csdn.net/qq_43544518/article/details/130019789