// =========================================================================== // 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. // =========================================================================== // // Description: // Polygon UV creation menu // global proc PolygonsCreateUVsMenu(string $parent) { if (! `isTrue "PolygonsExists"`) return; PolygonsCreateTextureMenu $parent 0 "ls -selection"; } global proc PolygonsCreateTextureMenu(string $parent, int $creator, string $selectCmd) // // Description: // Polygon Create UVs menu // { setParent -menu $parent; if (`menu -query -numberOfItems $parent` == 0) { string $planarLabel = (uiRes("m_PolygonsCreateUVsMenu.kPolyUVsPlanar")); string $createPlanarMapping = (uiRes("m_PolygonsCreateUVsMenu.kPolyUVsCreatePlanar")); 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 $args2 = ("{\"2\", \"Planar\", \"" + $selectCmd + "\", \"" + ($creator == 1 ? "1" : "0") + "\"}"); string $suffix = ($creator == 0 ? " \"\"" : ""); string $dmc = "performPolyProjectionArgList \"1\" {\"2\", \"Planar\", \"ls -selection\", \"0\"} \"\";"; string $c = ($cmd + " " + $version + " " + $args0 + $suffix); menuItem -label $planarLabel -enableCommandRepeat true -image "polyPlanProjLarge.png" -dragMenuCommand $dmc -annotation (uiRes("m_PolygonsCreateUVsMenu.kPolyUVsPlanarAnnot")) -command $c planarMappingItem ; $c = ($cmd + " " + $version + " " + $args1 + $suffix); menuItem -optionBox 1 -image "polyPlanProjLarge.png" -annotation (uiRes("m_PolygonsCreateUVsMenu.kPolyUVsPlanarOptionAnnot")) -enableCommandRepeat false -command $c planarMappingOptionItem ; string $cylindricalLabel = (uiRes("m_PolygonsCreateUVsMenu.kPolyUVsCylindrical")); string $createCylindricalMapping = (uiRes("m_PolygonsCreateUVsMenu.kPolyUVsCreateCylindrical")); $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") + "\"}"); $args2 = ("{\"2\", \"Cylindrical\", \"" + $selectCmd + "\", \"" + ($creator == 1 ? "1" : "0") + "\"}"); $suffix = ($creator == 0 ? " \"\"" : ""); $dmc = "performPolyProjectionArgList \"1\" {\"2\", \"Cylindrical\", \"ls -selection\", \"0\"} \"\";"; $c = ($cmd + " " + $version + " " + $args0 + $suffix); menuItem -label $cylindricalLabel -enableCommandRepeat true -image "polyCylProjLarge.png" -dragMenuCommand $dmc -annotation (uiRes("m_PolygonsCreateUVsMenu.kPolyUVsCylindricalAnnot")) -command $c cylindricMappingItem ; $c = ($cmd + " " + $version + " " + $args1 + $suffix); menuItem -optionBox 1 -image "polyCylProjLarge.png" -annotation (uiRes("m_PolygonsCreateUVsMenu.kPolyUVsCylindricalOptAnnot")) -enableCommandRepeat false -command $c cylindricMappingOptionItem ; // Spherical mapping string $sphericalLabel = (uiRes("m_PolygonsCreateUVsMenu.kPolyUVsSpherical")); string $createSphericalMapping = (uiRes("m_PolygonsCreateUVsMenu.kPolyUVsSphericalMapping")); $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") + "\"}"); $args2 = ("{\"2\", \"Spherical\", \"" + $selectCmd + "\", \"" + ($creator == 1 ? "1" : "0") + "\"}"); $suffix = ($creator == 0 ? " \"\"" : ""); $c = ($cmd + " " + $version + " " + $args0 + $suffix); $dmc = "performPolyProjectionArgList \"1\" {\"2\", \"Spherical\", \"ls -selection\", \"0\"} \"\";"; menuItem -label $sphericalLabel -enableCommandRepeat true -image "polySphereProjLage.png" -dragMenuCommand $dmc -annotation (uiRes("m_PolygonsCreateUVsMenu.kPolyUVsSphericalAnnot")) -command $c sphericMappingItem ; $c = ($cmd + " " + $version + " " + $args1 + $suffix); menuItem -optionBox 1 -image "polySphereProjLage.png" -annotation (uiRes("m_PolygonsCreateUVsMenu.kPolyUVsSphericalOptAnnot")) -enableCommandRepeat false -command $c sphericMappingOptionItem ; // Automatic mapping menuItem -label (uiRes("m_PolygonsCreateUVsMenu.kPolyUVsAutomatic")) -annotation (uiRes("m_PolygonsCreateUVsMenu.kPolyUVsAutomaticAnnot")) -command "performPolyAutoProj 0" -image "polyAutoProjLarge.png" ; menuItem -optionBox 1 -annotation (uiRes("m_PolygonsCreateUVsMenu.kPolyUVsAutomaticOptionAnnot")) -command "performPolyAutoProj 1" -enableCommandRepeat false -image "polyAutoProjLarge.png" ; // Camera Based mapping string $createUVsBasedOnCamera = (uiRes("m_PolygonsCreateUVsMenu.kPolyUVsCameraBasedUVsCreate")); $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") + "\"}"); $args2 = ("{\"2\", \"camera\", \"" + $selectCmd + "\", \"" + ($creator == 1 ? "1" : "0") + "\"}"); $suffix = ($creator == 0 ? " \"\"" : ""); $dmc = "performPolyForceUVArgList \"1\" {\"2\", \"camera\", \"ls -selection\", \"0\"} \"\";"; $c = ($cmd + " " + $version + " " + $args0 + $suffix); menuItem -label $createUVsBasedOnCamera -enableCommandRepeat true -annotation (uiRes("m_PolygonsCreateUVsMenu.kPolyUVsCameraAnnot")) -image "polyCameraUVs.png" -dragMenuCommand $dmc -command $c cameraProjectionItem ; $c = ($cmd + " " + $version + " " + $args1 + $suffix); menuItem -optionBox 1 -annotation (uiRes("m_PolygonsCreateUVsMenu.kPolyUVsCameraOptionAnnot")) -image "polyCameraUVs.png" -enableCommandRepeat false -command $c cameraProjectionOptionItem ; // Contour stretch mapping string $contourLabel = (uiRes("m_PolygonsCreateUVsMenu.kPolyUVsContour")); string $createContourMapping = (uiRes("m_PolygonsCreateUVsMenu.kPolyUVsContourMapping")); $prefix = ($creator == 0 ? "" : ("PolyRequestUVSetName \""+$createContourMapping+"\" ") ); $cmd = $prefix + "performPolyProjectionArgList"; $version = "\"1\""; $args0 = ("{\"0\", \"Contour\", \"" + $selectCmd + "\", \"" + ($creator == 1 ? "1" : "0") + "\"}"); $args1 = ("{\"1\", \"Contour\", \"" + $selectCmd + "\", \"" + ($creator == 1 ? "1" : "0") + "\"}"); $args2 = ("{\"2\", \"Contour\", \"" + $selectCmd + "\", \"" + ($creator == 1 ? "1" : "0") + "\"}"); $suffix = ($creator == 0 ? " \"\"" : ""); $c = ($cmd + " " + $version + " " + $args0 + $suffix); $dmc = "performPolyProjectionArgList \"1\" {\"2\", \"Contour\", \"ls -selection\", \"0\"} \"\";"; menuItem -version "2016" -label $contourLabel -enableCommandRepeat true -image "polyContourProjLarge.png" -dragMenuCommand $dmc -annotation (uiRes("m_PolygonsCreateUVsMenu.kPolyUVsContourAnnot")) -command $c contourMappingItem ; $c = ($cmd + " " + $version + " " + $args1 + $suffix); menuItem -optionBox 1 -image "polyContourProjLarge.png" -annotation (uiRes("m_PolygonsCreateUVsMenu.kPolyUVsContourOptAnnot")) -enableCommandRepeat false -command $c contourMappingOptionItem ; // Best Plane menuItem -version "2018" -label (uiRes("m_PolygonsCreateUVsMenu.kPolyUVsBestPlane")) -enableCommandRepeat true -image "bestPlaneTxt.png" -annotation (getRunTimeCommandAnnotation("BestPlaneTexturingTool")) -dragMenuCommand "polygonsMenuItemToShelf \"BestPlaneTexturingTool\"" -command "BestPlaneTexturingTool" polyBestPlaneTexturingItem ; menuItem -divider true; if ($creator != 1) { menuItem -enableCommandRepeat false -checkBox false -label (uiRes("m_PolygonsCreateUVsMenu.kPolyUVsAssignShaderToProjection")) -image "polyCheck.png" -dragMenuCommand "polygonUVsItemToShelf \"togglePolyCreateShaderWithMapping\"" -annotation (uiRes("m_PolygonsCreateUVsMenu.kPolyUVsAssignShaderToProjectionAnnot")) -command "togglePolyCreateShaderWithMapping" toggleCreateShaderItem ; } menuItem -divider true; // Create empty UV set string $createUVSetLabel = (uiRes("m_PolygonsCreateUVsMenu.kPolyUVsUVSetLabel")); string $createEmptyUVSet = (uiRes("m_PolygonsCreateUVsMenu.kPolyUVsCreateEmptyUVSet")); $prefix = ($creator == 0 ? "" : ("PolyRequestUVSetName \""+$createEmptyUVSet+"\" ") ); $cmd = $prefix + "performCreateUVSet"; $version = "\"1\""; $args0 = ("{\"0\", \"" + $selectCmd + "\", \"" + ($creator == 1 ? "1" : "0") + "\"}"); $args1 = ("{\"1\", \"" + $selectCmd + "\", \"" + ($creator == 1 ? "1" : "0") + "\"}"); $args2 = ("{\"2\", \"" + $selectCmd + "\", \"" + ($creator == 1 ? "1" : "0") + "\"}"); $suffix = ($creator == 0 ? " \"\"" : ""); $dmc = "performCreateUVSet \"1\" {\"2\", \"ls -selection\", \"0\"} \"\";"; $c = ($cmd + " " + $version + " " + $args0 + $suffix); menuItem -label $createUVSetLabel -enableCommandRepeat true -image "polyCreateUVSetLarge.png" -dragMenuCommand $dmc -annotation (uiRes("m_PolygonsCreateUVsMenu.kPolyUVsCreateUVSetAnnot")) -command $c createUVSetItem ; if ($creator != 1) { string $c = ($cmd + " " + $version + " " + $args1 + $suffix); menuItem -optionBox 1 -image "polyCreateUVSetLarge.png" -annotation (uiRes("m_PolygonsCreateUVsMenu.kPolyUVsCreateUVSetOptAnnot")) -enableCommandRepeat false -command $c createUVSetOptionItem ; } // Copy, Set Current, Rename and Delete // 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_PolygonsCreateUVsMenu.kPolyUVsCopyUVsToUVSet")) -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_PolygonsCreateUVsMenu.kPolyUVsCopyCurrentUVSet")); $prefix = ($creator == 0 ? "" : ("PolyRequestUVSetName \""+$copyCurrentUVSet+"\" ") ); $cmd = $prefix + "performCopyCurrentUVSet"; $version = "\"1\""; $args0 = ("{\"0\", \"" + $selectCmd + "\", \"" + ($creator == 1 ? "1" : "0") + "\"}"); $args1 = ("{\"1\", \"" + $selectCmd + "\", \"" + ($creator == 1 ? "1" : "0") + "\"}"); $args2 = ("{\"2\", \"" + $selectCmd + "\", \"" + ($creator == 1 ? "1" : "0") + "\"}"); $suffix = ($creator == 0 ? " \"\"" : ""); $dmc = "performCopyCurrentUVSet \"1\" {\"2\", \"ls -selection\", \"0\"} \"\";"; $c = ($cmd + " " + $version + " " + $args0 + $suffix); menuItem -label (uiRes("m_PolygonsCreateUVsMenu.kPolyUVsCopyIntoNewUVSet")) -ecr true -annotation (uiRes("m_PolygonsCreateUVsMenu.kPolyUVsCopyIntoNewUVSetAnnot")) -image "polyCopyUVSet.png" -dragMenuCommand $dmc -command $c copyCurrentUVSet ; if ($creator != 1) { string $c = ($cmd + " " + $version + " " + $args1 + $suffix); menuItem -optionBox 1 -image "polyCopyUVSet.png" -annotation (uiRes("m_PolygonsCreateUVsMenu.kPolyUVsCopyNewUVSetOptionAnnot")) -enableCommandRepeat false -command $c copyCurrentUVSetOB ; } setParent -menu ..; if ($creator != 1) { $cmd = "SetCurrentUVSet"; menuItem -label (uiRes("m_PolygonsCreateUVsMenu.kPolyUVsSetCurrentUVSet")) -enableCommandRepeat true -image "polySetCurrentUVSet.png" -annotation (getRunTimeCommandAnnotation($cmd)) -command $cmd setCurrentUVSet; $cmd = "RenameCurrentUVSet"; menuItem -label (uiRes("m_PolygonsCreateUVsMenu.kPolyUVsRenameCurrentUVSet")) -enableCommandRepeat true -image "polyRenameUVSet.png" -annotation (getRunTimeCommandAnnotation($cmd)) -command $cmd renameCurrentUVSet; $cmd = "DeleteCurrentUVSet"; menuItem -label (uiRes("m_PolygonsCreateUVsMenu.kPolyUVsDeleteCurrentUVSet")) -enableCommandRepeat true -image "polyDeleteUVSet.png" -annotation (getRunTimeCommandAnnotation($cmd)) -dragMenuCommand "performDeleteCurrentUVSet 2" -command $cmd deleteCurrentUVSet; $cmd = "UVSetEditor"; menuItem -label (uiRes("m_PolygonsCreateUVsMenu.kPolyUVSetEditor")) -enableCommandRepeat true -enable true -annotation (getRunTimeCommandAnnotation($cmd)) -image "polyUVSetEditor.png" -command $cmd ; menuItem -label (uiRes("m_PolygonsCreateUVsMenu.kPolyUVsPerInstance")) -subMenu true -to true -allowOptionBoxes true; $cmd = "SelectSharedUVInstances"; menuItem -label (uiRes("m_PolygonsCreateUVsMenu.kPolyUVSelectShared")) -annotation (getRunTimeCommandAnnotation($cmd)) -image "polyShareInstancesSelectLarge.png" -command $cmd; $cmd = "ShareUVInstances"; menuItem -label (uiRes("m_PolygonsCreateUVsMenu.kPolyUVShareInstances")) -annotation (getRunTimeCommandAnnotation($cmd)) -image "polyShareInstancesLarge.png" -command $cmd; $cmd = "MakeUVInstanceCurrent"; menuItem -label (uiRes("m_PolygonsCreateUVsMenu.kPolyUVMakeInstanceCurrent")) -annotation (getRunTimeCommandAnnotation($cmd)) -image "polyShareInstancesCurrent.png" -command $cmd; setParent -menu ..; } setParent -menu ..; } }