结合后以世界中心为中心的对象枢轴

Center object pivot with world center after combine

当我在 Maya 中取 2 个对象并组合它们时,组合对象的枢轴是世界的中心,因此我使用 修改中心轴 选项。

但是之后这个物体和其他物体的中心不一样了,比如我把它的位置设置为(0, 0, 0)它就不是世界的中心了。

我知道我可以将合并的对象移动到世界中心,然后使用 修改中心轴 但它是不准确。

有什么我想念的吗?如何使对象的枢轴居中并使其相对于世界?

这就是我的意思,如您所见,对象位于 (0,0,0) 位置但不在世界中心:

发生的事情是,当您使用中心枢轴时,它不会影响对象的平移值,而是用其枢轴偏移它(局部旋转枢轴属性)。因此,即使您的平移全部为零,枢轴的值也会导致您的对象偏离世界原点。

虽然了解上述内容是有道理的,但 Maya 处理它的方式仍然很烦人。

这里有一个脚本可以尝试解决这个问题。它本质上做的是获取其枢轴值,将其归零,并将其添加到其翻译中:

玛雅 2018

import maya.cmds as cmds

sel = cmds.ls(sl=True)[0]  # Get selection.

cmds.xform(sel, cpc=True)  # Center its pivot. Comment this out if you don't want to force it to center and use the pivot as-is.
pivots = cmds.xform(sel, q=True, piv=True)[:3]  # Get its pivot values.

temp_nul = cmds.createNode("transform")  # Create a temporary transform.
cmds.matchTransform(temp_nul, sel)  # Align the transform to our object.

try:
    cmds.xform(sel, piv=[0, 0, 0])  # Zero-out object's pivot values.
    cmds.move(-pivots[0], -pivots[1], -pivots[2], "{}.vtx[*]".format(sel), os=True, r=True)  # Negate and move object via its old pivot values.
    cmds.matchTransform(sel, temp_nul)  # Align the object back to the temporary transform, to maintain its old position.
finally:
    cmds.delete(temp_nul)  # Delete temporary transform.
    cmds.select(sel)  # Restore old selection.

玛雅 2016 和 <

import maya.cmds as cmds
import maya.mel as mel

sel = cmds.ls(sl=True)[0]  # Get selection.

mel.eval("CenterPivot;")  # Center its pivot. Comment this out if you don't want to force it to center and use the pivot as-is.
pivots = cmds.xform(sel, q=True, piv=True)[:3]  # Get its pivot values.
old_tm = cmds.xform(sel, q=True, ws=True, m=True) # Get its transform matrix.

temp_nul = cmds.createNode("transform")  # Create a temporary transform.
cmds.xform(temp_nul, ws=True, m=old_tm)  # Align it to the matrix.
cmds.xform(temp_nul, os=True, r=True, t=pivots)  # Move it to include the pivot offsets.
new_tm = cmds.xform(temp_nul, q=True, ws=True, m=True)  # Store it's transform matrix to align to later.

try:
    cmds.xform(sel, piv=[0, 0, 0])  # Zero-out object's pivot values.
    cmds.move(-pivots[0], -pivots[1], -pivots[2], "{}.vtx[*]".format(sel), os=True, r=True)  # Negate and move object via its old pivot values.
    cmds.xform(sel, ws=True, m=new_tm)  # Align the object back to the temporary transform, to maintain its old position.
finally:
    cmds.delete(temp_nul)  # Delete temporary transform.
    cmds.select(sel)  # Restore old selection.

Select 你的对象然后执行脚本到 运行 它。我在一个随机旋转的组合对象上测试了它,同时作为一个随机旋转对象的父级。好像没popping也正常

您也可以通过使用 polyMoveVertex 节点而不是脚本的节点组合实现相同的效果。