發點我的MEL小工具,大家分享

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

版主: h2o, stantang

發點我的MEL小工具,大家分享

文章阿春 » 16日 2月 2005年, 02:17

好長時間不來CGV了, 這裡的朋友也好多不了解了. 呵呵. 發一點我這段時間所寫的一些MAYA的MEL小工具吧, 讓這裡的朋友都分享一下, 希望能在各位工作的時候帶來一點點小的幫助吧.

如有問題, 可直接在這裡提出, 也可 E-mail 我.
spring_yhc@126.com
阿春

以下是我的一個關於燈光的MEL , 由於不會發帶附件的文件了, 所以把源代碼發上來吧. 呵呵.

proc check(string $thename)
{
string $thename;
if(`window -ex $thename`)
{
deleteUI $thename;
}
}//end of the check progame;

proc linelight()
{
string $sel[]=`ls -sl`;
int $numlight;
$numlight=`intSliderGrp -q -v numlSlider`;
float $s=1;
float $e=10000;
float $m=(($e-$s)+1)/$numlight;
float $l=$e+$m/2;
for($i=1;$i<=$numlight;$i++)
{
pointLight -rgb 1 1 1 -d 0;
rename ("linepoint"+$i);
}
for($i=1;$i<=$numlight;$i++)
{
select -r ("linepoint"+$i);
select -tgl $sel;
$s+=$m;
$e+=$m;
pathAnimation -fractionMode 1 -follow 0 -startTimeU $s -endTimeU $e;
currentTime $l;
}
select -cl;
for($i=1;$i<=$numlight;$i++)
{
select -tgl ("linepoint"+$i);
}
group -n linepoint;
select -cl;
for($i=1;$i<=$numlight;$i++)
{
select -r ("linepoint"+$i);
duplicate -rr;
}
select -cl;
currentTime 1;
for($i=1;$i<=$numlight;$i++)
{
select -tgl ("linepoint"+$i);
}
delete;
select -cl;
int $k=1;
for($i=($numlight+1);$i<=(2*$numlight);$i++)
{
select -r ("linepoint"+$i);
rename ("linepoint"+$i) ("linepoint"+$k);
$k++;
}
select -cl;
}

proc pointlight1()
{
int $numlight;
float $rad;
vector $rand;
vector $pos;
$numlight=`intSliderGrp -q -v numpSlider`;
$rad=`floatSliderGrp -q -v radpSlider`;
for($i=1;$i<=$numlight;$i++)
{
pointLight -rgb 1 1 1 -d 0;
$rand=sphrand(1);
$pos=unit($rand)*$rad;
move -a ($pos.x) (abs($pos.y)) ($pos.z);
}
select -cl;
for($i=1;$i<=$numlight;$i++)
{
select ("pointLight"+$i);
rename ("pointy"+$i);
}
select -cl;
for($i=1;$i<=$numlight;$i++)
{
select -tgl ("pointy"+$i);
}
group;
rename pointygroup;
select -cl;
}// end of the pointLight and group together program;

proc pointlight2()
{
int $numlight;
float $rad;
vector $rand;
vector $pos;
$numlight=`intSliderGrp -q -v numpSlider`;
$rad=`floatSliderGrp -q -v radpSlider`;
for($i=1;$i<=$numlight;$i++)
{
pointLight -rgb 1 1 1 -d 0;
$rand=sphrand(1);
$pos=unit($rand)*$rad;
move -a ($pos.x) ($pos.y) ($pos.z);
}
select -cl;
for($i=1;$i<=$numlight;$i++)
{
select ("pointLight"+$i);
rename ("pointy"+$i);
}
select -cl;
for($i=1;$i<=$numlight;$i++)
{
select -tgl ("pointy"+$i);
}
group;
rename pointygroup;
select -cl;
}// end of the pointLight and group together program;

proc arealight1()
{
int $numlight;
float $rad;
vector $rand;
vector $pos;
$numlight=`intSliderGrp -q -v numaSlider`;
$rad=`floatSliderGrp -q -v radaSlider`;
for($i=1;$i<=$numlight;$i++)
{
defaultAreaLight(1, 1,1,1, 0, 0, 0,0,0, 1);
$rand=sphrand(1);
$pos=unit($rand)*$rad;
move -a ($pos.x) (abs($pos.y)) ($pos.z);
}
select -cl;
for($i=1;$i<=$numlight;$i++)
{
select ("areaLight"+$i);
rename ("areay"+$i);
}
select -cl;
sphere -r 0.2 -n bally;
for($i=1;$i<=$numlight;$i++)
{
select -r bally;
select -tgl ("areay"+$i);
aimConstraint -w 1 -aim 0 0 -1;
select -cl;
}
for($i=1;$i<=$numlight;$i++)
{
select -tgl ("areay"+$i);
}
group;
rename areaygroup1;
select -cl;
delete bally;
}//end of the areaLight and group together programe;

proc arealight2()
{
int $numlight;
float $rad;
vector $rand;
vector $pos;
$numlight=`intSliderGrp -q -v numaSlider`;
$rad=`floatSliderGrp -q -v radaSlider`;
for($i=1;$i<=$numlight;$i++)
{
defaultDirectionalLight(1, 1,1,1, "0", 0,0,0);
// defaultAreaLight(1, 1,1,1, 0, 0, 0,0,0, 1);
$rand=sphrand(1);
$pos=unit($rand)*$rad;
move -a ($pos.x) ($pos.y) ($pos.z);
}
select -cl;
for($i=1;$i<=$numlight;$i++)
{
select ("directionalLight"+$i);
rename ("areay"+$i);
}
select -cl;
sphere -r 0.2 -n bally;
for($i=1;$i<=$numlight;$i++)
{
select -r bally;
select -tgl ("areay"+$i);
aimConstraint -w 1 -aim 0 0 -1;
select -cl;
}
for($i=1;$i<=$numlight;$i++)
{
select -tgl ("areay"+$i);
}
group;
rename areaygroup2;
select -cl;
delete bally;
}//end of the areaLight and group together programe;

