// =========================================================================== // 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 string $gCurvePresets[]; global int $gMaxCustomCurveSize = 8; global int $gCurrCustomIndex = -1; global proc initCurvePreset() { global string $gCurvePresets[]; if (size($gCurvePresets) == 0) { $gCurvePresets = { "0,1,0.12,0.422,0.452,0,1,0", "0,1,0.3,0.5,0.6,0.2,1,0", "0,1,0.5,1,0.5,0,1,0", "0,1,0.503,1,0.741,0,1,0", "0,1,0.753,1,0.709,0,1,0", "0,1,0.547,1,0.834,0.555,1,0", "0,0.5,0.508,0.492,0.506,0,1,0", "0,1,0.273,1,0.772,1,1,1" }; } } global proc makeLargeCurveWidget(string $currCmd, string $currContext, string $falloffName) { if(`window -exists largeCurveWindow`) showWindow largeCurveWindow; else { string $window = `window -title (uiRes("m_falloffUtility.kFalloffWindow")) largeCurveWindow`; string $form = `formLayout -numberOfDivisions 100`; string $curve = `falloffCurve -h 400 -w 400 fLargeCurveWidget`; string $column = `columnLayout`; checkBoxGrp -label1 (uiRes("m_falloffUtility.kSnapToGrid")) -cc ( ("falloffCurve -e -snapToGrid #1 fLargeCurveWidget; checkBoxGrp -e -value1 #1 useSnapToGrid_CBG; falloffCurve -e -snapToGrid #1 " + $falloffName ) ) useSnapToGridL_CBG; button -label (uiRes("m_falloffUtility.kResetCurveButton")) -command (("resetCurve( \"" + $currCmd + "\",\"" + $currContext + "\")")); string $curveString = eval($currCmd + " -q -sculptFalloffCurve " + $currContext ); int $snap = eval("falloffCurve -q -snapToGrid " + $falloffName ); falloffCurve -e -asString $curveString -snapToGrid $snap -cc ( ($currCmd + " -e -sculptFalloffCurve \"#1\" " + $currContext) ) fLargeCurveWidget; int $stgl = `checkBoxGrp -q -value1 useSnapToGrid_CBG`; checkBoxGrp -e -value1 $stgl useSnapToGridL_CBG; formLayout -edit -attachForm $curve "top" 5 -attachForm $curve "left" 5 -attachControl $curve "bottom" 1 $column -attachForm $curve "right" 5 -attachNone $column "top" -attachForm $column "left" 5 -attachForm $column "bottom" 5 -attachForm $column "right" 5 $form; showWindow; } } global proc resetCurve(string $currCmd, string $currContext) { string $resetCurve = "0.0,1.0,0.5,1.0,0.5,0.0,1.0,0.0"; string $texSculpCmd = $currCmd + " -e -sculptFalloffCurve " + "\"" +$resetCurve + "\" " + $currContext; eval($texSculpCmd); if(`falloffCurve -exists fLargeCurveWidget`) { falloffCurve -e -asString $resetCurve fLargeCurveWidget; } } global proc snapToGridChanged(int $bsnap, string $falloffName ) { string $changSnap = "falloffCurve -e -snapToGrid " + $bsnap + " " + $falloffName; eval($changSnap); if(`checkBoxGrp -exists useSnapToGridL_CBG`) { checkBoxGrp -e -value1 $bsnap useSnapToGridL_CBG; } if(`falloffCurve -exists fLargeCurveWidget`) { falloffCurve -e -snapToGrid $bsnap fLargeCurveWidget; } } global proc int customCurveOnClick(string $currCmd, string $currContext, string $curveValue, int $index) { global int $gCurrCustomIndex; int $size = 0; $gCurrCustomIndex = $index ; curveChanged( $currCmd, $currContext, $curveValue); if($gCurrCustomIndex != -1) { updateCustomOptionVar($gCurrCustomIndex,$curveValue); //Mainly for update deleted custom curve. if( $curveValue == " "||$curveValue == " " ) $gCurrCustomIndex = -1; } return $gCurrCustomIndex; } global proc curveChanged(string $currCmd, string $currContext, string $curveValue) { string $texSculpCmd = $currCmd + " -e -sculptFalloffCurve " + "\"" +$curveValue + "\" " + $currContext; eval($texSculpCmd); if(`falloffCurve -exists fLargeCurveWidget`) falloffCurve -e -asString $curveValue fLargeCurveWidget; } //Save one curve to custom curves. global proc int findCustomInsertSlot(string $currCmd) { int $customInsertIndex = -1; //insert positon global int $gCurrCustomIndex; if($gCurrCustomIndex != -1) //If some slot is selected, insert position is the select slot. $customInsertIndex = $gCurrCustomIndex; else { if(`optionVar -exists "optionvarCustomCurves"`) { int $curvesSize = `optionVar -as "optionvarCustomCurves"`; $customInsertIndex = $curvesSize; //Default:previous custom curve widgets all have curves. eg:$curveSize=3,insert position=3. |curve1|curve2|curve3|insert positon| | | | | string $customsArray[] = `optionVar -q "optionvarCustomCurves"`; for($i = 0 ; $i $index, need to replace the old one.|curve1|curve2 &&index|curve3|curve4| |curve6| | | { string $customsArray[] = `optionVar -q "optionvarCustomCurves"`; optionVar -ca "optionvarCustomCurves"; $customsArray[$index] = $value; for($i=0;$i