// =========================================================================== // Copyright 2018 Autodesk, Inc. All rights reserved. // // Use of this software is subject to the terms of the Autodesk license // agreement provided at the time of installation or download, or which // otherwise accompanies this software in either electronic or hard copy form. // =========================================================================== // // Procedure Name: // defaultAreaLight // // Description: // create a default area light // // Input Arguments: // None. // // Return Value: // None. // global proc defaultAreaLight( float $intensity, float $colourR, float $colourG, float $colourB, int $decay, int $shadows, float $shadowColourR, float $shadowColourG, float $shadowColourB, int $shadowSamples, int $interactive ) { // get selected objects in case user wants interactive placement // light will be framed on objects string $selection[] = `ls -sl`; string $lightName = `shadingNode -asLight areaLight`; // setOptionVars(false); if (!`optionVar -exists areaLightIntensity`) { optionVar -floatValue areaLightIntensity 1; } if (!`optionVar -exists areaLightColor`) { optionVar -floatValue areaLightColor 1 -floatValueAppend areaLightColor 1 -floatValueAppend areaLightColor 1; } if (!`optionVar -exists areaLightDecay`) { optionVar -intValue areaLightDecay 0; } if (!`optionVar -exists areaLightShadows`) { optionVar -intValue areaLightShadows false; } if (!`optionVar -exists areaLightShadowColor`) { optionVar -floatValue areaLightShadowColor 0 -floatValueAppend areaLightShadowColor 0 -floatValueAppend areaLightShadowColor 0; } if (!`optionVar -exists areaLightInteractivePlacement`) { optionVar -intValue areaLightInteractivePlacement 0; } string $cmd = ("setAttr " + $lightName + ".intensity " + `optionVar -query areaLightIntensity`); eval $cmd; float $rgb[3] = `optionVar -query areaLightColor`; $cmd = ("setAttr " + $lightName + ".colorR " + $rgb[0]); eval $cmd; $cmd = ("setAttr " + $lightName + ".colorG " + $rgb[1]); eval $cmd; $cmd = ("setAttr " + $lightName + ".colorB " + $rgb[2]); eval $cmd; // cant do exclusive, not in areaLight command!!!!! $cmd = ("setAttr " + $lightName + ".decayRate " + `optionVar -query areaLightDecay`); eval $cmd; $cmd = ("setAttr " + $lightName + ".useDepthMapShadows " + `optionVar -query areaLightShadows`); eval $cmd; $rgb = `optionVar -query areaLightShadowColor`; $cmd = ("setAttr " + $lightName + ".shadColorR " + $rgb[0]); eval $cmd; $cmd = ("setAttr " + $lightName + ".shadColorG " + $rgb[1]); eval $cmd; $cmd = ("setAttr " + $lightName + ".shadColorB " + $rgb[2]); eval $cmd; select -r $lightName; objectMoveCommand; if ($interactive){ string $panel = `getPanel -withFocus`; if (`getPanel -typeOf $panel` == "modelPanel"){ select -replace $lightName; lookThroughSelected 0 $panel; if (`size $selection`){ select -replace $selection; fitPanel -selected; } else { fitPanel -all; } } else { warning((uiRes("m_defaultAreaLight.kNotAModelingPanel"))); } } }