proc lineIntensity()
{
int $numlight=`intSliderGrp -q -v numlSlider`;
float $int=`floatSliderGrp -q -v intlSlider`;
float $intlast=($int/$numlight);
for($i=1;$i<=$numlight;$i++)
{
setAttr ("linepoint"+$i+".intensity") $intlast;
}
}

proc pointIntensity()
{
float $int=`floatSliderGrp -q -v intpSlider`;
int $numlight=`intSliderGrp -q -v numpSlider`;
float $intlast=($int/$numlight);
for($i=1;$i<=$numlight;$i++)
{
setAttr ("pointy"+$i+".intensity") $intlast;
}
}

proc areaIntensity()
{
float $int=`floatSliderGrp -q -v intaSlider`;
int $numlight=`intSliderGrp -q -v numaSlider`;
float $intlast=($int/$numlight);
for($i=1;$i<=$numlight;$i++)
{
setAttr ("areay"+$i+".intensity") $intlast;
}
}

proc color()
{
int $numlight=`intSliderGrp -q -v numpSlider`;
for($i=1;$i<=$numlight;$i++)
{
attrColorSliderGrp -vis 1 -at ("pointy"+$i+".color");
}
}

proc lnoDecay()
{
int $numlight=`intSliderGrp -q -v numlSlider`;
for($i=1;$i<=$numlight;$i++)
{
setAttr ("linepoint"+$i+".decayRate") 0;
}
}

proc llinear()
{
int $numlight=`intSliderGrp -q -v numlSlider`;
for($i=1;$i<=$numlight;$i++)
{
setAttr ("linepoint"+$i+".decayRate") 1;
}
}

proc lquadratic()
{
int $numlight=`intSliderGrp -q -v numlSlider`;
for($i=1;$i<=$numlight;$i++)
{
setAttr ("linepoint"+$i+".decayRate") 2;
}
}

proc lcubic()
{
int $numlight=`intSliderGrp -q -v numlSlider`;
for($i=1;$i<=$numlight;$i++)
{
setAttr ("linepoint"+$i+".decayRate") 3;
}
}

proc pnoDecay()
{
int $numlight=`intSliderGrp -q -v numpSlider`;
for($i=1;$i<=$numlight;$i++)
{
setAttr ("pointy"+$i+".decayRate") 0;
}
}


proc anoDecay()
{
int $numlight=`intSliderGrp -q -v numaSlider`;
for($i=1;$i<=$numlight;$i++)
{
setAttr ("areay"+$i+".decayRate") 0;
}
}

proc plinear()
{
int $numlight=`intSliderGrp -q -v numpSlider`;
for($i=1;$i<=$numlight;$i++)
{
setAttr ("pointy"+$i+".decayRate") 1;
}
}

proc alinear()
{
int $numlight=`intSliderGrp -q -v numaSlider`;
for($i=1;$i<=$numlight;$i++)
{
setAttr ("areay"+$i+".decayRate") 1;
}
}

proc pquadratic()
{
int $numlight=`intSliderGrp -q -v numpSlider`;
for($i=1;$i<=$numlight;$i++)
{
setAttr ("pointy"+$i+".decayRate") 2;
}
}

proc aquadratic()
{
int $numlight=`intSliderGrp -q -v numaSlider`;
for($i=1;$i<=$numlight;$i++)
{
setAttr ("areay"+$i+".decayRate") 2;
}
}

proc pcubic()
{
int $numlight=`intSliderGrp -q -v numpSlider`;
for($i=1;$i<=$numlight;$i++)
{
setAttr ("pointy"+$i+".decayRate") 3;
}
}

proc acbuic()
{
int $numlight=`intSliderGrp -q -v numaSlider`;
for($i=1;$i<=$numlight;$i++)
{
setAttr ("areay"+$i+".decayRate") 3;
}
}

proc lemitDon()
{
int $numlight=`intSliderGrp -q -v numlSlider`;
for($i=1;$i<=$numlight;$i++)
{
setAttr ("linepoint"+$i+".emitDiffuse") 1;
}
}

proc pemitDon()
{
int $numlight=`intSliderGrp -q -v numpSlider`;
for($i=1;$i<=$numlight;$i++)
{
setAttr ("pointy"+$i+".emitDiffuse") 1;
}
}

proc aemitDon()
{
int $numlight=`intSliderGrp -q -v numaSlider`;
for($i=1;$i<=$numlight;$i++)
{
setAttr ("areay"+$i+".emitDiffuse") 1;
}
}

proc lemitDoff()
{
int $numlight=`intSliderGrp -q -v numlSlider`;
for($i=1;$i<=$numlight;$i++)
{
setAttr ("linepoint"+$i+".emitDiffuse") 0;
}
}

proc pemitDoff()
{
int $numlight=`intSliderGrp -q -v numpSlider`;
for($i=1;$i<=$numlight;$i++)
{
setAttr ("pointy"+$i+".emitDiffuse") 0;
}
}

proc aemitDoff()
{
int $numlight=`intSliderGrp -q -v numaSlider`;
for($i=1;$i<=$numlight;$i++)
{
setAttr ("areay"+$i+".emitDiffuse") 0;
}
}

proc lemitSon()
{
int $numlight=`intSliderGrp -q -v numlSlider`;
for($i=1;$i<=$numlight;$i++)
{
setAttr ("linepoint"+$i+".emitSpecular") 1;
}
}

proc pemitSon()
{
int $numlight=`intSliderGrp -q -v numpSlider`;
for($i=1;$i<=$numlight;$i++)
{
setAttr ("pointy"+$i+".emitSpecular") 1;
}
}

proc aemitSon()
{
int $numlight=`intSliderGrp -q -v numaSlider`;
for($i=1;$i<=$numlight;$i++)
{
setAttr ("areay"+$i+".emitSpecular") 1;
}
}

proc lemitSoff()
{
int $numlight=`intSliderGrp -q -v numlSlider`;
for($i=1;$i<=$numlight;$i++)
{
setAttr ("linepoint"+$i+".emitSpecular") 0;
}
}

