// =========================================================================== // 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. // =========================================================================== // // provided at the time of installation or download, or which otherwise accompanies // // UV Size Assignment Editor procedures // global proc ilrUVSizeAssignmentEditor() { // Make sure the default nodes exists // ilrDefaultNodes(); // Remove any existing UI to avoid duplicate element names // if(`window -query -exists ilrUVSAMainWindow`) { deleteUI ilrUVSAMainWindow; } string $layerName = ilrGetCurrentBakeLayer(); string $shapes[] = `sets -query $layerName`; for ($s in $shapes) { ilrBakeAttributes(1, $s); } // Build the UI // string $oldParent = `setParent -query`; setUITemplate -pushTemplate attributeEditorTemplate; //-resizeToFitChildren true string $editor = `window -title "Turtle UV Size Assignment Editor" -widthHeight 320 500 -resizeToFitChildren false ilrUVSAMainWindow`; setParent $editor; paneLayout -configuration "horizontal2" -paneSize 1 100 50 -paneSize 2 100 50; string $activeList = `selectionConnection -parent $editor -object $layerName ilrBakeLayerSelection`; spreadSheetEditor -mainListConnection $activeList -ko false -fal {"ilrBakeResX","ilrBakeResY","ilrBakeResOverride","ilrBakeScale"}; tabLayout -tabsVisible 0 -scrollable 1 -innerMarginWidth 5 -innerMarginHeight 5; columnLayout -adjustableColumn true -rowSpacing 10; text -label "Resolution Settings" -align "left" -font "boldLabelFont"; rowLayout -numberOfColumns 3 -columnWidth3 170 170 180 -columnAttach3 "both" "both" "both" -columnOffset3 3 3 3 -columnAlign3 "center" "center" "center"; checkBox -label "Create Power of 2 Textures" -align "left" ilrCheckPower2; connectControl ilrCheckPower2 TurtleUIOptions.uvsaPower2; checkBox -label "Create Quadratic Textures" -align "left" ilrCheckQuadratic; connectControl ilrCheckQuadratic TurtleUIOptions.uvsaQuadratic; setParent ..; intFieldGrp -numberOfFields 2 -cw 1 90 -columnAlign3 left left left -label "Min Resolution:" ilrUVMin; connectControl -index 2 ilrUVMin TurtleUIOptions.uvsaMinResX; connectControl -index 3 ilrUVMin TurtleUIOptions.uvsaMinResY; intFieldGrp -numberOfFields 2 -cw 1 90 -columnAlign3 left left left -label "Max Resolution:" ilrUVMax; connectControl -index 2 ilrUVMax TurtleUIOptions.uvsaMaxResX; connectControl -index 3 ilrUVMax TurtleUIOptions.uvsaMaxResY; button -label "Compute Scale and Texture Sizes" -c "ilrUVSACallback"; separator; text -label "Shared UV-set" -align "left" -font "boldLabelFont"; floatSliderGrp -label "UV Padding" -field true -minValue 0.0 -maxValue 1.0 -fieldMinValue 0.0 -fieldMaxValue 1.0 -cal 1 left -precision 3 ilrUVPadding; connectControl ilrUVPadding TurtleUIOptions.uvsaUvPadding; float $padding = `getAttr TurtleUIOptions.uvsaUvPadding`; button -label "Compute Shared UV-set" -c "ilrSharedUVCallback"; setParent ..; setParent ..; setParent ..; setParent ..; setUITemplate -popTemplate; showWindow $editor; setParent $oldParent; } global proc ilrCloseUVSizeAssignmentEditor() { if(`window -query -exists ilrUVSAMainWindow`) { deleteUI ilrUVSAMainWindow; } } global proc int ilrUVSACallback() { // // Create the shared uv command // string $cmd = "ilrUVSACmd"; $cmd += " -bakelayer \"" + ilrGetCurrentBakeLayer() + "\""; $cmd += " -minx " + `getAttr TurtleUIOptions.uvsaMinResX`; $cmd += " -miny " + `getAttr TurtleUIOptions.uvsaMinResY`; $cmd += " -maxx " + `getAttr TurtleUIOptions.uvsaMaxResX`; $cmd += " -maxy " + `getAttr TurtleUIOptions.uvsaMaxResY`; $cmd += " -quadratic " + `getAttr TurtleUIOptions.uvsaQuadratic`; $cmd += " -powerof2 " + `getAttr TurtleUIOptions.uvsaPower2`; print($cmd + "\n"); // Run command // if ( catch( eval($cmd) ) ) { error("Error computing scale and texture sizes, see script editor for details!"); return 0; } return 1; } global proc int ilrSharedUVCallback() { // // Create the shared uv command // string $cmd = "ilrCreateSharedUVCmd"; $cmd += " -bakelayer \"" + ilrGetCurrentBakeLayer() + "\""; $cmd += " -padding " + `getAttr TurtleUIOptions.uvsaUvPadding`; print($cmd + "\n"); // Run command // if ( catch( eval($cmd) ) ) { error("Error computing shared UV-set, see script editor for details!"); return 0; } return 1; } global proc ilrUpdateUVSA() { if(!`window -query -exists ilrUVSAMainWindow`) { return; } string $oldParent = `setParent -query`; string $layerName = ilrGetCurrentBakeLayer(); string $shapes[] = `sets -query $layerName`; for ($s in $shapes) { ilrBakeAttributes(1, $s); } setParent ilrUVSAMainWindow; selectionConnection -edit -object $layerName ilrBakeLayerSelection; setParent $oldParent; }