Smooth redo ?

各Maya用戶可在這裡交流問題和分享制作經驗

版主: h2o, stantang

Smooth redo ?

文章Refrigerator » 16日 5月 2005年, 23:19

想問.....除了ctrl + z 之外有咩方法睇完Smooth 個樣,之後再轉返去未Smooth 之前個樣?
Refrigerator
討論區新秀
討論區新秀
 
文章: 47
註冊時間: 10日 3月 2005年, 20:03
來自: HK

Share On:

Share on Facebook Facebook Share on Twitter Twitter

文章TonyCcY » 17日 5月 2005年, 02:15

我用一個 Mel 叫 kwPloySmooth , 佢可以好似 XSI , 按 + and - 去 + Smooth 同 - Smooth , 幾方便的

由於放唔到 zip and mel 上來 我直接Post 上來

代碼: 選擇全部
/*  This file downloaded from Highend3d.com
'' 
''  Highend3d.com File Information:
'' 
''    Script Name: kwPloySmooth v1.0
''    Author: Kurt Wong
''    Last Updated: July 9, 2004
''    Update/Change this file at:
''    http://www.highend3d.com/maya/mel/?section=polygon#3023
'' 
''  Please do not alter any information above this line
''  it is generated dynamically by Highend3d.com and will
''  be changed automatically on any updates.
*/

//--------------------------------------------------------------------------------//
//--------------------------------------------------------------------------------//
//SCRIPT:       kwPloySmooth.mel
//VERSION:       1.o
//AUTHOR:       Kurt Wong
//              OnFootBuG@hotmail.com
//DATE:           July 9, 2oo4
//
//DESCRIPTION:   This handy Script plays as softImage|xsi does,When you press "+",
//              the subdivision levels of the object you select is increased,
//              and press "-" to decrease it.
//
//            This Script remaps "Ctrl +" & "Ctrl =" to command  "IncreaseManipulorSize"
//            and "Ctrl -" to "DecreaseManipulorSize";
//
//USAGE:        1.Put this script into maya's scripts folder,for example:
//                C:\Documents and Settings\yourUserName\My Documents\maya\scripts
//              2.In the maya's command line,type following commands:
//                 source kwPloySmooth;kwPloySmoothSetUp;
//              3.OK,then everytime you need to increase or decrease the objects'
//              subdivision levels,just press "+" or "-" of your keyboard.
//              Enjoy it!
//--------------------------------------------------------------------------------//
//--------------------------------------------------------------------------------//

//--------------------------------------------------------------------------------//
//The following procedure finds out all the "polySmoothFace" nodes.
proc string[] kwSeekPsfNodes(string $object)
{
   string $psfNodes[] = {}, $shapeNodes[] = {};
   int $psfNodeSum = 0;
   $shapeNodes = `listRelatives -s -pa $object`;
   string $sources[];
   for ($shapeNode in $shapeNodes)
   {
      string $temp[];
      $temp = `listConnections -d 0 $shapeNode`;
      $sources = stringArrayCatenate($sources,$temp);
   }
   string $newSources[] = {}, $tempSources[] = {}, $allSources[] = {};
   while (size($sources) != 0)
   {
      int $sourceSum = size($sources);
      $newSources = {};
      for ($i = 0; $i < $sourceSum; $i ++)
      {
         int $cycle = 0;
         for ($allSource in $allSources)
         {
            if ($sources[$i] == $allSource)
            {
               $cycle ++;
               break;
            }
         }
         if ($cycle == 0)
         {
            if (`nodeType $sources[$i]` == "polySmoothFace")
            {
               $psfNodeSum ++;
               $psfNodes[$psfNodeSum - 1] = $sources[$i];
            }
            $tempSources = `listConnections -d 0 $sources[$i]`;
            $newSources = stringArrayCatenate($newSources,$tempSources);
         }
      }
      $allSources = stringArrayCatenate($allSources,$sources);
      $sources = $newSources;
   }
   return $psfNodes;
}