proc pemitSoff()
{
int $numlight=`intSliderGrp -q -v numpSlider`;
for($i=1;$i<=$numlight;$i++)
{
setAttr ("pointy"+$i+".emitSpecular") 0;
}
}

proc aemitSoff()
{
int $numlight=`intSliderGrp -q -v numaSlider`;
for($i=1;$i<=$numlight;$i++)
{
setAttr ("areay"+$i+".emitSpecular") 0;
}
}

proc scalearea()
{
int $numlight=`intSliderGrp -q -v numaSlider`;
float $scal=`floatSliderGrp -q -v saSlider`;
for($i=1;$i<=$numlight;$i++)
{
setAttr ("areay"+$i+".scale") $scal $scal $scal;
}
}

proc linecolor()
{
int $numlight=`intSliderGrp -q -v numlSlider`;
float $color[]=`colorSliderGrp -q -rgb lineSlider`;
for($i=1;$i<=$numlight;$i++)
{
setAttr ("linepointShape"+$i+".colorR") $color[0];
setAttr ("linepointShape"+$i+".colorG") $color[1];
setAttr ("linepointShape"+$i+".colorB") $color[2];
}
}

proc pointcolor()
{
int $numlight=`intSliderGrp -q -v numpSlider`;
float $color[]=`colorSliderGrp -q -rgb pointSlider`;
for($i=1;$i<=$numlight;$i++)
{
setAttr ("pointyShape"+$i+".colorR") $color[0];
setAttr ("pointyShape"+$i+".colorG") $color[1];
setAttr ("pointyShape"+$i+".colorB") $color[2];
}
}

proc areacolor()
{
int $numlight=`intSliderGrp -q -v numaSlider`;
float $color[]=`colorSliderGrp -q -rgb areaSlider`;
//print $color;
for($i=1;$i<=$numlight;$i++)
{
setAttr ("areayShape"+$i+".colorR") $color[0];
setAttr ("areayShape"+$i+".colorG") $color[1];
setAttr ("areayShape"+$i+".colorB") $color[2];
}
}

proc depthon()
{
string $sel[]=`ls -sl`;
int $numlight=size($sel);
for($i=0;$i<$numlight;$i++)
{
setAttr ($sel[$i]+".useDepthMapShadows") 1;
}
}

proc depthoff()
{
string $sel[]=`ls -sl`;
int $numlight=size($sel);
for($i=0;$i<$numlight;$i++)
{
setAttr ($sel[$i]+".useDepthMapShadows") 0;
}
}

proc dmapresolution()
{
string $sel[]=`ls -sl`;
int $numlight=size($sel);
int $numDmap=`intSliderGrp -q -v dmaprSlider`;
for($i=0;$i<$numlight;$i++)
{
setAttr ($sel[$i]+".dmapResolution") $numDmap;
}
}

proc dmapfilter()
{
string $sel[]=`ls -sl`;
int $numlight=size($sel);
int $numDmap=`intSliderGrp -q -v dmapfSlider`;
for($i=0;$i<$numlight;$i++)
{
setAttr ($sel[$i]+".dmapFilterSize") $numDmap;
}
}

proc shadowcolor()
{
string $sel[]=`ls -sl`;
int $numlight=size($sel);
float $color[]=`colorSliderGrp -q -rgb dcolorSlider`;
for($i=0;$i<$numlight;$i++)
{
setAttr ($sel[$i]+".shadowColor") $color[0] $color[1] $color[2];
}
}

proc selectIntensity()
{
float $int=`floatSliderGrp -q -v siSlider`;
string $sel[]=`ls -sl`;
int $numlight=size($sel);
float $lastint=($int/$numlight);
for($i=0;$i<$numlight;$i++)
{
select -r $sel[$i];
setAttr ($sel[$i]+".intensity") $lastint;
}
select -cl;
for($i=0;$i<$numlight;$i++)
{
select -tgl $sel[$i];
}
}

proc changePercent()
{
float $percent=`floatSliderGrp -q -v percentSlider`;
string $sel[]=`ls -sl`;
int $numlight=size($sel);
float $lastPercent=((100+$percent)/100);
for($i=0;$i<$numlight;$i++)
{
select -r $sel[$i];
float $noChange[];
$noChange[$i]=`getAttr ($sel[$i]+".intensity")` ;
print $noChange[$i];
print "\n" ;
}


for($i=0;$i<$numlight;$i++)
{
select -r $sel[$i];
float $beforeInt=`getAttr ($sel[$i]+".intensity")` ;
setAttr ($sel[$i]+".intensity") ($beforeInt*$lastPercent) ;
}
select -cl;
for($i=0;$i<$numlight;$i++)
{
select -tgl $sel[$i];
}
}

proc selectColor()
{
string $sel[]=`ls -sl`;
int $numlight=size($sel);
float $color[]=`colorSliderGrp -q -rgb scSlider`;
for($i=0;$i<$numlight;$i++)
{
setAttr ($sel[$i]+".colorR") $color[0];
setAttr ($sel[$i]+".colorG") $color[1];
setAttr ($sel[$i]+".colorB") $color[2];
}
}

proc deepon()
{
string $sel[]=`ls -sl`;
int $numlight=size($sel);
for($i=0;$i<$numlight;$i++)
{
setAttr ($sel[$i]+".useDepthMapShadows") 1;
}
intSliderGrp -e -en 1 dmaprSlider;
intSliderGrp -e -en 1 dmapfSlider;
colorSliderGrp -e -en 1 dcolorSlider;
optionMenu -e -en 1 Foption02 ;
menuItem -e -en 1 OffSelection ;
menuItem -e -en 1 OverSelection ;
menuItem -e -en 1 ReuseSelection ;
}

