|
首先分别把它们复制到script editor中,然后拖到工具栏中即可。 
//把选择灯光的属性连接起来; //增加控制漫反射跟高光的属性 string $objects[] = `ls -sl`; string $i,$first,$temp; $first=$objects[0]; group; for($i in $objects) { if ($i==$first) {} else { //下行意思:LightConnectAttr("属性名字",$first,$i); //属性名字可以随便改成你所知道的名字 //举例,可以改成shadowRays、rayDepthLimit、castSoftShadows、 //useDepthMapShadows等: //下面四行去掉"//"时候可以连接阴影。 //LightConnectAttr("useDepthMapShadows",$TempName,$tempLight[0]); //LightConnectAttr("dmapResolution",$TempName,$tempLight[0]); //LightConnectAttr("dmapFilterSize",$TempName,$tempLight[0]); //LightConnectAttr("dmapBias",$TempName,$tempLight[0]); //下面四行去掉"//"时候可以连接光线跟踪阴影。 //LightConnectAttr("useRayTraceShadows",$TempName,$tempLight[0]); //LightConnectAttr("rayDepthLimit",$TempName,$tempLight[0]); //LightConnectAttr("shadowRays",$TempName,$tempLight[0]); //LightConnectAttr("lightRadius",$TempName,$tempLight[0]); LightConnectAttr("intensity",$first,$i); LightConnectAttr("color",$first,$i); $temp="connectAttr -f "+$first+".lightDiffuse "+$i+".emitDiffuse"; eval($temp); $temp="connectAttr -f "+$first+".lightSpecular "+$i+".emitSpecular"; eval($temp); } }; proc LightConnectAttr(string $AttrLight,string $first,string $i) { $temp="connectAttr -f "+$first+"."+$AttrLight+" "+$i+"."+$AttrLight; eval($temp); } //此功能,你只需要把几个灯光选择了之后,按一下按键,它就会自动把选择的灯光 //连接到第一个选择的灯光的color跟intensity上,也可以自己添加属性,里面的 //解释已经说得很清楚明白 //经过改进后,我已经把它们合成组,而不是连接成父子节点的关系,这样管理 //更加方便,第一个灯光的属性就可以控制了。 
//增加控制漫反射跟高光的属性 //又改进了,可以用光线追踪阴影的版本,如果不需要可以在前面添加"//" //因为太多连接在大型场景中有可能导致maya速度减低 //使用选择点生成灯场;可模拟GI
string $i,$temp,$TempName; string $faces[] = getSelVerts(); int $j=1; for($i in $faces) {
float $point[]=`pointPosition $i`;
defaultPointLight(1, 1,1,1, 0, 0, 0,0,0, 1); move -r $point[0] $point[1] $point[2];
string $tempLight[]=`ls -sl`;
if($j==1) { $TempName=$tempLight[0]; } else {
//下面四行去掉"//"时候可以连接阴影。 LightConnectAttr("useDepthMapShadows",$TempName,$tempLight[0]); LightConnectAttr("dmapResolution",$TempName,$tempLight[0]); LightConnectAttr("dmapFilterSize",$TempName,$tempLight[0]); LightConnectAttr("dmapBias",$TempName,$tempLight[0]);
//下面四行去掉"//"时候可以连接光线跟踪阴影。 LightConnectAttr("useRayTraceShadows",$TempName,$tempLight[0]); LightConnectAttr("rayDepthLimit",$TempName,$tempLight[0]); LightConnectAttr("shadowRays",$TempName,$tempLight[0]); LightConnectAttr("lightRadius",$TempName,$tempLight[0]);
//示范:LightConnectAttr("属性名字",$first,$i); //属性名字可以随便改成你所知道的名字
LightConnectAttr("intensity",$TempName,$tempLight[0]);
LightConnectAttr("color",$TempName,$tempLight[0]);
$temp="connectAttr -f "+$TempName+".lightDiffuse "+$tempLight[0]+".emitDiffuse"; eval($temp);
$temp="connectAttr -f "+$TempName+".lightSpecular "+$tempLight[0]+".emitSpecular"; eval($temp);
$temp="parent "+$tempLight[0]+" "+$TempName; eval($temp); };
$j+=1;
};
proc string[] getSelVerts(){
return `filterExpand -ex true -sm 31`; };
proc LightConnectAttr(string $AttrLight,string $TempName,string $tempLight) { $temp="connectAttr -f "+$TempName+"."+$AttrLight+" "+$tempLight+"."+$AttrLight; eval($temp); };
//此功能需要使用poly才行,而且一定要选择点它才能工作,它会自动在选择点的位置生成。 //灯光,而且会自动把第一个灯光设置成父对像,同时还把color跟intensity连到第一个灯。 //光上。
//它的用途嘛,多种多样,你可以用“平板”生成平面的点,也可以圆形生成“天”跟“地”。 //分别控制,还可以在装修图里分区域分布,不过控制它们亮度是需要计算的。
//你最好先用一个灯打好亮度,然后隐藏,再生成灯光组。 //灯光组的亮度=你需要的亮度/灯光数。 
上面代码改进过了,测试了一下,效果如图,像GI吧。 
它使用得好的话,完全可以代替GI_joe,例子。 
如图。 
这是我调节之后的最终效果图。 
.END. 对于在本教程的学习中遇到任何疑问和问题,请到技术论坛讨论。
|