// =========================================================================== // 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. // =========================================================================== // // // Creation Date: 2000 // // // // // // setStampDensity (float $stampDensity) // // // None. // // // Sets the stamp density for selected paint effects strokes while // automatically adjusting the brush transparency so that the // opacity of the stroke stays constant. This will only have // an effect for paint effects brushes with a "paint" brushtype. // Higher stamp densities can look smoother, while lower values // will render faster. // // // float $stampDensity The new brush stamp density value. // // // setStampDensity 1.5; // // global proc setStampDensity( float $stampDensity ) { string $selected[] = getSelectedBrushes(); string $sel; float $oldStampDensity, $expn; float $transp1R, $transp1G, $transp1B; float $transp2R, $transp2G, $transp2B; float $incand, $oldT, $newT; string $param; if( size( $selected ) <= 0 ) { warning( (uiRes("m_setStampDensity.kNoBrushesSelected"))); return; } for( $sel in $selected ) { $oldStampDensity = `getAttr ($sel + ".stampDensity")`; $transp1R = `getAttr ($sel + ".transparency1R")`; $transp1G = `getAttr ($sel + ".transparency1G")`; $transp1B = `getAttr ($sel + ".transparency1B")`; $transp2R = `getAttr ($sel + ".transparency2R")`; $transp2G = `getAttr ($sel + ".transparency2G")`; $transp2B = `getAttr ($sel + ".transparency2B")`; if( $oldStampDensity > 0 && $stampDensity > 0 ) { $stampRatio = $oldStampDensity/$stampDensity; float $oldT1R = $transp1R; float $oldT1G = $transp1G; float $oldT1B = $transp1B; float $oldT2R = $transp2R; float $oldT2G = $transp2G; float $oldT2B = $transp2B; $transp1R = pow( $transp1R, $stampRatio ); $transp1G = pow( $transp1G, $stampRatio ); $transp1B = pow( $transp1B, $stampRatio ); $transp2R = pow( $transp2R, $stampRatio ); $transp2G = pow( $transp2G, $stampRatio ); $transp2B = pow( $transp2B, $stampRatio ); $oldT = $oldT1R; $newT = $transp1R; $param = ($sel + ".incandescence1R"); if( $oldT != 1 ) { $incand = getAttr( $param ) * (1-$newT)/(1-$oldT); setAttr $param $incand; } $oldT = $oldT1G; $newT = $transp1G; $param = ($sel + ".incandescence1G"); if( $oldT != 1 ) { $incand = getAttr( $param ) * (1-$newT)/(1-$oldT); setAttr $param $incand; } $oldT = $oldT1B; $newT = $transp1B; $param = ($sel + ".incandescence1B"); if( $oldT != 1 ) { $incand = getAttr( $param ) * (1-$newT)/(1-$oldT); setAttr $param $incand; } $oldT = $oldT2R; $newT = $transp2R; $param = ($sel + ".incandescence2R"); if( $oldT != 1 ) { $incand = getAttr( $param ) * (1-$newT)/(1-$oldT); setAttr $param $incand; } $oldT = $oldT2G; $newT = $transp2G; $param = ($sel + ".incandescence2G"); if( $oldT != 1 ) { $incand = getAttr( $param ) * (1-$newT)/(1-$oldT); setAttr $param $incand; } $oldT = $oldT2B; $newT = $transp2B; $param = ($sel + ".incandescence2B"); if( $oldT != 1 ) { $incand = getAttr( $param ) * (1-$newT)/(1-$oldT); setAttr $param $incand; } } setAttr ($sel + ".stampDensity") $stampDensity; setAttr ($sel + ".transparency1R") $transp1R; setAttr ($sel + ".transparency1G") $transp1G; setAttr ($sel + ".transparency1B") $transp1B; setAttr ($sel + ".transparency2R") $transp2R; setAttr ($sel + ".transparency2G") $transp2G; setAttr ($sel + ".transparency2B") $transp2B; } }