【发布时间】:2017-08-17 17:41:05
【问题描述】:
我想找到来自 Maya 中的多个对象的顶点选择的中心(中心是指默认的枢轴位置)。我以为是centroid,但它似乎没有返回正确的坐标。
我选择了四个顶点,每个球体的两个极点。红色是这个顶点的“中心”,Maya 放置默认轴,蓝色是我计算的质心。
要么我的计算错误,要么顶点的中心不是质心,无论如何这些显然不是相同的坐标。这是我的代码:
loc = cmds.spaceLocator ()[0]
vtxList = cmds.ls (sl = True, fl = True)
vtxPosSum = [0, 0, 0]
for vtx in vtxList:
vtxPos = cmds.xform (vtx, q = True, ws = True, t = True)
vtxPosSum[0] += vtxPos[0]
vtxPosSum[1] += vtxPos[1]
vtxPosSum[2] += vtxPos[2]
barycentre = [vtxPosSum[0] / len(vtxList),
vtxPosSum[1] / len(vtxList),
vtxPosSum[2] / len(vtxList)]
cmds.xform (loc, ws = True, t = barycentre)
所以我的问题是,从多个多边形中选择顶点时如何找到默认 Maya 枢轴的位置?
谢谢
【问题讨论】: