// =========================================================================== // 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. // =========================================================================== global proc string[] meshSculptToolModes() { string $modes[] = { "Sculpt", "Smooth", "Grab", "Pinch", "Flatten", "Foamy", "Spray", "Repeat", "Imprint", "Wax", "Scrape", "Fill", "Knife", "Smear", "Bulge", "Amplify", "Freeze", "UV", "Relax", "Erase", "Mask", "SmoothTarget", "Clone" }; return $modes; } global proc setMeshSculptToolOptVars( string $tool, int $forceSet ) { // Create an option var for each brush mode we want to save. // Store the per-mode settings inside each option var. // Restores the per-mode settings if the option var exists already. if( ! `sculptMeshCacheCtx -exists $tool` ) { return; } string $currentMode = `sculptMeshCacheCtx -q -mode $tool`; string $modes[] = meshSculptToolModes(); int $sz = size($modes); int $i = 0; for($i = 0; $i < $sz; ++$i) { string $optVarName = "mesh" + $modes[$i] + "ToolSettings" ; if( !`optionVar -exists $optVarName` || $forceSet ) { sculptMeshCacheCtx -e -mode $modes[$i] $tool; float $strength = `sculptMeshCacheCtx -q -strength $tool`; float $size = `sculptMeshCacheCtx -q -size $tool`; int $direction = `sculptMeshCacheCtx -q -direction $tool`; int $useStampDist = `sculptMeshCacheCtx -q -useStampDistance $tool`; float $stampDist = `sculptMeshCacheCtx -q -stampDistance $tool`; int $inverted = `sculptMeshCacheCtx -q -inverted $tool`; float $minStrength = `sculptMeshCacheCtx -q -minStrength $tool`; float $minSize = `sculptMeshCacheCtx -q -minSize $tool`; int $useGlobalSize = `sculptMeshCacheCtx -q -useGlobalSize $tool`; int $useSteadyStroke = `sculptMeshCacheCtx -q -useSteadyStroke $tool`; float $steadyStrokeDist = `sculptMeshCacheCtx -q -steadyStrokeDistance $tool`; int $useStampImage = `sculptMeshCacheCtx -q -useStampImage $tool`; int $stampOrient = `sculptMeshCacheCtx -q -stampOrientToStroke $tool`; string $stampFile = `sculptMeshCacheCtx -q -stampFile $tool`; int $sfx = `sculptMeshCacheCtx -q -stampFlipX $tool`; int $sfy = `sculptMeshCacheCtx -q -stampFlipY $tool`; float $srot = `sculptMeshCacheCtx -q -stampRotation $tool`; int $srand = `sculptMeshCacheCtx -q -stampRandomization $tool`; int $srfx = `sculptMeshCacheCtx -q -stampRandomizeFlipX $tool`; int $srfy = `sculptMeshCacheCtx -q -stampRandomizeFlipY $tool`; float $srr = `sculptMeshCacheCtx -q -stampRandomizeRotation $tool`; float $srsc = `sculptMeshCacheCtx -q -stampRandomizeScale $tool`; float $srpx = `sculptMeshCacheCtx -q -stampRandomizePosX $tool`; float $srpy = `sculptMeshCacheCtx -q -stampRandomizePosY $tool`; float $srstr = `sculptMeshCacheCtx -q -stampRandomizeStrength $tool`; int $splac = `sculptMeshCacheCtx -q -stampPlacement $tool`; float $bur = `sculptMeshCacheCtx -q -buildUpRate $tool`; int $useScreenSpace = `sculptMeshCacheCtx -q -useScreenSpace $tool`; int $lockShellBorder = `sculptMeshCacheCtx -q -lockShellBorder $tool`; int $falloff = `sculptMeshCacheCtx -q -falloffType $tool`; string $falloffCurve = `sculptMeshCacheCtx -q -sculptFalloffCurve $tool`; int $twist = `sculptMeshCacheCtx -q -grabTwist $tool`; int $gsil = `sculptMeshCacheCtx -q -grabSilhouette $tool`; int $gfp = `sculptMeshCacheCtx -q -grabFollowPath $tool`; int $cts = `sculptMeshCacheCtx -q -constrainToSurface $tool`; int $upl = `sculptMeshCacheCtx -q -updatePlane $tool`; int $wst = `sculptMeshCacheCtx -q -wholeStroke $tool`; int $dw = `sculptMeshCacheCtx -q -displayWireframe $tool`; int $df = `sculptMeshCacheCtx -q -displayFrozen $tool`; int $dm = `sculptMeshCacheCtx -q -displayMask $tool`; int $aal = `sculptMeshCacheCtx -q -affectAllLayers $tool`; float $wfa = `sculptMeshCacheCtx -q -wireframeAlpha $tool`; float $color[] = `sculptMeshCacheCtx -q -wireframeColor $tool`; string $optVarValue = "-strength " + $strength + " -size " + $size + " -direction " + $direction + " -minSize " + $minSize + " -minStrength " + $minStrength + " -useStampDistance " + $useStampDist + " -stampDistance " + $stampDist + " -inverted " + $inverted + " -useGlobalSize " + $useGlobalSize + " -useSteadyStroke " + $useSteadyStroke + " -steadyStrokeDistance " + $steadyStrokeDist + " -useStampImage " + $useStampImage + " -stampOrientToStroke " + $stampOrient + " -stampFile \"" + $stampFile + "\"" + " -stampFlipX " + $sfx + " -stampFlipY " + $sfy + " -stampRotation " + $srot + " -stampRandomization " + $srand + " -stampRandomizeRotation " + $srr + " -stampRandomizeScale " + $srsc + " -stampRandomizePosX " + $srpx + " -stampRandomizePosY " + $srpy + " -stampRandomizeStrength " + $srstr + " -stampRandomizeFlipX " + $srfx + " -stampRandomizeFlipY " + $srfy + " -stampPlacement " + $splac + " -buildUpRate " + $bur + " -useScreenSpace " + $useScreenSpace + " -affectAllLayers " + $aal + " -grabTwist " + $twist + " -grabSilhouette " + $gsil + " -grabFollowPath " + $gfp + " -constrainToSurface " + $cts + " -updatePlane " + $upl + " -wholeStroke " + $wst + " -lockShellBorder " + $lockShellBorder + " -falloffType " + $falloff + " -displayWireframe " + $dw + " -displayFrozen " + $df + " -displayMask " + $dm + " -wireframeAlpha " + $wfa + " -sculptFalloffCurve \"" + $falloffCurve + "\"" + " -wireframeColor " + $color[0] + " " + $color[1] + " " + $color[2]; optionVar -stringValue $optVarName $optVarValue; } else { string $optVarValue = `optionVar -q $optVarName`; sculptMeshCacheCtx -e -mode $modes[$i] $tool; string $str = "sculptMeshCacheCtx -e " + $optVarValue + " " + $tool; eval( $str ); } } sculptMeshCacheCtx -e -mode $currentMode $tool; } global proc initMeshSculptTool() { string $tool = "sculptMeshCacheContext"; rememberCtxSettings `sculptMeshCacheCtx $tool`; string $curvesArray[]; if ( `optionVar -exists "optionvarCustomCurves"` ) { $curvesArray = `optionVar -q "optionvarCustomCurves"`; } string $modes[] = meshSculptToolModes(); // for each brush, // set all of the brush settings to their initial values. int $sz = size($modes); int $i = 0; for($i = 0; $i < $sz; ++$i) { sculptMeshCacheCtx -e -mode $modes[ $i ] $tool; sculptMeshCacheValues_ResetTool $tool ; } // Now, load the brush values from their option vars, if they exist setMeshSculptToolOptVars( $tool, false ); if ( `optionVar -exists "optionvarCustomCurves"` ) { optionVar -ca "optionvarCustomCurves"; for($i = 0; $i < size($curvesArray); $i++) { optionVar -sva "optionvarCustomCurves" $curvesArray[$i]; } } } global proc setMeshSculptTool (string $brush) { string $tool = "sculptMeshCacheContext"; if( ! `sculptMeshCacheCtx -exists $tool` ) initMeshSculptTool(); sculptMeshCacheCtx -e -mode $brush -i1 $brush $tool; if( `currentCtx` != $tool ) { setToolTo $tool; } } global proc sculptMeshUnFreeze() { string $scMode = `sculptMeshCacheCtx -q -mode sculptMeshCacheContext`; sculptMeshCacheCtx -e -mode "Freeze" -flood 0.0 sculptMeshCacheContext; sculptMeshCacheCtx -e -mode $scMode sculptMeshCacheContext; } global proc sculptMeshInvertFreeze() { string $scMode = `sculptMeshCacheCtx -q -mode sculptMeshCacheContext`; sculptMeshCacheCtx -e -mode "Freeze" -flood -1.0 sculptMeshCacheContext; sculptMeshCacheCtx -e -mode $scMode sculptMeshCacheContext; } global proc sculptMeshFlood() { float $strength = (`floatSliderGrp -q -value sculptMeshFalloffStrength_FSG`); sculptMeshCacheCtx -e -flood $strength `currentCtx`; } global proc sculptMeshUnmaskAll() { sculptMeshCacheCtx -e -flood 0 `currentCtx`; } global proc sculptMeshInvertMask() { sculptMeshCacheCtx -e -flood -1 `currentCtx`; }