2012-11-05

The Maya Ofen use Mel

剛用Maya的時候感到不方便的地方,就是有一些原本覺得應該要設定成快捷鍵方式來切換的顯示模式沒有,都要在選單上面點選,覺得有些不方便,後來在網路上找尋了一些人家寫好的mel,可以自己新增到Hptkeys,在此備份一下,順便分享給其他人,之後有我覺得比較必要的項目的話,會在新增在此。




這個mel主要是用來顯示線框模式

1.wireframe_on_shaded

string $currPanel = `getPanel -withFocus`;
if ("" != $currPanel && ("modelPanel" == `getPanel -to $currPanel`))
{
    int $xrayonoff = `modelEditor -q -wos $currPanel`;
    switch ($xrayonoff)
    {
        case 0: modelEditor -e -wos true $currPanel;
            break;
        case 1: modelEditor -e -wos false $currPanel;
            break;
        default: break;
    }
    $wosonoff = `modelEditor -q -wos $currPanel`;
    print("WireframeOnShaded: "+$wosonoff+"\n");
} else {
    error "No modeling panel selected or invalid.";
}




由於maya在選取物件的時候會自動顯示線框,用上面那個mel把線框關掉,可是選去的物件線框還是會開著,有時候在做High Poly物件的時候,觀察物件時會比較不方便,所以可以利用這個mel把選取物件的線框關掉。

2.turning_off_wireframe

string $wires = `displayPref -q -wsa`;
if ($wires == "none")
displayPref -wsa "full";
else
displayPref -wsa "none";




這個是整體XRay開關的mel

3.XRay

string $panel = `getPanel -wf`;
modelEditor -e -xray ( !`modelEditor -q -xray $panel` ) $panel;





這個是單一物件的XRay開關,有時候物件需要對位的時候只打開單一物件的XRay會比較好對位置,全部一起打開反而比較難查看。

4.XRay_select

global proc r_superXray()
{

string $select[] = `ls -sl`;
int $sizes = `size$select`;

if ($sizes >= 1)
 {
 string $mySel[] = `ls -sl -dag -s`;
 for ($s in $mySel)
 {
 int $xState[] = `displaySurface -q -xRay $s`;
 displaySurface -xRay ( !$xState[0] ) $s;
 }
 }

if ($sizes < 1)
 {
 string $all[] = `select -ado`;
 displaySurface -xRay 0;
 select -cl;
 $currentPanel = `getPanel -wf`;
 $mode = `modelEditor -q -xray $currentPanel`;
 modelEditor -edit -xray (!$mode) $currentPanel;
 }

}
r_superXray;

 



這個是把背面顯示關掉的~可以避免選擇到背面的點。

5.BackfaceCulling

setAttr yourSelection.backfaceCulling 0;


沒有留言: