我有一个动画定位器,它在不平坦的表面上移动。 但是,它的轴/旋转通道不符合凹凸不平的表面。
是否有工具或脚本可以让我使此动画定位器在移动时在曲面上对齐/定向?
答案 0 :(得分:1)
首先您尝试使用普通约束:
normalConstraint -weight 1 -aimVector 1 0 0 -upVector 0 1 0 -worldUpType "vector" -worldUpVector 0 1 0;
否则,您可以使用ClosestPointOnMesh(基于uv):https://download.autodesk.com/us/maya/2008help/Nodes/closestPointOnMesh.html
# USER DEFINE
surface = cmds.polySphere(n='pSphere1')
movingObj = cmds.spaceLocator(n='locator1')[0]
# AUTOMATION
aimLocator = cmds.spaceLocator(n='aimloc')[0]
closest = cmds.createNode('closestPointOnMesh')
surface_sh = cmds.listRelatives(surface, ni=True)[0]
cmds.connectAttr(surface_sh+'.worldMesh[0]', closest+'.inMesh')
cmds.connectAttr(surface_sh+'.worldMatrix[0]', closest+'.inputMatrix')
cmds.connectAttr(movingObj+'.t', closest+'.inPosition')
# this command is bugged in python so, lets use mel.eval
cmds.select(surface, aimLocator)
pctr = mel.eval('pointOnPolyConstraint -offset 0 0 0 -weight 1;')[0]
cmds.connectAttr('{}.parameterU'.format(closest), '{}.target[0].targetU'.format(pctr), f=True)
cmds.connectAttr('{}.parameterV'.format(closest), '{}.target[0].targetV'.format(pctr), f=True)
cmds.orientConstraint(aimLocator, movingObj, mo=False, weight=1)
您仍然可以插入普通输出,我让您按照他的教程进行操作(俄语,但每个步骤都在这里):https://www.youtube.com/watch?v=dPliNB4uZ0w