Advertisement
Scoba

UV Mover for Maya

Aug 13th, 2016
412
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.29 KB | None | 0 0
  1. /*
  2.  
  3.     Tool By Scobalula for easily moving UVs to specific parts of an image.
  4.  
  5.     This script (UV Mover) is free software: you can redistribute it and/or modify
  6.     it under the terms of the GNU General Public License as published by
  7.     the Free Software Foundation, either version 3 of the License, or
  8.     (at your option) any later version.
  9.  
  10.     This program is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.     GNU General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU General Public License
  16.     along with this program.  If not, see <http://www.gnu.org/licenses/>
  17. */
  18.  
  19. string $window = `window -title "Scoba's Dank UV Moving/Scaling Tool" -width 384`;
  20.     columnLayout -adjustableColumn true;
  21.         separator -height 15 -style "out";
  22.         text -label "Square Image (1:1)";
  23.         separator -height 15 -style "out";
  24.         string $OptionMenuX = `optionMenu -label "Where to Move:" SquareValue`;
  25.             menuItem -label "Select";
  26.             menuItem -label "Top Left";
  27.             menuItem -label "Top Right";
  28.             menuItem -label "Bottom Left";
  29.             menuItem -label "Bottom Right";
  30.         separator -height 15 -style "out";
  31.         button -label "Confirm" -command "ScaleUVsSquareImage";
  32.         separator -height 15 -style "out";
  33.         separator -height 15 -style "out";
  34.         text -label "Rect. Image (1:2)";
  35.         separator -height 15 -style "out";
  36.         string $OptionMenuX = `optionMenu -label "Where to Move:" RectValue`;
  37.             menuItem -label "Select";
  38.             menuItem -label "Top Left";
  39.             menuItem -label "Top Right";
  40.             menuItem -label "Upper Middle Left";
  41.             menuItem -label "Upper Middle Right";
  42.             menuItem -label "Lower Middle Left";
  43.             menuItem -label "Lower Middle Right";
  44.             menuItem -label "Bottom Left";
  45.             menuItem -label "Bottom Right";
  46.         separator -height 15 -style "out";
  47.         button -label "Confirm" -command "ScaleUVsRectImage";
  48.         separator -height 15 -style "out";
  49.         separator -height 15 -style "out";
  50.         text -label "Move UVs to center:";
  51.         separator -height 15 -style "out";
  52.         string $OptionMenuX = `optionMenu -label "Move UV to center from:" ValueToMove`;
  53.             menuItem -label "Select";
  54.             menuItem -label "Left";
  55.             menuItem -label "Right";
  56.             menuItem -label "Bottom";
  57.             menuItem -label "Top";
  58.         separator -height 15 -style "out";
  59.         button -label "Confirm" -command "MoveUVToImage";
  60.         separator -height 15 -style "out";
  61.         showWindow $window;
  62.  
  63.  
  64. global proc ScaleUVsRectImage()
  65. {
  66.     string $ScaleMoveRect = `optionMenu -q -v RectValue`;
  67.     switch($ScaleMoveRect)
  68.     {
  69.         case "Select":
  70.             print("Select and option to move UV.\n");
  71.             break;
  72.         case "Bottom Left":
  73.             print("UV Moved and scaled to " + $ScaleMoveRect + ".\n");
  74.             polyEditUV -u -0 -v 0 -su 0.5 -sv 0.25 ;
  75.             break;
  76.         case "Bottom Right":
  77.             print("UV Moved and scaled to " + $ScaleMoveRect + ".\n");
  78.             polyEditUV -u 0.5 -v 0 -su 0.5 -sv 0.25 ;  
  79.             break;
  80.         case "Lower Middle Left":
  81.             print("UV Moved and scaled to " + $ScaleMoveRect + ".\n");
  82.             polyEditUV -u -0 -v 0.25 -su 0.5 -sv 0.25 ;
  83.             break;
  84.         case "Lower Middle Right":
  85.             print("UV Moved and scaled to " + $ScaleMoveRect + ".\n");
  86.             polyEditUV -u 0.5 -v 0.25 -su 0.5 -sv 0.25 ;
  87.             break;
  88.         case "Upper Middle Left":
  89.             print("UV Moved and scaled to " + $ScaleMoveRect + ".\n");
  90.             polyEditUV -u -0 -v 0.5 -su 0.5 -sv 0.25 ;
  91.             break;
  92.         case "Upper Middle Right":
  93.             print("UV Moved and scaled to " + $ScaleMoveRect + ".\n");
  94.             polyEditUV -u 0.5 -v 0.5 -su 0.5 -sv 0.25 ;
  95.             break;
  96.         case "Top Left":
  97.             print("UV Moved and scaled to " + $ScaleMoveRect + ".\n");
  98.             polyEditUV -u -0 -v 0.75 -su 0.5 -sv 0.25 ;
  99.             break;
  100.         case "Top Right":
  101.             print("UV Moved and scaled to " + $ScaleMoveRect + ".\n");
  102.             polyEditUV -u 0.5 -v 0.75 -su 0.5 -sv 0.25 ;
  103.             break;
  104.     }
  105. }
  106.  
  107.  
  108. global proc ScaleUVsSquareImage()
  109. {
  110.     string $ScaleMove = `optionMenu -q -v SquareValue`;
  111.     switch($ScaleMove)
  112.     {
  113.         case "Select":
  114.             print("Select and option to move UV.\n");
  115.             break;
  116.         case "Bottom Left":
  117.             print("UV Moved and scaled to " + $ScaleMove + ".\n");
  118.             polyEditUV -u -0 -v 0 -su 0.5 -sv 0.5 ;
  119.             break;
  120.         case "Bottom Right":
  121.             print("UV Moved and scaled to " + $ScaleMove + ".\n");
  122.             polyEditUV -u 0.5 -v 0 -su 0.5 -sv 0.5 ;   
  123.             break;
  124.         case "Top Left":
  125.             print("UV Moved and scaled to " + $ScaleMove + ".\n");
  126.             polyEditUV -u -0 -v 0.5 -su 0.5 -sv 0.5 ;
  127.             break;
  128.         case "Top Right":
  129.             print("UV Moved and scaled to " + $ScaleMove + ".\n");
  130.             polyEditUV -u 0.5 -v 0.5 -su 0.5 -sv 0.5 ; 
  131.             break;
  132.     }
  133. }
  134. global proc MoveUVToImage()
  135. {
  136.     string $MoveOption = `optionMenu -q -v ValueToMove`;
  137.     switch($MoveOption)
  138.     {
  139.         case "Select":
  140.             print("Select and option to move UV.\n");
  141.             break;
  142.         case "Left":
  143.             print("UV Moved from Left to Center.\n");
  144.             polyEditUV -u 1 -v 0 ; 
  145.             break;
  146.         case "Right":
  147.             print("UV Moved from Right to Center.\n");
  148.             polyEditUV -u -1 -v 0 ;
  149.             break;
  150.         case "Bottom":
  151.             print("UV Moved from Bottom to Center.\n");
  152.             polyEditUV -u -0 -v 1 ;
  153.             break;
  154.         case "Top":
  155.             print("UV Moved from Top to Center.\n");
  156.             polyEditUV -u -0 -v -1 ;
  157.             break;
  158.     }  
  159. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement