Quick and dirty light editor
Eventually we all run across a shot that requires us to have a lot of lights that we want to be able to edit quickly. For myself, it was a downtown street with a slew of street lights. It quickly became tedious to tweak the lights with the attribute editor. This was especially true when I wanted to tinker with the decay rates. You would select a light, open the decay rate pull down, make a selection and repeat over and over – just to find you preferred it better before.
So I quickly wrote some code to create my own simplified attribute spreadsheet:
string $window = `window -title "LightEditor " -widthHeight 600 300`;
paneLayout;
select -r `listTransforms -lights`;
string $activeList = `selectionConnection -activeList`;
spreadSheetEditor -mainListConnection $activeList -ln true -showShapes true ;
showWindow $window;
To fix this we'll make a small proc to make additional values we want keyable visible. Decay rate is unique in that even if made keyable it doesn’t appear so, we'll make a stand in and connect the two.
proc showLightAttributes()
{
string $selection[] = `listTransforms -lights`;
for($obj in $selection)
{
string $shapes[] = `listRelatives -shapes $obj`;
if ( !`objExists ( $shapes[0] +".Decay" )` )
{
addAttr -k true -dv 0 -min 0 -max 3 -at double -ln Decay $shapes[0];
connectAttr ( $obj + ".Decay") ( $obj + ".decayRate");
}
setAttr -k true ( $obj + ".dmapFilterSize");
setAttr -k true ( $obj + ".dmapResolution");
}
}
Now we'll make it easier to execute that code when we need to by making a menu on the light editor. While were at it will add the ablity to reselect all the lights.
The final code:
// SCRIPT: ijLightEditor.mel
// AUTHOR: Ian Jones - mel@shrtcww.com
// DATE: July 29, 2005
// Version: 1.0
//
// DESCRIPTION: Creates a simply mass light editor
//
//
global proc ijLightEditor()
{
string $window = `window -title "LightEditor by Ian Jones" -menuBar true -menuBarVisible true -widthHeight 600 300`;
menu -label "Tools" -tearOff false;
menuItem -label "Re-select Lights" -command ("select -r `listTransforms -lights`");
menuItem -label "Show Light Attributes" -command ("showLightAttributes");
paneLayout;
select -r `listTransforms -lights`;
string $activeList = `selectionConnection -activeList`;
spreadSheetEditor -mainListConnection $activeList -ln true -showShapes true ;
showWindow $window;
}
global proc showLightAttributes()
{
string $selection[] = `listTransforms -lights`;
for($obj in $selection)
{
string $shapes[] = `listRelatives -shapes $obj`;
if ( !`objExists ( $shapes[0] +".Decay" )` )
{
addAttr -k true -dv 0 -min 0 -max 3 -at double -ln Decay $shapes[0];
connectAttr ( $obj + ".Decay") ( $obj + ".decayRate");
}
setAttr -k true ( $obj + ".dmapFilterSize");
setAttr -k true ( $obj + ".dmapResolution");
}
}

0 Comments:
Post a Comment
Links to this post:
Create a Link
<< Home