如何在 Autodesk Maya 中找到中心点...我知道使用中心枢轴但我找不到该点..如何找到使用 Autodesk Maya 创建的 3D 对象的确切坐标?谢谢。
8 回答
这个问题实际上有两种可能的答案。
对象的“中心”可能意味着:
对象边界框的中心:您可以按如下方式获得(使用python)
bbx = cmds.xform(object, q=True, bb=True, ws=True) # world space
centerX = (bbx[0] + bbx[3]) / 2.0
centerY = (bbx[1] + bbx[4]) / 2.0
centerZ = (bbx[2] + bbx[5]) / 2.0
对象枢轴的位置:这与对象的位置不同,因为您可以在不更改 Maya 报告的平移数的情况下移动枢轴。世界空间枢轴位置可以通过以下方式获得:
pivot = cmds.xform(object, q=True, rp=True, ws=True)
只需转到菜单,修改 > 中心轴。这将使您的枢轴转到模型的中心。
实际上有一个命令叫做objectCenter()
这将为您提供特定点或对象的真实世界空间。
将 maya.cmds 导入为 cmds
# create a simple hierarchy
cmds.polyCube( name='a' )
cmds.polyCube( name='b' )
cmds.parent( 'b', 'a' )
cmds.move( 3, 0, 0, 'a', localSpace=True )
cmds.move( 2, 2, 2, 'b', localSpace=True )
X_COORD = cmds.objectCenter('b',x=True)
# Result: 5 #
# Get the center of the bounding box of b in local space
XYZ = cmds.objectCenter('b', l=True)
# Result: 2 2 2 #
# Get the center of the bounding box of b in world space
XYZ = cmds.objectCenter('b', gl=True)
# Result: 5 2 2 #
# Get the center of the bounding box of a in world space
XYZ = cmds.objectCenter('a', gl=True)
http://download.autodesk.com/global/docs/maya2013/en_us/CommandsPython/index.html
香农
选择对象并选择:Animation > Create Deformers > Cluster。
簇变形器现在将出现在对象的确切中心,用“C”表示,您可以在任何需要居中的地方顶点捕捉到簇。集群的实际中心点将位于“C”下方。
如果您对中心枢轴命令放置枢轴的位置感到满意,并且只想知道它在世界空间中的位置,则可以执行以下操作(假设您选择了对象)
使用 PyMEL:
import pymel.core as pm
theObject = pm.ls(sl=1)[0]
theObject.getRotatePivot()
或使用 maya.cmds:
import maya.cmds as mc
mc.xform(query=True,rotatePivot=True)
或使用 MEL
xform -q -rotatePivot
选择对象,“修改中心枢轴..”如果不起作用,只需选择对象并按键盘中的“插入键”。然后它将允许您设置枢轴..只需拖放您要设置的位置...
如果您有任何疑问,请随时分享......
在 Maya 中选择对象并查看右侧的面板。
选择对象,然后在脚本编辑器中运行它:
string $sel[];
$sel = `ls -sl`;
print `getAttr ($sel[0]+".translate")`;
这将在历史面板中打印 X、Y 和 Z 坐标。