proc deepoff()
{
string $sel[]=`ls -sl`;
int $numlight=size($sel);
for($i=0;$i<$numlight;$i++)
{
setAttr ($sel[$i]+".useDepthMapShadows") 0;
}
intSliderGrp -e -en 0 dmaprSlider;
intSliderGrp -e -en 0 dmapfSlider;
colorSliderGrp -e -en 0 dcolorSlider;
optionMenu -e -en 0 Foption02 ;
menuItem -e -en 0 OffSelection ;
menuItem -e -en 0 OverSelection ;
menuItem -e -en 0 ReuseSelection ;
}

proc sNoDecay()
{
}

proc sLinear()
{
print "afafasd";
}

proc sQuadratic()
{
}

proc sCubic()
{
}

proc DmapSelect()
{

int $value = ` optionMenu -q -sl Foption02 ` ;
if ( $value == 1 )
{
checkBox -e -en 0 SceneName ;
checkBox -e -en 0 LightName ;
checkBox -e -en 0 FrameExt ;
rowColumnLayout -e -en 0 Frow01 ;
text -e -en 0 DmapName ;
textField -e -en 0 DmapNameControl ;
checkBox -e -en 0 SceneName ;
checkBox -e -en 0 LightName ;
checkBox -e -en 0 FrameExt ;
text -e -en 0 DmapUseName ;
textField -e -en 0 DmapUseNameControl ;
checkBox -e -v 1 LightName ;
columnLayout -e -en 0 Foption03 ;
}
else if ( $value == 2 )
{
checkBox -e -en 1 SceneName ;
checkBox -e -en 1 LightName ;
checkBox -e -en 1 FrameExt ;
rowColumnLayout -e -en 1 Frow01 ;
text -e -en 1 DmapName ;
textField -e -en 1 DmapNameControl ;
checkBox -e -en 1 SceneName ;
checkBox -e -en 1 LightName ;
checkBox -e -en 1 FrameExt ;
text -e -en 0 DmapUseName ;
textField -e -en 0 DmapUseNameControl ;
checkBox -e -v 1 LightName ;
columnLayout -e -en 1 Foption03 ;
}
else if ( $value == 3 )
{
checkBox -e -en 1 SceneName ;
checkBox -e -en 1 LightName ;
checkBox -e -en 1 FrameExt ;
rowColumnLayout -e -en 1 Frow01 ;
text -e -en 1 DmapName ;
textField -e -en 1 DmapNameControl ;
checkBox -e -en 1 SceneName ;
checkBox -e -en 1 LightName ;
checkBox -e -en 1 FrameExt ;
text -e -en 1 DmapUseName ;
textField -e -en 1 DmapUseNameControl ;
checkBox -e -v 1 LightName ;
columnLayout -e -en 1 Foption03 ;
}

string $sel[] = ` ls -sl ` ;
int $numlight = size($sel) ;
for( $i=0 ; $i < $numlight ; $i++ )
{
if ( $value == 3 )
{
setAttr ( $sel[$i] + " .reuseDmap " ) 1 ;
setAttr ( $sel[$i] + " .writeDmap " ) 0 ;
}
else if ( $value == 2 )
{
setAttr ( $sel[$i] + " .reuseDmap " ) 0 ;
setAttr ( $sel[$i] + " .writeDmap " ) 1 ;
}
else
{
setAttr ( $sel[$i] + " .reuseDmap " ) 0 ;
setAttr ( $sel[$i] + " .writeDmap " ) 0 ;
}
}

}

proc SceneOn()
{
string $sel[] = ` ls -sl ` ;
int $numlight = size($sel) ;
for( $i=0 ; $i<$numlight ; $i++ )
{
setAttr ( $sel[$i]+".dmapSceneName" ) 1 ;
}
}

proc SceneOff()
{
string $sel[] = ` ls -sl ` ;
int $numlight = size($sel) ;
for( $i=0 ; $i<$numlight ; $i++ )
{
setAttr ( $sel[$i]+".dmapSceneName" ) 0 ;
}
}

proc LightOn()
{
string $sel[] = ` ls -sl ` ;
int $numlight = size($sel) ;
for( $i=0 ; $i<$numlight ; $i++ )
{
setAttr ( $sel[$i]+".dmapLightName" ) 1 ;
}
}

proc LightOff()
{
string $sel[] = ` ls -sl ` ;
int $numlight = size($sel) ;
for( $i=0 ; $i<$numlight ; $i++ )
{
setAttr ( $sel[$i]+".dmapLightName" ) 0 ;
}
}

proc FrameOn()
{
string $sel[] = ` ls -sl ` ;
int $numlight = size($sel) ;
for( $i=0 ; $i<$numlight ; $i++ )
{
setAttr ( $sel[$i]+".dmapFrameExt" ) 1 ;
}
}

proc FrameOff()
{
string $sel[] = ` ls -sl ` ;
int $numlight = size($sel) ;
for( $i=0 ; $i<$numlight ; $i++ )
{
setAttr ( $sel[$i]+".dmapFrameExt" ) 0 ;
}
}

proc changeDmapName()
{
string $newName = ` textField -q -tx DmapNameControl ` ;
string $sel[] = ` ls -sl ` ;
int $numlight = size($sel) ;
for( $i=0 ; $i<$numlight ; $i++ )
{
setAttr -type "string" ( $sel[$i] + " .dmapName " ) $newName ;
}
}

