objectRand物体随机排列.txt

// 物体随机排列; 
// by居燕虹 2004.3
global proc objectRand()
{
string $selectObject[]=`ls-sl`;
int$amount=size($selectObject) ;
if($amount==0) error"Please select the object ";
if(`window-exists objectRand`)
   {
    deleteUI objectRand;
   }
 window-title"obiect rand"-h500objectRand;
 columnLayout;
 text-l" ";
 frameLayout-label" Translate"-mh10-mw5-labelAlign"center"-borderStyle"etchedIn";
  columnLayout-columnAttach"left"5-adjustableColumntrue-h10namecolumnLayout;  
    attrFieldSliderGrp-cat1"left"20-cw130-cat2"left"30-cw2110-min0-max10-fmn0-fmx100-label"Tx"-at ($selectObject[0]+".tx") tx;
    attrFieldSliderGrp-cat1"left"20-cw130-cat2"left"30-cw2110-min0-max10-fmn0-fmx100-label"Ty"-at ($selectObject[0]+".ty") ty;
    attrFieldSliderGrp-cat1"left"20-cw130-cat2"left"30-cw2110-min0-max10-fmn0-fmx100-label"Tz"-at ($selectObject[0]+".tz") tz;
    setParent ..;
    setParent ..;
 frameLayout-label" Rotate"-mh10-mw5-labelAlign"center"-borderStyle"etchedIn";
  columnLayout-columnAttach"left"5-adjustableColumntrue-h10namecolumnLayout;
    attrFieldSliderGrp-cat1"left"20-cw130-cat2"left"30-cw2110-min0-max360-label"Rx"-at ($selectObject[0]+".rx") rx;
    attrFieldSliderGrp-cat1"left"20-cw130-cat2"left"30-cw2110-min0-max360-label"Ry"-at ($selectObject[0]+".ry") ry;
    attrFieldSliderGrp-cat1"left"20-cw130-cat2"left"30-cw2110-min0-max360-label"Rz"-at ($selectObject[0]+".rz") rz;
    setParent ..;
    setParent ..;
 frameLayout-label" Scale"-mh10-mw5-labelAlign"center"-borderStyle"etchedIn";
  columnLayout-columnAttach"left"5-adjustableColumntrue-h10namecolumnLayout;
    attrFieldSliderGrp-cat1"left"20-cw130-cat2"left"30-cw2110-min0-max1-fmn0-fmx10-label"Sx"-at ($selectObject[0]+".sx") sx;
    attrFieldSliderGrp-cat1"left"20-cw130-cat2"left"30-cw2110-min0-max1-fmn0-fmx10-label"Sy"-at ($selectObject[0]+".sy") sy;
    attrFieldSliderGrp-cat1"left"20-cw130-cat2"left"30-cw2110-min0-max1-fmn0-fmx10-label"Sz"-at ($selectObject[0]+".sz") sz;   
    rowColumnLayout-numberOfColumns3-columnWidth1150-columnWidth2150;
    checkBox-label" 等比"-w10scaletmp;
    setParent ..;
    setParent ..;
    setParent ..;
    setParent ..;
  rowLayout-numberOfColumns4-w20;
    string $b1, $b1, $b3;
    $b1=` button-w95-c randdjuyh-l" Apply"`;
    $b2=` button-w95-c resetjuyh-l" Reset"`;
    $b3=` button-w95-c"deleteUI objectRand"-l" Close"`;    
 showWindow;
}
global proc randdjuyh()
 string $selectObject[]=`ls-sl`;
 int$amount=size($selectObject) ;
 if($amount==0) error"Please select the object ";
  float$ttx=`getAttr ($selectObject[0]+".tx")`;
  float$tty=`getAttr ($selectObject[0]+".ty")`;
  float$ttz=`getAttr ($selectObject[0]+".tz")`;
  float$trx=`getAttr ($selectObject[0]+".rx")`;
  float$try=`getAttr ($selectObject[0]+".ry")`;
  float$trz=`getAttr ($selectObject[0]+".rz")`;
  float$tsx=`getAttr ($selectObject[0]+".sx")`;
  float$tsy=`getAttr ($selectObject[0]+".sy")`;
  float$tsz=`getAttr ($selectObject[0]+".sz")`;
 for($i=0;$i<$amount;$i++)
 {
  float$tx=rand(-$ttx,$ttx);
  float$ty=rand(-$tty,$tty);
  float$tz=rand(-$ttz,$ttz);
  float$rx=rand(-$trx,$trx);
  float$ry=rand(-$try,$try);
  float$rz=rand(-$trz,$trz);
  float$sx;
  float$sy;
  float$sz;
  $bol=`checkBox-q-value scaletmp`;
  if($bol==0)
   { 
      if($tsx==1)
        $sx=$tsx; 
      else
        $sx=rand((1-$tsx),(1+$tsx));
      if($tsy==1)
        $sy=$tsy; 
      else
        $sy=rand((1-$tsy),(1+$tsy));
      if($tsz==1)
        $sz=$tsz; 
      else
        $sz=rand((1-$tsz),(1+$tsz));
   }
  else
   { 
      if($tsx==1) 
      $sz=$sy=$sx=$tsx;
      else
      $sz=$sy=$sx=rand((1-$tsx),(1+$tsx));
   }
  move-r $tx $ty $tz $selectObject[$i];
  rotate-r $rx $ry $rz $selectObject[$i];
  scale-a $sx $sy $sz $selectObject[$i];
 }
}
global proc resetjuyh()
{
    string $selectObject[]=`ls-sl`;
    makeIdentity-applytrue-t1-r1-s1$selectObject[0];
}
objectRand;




原文地址:https://www.cnblogs.com/xe2011/p/2535582.html