// =========================================================================== // 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 platonicSolidIcon(int $type) // // returns the icon filename for a given platonic solid type // 0=Dodecahedron, 1=Icosahedron, 2=Octahedron, 3=Tetrahedron // { switch ($type) { case 0: return "polyDodecahedron.png"; case 1: return "polyIcosahedron.png"; case 2: return "polyOctahedron.png"; case 3: return "polyTetrahedron.png"; } return "polyPlatonic.png"; } global proc createPolyPlatonicSolidValues(string $toolName) { string $name = "createPolyPlatonicSolid"; string $parent = (`toolPropertyWindow -q -location` + "|" + $name); setParent $parent; float $rad = `createPolyPlatonicSolidCtx -q -radius $toolName`; float $slen = `createPolyPlatonicSolidCtx -q -sideLength $toolName`; int $type = `createPolyPlatonicSolidCtx -q -solidType $toolName`; int $uvSetting = `createPolyPlatonicSolidCtx -q -createUVs $toolName`; int $createUV = 0; int $normalize = 0; int $preserveAR = 0; int $collective = 0; int $seperate = 0; int $select = 1; if ($uvSetting == 4){ $createUV = 1; $normalize = 1; $collective = 1; $preserveAR = 1; $select = 1; } else if ($uvSetting == 3){ $createUV = 1; $normalize = 1; $collective = 1; $select = 1; } else if ($uvSetting == 2){ $createUV = 1; $normalize = 1; $seperate = 1; $select = 2; } else if ($uvSetting == 1){ $createUV = 1; } int $axis = `createPolyPlatonicSolidCtx -q -axis $toolName`; string $radiusChangeString = "createPolyPlatonicSolidCtx -e -radius #1 " + $toolName + "; " + "changePolyPlatonicRadiusCallBack(\"" + $toolName+ "\", #1 )"; string $sideLengthChangeString = "createPolyPlatonicSolidCtx -e -sideLength #1 " + $toolName + "; " + "changePolyPlatonicEdgeLengthCallBack(\"" + $toolName+ "\", #1 )"; floatSliderGrp -e -v $rad -cc ($radiusChangeString) -dc ($radiusChangeString) createPolyPlatonicSolidRadiusSlider; floatSliderGrp -e -v $slen -cc ($sideLengthChangeString) -dc ($sideLengthChangeString) createPolyPlatonicSolidSideLengthSlider; optionMenuGrp -e -select ($type + 1) -cc ("int $type = `optionMenuGrp -q -select createPolyPlatonicSolidTypeOptionMenuGrp`; createPolyPlatonicSolidCtx -e -i1 `platonicSolidIcon(($type-1))` CreatePolyPlatonicSolidCtx; changeToolIcon; createPolyPlatonicSolidCtx -e -solidType ($type - 1) " + $toolName + "; " + "changePolyPlatonicRadiusCallBack(\"" + $toolName+ "\", " + `floatSliderGrp -q -v createPolyPlatonicSolidRadiusSlider` + ")") createPolyPlatonicSolidTypeOptionMenuGrp; radioButtonGrp -e -sl ($axis + 1) -cc ("changePlatonicSolidAxisSetting(\"" + $toolName+ "\")") createPolyPlatonicSolidAxisRadioButton; checkBoxGrp -e -v1 $createUV -cc1 ("changePlatonicSolidUVSettings(\"" + $toolName+ "\")") createPolyPlatonicSolidCreateUVCheckBox; checkBoxGrp -e -v1 $normalize -cc1 ("changePlatonicSolidUVSettings(\"" + $toolName+ "\")") createPolyPlatonicSolidNormalizeCheckBox; radioButtonGrp -e -sl $select -cc ("changePlatonicSolidUVSettings(\"" + $toolName+ "\")") createPolyPlatonicSolidNormalizeTypeRadioButton; checkBoxGrp -e -v1 $preserveAR -cc1 ("changePlatonicSolidUVSettings(\"" + $toolName+ "\")") createPolyPlatonicSolidPreserveAspectRatioCheckBox; string $icon = platonicSolidIcon($type); createPolyPlatonicSolidCtx -e -i1 $icon CreatePolyPlatonicSolidCtx; string $helpTag= "CreatePolyPlatonicSolidTool"; toolPropertySetCommon $toolName $icon $helpTag; toolPropertySelect $name; changePlatonicSolidUVSettings($toolName); } global proc getPlatonicSolidType(){ global string $gPlatonicSolidType; int $val = (`optionMenuGrp -query -sl createPolyPlatonicSolidTypeOptionMenuGrp`) - 1; if( $val == 0 ) $gPlatonicSolidType = "Dodecahedron"; if( $val == 1 ) $gPlatonicSolidType = "Icosahedron"; if( $val == 2 ) $gPlatonicSolidType = "Octahedron"; if( $val == 3 ) $gPlatonicSolidType = "Tetrahedron"; } global proc changePolyPlatonicRadiusCallBack(string $toolName, float $value){ global float $gDodecahedronRatio; global float $gIcosahedronRatio; global float $octahedronRatio; global float $tetrahedronRatio; global string $gPlatonicSolidType; getPlatonicSolidType(); float $length; if ($gPlatonicSolidType == "Dodecahedron") { $length = $value*$gDodecahedronRatio; } else if($gPlatonicSolidType == "Icosahedron") { $length = $value*$gIcosahedronRatio; } else if($gPlatonicSolidType == "Octahedron") { $length = $value*$octahedronRatio; } else if($gPlatonicSolidType == "Tetrahedron") { $length = $value*$tetrahedronRatio; } floatSliderGrp -edit -value $length createPolyPlatonicSolidSideLengthSlider; string $cmd = "createPolyPlatonicSolidCtx -e -sideLength " + $length + " " + $toolName; eval($cmd); } global proc changePolyPlatonicEdgeLengthCallBack(string $toolName, float $value){ global float $gDodecahedronRatio; global float $gIcosahedronRatio; global float $octahedronRatio; global float $tetrahedronRatio; global string $gPlatonicSolidType; getPlatonicSolidType(); float $radius; if ($gPlatonicSolidType == "Dodecahedron") { $radius = $value/$gDodecahedronRatio; } else if($gPlatonicSolidType == "Icosahedron") { $radius = $value/$gIcosahedronRatio; } else if($gPlatonicSolidType == "Octahedron") { $radius = $value/$octahedronRatio; } else if($gPlatonicSolidType == "Tetrahedron") { $radius = $value/$tetrahedronRatio; } floatSliderGrp -edit -value $radius createPolyPlatonicSolidRadiusSlider; string $cmd = "createPolyPlatonicSolidCtx -e -radius " + $radius + " " + $toolName; eval($cmd); } global proc changePlatonicSolidAxisSetting(string $toolName){ int $axisSetting = 0; if (`radioButtonGrp -exists createPolyPlatonicSolidAxisRadioButton`){ $axisSetting = (`radioButtonGrp -q -sl createPolyPlatonicSolidAxisRadioButton` - 1); } if ($axisSetting < 0){ $axisSetting = 0; } string $cmd = "createPolyPlatonicSolidCtx -e -axis " + $axisSetting + " " + $toolName; eval($cmd); } global proc changePlatonicSolidUVSettings(string $toolName) { int $value = 0; int $createUVVal; int $normalizeVal; int $preserveARVal; int $collectiveVal; int $seperateVal; if (`checkBoxGrp -exists createPolyPlatonicSolidCreateUVCheckBox`){ $createUVVal = `checkBoxGrp -q -v1 createPolyPlatonicSolidCreateUVCheckBox`; } if (`checkBoxGrp -exists createPolyPlatonicSolidNormalizeCheckBox`){ $normalizeVal = `checkBoxGrp -q -v1 createPolyPlatonicSolidNormalizeCheckBox`; } if (`checkBoxGrp -exists createPolyPlatonicSolidPreserveAspectRatioCheckBox`){ $preserveARVal = `checkBoxGrp -q -v1 createPolyPlatonicSolidPreserveAspectRatioCheckBox`; } if (`radioButtonGrp -exists createPolyPlatonicSolidNormalizeTypeRadioButton`){ $collectiveVal = `radioButtonGrp -q -sl createPolyPlatonicSolidNormalizeTypeRadioButton`; $seperateVal = `radioButtonGrp -q -sl createPolyPlatonicSolidNormalizeTypeRadioButton`; } if ($collectiveVal == 1){ $collectiveVal = 1; } else { $collectiveVal = 0; } if ($seperateVal == 2){ $seperateVal = 1; } else { $seperateVal = 0; } if ($createUVVal){ checkBoxGrp -edit -enable true createPolyPlatonicSolidNormalizeCheckBox; if ($normalizeVal){ radioButtonGrp -edit -enable true createPolyPlatonicSolidNormalizeTypeRadioButton; if($collectiveVal){ checkBoxGrp -edit -enable true createPolyPlatonicSolidPreserveAspectRatioCheckBox; } else { checkBoxGrp -edit -enable false createPolyPlatonicSolidPreserveAspectRatioCheckBox; } }else { checkBoxGrp -edit -enable false createPolyPlatonicSolidPreserveAspectRatioCheckBox; radioButtonGrp -edit -enable false createPolyPlatonicSolidNormalizeTypeRadioButton; } }else { checkBoxGrp -edit -enable false createPolyPlatonicSolidNormalizeCheckBox; checkBoxGrp -edit -enable false createPolyPlatonicSolidPreserveAspectRatioCheckBox; radioButtonGrp -edit -enable false createPolyPlatonicSolidNormalizeTypeRadioButton; } if($createUVVal && $normalizeVal && $collectiveVal && $preserveARVal){ $value = 4; } else if($createUVVal && $normalizeVal && $collectiveVal){ $value = 3; } else if ($createUVVal && $normalizeVal){ $value = 2; } else if ($createUVVal){ $value = 1; } string $cmd = ("createPolyPlatonicSolidCtx -edit -cuv " + $value + " " + $toolName); eval($cmd); }