global proc vectlight()
{
string $winname="vector Light2.0";
check ($winname);
window -vis 1 -wh 480 375 $winname;
//scrollLayout ;
tabLayout -vis 1 -w 600 mainwin;

columnLayout -p mainwin -w 600 -h 200 column0;

intSliderGrp -f 1 -l "Number of linelight" -min 1 -max 200 -v 1 numlSlider;
text " *** At First Select One Curve ***";
button -l "Creat lineLight" -w 110 -h 30 -c linelight;

floatSliderGrp -f 1 -l "Intensity of linelight" -min -1 -max 1000 -s 0.001 -v 0 intlSlider;
button -l "Intensity" -w 110 -h 30 -c lineIntensity;

colorSliderGrp -l "linelight color" -rgb 1 1 1 lineSlider;
button -l "Change color" -w 110 -h 30 -c linecolor;

rowLayout -nc 3 -p column0;
text "Emit Diffuse:";
button -l "Diffuse off" -w 90 -h 30 -c lemitDoff;
button -l "Diffuse on" -w 90 -h 30 -c lemitDon;

rowLayout -nc 3 -p column0;
text "Emit Specular:";
button -l "Specular off" -w 90 -h 30 -c lemitSoff;
button -l "Specular on" -w 90 -h 30 -c lemitSon;

rowLayout -nc 3 -p column0;
text "The Decay:";
button -l "No Decay" -w 90 -h 30 -c lnoDecay;
button -l "Linear" -w 90 -h 30 -c llinear;

rowLayout -nc 3 -p column0;
text " ";
button -l "Quadratic" -w 90 -h 30 -c lquadratic;
button -l "Cubic" -w 90 -h 30 -c lcubic;


columnLayout -p mainwin -w 600 -h 200 column1;

text " ";
intSliderGrp -f 1 -l "Number of pointlight" -min 1 -max 500 -v 1 numpSlider;
floatSliderGrp -f 1 -l "PointLight radius" -min 1 -max 5000 -v 1 radpSlider;
button -l "Creat HalfBall PointLight" -w 150 -h 30 -c pointlight1;
button -l "Creat AllBall PointLights" -w 150 -h 30 -c pointlight2;
text "\n";

floatSliderGrp -f 1 -l "Intensity of pointlight" -min -1 -max 1000 -s 0.001 -v 0 -cc pointIntensity intpSlider;
//button -l "Intensity" -w 110 -h 30 -c pointIntensity;
//text "\n";

colorSliderGrp -l "PointLight color" -rgb 1 1 1 -cc pointcolor pointSlider;
//button -l "Change color" -w 110 -h 30 -c pointcolor;

formLayout -p mainwin -vis 1 FORM1;

columnLayout -p FORM1 Fcom1;

rowLayout -nc 3 -p FORM1 Frow11;
text "The Decay:";
button -l "No Decay" -w 90 -h 30 -c pnoDecay;
button -l " Linear " -w 90 -h 30 -c plinear;

rowLayout -nc 4 -p FORM1 Frow12;
text "\t";
button -l "Quadratic" -w 90 -h 30 -c pquadratic;
button -l " Cubic " -w 90 -h 30 -c pcubic;
text "\n";

rowLayout -p FORM1 -nc 4 Frow13;
text "Emit Diffuse: " ;
button -l "Diffuse off" -w 90 -h 30 -c pemitDoff;
button -l "Diffuse on" -w 90 -h 30 -c pemitDon;
text "\n";

rowLayout -p FORM1 -nc 4 Frow14;
text "Emit Specular:";
button -l "Specular off" -w 90 -h 30 -c pemitSoff;
button -l "Specular on" -w 90 -h 30 -c pemitSon;
text "\n";
columnLayout -p FORM1 Fcolumnp11;
intSliderGrp -f 1 -l "point light " iSlider;
button -w 110 -h 30;

formLayout -e -af Fcom1 top 0
-af Fcom1 left 20
-ac Frow13 top 20 Fcom1
-ac Frow14 top 20 Frow13
-ac Frow11 top 20 Frow14
-ac Frow12 top 10 Frow11
-ac Fcolumnp11 top 10 Frow12
FORM1;

columnLayout -p mainwin -w 600 -h 200 column2;

text " ";
intSliderGrp -f 1 -l "Number of arealight" -min 1 -max 500 -v 1 numaSlider;
floatSliderGrp -f 1 -l "AreaLight radius" -min 1 -max 500 -v 1 radaSlider;
button -l "Creat HalfBall AreaLight" -w 150 -h 30 -c " arealight1 " ;
button -l "Creat AllBall AreaLights" -w 150 -h 30 -c " arealight2 " ;

// text "\n" ;
// button -l "Creat HalfBall AreaLight" -w 150 -h 30 -c " directLight1 " ;
// button -l "Creat AllBall AreaLight" -w 150 -h 30 -c " directLight2 " ;
//button -l "Aim AreaLight" -c aimball;
text "\n";

floatSliderGrp -f 1 -l "Intensity of arealight" -min -1 -max 50 -s 0.001 -v 0 -cc areaIntensity intaSlider;
//button -l "Intensity" -w 110 -h 30 -c areaIntensity;
//text "\n";

colorSliderGrp -l "AreaLight color" -rgb 1 1 1 -cc areacolor areaSlider;
//button -l "Change color" -w 110 -h 30 -c areacolor;

formLayout -p mainwin -vis 1 FORM2;
columnLayout -p FORM2 Fcom2;

rowLayout -nc 3 -p FORM2 Frow21;
text "the Decay:";
button -l "no Decay" -w 90 -h 30 -c anoDecay;
button -l " Linear " -w 90 -h 30 -c alinear;

rowLayout -nc 4 -p FORM2 Frow22;
text "\t";
button -l "Quadratic" -w 90 -h 30 -c aquadratic;
button -l " Cubic " -w 90 -h 30 -c acbuic;
text "\n";

rowLayout -nc 4 -p FORM2 Frow23;
text "Emit Diffuse:";
button -l "Diffuse off" -w 90 -h 30 -c aemitDoff;
button -l "Diffuse on " -w 90 -h 30 -c aemitDon;
text "\n";

rowLayout -nc 4 -p FORM2 Frow24;
text "Emit Specular:";
button -l "Specular off" -w 90 -h 30 -c aemitSoff;
button -l "Specular on " -w 90 -h 30 -c aemitSon;
text "\n";

columnLayout -p FORM2 Fcolumn21;
floatSliderGrp -f 1 -l "Scale areaLight" -min 0 -max 10 -s 0.001 -v 1.0 -cc scalearea saSlider;
//button -l "Scale AreaLight" -w 110 -h 30 -c scalearea;

formLayout -e -af Fcom2 top 0
-af Fcom2 left 20
-ac Frow23 top 20 Fcom2
-ac Frow24 top 20 Frow23
-ac Frow21 top 20 Frow24
-ac Frow22 top 10 Frow21
-ac Fcolumn21 top 10 Frow22
FORM2;

formLayout -p mainwin -vis 1 FORM3;
columnLayout -p FORM3 Fcom3;

columnLayout -p FORM3 Fcolumn30;
checkBox -l "DeepMap On/Off" -onc deepon -ofc deepoff -v 0 ;


/*
rowLayout -p FORM3 -nc 4 -cw4 150 100 100 100 Frow31;
text "DeepMap on/off";
button -l "DepthMap On" -w 90 -h 30 -c depthon;
button -l "DepthMap Off" -w 90 -h 30 -c depthoff;
text "\n";
*/

columnLayout -p FORM3 Fcolumn31;
intSliderGrp -f 1 -l "Dmap Resolution" -min 0 -max 8192 -v 512 -en 0 -cc dmapresolution dmaprSlider;
//button -l "DmapResolution" -w 120 -h 30 -c dmapresolution;

columnLayout -p FORM3 Fcolumn32;
intSliderGrp -f 1 -l "Dmap Filter Size" -min 0 -max 50 -v 5 -en 0 -cc dmapfilter dmapfSlider;
//button -l "DmapFilter" -w 120 -h 30 -c dmapfilter;

columnLayout -p FORM3 Fcolumn33;
colorSliderGrp -l "Shadow Color" -rgb 0 0 0 -en 0 -cc shadowcolor dcolorSlider;
//button -l "Change ShadowColor" -c shadowcolor;

columnLayout -p FORM3 Fcolumn34;
text " ";
floatSliderGrp -f 1 -l " Light Intensity:" -min -1 -max 1000 -s 0.001 -v 0 -cc selectIntensity siSlider;
floatSliderGrp -f 1 -l "Intensity Percent:" -min 0 -max 100 -s 0.001 -v 0 -cc changePercent percentSlider;
//button -l "Change Intensity" -w 120 -h 30 -c selectIntensity;
//text "\n" ;

columnLayout -p FORM3 Fcolumn35;
colorSliderGrp -l "Light Color" -rgb 1 1 1 -cc selectColor scSlider;
//button -l "Change Color" -c selectColor;
//text "\n" ;

optionMenu -p FORM3 -l "Decay Rate" Foption01;
menuItem -l "no Decay" -c sNoDecay ;
menuItem -l "Linear" -c sLinear ;
menuItem -l "Quadratic" -c sQuadratic ;
menuItem -l "Cubic" -c sCubic ;

optionMenu -p FORM3 -l " Disk Based Dmaps " -en 0 -cc DmapSelect Foption02 ;
menuItem -l " Off " -en 0 OffSelection ;
menuItem -l " Overwrite Existing Dmap(s) " -en 0 OverSelection ;
menuItem -l " Reuse Existing Dmap(s) " -en 0 ReuseSelection ;

rowColumnLayout -p FORM3 -nc 2 -cat 1 "right" 0 -cw 1 100 -cw 2 250 -en 0 Frow01 ;
text -l " Dmap Name " -en 0 DmapName ;
textField -en 0 -cc changeDmapName DmapNameControl ;

columnLayout -p FORM3 -en 0 Foption03 ;
checkBox -l " Dmap Scene Name " -en 0 -v 0 -onc SceneOn -ofc SceneOff SceneName ;
checkBox -l " Dmap Light Name " -en 0 -v 1 -onc LightOn -ofc LightOff LightName ;
checkBox -l " Dmap Frame Ext " -en 0 -v 0 -onc FrameOn -ofc FrameOff FrameExt ;


rowColumnLayout -p FORM3 -nc 2 -cat 1 "right" 0 -cw 1 100 -cw 2 250 -en 0 Frow02 ;
text -l " dmap Use Macro " -en 0 DmapUseName ;
textField -en 0 DmapUseNameControl ;

formLayout -e -af Fcom3 top 0
-af Fcom3 left 20
-ac Fcolumn34 top 0 Fcom3
-ac Fcolumn35 top 0 Fcolumn34
-ac Foption01 top 5 Fcolumn35
-ac Fcolumn30 top 5 Foption01
-ac Fcolumn31 top 0 Fcolumn30
-ac Fcolumn32 top 0 Fcolumn31
-ac Fcolumn33 top 0 Fcolumn32
-ac Foption02 top 5 Fcolumn33
-ac Foption03 top 5 Frow01
-ac Frow01 top 5 Foption02
-ac Frow02 top 5 Foption03
FORM3;

tabLayout -e -tl column0 "LineLight"
-tl column1 "PointLight"
-tl FORM1 "PointControl"
-tl column2 "Area/Direct:Light"
-tl FORM2 "Area/Direct:Control"
-tl FORM3 "Control Select"
mainwin;
showWindow ;
}
vectlight ;

