jookyboi
10/1/2013 - 11:44 PM

physicalLight2PointLight.mel

//Here is a small script to automate the creation of a point light. It creates a point light with a connected Physical Light. Alternatively it connects a physical Light to the selected Lights.

proc string create_Physical_Light(int $interior){
 string $sel_lights[] = `ls -sl -dag -leaf -lights`;
 string $phyLight = `mrCreateCustomNode -asUtility "" physical_light`;
 string $blackbody;
 
 if ($interior) {
 $blackbody = `mrCreateCustomNode -asUtility "" mib_blackbody`;
 } else {
 $blackbody = `mrCreateCustomNode -asUtility "" mib_cie_d`;
 }
 setAttr ($blackbody+".intensity") 1000;
 connectAttr -force ($blackbody+".outValue") ($phyLight+".color");
 
 if (0 == size ($sel_lights) ){
 $sel_lights[0] = `pointLight`;

}
 
 for ($light in $sel_lights){
 connectAttr -force ($phyLight+".message") ($light+".miLightShader");
 }
 return $phyLight;
}
 
create_Physical_Light(false);