// =========================================================================== // 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: // defaultDirectionalLight // // Description: // Create a default directional light // // Input Arguments: // None. // // Return Value: // None. // global proc defaultDirectionalLight( float $intensity, float $colorR, float $colorG, float $colorB, string $useShadows, float $shadowColorR, float $shadowColorG, float $shadowColorB, 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 directionalLight`; // setOptionVars(false); $cmd = ("setAttr " + $lightName + ".intensity " + $intensity); eval $cmd; $cmd = ("setAttr " + $lightName + ".colorR " + $colorR); eval $cmd; $cmd = ("setAttr " + $lightName + ".colorG " + $colorG); eval $cmd; $cmd = ("setAttr " + $lightName + ".colorB " + $colorB); eval $cmd; // cant do exclusive, not in directionalLight command!!!!! $cmd = ("setAttr " + $lightName + ".useDepthMapShadows " + $useShadows); eval $cmd; $cmd = ("setAttr " + $lightName + ".shadColorR " + $shadowColorR); eval $cmd; $cmd = ("setAttr " + $lightName + ".shadColorG " + $shadowColorG); eval $cmd; $cmd = ("setAttr " + $lightName + ".shadColorB " + $shadowColorB); eval $cmd; select -r $lightName; objectMoveCommand; if ($interactive){ string $panel = `getPanel -withFocus`; if (`getPanel -typeOf $panel` == "modelPanel"){ select -replace $lightName; lookThroughSelected 0 $panel; // lookThroughSelected makes camera orthographic for directional // light which messes up the fitPanel command so change to a // persp cam string $cameraShape[] = `listRelatives -c -type camera $lightName`; setAttr ($cameraShape[0] + ".orthographic") 0; if (`size $selection`){ select -replace $selection; fitPanel -selected; } else { fitPanel -all; } } else { warning((uiRes("m_defaultDirectionalLight.kNotAModelingPanel"))); } } }