// =========================================================================== // 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: Aug 28, 1998 // // // Description: // This implements the Texture UVs on the main menubar. // global proc PolyRequestUVSetName (string $title, string $cmd, string $version, string $args[]) // // Procedure Name: // PolyRequestUVSetName // // Description: // Helper method to ask the user for a new UV set name and then call // a command with the name as the final argument. The command will be // called like: $cmd $version $args "uvSetName" // // Input Arguments: // string $title The title for the dialog box // string $cmd The command to issue // string $version Version to pass onto the command // string $args Arguments to pass onto the command // // Return Value: // None. // { string $ok = (uiRes("m_PolyTextureMenu.kOK")); string $cancel = (uiRes("m_PolyTextureMenu.kCancel")); string $response = `promptDialog -title $title -message (uiRes("m_PolyTextureMenu.kDialogUVSetName")) -text "uvSet" -button $ok -button $cancel -defaultButton $ok -cancelButton $cancel -dismissString $cancel`; if ($response == $ok) { string $name = `promptDialog -query -text`; string $execute = ($cmd + " \"" + $version + "\" {"); string $comma = ""; for ($arg in $args) { $execute += ($comma + "\"" + $arg + "\""); $comma = ", "; } $execute += ("} \"" + $name + "\""); eval ($execute); } } global proc string polygonUVsMenuItemToShelf (string $item) { return $item; } ////////////////////////////////////////////////////////////////////// // // Description: // Polygon UV creation menu // global proc PolygonUVsMenu(string $parent) { if (! `isTrue "PolygonsExists"`) return; PolyTextureMenu $parent 0 "ls -sl"; } global proc PolyTextureMenu (string $parent, int $creator, string $selectCmd) // // Procedure Name: // PolyTextureMenu // // Description: // Helper method to generate the menu items for the texture menus // // Input Arguments: // string $parent The name of the parent widget // int $creator Which creator is calling this // Current known creators // 0 PolygonUVs ( menu bar, was Edit Polygons -> Texture ) // 1 Relationship Editor->Edit->Create UV Set // string $selectCmd The command to issue to determine which objects // to affect // // Return Value: // None. // { setParent -m $parent; if( `menu -query -numberOfItems $parent` != 0 ) { if ($creator != 1) { // Menu already created, just set options menuItem -edit -checkBox `optionVar -query polyCreateShaderWithMapping` toggleCreateShaderItem; } } else { if ($creator != 1) { menuItem -ecr false -cb false -label (uiRes("m_PolyTextureMenu.kAssignShaderToProjection")) -i "polyCheck.png" -dmc "polygonUVsItemToShelf \"togglePolyCreateShaderWithMapping\"" -annotation (uiRes("m_PolyTextureMenu.kAssignShaderToProjectionAnnot")) -c "togglePolyCreateShaderWithMapping" toggleCreateShaderItem; } string $createPlanarMapping = (uiRes("m_PolyTextureMenu.kCreatePlanarMapping")); string $prefix = ($creator == 0 ? "" : ("PolyRequestUVSetName \""+$createPlanarMapping+"\" ") ); string $cmd = $prefix + "performPolyProjectionArgList"; string $version = "\"1\""; string $args0 = ("{\"0\", \"Planar\", \"" + $selectCmd + "\", \"" + ($creator == 1 ? "1" : "0") + "\"}"); string $args1 = ("{\"1\", \"Planar\", \"" + $selectCmd + "\", \"" + ($creator == 1 ? "1" : "0") + "\"}"); string $suffix = ($creator == 0 ? " \"\"" : ""); string $dmc = "performPolyProjectionArgList \"1\" {\"2\", \"Planar\", \"ls -sl\", \"0\"} \"\";"; string $c = ($cmd + " " + $version + " " + $args0 + $suffix); string $planarLabel, $cylindricalLabel, $sphericalLabel; string $createUVSetLabel, $createCameraUVLabel, $unitizeLabel; if ($creator == 1) { $planarLabel = (uiRes("m_PolyTextureMenu.kPlanarMapping1")); $cylindricalLabel = (uiRes("m_PolyTextureMenu.kCylindricalMapping1")); $sphericalLabel = (uiRes("m_PolyTextureMenu.kSphericalMapping1")); $createUVSetLabel = (uiRes("m_PolyTextureMenu.kCreateUVSetLabel1")); $createCameraUVLabel = (uiRes("m_PolyTextureMenu.kCreateCameraUVLabel1")); $unitizeLabel = (uiRes("m_PolyTextureMenu.kUnitizeLabel1")); } else { $planarLabel = (uiRes("m_PolyTextureMenu.kPlanarMapping0")); $cylindricalLabel = (uiRes("m_PolyTextureMenu.kCylindricalMapping0")); $sphericalLabel = (uiRes("m_PolyTextureMenu.kSphericalMapping0")); $createUVSetLabel = (uiRes("m_PolyTextureMenu.kCreateUVSetLabel0")); $createCameraUVLabel = (uiRes("m_PolyTextureMenu.kCreateCameraUVLabel0")); $unitizeLabel = (uiRes("m_PolyTextureMenu.kUnitizeLabel0")); } menuItem -label $planarLabel -ecr true -i "polyPlanProjLarge.png" -dmc $dmc -annotation (uiRes("m_PolyTextureMenu.kPlanarMappingAnnot")) -c $c planarMappingItem; $c = ($cmd + " " + $version + " " + $args1 + $suffix); menuItem -optionBox 1 -i "polyPlanProjLarge.png" -annotation (uiRes("m_PolyTextureMenu.kPlanarMappingOptionAnnot")) -ecr false -c $c planarMappingOptionItem; string $createCylindricalMapping = (uiRes("m_PolyTextureMenu.kCreateCylindricalMapping")); $prefix = ($creator == 0 ? "" : ("PolyRequestUVSetName \""+$createCylindricalMapping+"\" ") ); $cmd = $prefix + "performPolyProjectionArgList"; $version = "\"1\""; $args0 = ("{\"0\", \"Cylindrical\", \"" + $selectCmd + "\", \"" + ($creator == 1 ? "1" : "0") + "\"}"); $args1 = ("{\"1\", \"Cylindrical\", \"" + $selectCmd + "\", \"" + ($creator == 1 ? "1" : "0") + "\"}"); $suffix = ($creator == 0 ? " \"\"" : ""); $dmc = "performPolyProjectionArgList \"1\" {\"2\", \"Cylindrical\", \"ls -sl\", \"0\"} \"\";"; $c = ($cmd + " " + $version + " " + $args0 + $suffix); menuItem -label $cylindricalLabel -ecr true -i "polyCylProjLarge.png" -dmc $dmc -annotation (uiRes("m_PolyTextureMenu.kCylindricalMapping")) -c $c cylindricMappingItem; $c = ($cmd + " " + $version + " " + $args1 + $suffix); menuItem -optionBox 1 -i "polyCylProjLarge.png" -annotation (uiRes("m_PolyTextureMenu.kCylindricalMappingAnnot")) -ecr false -c $c cylindricMappingOptionItem; string $createSphericalMapping = (uiRes("m_PolyTextureMenu.kCreateSphericalMapping")); $prefix = ($creator == 0 ? "" : ("PolyRequestUVSetName \""+$createSphericalMapping+"\" ") ); $cmd = $prefix + "performPolyProjectionArgList"; $version = "\"1\""; $args0 = ("{\"0\", \"Spherical\", \"" + $selectCmd + "\", \"" + ($creator == 1 ? "1" : "0") + "\"}"); $args1 = ("{\"1\", \"Spherical\", \"" + $selectCmd + "\", \"" + ($creator == 1 ? "1" : "0") + "\"}"); $suffix = ($creator == 0 ? " \"\"" : ""); $c = ($cmd + " " + $version + " " + $args0 + $suffix); $dmc = "performPolyProjectionArgList \"1\" {\"2\", \"Spherical\", \"ls -sl\", \"0\"} \"\";"; menuItem -label $sphericalLabel -ecr true -i "polySphereProjLarge.png" -dmc $dmc -annotation (uiRes("m_PolyTextureMenu.kSphericalMapping")) -c $c sphericMappingItem; $c = ($cmd + " " + $version + " " + $args1 + $suffix); menuItem -ob 1 -i "polySphereProjLarge.png" -annotation (uiRes("m_PolyTextureMenu.kSphericalMappingAnnot")) -label (uiRes("m_PolyTextureMenu.kSphericalMappingOption")) -ecr false -c $c sphericMappingOptionItem; menuItem -label (uiRes("m_PolyTextureMenu.kAutomaticMapping")) -annotation (uiRes("m_PolyTextureMenu.kAutomaticMappingAnnot")) -c "performPolyAutoProj 0" -i "polyAutoProjLarge.png" ; menuItem -optionBox 1 -annotation (uiRes("m_PolyTextureMenu.kAutomaticMappingOptionAnnot")) -c "performPolyAutoProj 1" -ecr false -i "polyAutoProjLarge.png"; ////////////////////////////////////////////////////////////////////// menuItem -divider true; string $createEmptyUVSet = (uiRes("m_PolyTextureMenu.kCreateEmptyUVSet")); $prefix = ($creator == 0 ? "" : ("PolyRequestUVSetName \""+$createEmptyUVSet+"\" ") ); $cmd = $prefix + "performCreateUVSet"; $version = "\"1\""; $args0 = ("{\"0\", \"" + $selectCmd + "\", \"" + ($creator == 1 ? "1" : "0") + "\"}"); $args1 = ("{\"1\", \"" + $selectCmd + "\", \"" + ($creator == 1 ? "1" : "0") + "\"}"); $suffix = ($creator == 0 ? " \"\"" : ""); $dmc = "performCreateUVSet \"1\" {\"2\", \"ls -sl\", \"0\"} \"\";"; $c = ($cmd + " " + $version + " " + $args0 + $suffix); menuItem -label $createUVSetLabel -ecr true -i "polyCreateUVSetLarge.png" -dmc $dmc -annotation (uiRes("m_PolyTextureMenu.kCreateUVSet")) -c $c createUVSetItem; if ($creator != 1) { $c = ($cmd + " " + $version + " " + $args1 + $suffix); menuItem -optionBox 1 -i "polyCreateUVSetLarge.png" -annotation (uiRes("m_PolyTextureMenu.kCreateUVSetAnnot")) -ecr false -c $c createUVSetOptionItem; } // Copy UVs to UV set $prefix = "M"; // M is just to ensure a unique name for the menu item string $selectUVSetMenu = `menuItem -label (uiRes("m_PolyTextureMenu.kCopyUVsToUVSet")) -subMenu true -allowOptionBoxes true ($prefix+"CopyUVSets")`; $cmd = "string $menuNames[];" + "buildUVSetMenuNames( $menuNames ); " + "buildUVSetMenu " + $selectUVSetMenu + " $menuNames \"" + $prefix + " \" 1;" + "buildUVSetMenuWithCopyUVsCmd " + $selectUVSetMenu + " $menuNames ;"; menuItem -e -pmc $cmd $selectUVSetMenu; string $copyCurrentUVSet = (uiRes("m_PolyTextureMenu.kCopyCurrentUVSet")); $prefix = ($creator == 0 ? "" : ("PolyRequestUVSetName \""+$copyCurrentUVSet+"\" ") ); $cmd = $prefix + "performCopyCurrentUVSet"; $version = "\"1\""; $args0 = ("{\"0\", \"" + $selectCmd + "\", \"" + ($creator == 1 ? "1" : "0") + "\"}"); $args1 = ("{\"1\", \"" + $selectCmd + "\", \"" + ($creator == 1 ? "1" : "0") + "\"}"); $suffix = ($creator == 0 ? " \"\"" : ""); $dmc = "performCopyCurrentUVSet \"1\" {\"2\", \"ls -sl\", \"0\"} \"\";"; $c = ($cmd + " " + $version + " " + $args0 + $suffix); menuItem -label (uiRes("m_PolyTextureMenu.kCopyIntoNewUVSet")) -ecr true -annotation (uiRes("m_PolyTextureMenu.kCopyIntoNewUVSetAnnot")) -image "polyCopyUVSet.png" -dmc $dmc -c $c copyCurrentUVSet; if ($creator != 1) { $c = ($cmd + " " + $version + " " + $args1 + $suffix); menuItem -optionBox 1 -image "polyCopyUVSet.png" -annotation (uiRes("m_PolyTextureMenu.kCopyIntoNewUVSetOptionAnnot")) -ecr false -c $c copyCurrentUVSetOB; } setParent -m ..; if ($creator != 1) { $cmd = "SetCurrentUVSet"; menuItem -label (uiRes("m_PolyTextureMenu.kSetCurrentUVSet")) -ecr true -i "polySetCurrentUVSet.png" -annotation (getRunTimeCommandAnnotation($cmd)) -c $cmd setCurrentUVSet; $cmd = "RenameCurrentUVSet"; menuItem -label (uiRes("m_PolyTextureMenu.kRenameCurrentUVSet")) -ecr true -i "polyRenameUVSet.png" -annotation (getRunTimeCommandAnnotation($cmd)) -c $cmd renameCurrentUVSet; $cmd = "DeleteCurrentUVSet"; menuItem -label (uiRes("m_PolyTextureMenu.kDeleteCurrentUVSet")) -ecr true -i "polyDeleteUVSet.png" -annotation (getRunTimeCommandAnnotation($cmd)) -dmc "performDeleteCurrentUVSet 2" -c $cmd deleteCurrentUVSet; } ////////////////////////////////////////////////////////////////////// menuItem -divider true; string $createUVsBasedOnCamera = (uiRes("m_PolyTextureMenu.kCreateCameraBasedUVs")); $prefix = ($creator == 0 ? "" : ( "PolyRequestUVSetName \""+$createUVsBasedOnCamera+ "\" ") ); $cmd = $prefix + "performPolyForceUVArgList"; $version = "\"1\""; $args0 = ("{\"0\", \"camera\", \"" + $selectCmd + "\", \"" + ($creator == 1 ? "1" : "0") + "\"}"); $args1 = ("{\"1\", \"camera\", \"" + $selectCmd + "\", \"" + ($creator == 1 ? "1" : "0") + "\"}"); $suffix = ($creator == 0 ? " \"\"" : ""); $dmc = "performPolyForceUVArgList \"1\" {\"2\", \"camera\", \"ls -sl\", \"0\"} \"\";"; $c = ($cmd + " " + $version + " " + $args0 + $suffix); menuItem -label $createCameraUVLabel -ecr true -annotation (uiRes("m_PolyTextureMenu.kCreateUVsBasedOnCamera")) -image "polyCameraUVs.png" -dmc $dmc -c $c cameraProjectionItem; $c = ($cmd + " " + $version + " " + $args1 + $suffix); menuItem -optionBox 1 -annotation (uiRes("m_PolyTextureMenu.kCreateUVsBasedOnCameraOptionAnnot")) -image "polyCameraUVs.png" -ecr false -c $c cameraProjectionOptionItem; if ($creator != 1) { menuItem -label (uiRes("m_PolyTextureMenu.kNormalizeUVs")) -ecr true -annotation ( getRunTimeCommandAnnotation("NormalizeUVs") ) -image "polyNormalizeUVs.png" -dmc "performPolyForceUV normalize 2" -c "NormalizeUVs" normalizeUVItem; menuItem -optionBox 1 -annotation ( getRunTimeCommandAnnotation("NormalizeUVsOptions") ) -image "polyNormalizeUVs.png" -ecr false -c "NormalizeUVsOptions" normalizeUVOptionItem; } string $createUnitizedUVs = (uiRes("m_PolyTextureMenu.kCreateUnitizedUVs")); $prefix = ($creator == 0 ? "" : ( "PolyRequestUVSetName \"" +$createUnitizedUVs+ "\" ") ); $cmd = $prefix + "performPolyForceUVArgList"; $version = "\"1\""; $args0 = ("{\"0\", \"unitize\", \"" + $selectCmd + "\", \"" + ($creator == 1 ? "1" : "0") + "\"}"); $args1 = ("{\"1\", \"unitize\", \"" + $selectCmd + "\", \"" + ($creator == 1 ? "1" : "0") + "\"}"); $suffix = ($creator == 0 ? " \"\"" : ""); $dmc = "performPolyForceUVArgList \"1\" {\"2\", \"unitize\", \"ls -sl\", \"0\"} \"\""; $c = ($cmd + " " + $version + " " + $args0 + $suffix); menuItem -label $unitizeLabel -ecr true -annotation (uiRes("m_PolyTextureMenu.kUnitizeUVsAnnot")) -image "polyUnitizeUVs.png" -dmc $dmc -c $c unitizeUVItem; $c = ($cmd + " " + $version + " " + $args1 + $suffix); menuItem -optionBox 1 -annotation (uiRes("m_PolyTextureMenu.kUnitizeUVsOptionAnnot")) -image "polyUnitizeUVs.png" -ecr false -c $c unitizeUVOptionItem; if ($creator != 1) { menuItem -label (uiRes("m_PolyTextureMenu.kFlipUVs")) -ecr true -iol (uiRes("m_PolyTextureMenu.kFlipUvIconOverlay")) -annotation ( getRunTimeCommandAnnotation("FlipUVs") ) -image "polyFlipUVs.png" -dmc "performPolyForceUV flip 2" -c "FlipUVs" flipUVItem; menuItem -optionBox 1 -annotation ( getRunTimeCommandAnnotation("FlipUVsOptions") ) -image "polyFlipUVs.png" -ecr false -c "FlipUVsOptions" flipUVOptionItem; // m2.1 Rotate uvs about vertex menuItem -label (uiRes("m_PolyTextureMenu.kRotateUVs")) -ecr true -i "polyTextureRotateUV.png" -annotation ( getRunTimeCommandAnnotation("RotateUVs") ) -dmc "performPolyRotateUVs 2" -ddc "RotateUVsOptions" -c "RotateUVs" rotateUVItem; menuItem -optionBox 1 -ecr false -i "polyTextureRotateUV.png" -annotation ( getRunTimeCommandAnnotation("RotateUVsOptions") ) -c "RotateUVsOptions" rotateUVOptionItem; menuItem -label (uiRes("m_PolyTextureMenu.kBestPlaneTexturing")) -ecr true -version "2018" -i "bestPlaneTxt.png" -annotation (getRunTimeCommandAnnotation("BestPlaneTexturingTool")) -dmc "polygonUVsMenuItemToShelf \"BestPlaneTexturingTool\"" -c "BestPlaneTexturingTool" polyBestPlaneTexturingItem; menuItem -label (uiRes("m_PolyTextureMenu.kMapUVBorder")) -ecr true -i "polyMapUVBorder.png" -annotation ( getRunTimeCommandAnnotation("MapUVBorder") ) -ddc "performPolyUntangleUV map 1" -dmc "performPolyUntangleUV map 2" -c "MapUVBorder" mapUVBorderItem; menuItem -optionBox 1 -i "polyMapUVBorder.png" -annotation ( getRunTimeCommandAnnotation("MapUVBorderOptions") ) -ecr false -c "MapUVBorderOptions" mapUVBorderOptionItem; menuItem -label (uiRes("m_PolyTextureMenu.kStraightenUVBorder")) -annotation ( getRunTimeCommandAnnotation("StraightenUVBorder") ) -i "polyStraightenUVBorder.png" -c "StraightenUVBorder"; menuItem -optionBox 1 -annotation ( getRunTimeCommandAnnotation("StraightenUVBorderOptions") ) -i "polyStraightenUVBorder.png" -c "StraightenUVBorderOptions" -ecr false; menuItem -label (uiRes("m_PolyTextureMenu.kRelaxUVs")) -ecr true -i "polyRelaxUVShell.png" -annotation ( getRunTimeCommandAnnotation("RelaxUVShell") ) -ddc "RelaxUVShellOptions" -dmc "performPolyUntangleUV relax 2" -c "RelaxUVShell" relaxUVShellItem; menuItem -optionBox 1 -i "polyRelaxUVShell.png" -annotation ( getRunTimeCommandAnnotation("RelaxUVShellOptions") ) -ecr false -c "RelaxUVShellOptions" relaxUVShellOptionItem; menuItem -label (uiRes("m_PolyTextureMenu.kUnfoldUVs")) -annotation ( getRunTimeCommandAnnotation("UnfoldUV") ) -dragMenuCommand "performUnfold 2" -c "UnfoldUV" -i "textureEditorUnfoldUVsLarge.png" unfoldUVItem; menuItem -optionBox true -annotation ( getRunTimeCommandAnnotation("UnfoldUVOptions") ) -c "UnfoldUVOptions" -ecr false -i "textureEditorUnfoldUVsLarge.png" unfoldUVOptItem; menuItem -label (uiRes("m_PolyTextureMenu.kLayoutUVs")) -version "2017" -annotation (uiRes("m_PolyTextureMenu.kLayoutUVsAnnot")) -c "performPolyLayoutUV 0" -i "polyLayoutUVLarge.png"; menuItem -optionBox 1 -annotation (uiRes("m_PolyTextureMenu.kLayoutUVsOptionAnnot")) -c "performPolyLayoutUV 1" -ecr false -i "polyLayoutUVLarge.png"; menuItem -label (uiRes("m_PolyTextureMenu.kGridUVs")) -annotation ( getRunTimeCommandAnnotation("GridUV") ) -c "GridUV" -i "polyGridUV.png"; menuItem -optionBox 1 -annotation ( getRunTimeCommandAnnotation("GridUVOptions") ) -c "GridUVOptions" -ecr false -i "polyGridUV.png"; menuItem -label (uiRes("m_PolyTextureMenu.kAlignUVs")) -c ( "AlignUV" ) -annotation ( getRunTimeCommandAnnotation("AlignUV") ) -image "polyAlignUVs.png" ; menuItem -optionBox true -annotation ( getRunTimeCommandAnnotation("AlignUVOptions") ) -image "polyAlignUVs.png" -ecr false -c ( "AlignUVOptions" ) ; menuItem -label (uiRes("m_PolyTextureMenu.kWarpImage")) -annotation ( getRunTimeCommandAnnotation("WarpImage") ) -image "polyWarpImage.png" -echoCommand true -dragMenuCommand "performPolyWarpImage 2" -c "WarpImage" layoutWarpImageItem; menuItem -optionBox true -annotation ( getRunTimeCommandAnnotation("WarpImageOptions") ) -image "polyWarpImage.png" -c "WarpImageOptions" layoutWarpImageOptItem; } ////////////////////////////////////////////////////////////////////// if ($creator != 1) { menuItem -divider true; menuItem -label (uiRes("m_PolyTextureMenu.kCutUVs")) -ecr true -i "polyMapCut.png" -annotation ( getRunTimeCommandAnnotation ( "CutUVs" ) ) -dmc "polygonUVsMenuItemToShelf \"polyPerformAction polyMapCut e 0\"" -c "CutUVs" cutTextureItem; $cmd = "SewUVs"; menuItem -label (uiRes("m_PolyTextureMenu.kSewUVs")) -ecr true -i "polyMapSew.png" -annotation (getRunTimeCommandAnnotation($cmd)) -dmc "polygonUVsMenuItemToShelf \"polyPerformAction polyMapSew e 0\"" -c $cmd sewTextureItem; menuItem -label (uiRes("m_PolyTextureMenu.kMoveAndSewUVs")) -annotation (uiRes("m_PolyTextureMenu.kMoveAndSewUVsAnnot")) -c "performPolyMapSewMove 0" -i "polyMoveSew.png"; menuItem -optionBox 1 -annotation (uiRes("m_PolyTextureMenu.kMoveAndSewUVsOptionAnnot")) -c "performPolyMapSewMove 1" -ecr false -i "polyMoveSew.png"; menuItem -label (uiRes("m_PolyTextureMenu.kMergeUVs")) -annotation ( getRunTimeCommandAnnotation ( "MergeUV" ) ) -c "MergeUV" -i "polyMergeUV.png" ; menuItem -optionBox 1 -annotation ( getRunTimeCommandAnnotation ( "MergeUVOptions" ) ) -c "MergeUVOptions" -ecr false -i "polyMergeUV.png" ; menuItem -label (uiRes("m_PolyTextureMenu.kDeleteUVs")) -ecr true -i "polyMapDel.png" -annotation (getRunTimeCommandAnnotation("DeleteUVs")) -dmc "polygonUVsMenuItemToShelf \"polyPerformAction polyMapDel f 0\"" -c "DeleteUVs" delTextureItem; } } }