//--------------------------------------------------------------------------------//
//The following procedure increases subdivision levels.
global proc kwIncreaseSmooth()
{
   string $sel[] = `ls -sl`;
   if (size($sel) == 0)
   {
      error ("------->>> No objects were selected, please select any polygon objects you want to smooth. <<<-------\n");
   }
   else
   {
      for ($object in $sel)
      {
         //checking the selected object
         string $objType[] = `ls -dag -s -ni -showType $object`;
         if ($objType[1] != "mesh")
         {
            warning ("------->>> " + $object + " is not a polygon object. <<<-------\n");
            continue;
         }

         string $psfNodes[] = kwSeekPsfNodes($object);for ($psfNode in $psfNodes) print $psfNode;
         int $psfNodeSum = size($psfNodes);
         int $dv, $divisionSum = 0;
         string $oldName[], $newName;
         $shapeNodes = `listRelatives -s -pa $object`;
         if ($psfNodeSum == 0)
         {
            $newName = "polySmoothFace1" + "_" + $object;
            $dv = 1;
            $oldName = `polySmooth -mth 0 -dv $dv -c 1 -kb 1 -ksb 1 -khe 0 -kt 1 -kmb 1 -suv 1 -sl 1 -dpe 1 -ps 0.1 -ro 1 -ch 1 $shapeNodes[0]`;
            rename $oldName[0] $newName;
         }
         else
         {
            int $divisions, $dv4Num = 0, $sn = 1;
            for ($i = 0; $i < $psfNodeSum; $i ++)
            {
               $divisions = `getAttr ($psfNodes[$i] + ".dv")`;
               if ($divisions == 4)
               {
                  string $dvs4obj[];
                  $dvs4obj[$dv4Num] = $psfNodes[$i];
                  $oldName[0] = $psfNodes[$i];
                  $newName = "polySmoothFace" + $sn + "_" + $object;
                  rename $oldName[0] $newName;
                  $sn ++;
                  $dv4Num ++;
               }
               else
               {
                  setAttr ($psfNodes[$i] + ".divisions") 0;
                  delete $psfNodes[$i];
               }
               $divisionSum += $divisions;
            }
            int $dvsLeft = $divisionSum%4, $dvs4Left = ($divisionSum - $dvsLeft)/4 - $dv4Num;

            for ($i = 0; $i < $dvs4Left; $i ++)
            {
               $newName = "polySmoothFace" + $sn + "_" + $object;
               $dv = 4;
               $oldName = `polySmooth -mth 0 -dv $dv -c 1 -kb 1 -ksb 1 -khe 0 -kt 1 -kmb 1 -suv 1 -sl 1 -dpe 1 -ps 0.1 -ro 1 -ch 1 $shapeNodes[0]`;
               rename $oldName[0] $newName;
               $sn ++;
            }
            $newName = "polySmoothFace" + $sn + "_" + $object;
            $dv = $dvsLeft + 1;
            $oldName = `polySmooth -mth 0 -dv $dv -c 1 -kb 1 -ksb 1 -khe 0 -kt 1 -kmb 1 -suv 1 -sl 1 -dpe 1 -ps 0.1 -ro 1 -ch 1 $shapeNodes[0]`;
            rename $oldName[0] $newName;
         }
         print ("------->>> + " + $object + ".divisions: " + ($divisionSum + 1)+ " <<<-------\n");
      }
   }
   select -r $sel;
}


