commands.py 文件源码

python
阅读 34 收藏 0 点赞 0 评论 0

项目:config 作者: mindbender-studio 项目源码 文件源码
def match_transform(src, dst):
    """Transform `src` to `dst`, taking worldspace into account

    Arguments:
        src (str): Absolute path to source transform
        dst (str): Absolute path to destination transform

    """

    try:
        parent = cmds.listRelatives(src, parent=True)[0]
    except Exception:
        parent = None

    node_decompose = cmds.createNode("decomposeMatrix")
    node_multmatrix = cmds.createNode("multMatrix")

    connections = {
        dst + ".worldMatrix": node_multmatrix + ".matrixIn[0]",
        node_multmatrix + ".matrixSum": node_decompose + ".inputMatrix",
        node_decompose + ".outputTranslate": src + ".translate",
        node_decompose + ".outputRotate": src + ".rotate",
        node_decompose + ".outputScale": src + ".scale",
    }

    if parent:
        connections.update({
            parent + ".worldInverseMatrix": node_multmatrix + ".matrixIn[1]"
        })

    for s, d in connections.iteritems():
        cmds.connectAttr(s, d, force=True)

    cmds.refresh()

    cmds.delete([node_decompose, node_multmatrix])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号