以下是應用說明:
該工具組有兩個工具,一個是"lineLight.mel"一個是"matrixlight.mel",分別對應的是
"管道燈光"和"矩陣燈光"工具.其中"matrixlight2.0.mel"是一個集合了以上兩種工具的綜合
性燈光工具.可以針對管道及矩陣燈光的不同應用及各自常用的屬性進行集體調整.

應用:
運行該工具後,會產生一個分為多個模塊的窗口,分別是"管道燈光","矩陣點光源","矩陣
點光源控制","矩陣面片光","矩陣面片光控制"和"選擇光源的陰影控制".

"管道燈光"模塊:
在場景內選擇一條曲線,確定要生成的燈光數目並填入"Number of lin
elight"內,按"Creat lineLight"按鍵即生成要求數目的點光源於選擇的曲線
上並均勻放置;確定想要的整體燈光強度並輸入"Intensity of linelight"內,
按"Intensity"按鍵即可將該強度值平均分配給該管道內的所有燈光;更改"line
light color"中的顏色,按"change color"按鍵即可更改該管道內的所有燈光
光源的顏色設置;下邊的那些按鍵則分別對應的是該管道燈光的"Emit Diffuse"
"Emit Specular"和"Decay"屬性;

"點光源矩陣"模塊:
在場景內按用戶給定的"number of pointlight"值和"pointlight
radius"值生成指定的半球狀或全球狀點光源矩陣,並可以更改該矩陣中所有燈光
光源總的"Intensity of pointlight"值及該矩陣中各燈光光源的"pointlight
color"屬性;

