原理:
抓取軸向數(shù)據(jù)(從右側(cè)屬性數(shù)據(jù)里抓取,并不是坐標所在位置的數(shù)據(jù)),然后找到模型最低點,把移動放過去。

比如原始坐標數(shù)據(jù)就在物體中心,他就會在物體中心底部。


比如原始坐標數(shù)據(jù)為不在模型身上,他就會抓取x和z軸數(shù)據(jù),y的數(shù)據(jù)在模型底部

所以在執(zhí)行之前最好坐標歸位到物體中心,烘焙坐標數(shù)據(jù),再執(zhí)行代碼。
如果多選模型,則x、z按照數(shù)字數(shù)據(jù),y軸所有模型的最低點。
代碼:
string $sel[]= `ls -sl`;
//$sel[0] != "" to check if the first item is empty, but `size $sel` == 1 already cover that
if(`size $sel` > 0)
{
int $vtxIdx;
int $vCount[];
float $lowestY = 2147483647.0;
float $crtY = 0.0;
float $pos[];
string $item;
for ($item in $sel)
{
$vCount = `polyEvaluate -vertex $item`; //Get vertex count
for ($vtxIdx = 0; $vtxIdx < $vCount[0]; $vtxIdx++)//Loop through vetex
{
$pos = `xform -q -ws -t ($item+".vtx["+$vtxIdx+"]")`;//Get vertex position
$crtY = $pos[1];
if($crtY < $lowestY)
{
$lowestY = $crtY;//Get the lowest Y
}
}
$pos = `xform -q -ws -t ($item)`;
xform -ws -a -piv $pos[0] $lowestY $pos[2] ($item);
print ($lowestY);
}
}
使用方法:
-
將代碼復(fù)制,粘貼到MEL代碼窗口
選中要修改的模型,把坐標歸位到物體中心,烘焙坐標數(shù)據(jù),直接按藍色播放鍵或者小鍵盤的enter執(zhí)行代碼
-
全選代碼按住中間拖到工具欄里生成按鈕