//--------------------------------------------------------------------------------//
//The following procedure decreases subdivision levels.
global proc kwDecreaseSmooth()
{
   string $sel[] = `ls -sl`;
   if (size($sel) == 0)
   {
      error ("------->>> No objects were selected, please select any polygon objects you want to smooth. <<<-------\n");
   }
   else
   {
      for ($object in $sel)
      {
         //checking object type
         string $objType[] = `ls -dag -s -ni -showType $object`;
         if ($objType[1] != "mesh")
         {
            warning ("------->>> " + $object + " is not a polygon object. <<<-------\n");
            continue;
         }

         string $psfNodes[] = kwSeekPsfNodes($object);
         int $psfNodeSum = size($psfNodes);
         int $dv, $divisionSum = 0;
         string $oldName[], $newName;
         $shapeNodes = `listRelatives -s -pa $object`;
         if ($psfNodeSum == 0)
         {
            warning ("------->>> " + $object + " is currently not smoothed. <<<-------\n");
         }
         else
         {
            int $divisions, $dv4Num = 0, $sn = 1;
            for ($i = 0; $i < $psfNodeSum; $i ++)
            {
               $divisions = `getAttr ($psfNodes[$i] + ".dv")`;
               if ($divisions == 4)
               {
                  string $dvs4obj[];
                  $dvs4obj[$dv4Num] = $psfNodes[$i];
                  $oldName[0] = $psfNodes[$i];
                  $newName = "polySmoothFace" + $sn + "_" + $object;
                  rename $oldName[0] $newName;
                  $sn ++;
                  $dv4Num ++;
               }
               else
               {
                  setAttr ($psfNodes[$i] + ".divisions") 0;
                  delete $psfNodes[$i];
               }
               $divisionSum += $divisions;
            }
            int $dvsLeft = $divisionSum%4, $dvs4Left = ($divisionSum - $dvsLeft)/4 - $dv4Num;

            for ($i = 0; $i < $dvs4Left; $i ++)
            {
               $newName = "polySmoothFace" + $sn + "_" + $object;
               $dv = 4;
               $oldName = `polySmooth -mth 0 -dv $dv -c 1 -kb 1 -ksb 1 -khe 0 -kt 1 -kmb 1 -suv 1 -sl 1 -dpe 1 -ps 0.1 -ro 1 -ch 1 $shapeNodes[0]`;
               rename $oldName[0] $newName;
               $sn ++;
            }
            if ($dvsLeft == 0 && $sn >1)
            {
               setAttr ("polySmoothFace" + ($sn - 1) + "_" + $object + ".divisions") 3;
            }
            else if ($dvsLeft > 1)
            {
               $newName = "polySmoothFace" + $sn + "_" + $object;
               $dv = $dvsLeft - 1;
               $oldName = `polySmooth -mth 0 -dv $dv -c 1 -kb 1 -ksb 1 -khe 0 -kt 1 -kmb 1 -suv 1 -sl 1 -dpe 1 -ps 0.1 -ro 1 -ch 1 $shapeNodes[0]`;
               rename $oldName[0] $newName;
            }
         }
         if ($divisionSum > 0) print ("------->>> - " + $object + ".divisions: " + ($divisionSum - 1)+ " <<<-------\n");
      }
   }
   select -r $sel;
}


//--------------------------------------------------------------------------------//
//The following procedure maps the hotKeys.
global proc kwPloySmoothSetUp()
{
    hotkey -pcr 1 -k "+" -ctl -name `hotkey -query -name "+"`;
    hotkey -pcr 1 -k "=" -ctl -name `hotkey -query -name "="`;
    hotkey -pcr 1 -k "-" -ctl -name `hotkey -query -name Dash`;

  //Remapping the default hotkeys of commands --- IncreaseManipulorSize, DecreaseManipulorSize;
  //-----------------------------------------------------------------------------------------
  //mapping "+" & "=" to command kwIncreaseSmooth; and "-" to command kwDecreaseSmooth;

    nameCommand
       -annotation "kwPloySmooth proc kwIncreaseSmooth"
       -command "source kwPloySmooth;kwIncreaseSmooth"
       kwIncreaseSmooth;
    nameCommand
       -annotation "kwPloySmooth proc kwDecreaseSmooth"
       -command "source kwPloySmooth;kwDecreaseSmooth"
       kwDecreaseSmooth;
    hotkey -pcr 1 -k "=" -name "kwIncreaseSmooth";
    hotkey -pcr 1 -k "+" -name "kwIncreaseSmooth";
    hotkey -pcr 1 -k "-" -name "kwDecreaseSmooth";
    savePrefs -hotkeys;
}



//the end of this script
TonyCcY
討論區新秀
討論區新秀
 
文章: 25
註冊時間: 11日 4月 2004年, 01:59
來自: 香港

文章CG SEED » 17日 5月 2005年, 23:07

在Input Channel有個Divisions的參數, 輸入0的話便會變回原來的樣子, 不過會有History的, 小心啊......
CG SEED
CGV討論區會員
CGV討論區會員
 
文章: 114
註冊時間: 13日 6月 2004年, 11:14
來自: Hong Kong

文章Refrigerator » 18日 5月 2005年, 20:23

上面咁大段果d 我唔明啊~~sorry
input channel 果度我今晚試試先

謝謝兩位^^
Refrigerator
討論區新秀
討論區新秀
 
文章: 47
註冊時間: 10日 3月 2005年, 20:03
來自: HK


回到 Autodesk Maya

誰在線上

正在瀏覽這個版面的使用者:沒有註冊會員 和 6 位訪客

cron