"點光源控制"模塊:
是針對上一模塊所產生的所有點光源矩陣中的各點光源的"Emit Diffuse"
"Emit Specular"及"Decay"屬性的設置;

"面片光源"模塊:
在場景內按用戶給定的"number of arealight"值和"arealight radius"
值生成指定的半球狀或全球狀面片光源矩陣,並可以更改該矩陣中所有面片光源總的
"Intensity of arealight"值及該矩陣中各面片光源的"arealight color"屬
性;

"面片光控制"模塊:
是針對上一模塊所產生的所有面片光源矩陣中的各面片光源的"Emit Diff
use""Emit Specular"及"Decay"屬性的設置,並且可以通過更改"Scale arealight"
的值進行各面片光源的體積的更改.

"控制"模塊:
是針對場景內用戶所選擇的所有燈光的"DeepMap Shadow"屬性的一些常用設置的
功能模塊,可以對場景內用戶所選擇的燈光的"DeepMap"的開關屬性進行打開和關閉,
並可通過更改"Dmap resolution"值來更改渲染的精度,通過更改" Dmap filter size"
值來設置陰影的虛化問題,通過更改"Shadow color"的顏色設置來更改陰影的顏色設置.

*注意:
除了控制模塊外,其它功能模塊均只能在不關閉該窗口的動作狀態下更改場景內的各自控制燈
光的各種屬性.即在生成各種功能模塊下的對應燈光後,盡可能的將所能更改的模塊下參數在生
成的同時進行調整或不關閉該程序窗口,可以隨時進行調整.而當關閉該窗口後想再次更改某模
塊下的功能模塊所設定的各屬性,只能通過其它方法來更改了.
在兩個矩陣模塊下生成矩陣燈光時,半球狀或全球狀只能生成其中的一種,即在場景內不可同時
生成某種燈光的不同矩陣形式,並且各模塊下生成的燈光均在MAYA中進行成組操作了,不用再對
其的選擇及查找頭痛了.

阿春

* 由於這是以前為公司寫的一段MEL, 有些功能還沒有完善, 希望各位朋友多多包含. 呵呵. *
最後由 阿春 於 16日 2月 2005年, 02:22 編輯,總共編輯了 2 次。
MAYA 是我的最愛, MEL是我的方向, 特技效果是我的希望.
阿春
討論區新秀
討論區新秀
 
文章: 25
註冊時間: 28日 9月 2002年, 14:04
來自: china

Share On:

Share on Facebook Facebook Share on Twitter Twitter

文章badBoy » 16日 2月 2005年, 02:21

謝謝分享 :mrgreen:
badBoy
CGV討論區會員
CGV討論區會員
 
文章: 142
註冊時間: 13日 8月 2001年, 08:00

文章web_sdas » 16日 2月 2005年, 20:19

多謝分享
本人都有少許progrmme底
但不是善長lighting
你會有effect的mel可以一起研究或分享嗎?
web_sdas
CGV討論區會員
CGV討論區會員
 
文章: 156
註冊時間: 18日 9月 2004年, 12:48
來自: HK

文章阿春 » 17日 2月 2005年, 00:02

有一點關於粒子方面的MEL我也做過, 還有幾個是通過動畫效果來體現群體類似爆炸效果的MEL, 如果大家感興趣,我先發一個通過動畫效果來體現群體無規律動畫的小MEL,大家一起來玩玩, 不過關於應用說明還沒有寫, 朋友先用著看看, 我過幾天再寫一個說明上來.
MAYA 是我的最愛, MEL是我的方向, 特技效果是我的希望.
阿春
討論區新秀
討論區新秀
 
文章: 25
註冊時間: 28日 9月 2002年, 14:04
來自: china

文章阿春 » 17日 2月 2005年, 00:02

global proc timeMask ()
{
int $timeVolue = ` radioButtonGrp -q -sl timeButton ` ;

if( $timeVolue == 1 )
{
floatFieldGrp -e -en 0 startTime ;
floatFieldGrp -e -en 0 endTime ;
}
else if ( $timeVolue == 2 )
{
floatFieldGrp -e -en 1 startTime ;
floatFieldGrp -e -en 0 endTime ;
}
else if ( $timeVolue == 3 )
{
floatFieldGrp -e -en 1 startTime ;
floatFieldGrp -e -en 1 endTime ;
}
}

