好長時間不來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, 有些功能還沒有完善, 希望各位朋友多多包含. 呵呵. *