global proc PanAnimation()
{
float $startFrame , $endFrame ;
float $tempStartFrame[] , $tempEndFrame[] ;
int $timeVolue = ` radioButtonGrp -q -sl timeButton ` ;

if( $timeVolue == 1 )
{
$startFrame = ` playbackOptions -q -min ` ;
$endFrame = ` playbackOptions -q -max ` ;
}
else if ( $timeVolue == 2 )
{
$tempStartFrame = ` floatFieldGrp -q -v startTime ` ;
$endFrame = ` playbackOptions -q -max ` ;
$startFrame = $tempStartFrame[0] ;
}
else if ( $timeVolue == 3 )
{
$tempStartFrame = ` floatFieldGrp -q -v startTime ` ;
$tempEndFrame = ` floatFieldGrp -q -v endTime ` ;
$startFrame = $tempStartFrame[0] ;
$endFrame = $tempEndFrame[0] ;
}

string $selCube[] = ` ls -sl ` ;
int $num = size ( $selCube ) ;
for( $i = 0 ; $i < $num ; $i++ )
{
float $tempStartRandTime[] = ` floatFieldGrp -q -v startRandTime ` ;
float $startRandTime = $tempStartRandTime[0] ;
float $tempEndRandTime[] = ` floatFieldGrp -q -v endRandTime ` ;
float $endRandTime = $tempEndRandTime[0] ;
float $startRandVolue = rand ( $startRandTime ) ;
float $endRandVolue = rand ( $endRandTime ) ;
float $xxx = ` getAttr ( $selCube[$i] + ".tx" ) ` ;
float $yyy = ` getAttr ( $selCube[$i] + ".ty" ) ` ;
float $zzz = ` getAttr ( $selCube[$i] + ".tz" ) ` ;
curve -d 1 -name ( "springCurve" + $i ) -p 0 $yyy 0 -p $xxx $yyy $zzz ;
select -r $selCube[$i] ;
select -tgl ( "myCurve" + $i ) ;
pathAnimation -fractionMode false -follow true -followAxis x -upAxis y
-worldUpType "vector" -worldUpVector 0 1 0 -inverseUp false
-inverseFront true -bank false -startTimeU ( $startFrame + $startRandVolue )
-endTimeU ( $endFrame + $endRandVolue ) ;
select -r $selCube[$i] ;
rename ( "spring" + $i ) ;
}
select -cl ;
for( $i = 0 ; $i < $num ; $i++ )
{
select -tgl ( "myCurve" + $i ) ;
}
group -name CurveGroup ;
select -cl ;
select -r CurveGroup ;
HideSelectedObjects;
}

global proc panyangMEL()
{
int $start , $end ;
string $winName = "PanYang" ;
if( ` window -ex ("PanYang") ` )
{
deleteUI PanYang ;
}
window -t " PanYang Animation " -wh 520 300 $winName ;
formLayout MAIN ;

columnLayout -p MAIN TimeLine ;
text " " ;
radioButtonGrp -l " Time Range " -nrb 3 -l1 " Time Slider " -l2 " Start " -l3 " Start/End "
-cc timeMask -sl 1 timeButton ;
floatFieldGrp -l " Start Time " -pre 3 -en $start startTime ;
floatFieldGrp -l " End Time " -pre 3 -en $end endTime ;
floatFieldGrp -l " Start rand Time " -pre 3 -en 1 startRandTime ;
floatFieldGrp -l " End rand Time " -pre 3 -en 1 endRandTime ;
text " " ;
/*
floatSliderGrp -l " Animation Radius :" -min 0 -max 30 -pre 3 Radius ;
floatSliderGrp -l " Sweep Angle Value : " -min 0 -max 360 -pre 3 Sweep ;
*/

button -p MAIN -l " Attach " -w 100 -c PanAnimation buttonOne ;
button -p MAIN -l " Apply " -w 100 buttonTwo ;
button -p MAIN -l " Close " -w 100 -c " deleteUI PanYang " buttonThree ;

formLayout -e -af TimeLine top 5
-af TimeLine left 10
-ac buttonOne top 15 TimeLine
-af buttonOne left 80
-ac buttonTwo left 25 buttonOne
-ac buttonTwo top 15 TimeLine
-ac buttonThree left 25 buttonTwo
-ac buttonThree top 15 TimeLine
MAIN ;

showWindow ;
}

panyangMEL
MAYA 是我的最愛, MEL是我的方向, 特技效果是我的希望.
阿春
討論區新秀
討論區新秀
 
文章: 25
註冊時間: 28日 9月 2002年, 14:04
來自: china

文章阿春 » 17日 2月 2005年, 00:09

簡單說明一下用法, 大概的用MAYA來打開MEL窗口我想我就不用說明了, 當打開這個MEL工具的窗口後, 選擇場景內的想要處理的物體,(當然是越我越好) 然後對啟始時間和動畫最後結束時間進行設定,並把想要對動畫過程中的變量參數定到一定程度, 運行就OK了. 當然這是一個我曾為公司的一個小動畫做的, 有些小小的局限性, 就是只針對Y軸進行動畫過程, 大家可以把原文件中的關於這一點的變量改變一下, 就可以產生多樣性的效果了.
哈哈, 如果還有問題, 我會加以解決的.

哎, 兄弟一直想換換工作, 不知哪有朋友能幫上忙呀. 阿春這裡先謝過這裡的兄弟姐妹了.
MAYA 是我的最愛, MEL是我的方向, 特技效果是我的希望.
阿春
討論區新秀
討論區新秀
 
文章: 25
註冊時間: 28日 9月 2002年, 14:04
來自: china

文章leeho » 25日 2月 2005年, 23:31

:wink: 6.01能用嗎 ?
頭像
leeho
CGV討論區會員
CGV討論區會員
 
文章: 2353
註冊時間: 20日 12月 2001年, 08:00
來自: HONG KONG

文章阿春 » 3日 3月 2005年, 09:07

我還沒有MAYA6.01,不過我想應該可以用的,因為MEL一直是MAYA內部的東東,只要MAYA的構架沒有發生變化,應該就OK,再說這兩個小東東我也沒有加關於識別MAYA版本號的內容進去, 所以我想沒問題的.
MAYA 是我的最愛, MEL是我的方向, 特技效果是我的希望.
阿春
討論區新秀
討論區新秀
 
文章: 25
註冊時間: 28日 9月 2002年, 14:04
來自: china

文章leeho » 3日 3月 2005年, 23:05

:mrgreen: 謝謝 :wink:
頭像
leeho
CGV討論區會員
CGV討論區會員
 
文章: 2353
註冊時間: 20日 12月 2001年, 08:00
來自: HONG KONG

文章3dfactory » 4日 3月 2005年, 07:06

Nice Job! learning some stuff, thank you!
3dfactory
討論區新秀
討論區新秀
 
文章: 44
註冊時間: 17日 1月 2004年, 23:48

文章第零幀 » 13日 3月 2005年, 02:19

謝謝了。哈哈
第零幀
討論區新秀
討論區新秀
 
文章: 36
註冊時間: 13日 3月 2005年, 02:14


回到 Autodesk Maya

誰在線上

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