├── .gitignore ├── InstallData ├── FinalMessage.rtf ├── LicenseAgreement.rtf └── icon.ico ├── InstallScript.nsi ├── LICENSE ├── README.md ├── UVAutoRatio ├── GetSurfaceUVArea.cpp ├── GetSurfaceUVArea.h ├── GetUVShellSelectionStrings.cpp ├── GetUVShellSelectionStrings.h ├── MayaPCH.cpp ├── MayaPCH.h ├── MayaPlugin.cpp ├── MayaPlugin.h ├── MayaUtility.cpp ├── MayaUtility.h ├── MeshProcessor.cpp ├── Processor.cpp ├── ShellProcessor.cpp ├── ShellProcessor.h ├── Timer.cpp ├── Timer.h ├── UVAutoRatioPlugin.cpp ├── UVAutoRatioPlugin.h ├── UVAutoRatioPro.cpp ├── UVAutoRatioPro.h ├── UVAutoRatioPro.sln ├── UVAutoRatioPro.vcproj ├── UVAutoRatioPro_Setup.cpp ├── UVSpringLayout.cpp ├── UVSpringLayout.h ├── Utility.cpp ├── Utility.h └── main.cpp ├── docs ├── UITabsExpanded_small.png ├── UVRatio00.jpg ├── foo.txt └── rtt_examplecar_small.jpg └── module ├── InstallationInstructions-MacOSX.txt ├── UVAutoRatio2ProModule.txt ├── UVAutoRatio2ProWindowsModule.txt ├── docs └── manual │ ├── images │ ├── image00.png │ ├── image01.png │ ├── image02.png │ ├── image03.png │ ├── image04.png │ ├── image05.png │ ├── image06.png │ ├── image07.png │ ├── image08.png │ ├── image09.png │ ├── image10.png │ ├── image11.png │ ├── image12.png │ ├── image13.jpg │ ├── image14.png │ ├── image15.png │ ├── image16.png │ ├── image17.png │ ├── image18.png │ ├── image19.png │ ├── image20.png │ ├── image21.png │ ├── image22.png │ ├── image23.png │ ├── image24.png │ ├── image25.png │ ├── image26.png │ ├── image27.png │ ├── image28.png │ ├── image29.png │ ├── image30.png │ ├── image31.png │ ├── image32.png │ ├── image33.png │ └── image34.png │ └── index.html ├── icons ├── RenderHeads1.xpm ├── RenderHeads2.xpm ├── UVAutoRatioIcon.xpm └── UVAutoRatioIconOver.xpm ├── plug-ins └── native-plugins-built-here.txt └── scripts ├── UVAutoRatioBase.mel ├── UVAutoRatioBase.res.mel ├── UVAutoRatioPro.res.mel ├── UVAutoRatioProUI.mel ├── UVAutoRatioProUI_AboutTab.mel ├── UVAutoRatioProUI_MainTab.mel ├── UVAutoRatioProUI_RatioPresets.mel ├── UVAutoRatioProUI_SettingsTab.mel ├── UVAutoRatioPro_Inspector.mel └── UVAutoRatioPro_Utility.mel /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | *.obj 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Compiled Dynamic libraries 12 | *.so 13 | *.dylib 14 | *.dll 15 | *.mll 16 | 17 | # Fortran module files 18 | *.mod 19 | 20 | # Compiled Static libraries 21 | *.lai 22 | *.la 23 | *.a 24 | *.lib 25 | 26 | # Executables 27 | *.exe 28 | *.out 29 | *.app 30 | 31 | # MS Visual Studio 32 | *.ncb 33 | *.exp 34 | *.manifest 35 | *.idb 36 | *.suo 37 | *.user 38 | BuildLog.htm -------------------------------------------------------------------------------- /InstallData/FinalMessage.rtf: -------------------------------------------------------------------------------- 1 | {\rtf1\adeflang1025\ansi\ansicpg1252\uc1\adeff0\deff0\stshfdbch11\stshfloch0\stshfhich0\stshfbi0\deflang1033\deflangfe1041{\fonttbl{\f0\froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\f1\fswiss\fcharset0\fprq2{\*\panose 020b0604020202020204}Arial;} 2 | {\f11\fmodern\fcharset128\fprq1{\*\panose 02020609040205080304}MS Mincho{\*\falt ?l?r ??\'81\'66c};}{\f37\fmodern\fcharset128\fprq1{\*\panose 02020609040205080304}@MS Mincho;}{\f38\froman\fcharset238\fprq2 Times New Roman CE;} 3 | {\f39\froman\fcharset204\fprq2 Times New Roman Cyr;}{\f41\froman\fcharset161\fprq2 Times New Roman Greek;}{\f42\froman\fcharset162\fprq2 Times New Roman Tur;}{\f43\fbidi \froman\fcharset177\fprq2 Times New Roman (Hebrew);} 4 | {\f44\fbidi \froman\fcharset178\fprq2 Times New Roman (Arabic);}{\f45\froman\fcharset186\fprq2 Times New Roman Baltic;}{\f46\froman\fcharset163\fprq2 Times New Roman (Vietnamese);}{\f48\fswiss\fcharset238\fprq2 Arial CE;} 5 | {\f49\fswiss\fcharset204\fprq2 Arial Cyr;}{\f51\fswiss\fcharset161\fprq2 Arial Greek;}{\f52\fswiss\fcharset162\fprq2 Arial Tur;}{\f53\fbidi \fswiss\fcharset177\fprq2 Arial (Hebrew);}{\f54\fbidi \fswiss\fcharset178\fprq2 Arial (Arabic);} 6 | {\f55\fswiss\fcharset186\fprq2 Arial Baltic;}{\f56\fswiss\fcharset163\fprq2 Arial (Vietnamese);}{\f150\fmodern\fcharset0\fprq1 MS Mincho Western{\*\falt ?l?r ??\'81\'66c};}{\f148\fmodern\fcharset238\fprq1 MS Mincho CE{\*\falt ?l?r ??\'81\'66c};} 7 | {\f149\fmodern\fcharset204\fprq1 MS Mincho Cyr{\*\falt ?l?r ??\'81\'66c};}{\f151\fmodern\fcharset161\fprq1 MS Mincho Greek{\*\falt ?l?r ??\'81\'66c};}{\f152\fmodern\fcharset162\fprq1 MS Mincho Tur{\*\falt ?l?r ??\'81\'66c};} 8 | {\f155\fmodern\fcharset186\fprq1 MS Mincho Baltic{\*\falt ?l?r ??\'81\'66c};}{\f410\fmodern\fcharset0\fprq1 @MS Mincho Western;}{\f408\fmodern\fcharset238\fprq1 @MS Mincho CE;}{\f409\fmodern\fcharset204\fprq1 @MS Mincho Cyr;} 9 | {\f411\fmodern\fcharset161\fprq1 @MS Mincho Greek;}{\f412\fmodern\fcharset162\fprq1 @MS Mincho Tur;}{\f415\fmodern\fcharset186\fprq1 @MS Mincho Baltic;}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0; 10 | \red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128; 11 | \red192\green192\blue192;}{\stylesheet{\ql \li0\ri0\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \af0\afs24\alang1025 \ltrch\fcs0 \fs24\lang1033\langfe1041\loch\f0\hich\af0\dbch\af11\cgrid\langnp1033\langfenp1041 12 | \snext0 Normal;}{\*\cs10 \additive \ssemihidden Default Paragraph Font;}{\* 13 | \ts11\tsrowd\trftsWidthB3\trpaddl108\trpaddr108\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3\trcbpat1\trcfpat1\tblind0\tblindtype3\tscellwidthfts0\tsvertalt\tsbrdrt\tsbrdrl\tsbrdrb\tsbrdrr\tsbrdrdgl\tsbrdrdgr\tsbrdrh\tsbrdrv 14 | \ql \li0\ri0\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \af0\afs20 \ltrch\fcs0 \fs20\lang1024\langfe1024\loch\f0\hich\af0\dbch\af11\cgrid\langnp1024\langfenp1024 \snext11 \ssemihidden Normal Table;}} 15 | {\*\latentstyles\lsdstimax156\lsdlockeddef0}{\*\rsidtbl \rsid9452167\rsid10305272\rsid13461638}{\*\generator Microsoft Word 11.0.0000;}{\info{\author -}{\operator -}{\creatim\yr2008\mo7\dy30\hr20\min56}{\revtim\yr2009\mo10\dy16\hr9\min14}{\version4} 16 | {\edmins3}{\nofpages1}{\nofwords17}{\nofchars100}{\*\company --}{\nofcharsws116}{\vern24615}{\*\password 00000000}}{\*\xmlnstbl {\xmlns1 http://schemas.microsoft.com/office/word/2003/wordml}} 17 | \paperw12240\paperh15840\margl1800\margr1800\margt1440\margb1440\gutter0\ltrsect 18 | \widowctrl\ftnbj\aenddoc\donotembedsysfont0\donotembedlingdata1\grfdocevents0\validatexml0\showplaceholdtext0\ignoremixedcontent0\saveinvalidxml0\showxmlerrors0\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\hyphcaps0\horzdoc\dghspace120 19 | \dgvspace120\dghorigin1701\dgvorigin1984\dghshow0\dgvshow3\jcompress\viewkind4\viewscale100\nolnhtadjtbl\rsidroot9452167 \fet0{\*\wgrffmtfilter 013f}\ilfomacatclnup0\ltrpar \sectd \ltrsect\linex0\sectdefaultcl\sftnbj {\*\pnseclvl1 20 | \pnucrm\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl2\pnucltr\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl3\pndec\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl4\pnlcltr\pnstart1\pnindent720\pnhang {\pntxta )}}{\*\pnseclvl5 21 | \pndec\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl6\pnlcltr\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl7\pnlcrm\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl8\pnlcltr\pnstart1\pnindent720\pnhang 22 | {\pntxtb (}{\pntxta )}}{\*\pnseclvl9\pnlcrm\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}\pard\plain \ltrpar\ql \li0\ri0\nowidctlpar\wrapdefault\faauto\rin0\lin0\itap0 \rtlch\fcs1 \af0\afs24\alang1025 \ltrch\fcs0 23 | \fs24\lang1033\langfe1041\loch\af0\hich\af0\dbch\af11\cgrid\langnp1033\langfenp1041 {\rtlch\fcs1 \af1\afs20 \ltrch\fcs0 \f1\fs20\insrsid13461638 \hich\af1\dbch\af11\loch\f1 Enter the command}{\rtlch\fcs1 \af1\afs20 \ltrch\fcs0 \f1\fs20\insrsid9452167 24 | \hich\af1\dbch\af11\loch\f1 }{\rtlch\fcs1 \af1 \ltrch\fcs0 \b\f1\insrsid9452167\charrsid10305272 \hich\af1\dbch\af11\loch\f1 "}{\rtlch\fcs1 \ab\af1 \ltrch\fcs0 \b\f1\insrsid9452167\charrsid10305272 \hich\af1\dbch\af11\loch\f1 UVAutoRatioProUI}{ 25 | \rtlch\fcs1 \af1 \ltrch\fcs0 \b\f1\insrsid9452167\charrsid10305272 \hich\af1\dbch\af11\loch\f1 "}{\rtlch\fcs1 \af1\afs20 \ltrch\fcs0 \f1\fs20\insrsid9452167 \hich\af1\dbch\af11\loch\f1 into Maya's command}{\rtlch\fcs1 \af1\afs20 \ltrch\fcs0 26 | \f1\fs20\insrsid13461638 \hich\af1\dbch\af11\loch\f1 -line}{\rtlch\fcs1 \af1\afs20 \ltrch\fcs0 \f1\fs20\insrsid10305272 \hich\af1\dbch\af11\loch\f1 window\hich\af1\dbch\af11\loch\f1 t}{\rtlch\fcs1 \af1\afs20 \ltrch\fcs0 \f1\fs20\insrsid13461638 27 | \hich\af1\dbch\af11\loch\f1 o start using the plugin.}{\rtlch\fcs1 \af1\afs20 \ltrch\fcs0 \f1\fs20\insrsid9452167 28 | \par 29 | \par \hich\af1\dbch\af11\loch\f1 Enjoy! 30 | \par 31 | \par \hich\af1\dbch\af11\loch\f1 RenderHeads 32 | \par }} -------------------------------------------------------------------------------- /InstallData/LicenseAgreement.rtf: -------------------------------------------------------------------------------- 1 | {\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Arial;}} 2 | {\colortbl ;\red73\green73\blue73;\red255\green255\blue255;} 3 | {\*\generator Msftedit 5.41.21.2510;}\viewkind4\uc1\pard\cbpat2\sb144\sa288\sl310\slmult0\cf1\lang2057\fs16 The MIT License (MIT)\line\line Copyright (c) 2015 RenderHeads Ltd\line\line Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\line\line The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\line\line THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\line THE SOFTWARE.\cf0\lang9\par 4 | } 5 | -------------------------------------------------------------------------------- /InstallData/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenderHeads/MayaPlugin-UVAutoRatio/9f717c924f63eb726f63f3ebb6297e2b0e0a30ef/InstallData/icon.ico -------------------------------------------------------------------------------- /InstallScript.nsi: -------------------------------------------------------------------------------- 1 | ; Installation Script (C) 2007-2014 RenderHeads Ltd. All Rights Reserved. 2 | ; ________________________________________________________________________ 3 | 4 | !define PRODUCTNAME "UVAutoRatio 2.0 Pro" ; This is the parent product name 5 | !define SHORTPRODUCTNAME "UVAutoRatio2Pro" ; This is the parent product name 6 | !define VERSIONNAME "UVAutoRatio 2.6.0 Pro" ; All subversion (2.1 etc) go here 7 | !define COMPANY "RenderHeads" 8 | !define PRODUCTTYPE "Maya Plugin" 9 | !define VERSION "2.0 Pro" 10 | !define SHORTVERSION "2.6.0" 11 | !define INSTALLDATA "InstallData" ; Folder where data used for installation is kept 12 | 13 | SetCompressor /Solid lzma 14 | 15 | Name "${VERSIONNAME}" 16 | Caption "${VERSIONNAME} - ${PRODUCTTYPE}" 17 | 18 | ;OutFile "Releases\${VERSIONNAME} Install.exe" 19 | OutFile "Releases\UVAutoRatioPro-${SHORTVERSION}-Setup.exe" 20 | 21 | Icon "${InstallData}\icon.ico" 22 | 23 | XPStyle on 24 | InstallDir "$PROGRAMFILES\${COMPANY}\${PRODUCTNAME}" 25 | 26 | ; _____________________________ 27 | ; Install Pages 28 | ; 29 | 30 | PageEx license 31 | Caption " - License Agreement" 32 | LicenseText "License Agreement" 33 | LicenseData "${InstallData}\LicenseAgreement.rtf" 34 | PageExEnd 35 | 36 | PageEx directory 37 | Caption " - Select Install Path" 38 | DirVar $INSTDIR 39 | DirText "Select the path where you'd like to install the plugin" "Install Path" "Browse" "Browse" 40 | PageCallbacks "" "" CheckMayaRunning 41 | PageExEnd 42 | 43 | 44 | PageEx instfiles 45 | Caption " - Installing" 46 | PageExEnd 47 | 48 | PageEx license 49 | Caption " - Read Instructions" 50 | LicenseText "Launch Instructions" 51 | LicenseData "${InstallData}\FinalMessage.rtf" 52 | PageExEnd 53 | 54 | 55 | ;Function validateMayaFolder 56 | ; IfFileExists $MAYA_DIR\bin\maya.exe PathGood 57 | ; MessageBox MB_OK "This doesn't appear to be a valid Maya installation folder. It should look something like this: 'C:\Program Files\Autodesk\Maya2008'." 58 | ; Abort 59 | ; PathGood: 60 | ; call CheckMayaRunning 61 | ;FunctionEnd 62 | 63 | 64 | Function CheckMayaRunning 65 | FindProcDLL::FindProc "maya.exe" 66 | StrCmp $R0 "1" found not_found 67 | found: 68 | MessageBox MB_OK "Please close Maya before running this installation" 69 | Abort 70 | not_found: 71 | FunctionEnd 72 | 73 | ; _____________________________ 74 | ; Maya Module Operations 75 | ; 76 | 77 | Section "Maya Module" 78 | ; Copy the module file into the Maya\modules folder 79 | ;SetOutPath $MAYA_DIR\modules 80 | ;SetOutPath $DOCUMENTS\maya\modules 81 | ;File "module\${SHORTPRODUCTNAME}WindowsModule.txt" 82 | 83 | ; Append the module installation path to the file 84 | ClearErrors 85 | ;FileOpen $0 $MAYA_DIR\modules\${SHORTPRODUCTNAME}WindowsModule.txt a 86 | CreateDirectory $DOCUMENTS\maya\modules 87 | FileOpen $0 $DOCUMENTS\maya\modules\${SHORTPRODUCTNAME}Module.txt w 88 | IfErrors done 89 | FileSeek $0 0 END 90 | FileWrite $0 "+ ${SHORTPRODUCTNAME} " 91 | FileWrite $0 "${SHORTVERSION} " 92 | FileWrite $0 $INSTDIR 93 | FileClose $0 94 | done: 95 | SectionEnd 96 | 97 | ; ____________________________ 98 | ; Program Files Operations 99 | ; 100 | 101 | Section "Plugin Files" 102 | SetOutPath $INSTDIR 103 | File /r /x *.bundle /x *.so /x *.svn /x thumbs.db /x *.tga /x *.exe /x *.bat module\*.* 104 | SectionEnd 105 | 106 | ; _____________________________ 107 | ; Registry Operations 108 | ; 109 | 110 | Section "Registry" 111 | WriteRegStr HKLM "Software\${COMPANY}\${PRODUCTNAME}" "InstallPath" $INSTDIR 112 | ;WriteRegStr HKLM "Software\${COMPANY}\${PRODUCTNAME}" "MayaPath" $MAYA_DIR 113 | 114 | ; Write the uninstall keys for Windows 115 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANY}\${PRODUCTNAME}" "DisplayName" "${PRODUCTNAME}" 116 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANY}\${PRODUCTNAME}" "UninstallString" '"$INSTDIR\uninstall.exe"' 117 | WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANY}\${PRODUCTNAME}" "NoModify" 1 118 | WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANY}\${PRODUCTNAME}" "NoRepair" 1 119 | WriteUninstaller "uninstall.exe" 120 | 121 | CreateDirectory "$APPDATA\RenderHeads\${PRODUCTNAME}" 122 | CreateDirectory "$SMPROGRAMS\RenderHeads\${PRODUCTNAME}" 123 | createShortCut "$SMPROGRAMS\RenderHeads\${PRODUCTNAME}\Uninstall.lnk" "$INSTDIR\uninstall.exe" 124 | createShortCut "$SMPROGRAMS\RenderHeads\${PRODUCTNAME}\Documentation.lnk" "$INSTDIR\docs\manual\index.html" 125 | SectionEnd 126 | 127 | ; _______________________ 128 | ; Uninstall 129 | ; 130 | 131 | UninstPage uninstConfirm 132 | UninstPage instfiles 133 | 134 | UninstallIcon "installdata\icon.ico" 135 | 136 | Section "Uninstall" 137 | ; remove maya module file 138 | ReadRegStr $0 HKLM "Software\${COMPANY}\${PRODUCTNAME}" "MayaPath" 139 | ;Delete "$0\modules\${SHORTPRODUCTNAME}WindowsModule.txt" 140 | Delete "$DOCUMENTS\maya\modules\${SHORTPRODUCTNAME}Module.txt" 141 | 142 | ; remove registry keys 143 | DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANY}\${PRODUCTNAME}" 144 | DeleteRegKey HKLM "Software\${COMPANY}\${PRODUCTNAME}" 145 | 146 | ; remove files 147 | RMDir /r "$INSTDIR" 148 | 149 | ; remove the links from the start menu 150 | RMDir /r "$SMPROGRAMS\RenderHeads\${PRODUCTNAME}" 151 | ; remove the company folder only if empty 152 | RMDir "$SMPROGRAMS\RenderHeads" 153 | SectionEnd -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 RenderHeads 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # UV Auto Ratio 2 | ###### Plugin for Autodesk Maya for unifying texture area usage. 3 | ![UI](https://github.com/RenderHeads/MayaPlugin-UVAutoRatio/blob/master/docs/rtt_examplecar_small.jpg "UVAudioRatio") 4 | 5 | ## Introduction 6 | 7 | UVAutoRatio was a Maya plugin developed by RenderHeads Ltd between 2007-2013 and open-sourced in 2015. The software is no longer supported or developed by RenderHeads Ltd and this serves as a historic archive. 8 | 9 | Artists in the film and games industry spend hours manually scaling the texture coordinates of models to get them in the right proportion. This plugin completely automates this process but still leaves the artist in control. 10 | 11 | To get the most out of textures they should be mapped in proportion to the size of the geometry. Not doing so means that different parts of the scene will have different texture distribution, resulting in some textures appearing blurrier than others while some will be overly sharp, making the scene appear inconsistent and strange. Those objects with too much texture mapped to them waste memory and cause aliasing (flickering) due to the overly high frequency of texels. 12 | 13 | Artists in the game and film industry can spend hours scaling UVs up and down manually trying to get them to the ideal proportion. This isn’t a particularly fun job, in fact it’s not something we should be wasting our time with. Wouldn’t it be great if this tiresome task was automated? 14 | 15 | Enter UVAutoRatio Pro: the complete tool for automating all texel ratio tasks. 16 | 17 | ## Features 18 | 19 | + Automatically scale UVs based on surface area 20 | + Fast and accurate processing algorithm 21 | + Ability to specify UV-set 22 | + Operates on UV shells 23 | + Automatically moves overlapping UV shells 24 | + Normalise across multiple objects 25 | + UV shell finder tool 26 | + Ratio inspector tool 27 | + Maintains settings between sessions 28 | 29 | ![UI](https://github.com/RenderHeads/MayaPlugin-UVAutoRatio/blob/master/docs/UITabsExpanded_small.png "UI") 30 | 31 | ## Links 32 | 33 | + [PDF docs](https://github.com/RenderHeads/MayaPlugin-UVAutoRatio/releases/download/2015-2.5.x/UVAutoRatio2.0ProDocumentation.pdf) 34 | + [Tutorial video](https://vimeo.com/856301) 35 | + [Cached website 2011](https://web.archive.org/web/20111205111334/http://www.renderheads.com/portfolio/UVAutoRatio/) 36 | 37 | ## Open Source 38 | 39 | After selling this software for many years, we decided to stop developing it, so we released it as an open source project. 40 | 41 | + Written in C++ 42 | + Maya scripts written in MEL 43 | + Builds for Windows, macOS and Linux 44 | 45 | If you are prompted for a license key, you can use the following: 46 | 47 | `contact@renderheads.com-(0 user license)-RenderHeads-RenderHeads-UVAutoRatio 2.0 Pro-5A5W-2K55-6J2Z-343C-5A5W-2K55-4R2Z-343C-2K4N-0E1M-3G3C-1N4H` 48 | 49 | ## Maya SDK Setup 50 | 51 | The core Maya SDK must be available to the plugin in order to compile. The 3 folders needed are: 52 | + include 53 | + lib 54 | + lib64 55 | 56 | In order to build for multiple versions of Maya we use the following directory structure: 57 | 58 | MayaSDK/ 59 | Common/ 60 | Windows/ 61 | MacOSX/ 62 | Linux/ 63 | 64 | The Common folder contains all of the header files (contents of include folder), and the platform folders contain all the of the platform specific libraries (lib and lib64 folder). 65 | 66 | Each sub-folder starts with the Maya version number. 67 | 68 | For example: 69 | 70 | MayaSDK/ 71 | Common/ 72 | 6.0/ 73 | maya/ 74 | 8.5/ 75 | maya/ 76 | 2011/ 77 | maya/ 78 | tbb/ 79 | Windows/ 80 | 6.0/ 81 | lib/ 82 | 2008/ 83 | lib/ 84 | lib64/ 85 | 2011/ 86 | lib/ 87 | lib64/ 88 | MacOSX/ 89 | Linux/ 90 | 91 | In Windows set the environment variable MAYALIBBASE to the path of your MayaSDK folder. After adding the environment variable you may need to reopen Visual Studio. 92 | 93 | ## Compiling for Windows 94 | 95 | + The project solution is created with Visual Studio 2008. 96 | + Make sure you have set up your Maya SDK files as specified above 97 | + Each version of Maya has its own solution configuration. 32-bit and 64-bit cpu targets can be selected from the solution platform list. 98 | + Hit 'Build' and it should build a plugin for the current configuration. 99 | 100 | #### Add support for additional Maya versions 101 | To add a new configuration for another version of Maya: 102 | + Right-click on the solution and open Configuration Manager 103 | + In "Action solution configuration" select "New" 104 | + Select the latest release version of Maya from the list of "Copy settings from" 105 | + Make the name the same format but replace the version number 106 | + Make sure that the 32 and 64-bit settings are correct 107 | 108 | + Once the new configuration is created you'll need to configure the project for that configuration: 109 | + Right-click on the UVAutoRatio project and go to Properties 110 | + Select C/C++ > General 111 | + Edit "Additional Include Directories" to point the location of that versions include files. For example in Maya 2011 it would read "$(MAYALIBBASE)\Common\2011;" 112 | + Select C/C++ > Preprocessor 113 | + Make sure the list contains an entry for your version of Maya. For 2011 use "MAYA2011". This preprocessor is used later when including the Maya SDK headers to exclude or include certain features based on the version we're building for. 114 | + Select Linker > General 115 | + Set the Output File property to match your Maya version number. For 2011 it should read "$(OutDir)\UVAutoRatioPro2011.mll" 116 | + Set Additional Library Directories to point to the relevent Maya SDK folder. 117 | For Maya 2011 32-bit it would read "$(OutDir)";"$(MAYALIBBASE)\Windows\2011\lib"; 118 | For Maya 2011 64-bit it would read "$(OutDir)";"$(MAYALIBBASE)\Windows\2011\lib64"; 119 | 120 | ## Compiling for MacOSX 121 | 122 | + Use XCode to load the project "uvAutoRatioPro.xcodeproj" 123 | 124 | ## Compiling for Linux 125 | 126 | + See build.sh and buildall.sh 127 | + Use 'make' 128 | + The build script needs the following variales defines: 129 | + export ARCH=64 (for 64-bit building) 130 | + export MAYAVER=2011 (this is the maya version number, eg 8.5) 131 | + export MAYAVERs=2011 (this is the string version of the Maya version, so Maya 8.5 would be 85) 132 | 133 | ## Packaging for Windows 134 | 135 | + We build to a setup executable 136 | + Install NSIS v2.46 with the FindProcDLL plugin (http://nsis.sourceforge.net/FindProcDLL_plug-in) 137 | + Open InstallScript.NSI and increment the version numbers at the top to match the new build version number 138 | + Right-click the InstallScript.NSI and compile with NSI 139 | + The resulting installer file should appear in the Releases folder 140 | 141 | NOTE: If the installer fails to run, it may be because using a mapped drive 142 | 143 | ## Packaging for OSX and Linux 144 | 145 | + There is no setup, simply ZIP up all the files in the module folder to an appropriatly named ZIP file. 146 | -------------------------------------------------------------------------------- /UVAutoRatio/GetSurfaceUVArea.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // UVAutoRatio Maya Plugin Source Code 3 | // Copyright (C) 2007-2014 RenderHeads Ltd. 4 | // 5 | // This source is available for distribution and/or modification 6 | // only under the terms of the MIT license. All rights reserved. 7 | // 8 | // The source is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // FITNESS FOR A PARTICULAR PURPOSE. See the MIT license 11 | // for more details. 12 | // 13 | 14 | #include "MayaPCH.h" 15 | #include "MayaUtility.h" 16 | #include "Utility.h" 17 | #include "GetSurfaceUVArea.h" 18 | 19 | using namespace std; 20 | 21 | static const char* error_minimumSelection = "Something must be selected"; 22 | 23 | const char* GetSurfaceUVArea::GetSurfaceUVArea_Help[] = { 24 | " GetSurfaceUVArea Help\n", 25 | "\n", 26 | "\t-help (-hlp) This gets printed\n", 27 | "\t-uvSetName (-us) [string] The name of the UV set to use (optional)\n", 28 | "\t-fallback (-fb) If the named UV set is not found in a mesh, use the default UV set instead of skipping it (optional)\n", 29 | "\n" 30 | }; 31 | 32 | unsigned int GetSurfaceUVArea::helpLineCount = sizeof(GetSurfaceUVArea_Help)/sizeof(GetSurfaceUVArea_Help[0]); 33 | 34 | 35 | GetSurfaceUVArea::GetSurfaceUVArea() 36 | { 37 | m_isHelp = false; 38 | m_isFallback = true; 39 | m_isUVSetOverride = false; 40 | m_reportZeroAreas = false; 41 | } 42 | 43 | GetSurfaceUVArea::~GetSurfaceUVArea() 44 | { 45 | } 46 | 47 | void* 48 | GetSurfaceUVArea::creator() 49 | { 50 | return new GetSurfaceUVArea; 51 | } 52 | 53 | bool 54 | GetSurfaceUVArea::isUndoable() const 55 | { 56 | return false; 57 | } 58 | 59 | bool 60 | GetSurfaceUVArea::hasSyntax() const 61 | { 62 | return true; 63 | } 64 | 65 | MSyntax 66 | GetSurfaceUVArea::newSyntax() 67 | { 68 | MStatus status; 69 | MSyntax syntax; 70 | 71 | // flags 72 | syntax.addFlag("-hlp", "-help"); 73 | syntax.addFlag("-fb", "-fallback"); 74 | syntax.addFlag("-za", "-zeroArea"); 75 | syntax.addFlag("-us", "-uvSetName",MSyntax::kString); 76 | 77 | syntax.useSelectionAsDefault(false); 78 | syntax.enableQuery(false); 79 | syntax.enableEdit(false); 80 | return syntax; 81 | } 82 | 83 | const char* 84 | GetSurfaceUVArea::ParseArguments(const MArgList& args) 85 | { 86 | MArgDatabase argData(syntax(), args); 87 | 88 | m_isHelp = argData.isFlagSet("-help"); 89 | m_isFallback = argData.isFlagSet("-fallback"); 90 | m_reportZeroAreas = argData.isFlagSet("-zeroArea"); 91 | 92 | if (getArgValue(argData, "-us", "-uvSetName", m_UVSetName)) 93 | { 94 | m_isUVSetOverride = true; 95 | } 96 | 97 | return NULL; 98 | } 99 | 100 | MStatus 101 | GetSurfaceUVArea::Initialise(const MArgList& args) 102 | { 103 | clearResult(); 104 | 105 | // Parse arguments 106 | const char* errorMessage = ParseArguments(args); 107 | 108 | // Display help 109 | if (m_isHelp) 110 | { 111 | DisplayHelp(); 112 | return MS::kSuccess; 113 | } 114 | 115 | if (errorMessage) 116 | { 117 | displayError(errorMessage); 118 | return MS::kFailure; 119 | } 120 | 121 | return MS::kSuccess; 122 | } 123 | 124 | void 125 | GetSurfaceUVArea::DisplayHelp() const 126 | { 127 | for (unsigned int i=0; i 0) 155 | { 156 | // Split selection names out from string into string array 157 | MStringArray selectionNames; 158 | selectionString.split(' ', selectionNames); 159 | 160 | // Build up selection from selection names 161 | MSelectionList selection; 162 | selection.clear(); 163 | for (unsigned int i = 0; i < selectionNames.length(); i++) 164 | { 165 | selection.add(selectionNames[i]); 166 | } 167 | MGlobal::setActiveSelectionList(selection); 168 | }*/ 169 | 170 | // Convert selection to internal faces 171 | //status = MGlobal::executeCommand("select `polyListComponentConversion -fromUV -fromFace -fromVertex -toFace -internal`"); 172 | 173 | // Get selection 174 | //status = MGlobal::getActiveSelectionList(selection); 175 | 176 | MStringArray selections; 177 | MGlobal::executeCommand("polyListComponentConversion -fromUV -fromEdge -fromFace -fromVertex -toFace -internal;", selections); 178 | 179 | selection.clear(); 180 | for (unsigned int i = 0; i < selections.length(); i++) 181 | { 182 | selection.add(selections[i]); 183 | } 184 | 185 | double uvArea = 0.0; 186 | double surfaceArea = 0.0; 187 | 188 | // Process the selection 189 | MItSelectionList iter(selection); 190 | for ( ; !iter.isDone(); iter.next() ) 191 | { 192 | MDagPath dagPath; 193 | MObject component; 194 | 195 | iter.getDagPath( dagPath, component ); 196 | if (dagPath.node().hasFn(MFn::kPolyMesh) || dagPath.node().hasFn(MFn::kMesh)) 197 | { 198 | dagPath.extendToShape(); 199 | 200 | const MString* desiredUVSetName = NULL; 201 | if (m_isUVSetOverride) 202 | { 203 | desiredUVSetName = &m_UVSetName; 204 | } 205 | MFnMesh mesh(dagPath); 206 | if (FindMeshUVSetName(mesh, m_isUVSetOverride, m_isFallback, &desiredUVSetName)) 207 | { 208 | // Accumulate areas 209 | uvArea += GetAreaFacesUV(dagPath, component, desiredUVSetName); 210 | surfaceArea += GetAreaFacesSurface(dagPath, component, true); 211 | } 212 | } 213 | } 214 | 215 | double ratio = 1.0; 216 | if (surfaceArea != 0.0 && uvArea != 0.0) 217 | { 218 | ratio = surfaceArea / uvArea; 219 | } 220 | 221 | // Due to Maya's lack of precision when returning doubles, we need to convert to strings... 222 | // or NOT, seems this also sucks 223 | appendToResult(surfaceArea); 224 | appendToResult(uvArea); 225 | appendToResult(ratio); 226 | 227 | /* 228 | surfaceArea=0.00000001; 229 | uvArea=0.0000000000000002; 230 | 231 | static char text[128]; 232 | sprintf_s(text, sizeof(text), "%.25f", surfaceArea); 233 | appendToResult(text); 234 | sprintf_s(text, sizeof(text), "%.25f", uvArea); 235 | appendToResult(text); 236 | */ 237 | //appendToResult("0.00000001"); 238 | //appendToResult("0.0000000000000002"); 239 | 240 | /*MDoubleArray results; 241 | results.append(0.00000001); 242 | results.append(0.0000000000000002); 243 | setResult(results);*/ 244 | 245 | return MS::kSuccess; 246 | } 247 | 248 | /////////////////////////////////////////////////////////////////////////////// 249 | /////////////////////////////////////////////////////////////////////////////// 250 | 251 | -------------------------------------------------------------------------------- /UVAutoRatio/GetSurfaceUVArea.h: -------------------------------------------------------------------------------- 1 | // 2 | // UVAutoRatio Maya Plugin Source Code 3 | // Copyright (C) 2007-2014 RenderHeads Ltd. 4 | // 5 | // This source is available for distribution and/or modification 6 | // only under the terms of the MIT license. All rights reserved. 7 | // 8 | // The source is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // FITNESS FOR A PARTICULAR PURPOSE. See the MIT license 11 | // for more details. 12 | // 13 | 14 | #ifndef GETSURFACEUVAREA_H 15 | #define GETSURFACEUVAREA_H 16 | 17 | // Given a selection or a selection string argument, this command 18 | // returns 2 doubles, the surface area and then UV area. 19 | // 20 | // All types of selections are supported, and are converted to faces internally. 21 | class GetSurfaceUVArea : 22 | public MPxCommand 23 | { 24 | public: 25 | GetSurfaceUVArea(); 26 | virtual ~GetSurfaceUVArea(); 27 | 28 | MStatus doIt ( const MArgList& args ); 29 | bool isUndoable() const; 30 | bool hasSyntax() const; 31 | static void* creator(); 32 | static MSyntax newSyntax(); 33 | 34 | private: 35 | MStatus Initialise(const MArgList& args); 36 | const char* ParseArguments(const MArgList& args); 37 | void DisplayHelp() const; 38 | 39 | bool m_isHelp; 40 | bool m_isFallback; 41 | bool m_isUVSetOverride; 42 | bool m_reportZeroAreas; 43 | MString m_UVSetName; 44 | 45 | // Help static string data 46 | static const char* GetSurfaceUVArea_Help[]; 47 | static unsigned int helpLineCount; 48 | }; 49 | 50 | #endif 51 | 52 | -------------------------------------------------------------------------------- /UVAutoRatio/GetUVShellSelectionStrings.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // UVAutoRatio Maya Plugin Source Code 3 | // Copyright (C) 2007-2014 RenderHeads Ltd. 4 | // 5 | // This source is available for distribution and/or modification 6 | // only under the terms of the MIT license. All rights reserved. 7 | // 8 | // The source is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // FITNESS FOR A PARTICULAR PURPOSE. See the MIT license 11 | // for more details. 12 | // 13 | 14 | #include "MayaPCH.h" 15 | #include "MayaUtility.h" 16 | #include "Utility.h" 17 | #include "GetUVShellSelectionStrings.h" 18 | 19 | using namespace std; 20 | 21 | GetUVShellSelectionStrings::GetUVShellSelectionStrings() 22 | { 23 | } 24 | 25 | GetUVShellSelectionStrings::~GetUVShellSelectionStrings() 26 | { 27 | } 28 | 29 | void* 30 | GetUVShellSelectionStrings::creator() 31 | { 32 | return new GetUVShellSelectionStrings; 33 | } 34 | 35 | bool 36 | GetUVShellSelectionStrings::isUndoable() const 37 | { 38 | return false; 39 | } 40 | 41 | bool 42 | GetUVShellSelectionStrings::hasSyntax() const 43 | { 44 | return false; 45 | } 46 | 47 | MStatus 48 | GetUVShellSelectionStrings::doIt( const MArgList& args ) 49 | { 50 | MStatus status; 51 | MStringArray result; 52 | 53 | MSelectionList activeList; 54 | MGlobal::getActiveSelectionList (activeList); 55 | 56 | // Process the selection 57 | int objectIndex = 0; 58 | MItSelectionList iter(activeList); 59 | for ( ; !iter.isDone(); iter.next() ) 60 | { 61 | MDagPath dagPath; 62 | MObject component; 63 | iter.getDagPath( dagPath, component ); 64 | if (dagPath.node().hasFn(MFn::kTransform) || dagPath.node().hasFn(MFn::kPolyMesh) || dagPath.node().hasFn(MFn::kMesh)) 65 | { 66 | // Get Mesh 67 | dagPath.extendToShape(); 68 | MFnMesh mesh(dagPath, &status); 69 | 70 | MString uvSetName; 71 | //MStringArray setNames; 72 | //mesh.getUVSetNames(setNames) 73 | //for (int j = 0; j < setNames.length(); j++) 74 | //{ 75 | // MString uvSetName = setNames[j]; 76 | 77 | #ifdef MAYA85 78 | uvSetName = mesh.currentUVSetName(); 79 | #else 80 | mesh.getCurrentUVSetName(uvSetName); 81 | #endif 82 | 83 | //} 84 | 85 | MIntArray uvShellIDs; 86 | unsigned int numShells; 87 | status = mesh.getUvShellsIds(uvShellIDs, numShells, &uvSetName); 88 | 89 | for (unsigned int shellIndex = 0; shellIndex < numShells; shellIndex++) 90 | { 91 | /*// Count number of UV in this shell 92 | int numUVs = 0; 93 | for (unsigned int j = 0; j < uvShellIDs.length(); j++) 94 | { 95 | if (i == uvShellIDs[j]) 96 | { 97 | numUVs++; 98 | } 99 | }*/ 100 | 101 | // Build component list for UVs in shell 102 | int numComponents = 0; 103 | MFnSingleIndexedComponent uvComponent; 104 | MObject uvComponentObject = uvComponent.create(MFn::kMeshMapComponent, &status); 105 | for (unsigned int j = 0; j < uvShellIDs.length(); j++) 106 | { 107 | if (shellIndex == uvShellIDs[j]) 108 | { 109 | uvComponent.addElement(j); 110 | numComponents++; 111 | } 112 | } 113 | 114 | // Create selection for UVs 115 | MSelectionList uvSelection; 116 | uvSelection.add(dagPath, uvComponentObject); 117 | 118 | /*// Select UVs 119 | status = MGlobal::clearSelectionList(); 120 | status = MGlobal::setSelectionMode(MGlobal::MSelectionMode::kSelectComponentMode); 121 | MSelectionMask uvSelectionMask(MSelectionMask::kSelectMeshUVs); 122 | status = MGlobal::setComponentSelectionMask(uvSelectionMask); 123 | status = MGlobal::setActiveSelectionList(uvSelection);*/ 124 | 125 | 126 | MStringArray selectionStrings; 127 | uvSelection.getSelectionStrings(selectionStrings); 128 | MString selectionString = Convert(selectionStrings); 129 | 130 | // Friendly name 131 | MString friendlyString; 132 | 133 | friendlyString += objectIndex; 134 | friendlyString += ") " + mesh.name() + ".shell"; 135 | friendlyString += (int)shellIndex; 136 | friendlyString += " "; 137 | friendlyString += numComponents; 138 | friendlyString += "uvs (" + uvSetName + ") "; 139 | friendlyString += "*" + selectionString; 140 | 141 | // 1) polySurfaceShape14 s34 34 (map1) 142 | this->appendToResult(friendlyString); 143 | //this->appendToResult(selectionString); 144 | 145 | objectIndex++; 146 | } 147 | } 148 | } 149 | 150 | 151 | return MS::kSuccess; 152 | } 153 | 154 | /////////////////////////////////////////////////////////////////////////////// 155 | /////////////////////////////////////////////////////////////////////////////// 156 | 157 | -------------------------------------------------------------------------------- /UVAutoRatio/GetUVShellSelectionStrings.h: -------------------------------------------------------------------------------- 1 | // 2 | // UVAutoRatio Maya Plugin Source Code 3 | // Copyright (C) 2007-2014 RenderHeads Ltd. 4 | // 5 | // This source is available for distribution and/or modification 6 | // only under the terms of the MIT license. All rights reserved. 7 | // 8 | // The source is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // FITNESS FOR A PARTICULAR PURPOSE. See the MIT license 11 | // for more details. 12 | // 13 | 14 | #ifndef GETUVSHELLSELECTIONSTRINGS_H 15 | #define GETUVSHELLSELECTIONSTRINGS_H 16 | 17 | // Return discreet strings for all the selection strings that make up UV shells. 18 | // So if there are 2 shells, and each shell needs multiple things to define their selection, 19 | // It will return a string array of 2 strings, where each string is a space separated 20 | // list of the selection elements 21 | class GetUVShellSelectionStrings : 22 | public MPxCommand 23 | { 24 | public: 25 | GetUVShellSelectionStrings(); 26 | virtual ~GetUVShellSelectionStrings(); 27 | 28 | MStatus doIt ( const MArgList& args ); 29 | bool isUndoable() const; 30 | bool hasSyntax() const; 31 | static void* creator(); 32 | 33 | private: 34 | }; 35 | 36 | #endif 37 | 38 | -------------------------------------------------------------------------------- /UVAutoRatio/MayaPCH.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // UVAutoRatio Maya Plugin Source Code 3 | // Copyright (C) 2007-2014 RenderHeads Ltd. 4 | // 5 | // This source is available for distribution and/or modification 6 | // only under the terms of the MIT license. All rights reserved. 7 | // 8 | // The source is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // FITNESS FOR A PARTICULAR PURPOSE. See the MIT license 11 | // for more details. 12 | // 13 | 14 | //#define MNoVersionString 15 | #include "MayaPCH.h" 16 | 17 | -------------------------------------------------------------------------------- /UVAutoRatio/MayaPCH.h: -------------------------------------------------------------------------------- 1 | // 2 | // UVAutoRatio Maya Plugin Source Code 3 | // Copyright (C) 2007-2014 RenderHeads Ltd. 4 | // 5 | // This source is available for distribution and/or modification 6 | // only under the terms of the MIT license. All rights reserved. 7 | // 8 | // The source is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // FITNESS FOR A PARTICULAR PURPOSE. See the MIT license 11 | // for more details. 12 | // 13 | 14 | #ifndef MAYAPCH_H 15 | #define MAYAPCH_H 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | #if MAYA85 || MAYA2008 || MAYA2009 || MAYA2010 || MAYA2011 || MAYA2012 || MAYA2013 || MAYA20135 || MAYA2014 || MAYA2015 || MAYA2016 23 | #include 24 | using namespace std; 25 | #endif 26 | 27 | #define MNoVersionString 28 | 29 | // Common 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | //#include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | #include 53 | #include 54 | #include 55 | #include 56 | 57 | // Components 58 | #include 59 | #include 60 | 61 | 62 | 63 | // Iterators 64 | #include 65 | #include 66 | #include 67 | #include 68 | #include 69 | #include 70 | #include 71 | #include 72 | #include 73 | #include 74 | 75 | // Components 76 | #include 77 | #include 78 | 79 | // Types 80 | #include 81 | #include 82 | #include 83 | #include 84 | #include 85 | #include 86 | #include 87 | #include 88 | #include 89 | #include 90 | #include 91 | 92 | // Data 93 | #include 94 | #include 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /UVAutoRatio/MayaPlugin.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // UVAutoRatio Maya Plugin Source Code 3 | // Copyright (C) 2007-2014 RenderHeads Ltd. 4 | // 5 | // This source is available for distribution and/or modification 6 | // only under the terms of the MIT license. All rights reserved. 7 | // 8 | // The source is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // FITNESS FOR A PARTICULAR PURPOSE. See the MIT license 11 | // for more details. 12 | // 13 | 14 | #include "MayaPCH.h" 15 | #include "MayaUtility.h" 16 | #include "MayaPlugin.h" 17 | 18 | MayaPlugin::MayaPlugin(const MayaPluginParams& params) 19 | { 20 | m_productName = params.productName; 21 | m_productShortName = params.productShortName; 22 | m_authorString = params.authorString; 23 | m_versionString = params.versionString; 24 | 25 | #ifdef _DEBUG 26 | MGlobal::startErrorLogging(); 27 | #endif 28 | } 29 | 30 | MayaPlugin::~MayaPlugin() 31 | { 32 | #ifdef _DEBUG 33 | MGlobal::stopErrorLogging(); 34 | MGlobal::closeErrorLog(); 35 | #endif 36 | } 37 | 38 | void 39 | MayaPlugin::Load(MObject& pluginObject) 40 | { 41 | char finalVersionStr[256]; 42 | #ifdef WIN32 43 | sprintf_s(finalVersionStr, sizeof(finalVersionStr), "%s, %s @ %s", m_versionString.asChar(), __DATE__, __TIME__); 44 | #else 45 | sprintf(finalVersionStr, "%s, | %s @ %s", m_versionString.asChar(), __DATE__, __TIME__); 46 | #endif 47 | 48 | MFnPlugin plugin(pluginObject, m_authorString.asChar(), finalVersionStr, "Any"); 49 | 50 | 51 | LoadFeatures(plugin); 52 | } 53 | 54 | void 55 | MayaPlugin::Unload(MObject& pluginObject) 56 | { 57 | MStatus status; 58 | MFnPlugin plugin(pluginObject); 59 | 60 | UnloadUserPlugins(plugin); 61 | } 62 | 63 | void 64 | MayaPlugin::LoadFeatures(MFnPlugin& plugin) 65 | { 66 | LoadUserPlugins(plugin); 67 | } 68 | 69 | void 70 | MayaPlugin::DisplayInfo(const MString& text) const 71 | { 72 | MGlobal::displayInfo(m_productShortName + ": " + text); 73 | } 74 | 75 | void 76 | MayaPlugin::DisplayWarning(const MString& text) const 77 | { 78 | MGlobal::displayWarning(m_productShortName + ": " + text); 79 | } 80 | 81 | /////////////////////////////////////////////////////////////////////////////// 82 | /////////////////////////////////////////////////////////////////////////////// -------------------------------------------------------------------------------- /UVAutoRatio/MayaPlugin.h: -------------------------------------------------------------------------------- 1 | // 2 | // UVAutoRatio Maya Plugin Source Code 3 | // Copyright (C) 2007-2014 RenderHeads Ltd. 4 | // 5 | // This source is available for distribution and/or modification 6 | // only under the terms of the MIT license. All rights reserved. 7 | // 8 | // The source is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // FITNESS FOR A PARTICULAR PURPOSE. See the MIT license 11 | // for more details. 12 | // 13 | 14 | #ifndef MAYAPLUGIN_H 15 | #define MAYAPLUGIN_H 16 | 17 | struct MayaPluginParams 18 | { 19 | MString productName, productShortName; 20 | MString versionString; 21 | MString authorString; 22 | }; 23 | 24 | class MayaPlugin 25 | { 26 | public: 27 | MayaPlugin(const MayaPluginParams& params); 28 | virtual ~MayaPlugin(); 29 | 30 | void Load(MObject& pluginObject); 31 | void Unload(MObject& pluginObject); 32 | 33 | protected: 34 | void LoadFeatures(MFnPlugin& plugin); 35 | virtual void LoadUserPlugins(MFnPlugin& plugin) = 0; 36 | virtual void UnloadUserPlugins(MFnPlugin& plugin) = 0; 37 | void DisplayWarning(const MString& text) const; 38 | void DisplayInfo(const MString& text) const; 39 | 40 | MString m_authorString; 41 | MString m_versionString; 42 | MString m_productName, m_productShortName; 43 | 44 | private: 45 | const char* ErrorLogFilename; 46 | }; 47 | 48 | #endif 49 | 50 | /////////////////////////////////////////////////////////////////////////////// 51 | /////////////////////////////////////////////////////////////////////////////// -------------------------------------------------------------------------------- /UVAutoRatio/MayaUtility.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // UVAutoRatio Maya Plugin Source Code 3 | // Copyright (C) 2007-2014 RenderHeads Ltd. 4 | // 5 | // This source is available for distribution and/or modification 6 | // only under the terms of the MIT license. All rights reserved. 7 | // 8 | // The source is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // FITNESS FOR A PARTICULAR PURPOSE. See the MIT license 11 | // for more details. 12 | // 13 | 14 | #define MNoVersionString 15 | #include "MayaPCH.h" 16 | #include "MayaUtility.h" 17 | 18 | void 19 | SetOptionVar(const MString& varName, const std::string& val) 20 | { 21 | #if MAYA_API_VERSION < 800 22 | MString command = "optionVar -stringValue \""; 23 | command += varName; 24 | command += "\" \""; 25 | command += val.c_str(); 26 | command += "\";"; 27 | MGlobal::executeCommand(command); 28 | #else 29 | MGlobal::setOptionVarValue(varName, val.c_str()); 30 | #endif 31 | } 32 | 33 | MString 34 | Convert(MStringArray& strings) 35 | { 36 | MString result; 37 | for (unsigned int i = 0; i < strings.length(); i++) 38 | { 39 | if (i != 0) 40 | { 41 | result += " "; 42 | } 43 | result += strings[i]; 44 | } 45 | 46 | return result; 47 | } 48 | 49 | bool 50 | hasArg(const MArgDatabase& argData,const char* shortName,const char* longName) 51 | { 52 | return (argData.isFlagSet(shortName) || argData.isFlagSet(longName)); 53 | } 54 | 55 | bool 56 | getArgValue(const MArgDatabase& argData,const char* shortName,const char* longName,unsigned int& result) 57 | { 58 | MStatus status; 59 | if (hasArg(argData,shortName,longName)) 60 | { 61 | unsigned int val; 62 | status=argData.getFlagArgument(longName, 0, val); 63 | if (status==MS::kSuccess) 64 | { 65 | result=val; 66 | return true; 67 | } 68 | } 69 | return false; 70 | } 71 | 72 | bool 73 | getArgValue(const MArgDatabase& argData,const char* shortName,const char* longName,int& result) 74 | { 75 | MStatus status; 76 | if (hasArg(argData,shortName,longName)) 77 | { 78 | int val; 79 | status=argData.getFlagArgument(longName, 0, val); 80 | if (status==MS::kSuccess) 81 | { 82 | result=val; 83 | return true; 84 | } 85 | } 86 | return false; 87 | } 88 | 89 | bool 90 | getArgValue(const MArgDatabase& argData,const char* shortName,const char* longName,double& result) 91 | { 92 | MStatus status; 93 | if (hasArg(argData,shortName,longName)) 94 | { 95 | double val; 96 | status=argData.getFlagArgument(longName, 0, val); 97 | if (status==MS::kSuccess) 98 | { 99 | result=val; 100 | return true; 101 | } 102 | } 103 | return false; 104 | } 105 | 106 | bool 107 | getArgValue(const MArgDatabase& argData,const char* shortName,const char* longName,float& result) 108 | { 109 | MStatus status; 110 | if (hasArg(argData,shortName,longName)) 111 | { 112 | double val; 113 | status=argData.getFlagArgument(longName, 0, val); 114 | if (status==MS::kSuccess) 115 | { 116 | result=(float)val; 117 | return true; 118 | } 119 | } 120 | return false; 121 | } 122 | 123 | bool 124 | getArgValue(const MArgDatabase& argData,const char* shortName,const char* longName,float2& result) 125 | { 126 | MStatus status; 127 | if (hasArg(argData,shortName,longName)) 128 | { 129 | double val1, val2; 130 | status=argData.getFlagArgument(longName, 0, val1); 131 | status=argData.getFlagArgument(longName, 1, val2); 132 | if (status==MS::kSuccess) 133 | { 134 | result[0]=(float)val1; 135 | result[1]=(float)val2; 136 | return true; 137 | } 138 | } 139 | return false; 140 | } 141 | 142 | bool 143 | getArgValue(const MArgDatabase& argData,const char* shortName,const char* longName,float3& result) 144 | { 145 | MStatus status; 146 | if (hasArg(argData,shortName,longName)) 147 | { 148 | double val1, val2, val3; 149 | status=argData.getFlagArgument(longName, 0, val1); 150 | status=argData.getFlagArgument(longName, 1, val2); 151 | status=argData.getFlagArgument(longName, 2, val3); 152 | if (status==MS::kSuccess) 153 | { 154 | result[0]=(float)val1; 155 | result[1]=(float)val2; 156 | result[2]=(float)val3; 157 | return true; 158 | } 159 | } 160 | return false; 161 | } 162 | 163 | bool 164 | getArgValue(const MArgDatabase& argData,const char* shortName,const char* longName,double3& result) 165 | { 166 | MStatus status; 167 | if (hasArg(argData,shortName,longName)) 168 | { 169 | double val1, val2, val3; 170 | status=argData.getFlagArgument(longName, 0, val1); 171 | status=argData.getFlagArgument(longName, 1, val2); 172 | status=argData.getFlagArgument(longName, 2, val3); 173 | if (status==MS::kSuccess) 174 | { 175 | result[0]=val1; 176 | result[1]=val2; 177 | result[2]=val3; 178 | return true; 179 | } 180 | } 181 | return false; 182 | } 183 | 184 | bool 185 | getArgValue(const MArgDatabase& argData,const char* shortName,const char* longName,MString& result) 186 | { 187 | MStatus status; 188 | if (hasArg(argData,shortName,longName)) 189 | { 190 | MString val; 191 | status=argData.getFlagArgument(longName, 0, val); 192 | if (status==MS::kSuccess) 193 | { 194 | result=val; 195 | return true; 196 | } 197 | } 198 | return false; 199 | } -------------------------------------------------------------------------------- /UVAutoRatio/MayaUtility.h: -------------------------------------------------------------------------------- 1 | // 2 | // UVAutoRatio Maya Plugin Source Code 3 | // Copyright (C) 2007-2014 RenderHeads Ltd. 4 | // 5 | // This source is available for distribution and/or modification 6 | // only under the terms of the MIT license. All rights reserved. 7 | // 8 | // The source is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // FITNESS FOR A PARTICULAR PURPOSE. See the MIT license 11 | // for more details. 12 | // 13 | 14 | #ifndef MAYAUTILITY_H 15 | #define MAYAUTILITY_H 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | struct TimerResult 25 | { 26 | MString name; 27 | float time; 28 | }; 29 | 30 | void SetOptionVar(const MString& varName, const std::string& val); 31 | 32 | MString Convert(MStringArray& strings); 33 | 34 | bool hasArg(const MArgDatabase& argData,const char* shortName,const char* longName); 35 | bool getArgValue(const MArgDatabase& argData,const char* shortName,const char* longName,int& result); 36 | bool getArgValue(const MArgDatabase& argData,const char* shortName,const char* longName,unsigned int& result); 37 | bool getArgValue(const MArgDatabase& argData,const char* shortName,const char* longName,double& result); 38 | bool getArgValue(const MArgDatabase& argData,const char* shortName,const char* longName,float& result); 39 | bool getArgValue(const MArgDatabase& argData,const char* shortName,const char* longName,float2& result); 40 | bool getArgValue(const MArgDatabase& argData,const char* shortName,const char* longName,float3& result); 41 | bool getArgValue(const MArgDatabase& argData,const char* shortName,const char* longName,double3& result); 42 | bool getArgValue(const MArgDatabase& argData,const char* shortName,const char* longName,MString& result); 43 | 44 | inline double 45 | RandomSignedUnit() 46 | { 47 | return (((double)rand() / (double)RAND_MAX) - 0.5) * 2.0; 48 | } 49 | 50 | inline MColor 51 | Lerp(const MColor& src, const MColor& dst, float t) 52 | { 53 | MColor result; 54 | result.r = src.r + (dst.r - src.r) * t; 55 | result.g = src.g + (dst.g - src.g) * t; 56 | result.b = src.b + (dst.b - src.b) * t; 57 | result.a = src.a + (dst.a - src.a) * t; 58 | return result; 59 | } 60 | 61 | inline unsigned int 62 | Min(unsigned int value1, unsigned int value2) 63 | { 64 | #ifdef WIN32 65 | return min(value1, value2); 66 | #else 67 | return std::min(value1, value2); 68 | #endif 69 | } 70 | 71 | inline int 72 | Min(int value1, int value2) 73 | { 74 | #ifdef WIN32 75 | return min(value1, value2); 76 | #else 77 | return std::min(value1, value2); 78 | #endif 79 | } 80 | 81 | inline double 82 | Min(double value1, double value2) 83 | { 84 | #ifdef WIN32 85 | return min(value1, value2); 86 | #else 87 | return std::min(value1, value2); 88 | #endif 89 | } 90 | 91 | inline float 92 | Min(float value1, float value2) 93 | { 94 | #ifdef WIN32 95 | return min(value1, value2); 96 | #else 97 | return std::min(value1, value2); 98 | #endif 99 | } 100 | 101 | inline double 102 | Max(double value1, double value2) 103 | { 104 | #ifdef WIN32 105 | return max(value1, value2); 106 | #else 107 | return std::max(value1, value2); 108 | #endif 109 | } 110 | 111 | inline float 112 | Max(float value1, float value2) 113 | { 114 | #ifdef WIN32 115 | return max(value1, value2); 116 | #else 117 | return std::max(value1, value2); 118 | #endif 119 | } 120 | 121 | inline unsigned int 122 | ClampUInt(unsigned int low, unsigned int high, unsigned int val) 123 | { 124 | #ifdef WIN32 125 | return min(max(low, val), high); 126 | #else 127 | return std::min(std::max(low, val), high); 128 | #endif 129 | } 130 | 131 | inline int 132 | ClampInt(int low, int high, int val) 133 | { 134 | #ifdef WIN32 135 | return min(max(low, val), high); 136 | #else 137 | return std::min(std::max(low, val), high); 138 | #endif 139 | } 140 | 141 | inline float 142 | ClampFloat(float low, float high, float val) 143 | { 144 | #ifdef WIN32 145 | return min(max(low, val), high); 146 | #else 147 | return std::min(std::max(low, val), high); 148 | #endif 149 | } 150 | 151 | inline double 152 | ClampDouble(double low, double high, double val) 153 | { 154 | #ifdef WIN32 155 | return min(max(low, val), high); 156 | #else 157 | return std::min(std::max(low, val), high); 158 | #endif 159 | } 160 | 161 | // Macros 162 | // 163 | #define MCheckStatus(status,message) \ 164 | if( MStatus::kSuccess != status ) \ 165 | { \ 166 | status.perror(message); \ 167 | return status; \ 168 | } 169 | 170 | #endif 171 | -------------------------------------------------------------------------------- /UVAutoRatio/MeshProcessor.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // UVAutoRatio Maya Plugin Source Code 3 | // Copyright (C) 2007-2014 RenderHeads Ltd. 4 | // 5 | // This source is available for distribution and/or modification 6 | // only under the terms of the MIT license. All rights reserved. 7 | // 8 | // The source is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // FITNESS FOR A PARTICULAR PURPOSE. See the MIT license 11 | // for more details. 12 | // 13 | 14 | #include "MayaPCH.h" 15 | #include "Utility.h" 16 | #include "Timer.h" 17 | #include "ShellProcessor.h" 18 | 19 | void 20 | MeshProcessor::Gather(UVJob& job) 21 | { 22 | MStatus status; 23 | 24 | job.surfaceArea = GetAreaMeshSurface(job.mesh->dagPath, true); 25 | if (job.surfaceArea == 0.0) 26 | { 27 | job.error = ZERO_SURFACE_AREA; 28 | return; 29 | } 30 | 31 | job.textureArea = GetAreaMeshUV(job.mesh->dagPath, &job.mesh->useUVSetName); 32 | job.finalTextureArea = job.textureArea; 33 | if (job.textureArea == 0.0) 34 | { 35 | job.error = ZERO_TEXTURE_AREA; 36 | return; 37 | } 38 | 39 | // Get the UV's 40 | status = job.mesh->model->getUVs(job.mesh->uArray, job.mesh->vArray, &job.mesh->useUVSetName); 41 | assert(job.mesh->uArray.length() == job.mesh->vArray.length()); 42 | if (job.mesh->uArray.length() != job.mesh->vArray.length()) 43 | { 44 | job.error = U_V_LISTS_DIFFERENT_LENGTHS; 45 | return; 46 | } 47 | 48 | // Find the UV Center 49 | double minU, maxU, minV, maxV; 50 | GetMinMaxValues(job.mesh->uArray, minU, maxU); 51 | GetMinMaxValues(job.mesh->vArray, minV, maxV); 52 | job.centerU = (minU + maxU) * 0.5; 53 | job.centerV = (minV + maxV) * 0.5; 54 | job.uvWidth = maxU - minU; 55 | job.uvHeight = maxV - minV; 56 | } 57 | 58 | JobError 59 | MeshProcessor::FindScale(MeshJob& job, double threshold, double& finalScale, double& finalTextureArea, int& iterationsPerformed) 60 | { 61 | MStatus status; 62 | 63 | JobError result = OK; 64 | 65 | double minScale, maxScale; 66 | double scale = 1.0; 67 | 68 | finalTextureArea = job.surfaceArea / m_params.m_goalRatio; 69 | 70 | if (job.textureArea > finalTextureArea) 71 | { 72 | // we need to scale uv's DOWN 73 | minScale = 0.00001; 74 | maxScale = 1.0; 75 | } 76 | else 77 | { 78 | // we need to scale uv's UP 79 | minScale = 1.0; 80 | maxScale = 100000.0; 81 | } 82 | 83 | // iterate until UV area is within the threshold of the goal 84 | int numIterations = 0; 85 | while (numIterations < m_params.m_maxIterations) 86 | { 87 | // Pick a midpoint between the scale ranges 88 | scale = minScale + (maxScale - minScale) * 0.5; 89 | 90 | // Scale the UV's 91 | ScaleMeshUVs(job, scale); 92 | 93 | // Read the new UV Area 94 | double newUVArea = GetAreaMeshUV(job.mesh->dagPath, &job.mesh->useUVSetName); 95 | 96 | // If it is within threshold, leave it and return 97 | { 98 | double ratio = job.surfaceArea / newUVArea; 99 | if (fabs(ratio - m_params.m_goalRatio) < threshold) 100 | //if (fabs(newUVArea - finalTextureArea) < threshold) 101 | { 102 | finalScale = scale; 103 | break; 104 | } 105 | } 106 | 107 | // Converge the min and max scale range 108 | if (newUVArea > finalTextureArea) 109 | { 110 | maxScale = scale; 111 | } 112 | else 113 | { 114 | minScale = scale; 115 | } 116 | 117 | // Check for impossible situation, perhaps change this to < threshold check 118 | if (minScale == maxScale) 119 | { 120 | // Exit here, otherwise this function will never exit 121 | result = ITERATION_FAILED; 122 | break; 123 | } 124 | 125 | numIterations++; 126 | } 127 | 128 | if (numIterations >= m_params.m_maxIterations) 129 | { 130 | result = RATIO_NOT_FOUND; 131 | } 132 | 133 | iterationsPerformed = numIterations; 134 | 135 | return result; 136 | } 137 | 138 | double 139 | MeshProcessor::FindScaleFactor(double shapeArea, double targetArea, double width, double height) const 140 | { 141 | double rectArea = width * height; 142 | double areaRatio = rectArea / shapeArea; // how many times bigger the square is compared to the shape, and it'll ALWAYS be bigger 143 | 144 | double targetSquareArea = targetArea * areaRatio; 145 | double rectRatio = width / height; 146 | double targetHeight = sqrt(targetSquareArea / rectRatio); 147 | //double targetWidth = targetSquareArea / targetHeight; 148 | 149 | return targetHeight / height; 150 | } 151 | 152 | void 153 | MeshProcessor::FindScale(UVJob& uvjob) 154 | { 155 | MeshJob& job = (MeshJob&)uvjob; 156 | 157 | bool fast = true; 158 | 159 | if (m_params.m_scalingAxis != Both) 160 | fast = false; 161 | 162 | // try to quickly find the scale 163 | if (fast) 164 | { 165 | double targetTextureArea = job.surfaceArea / m_params.m_goalRatio; 166 | double scale = FindScaleFactor(job.textureArea, targetTextureArea, job.uvWidth, job.uvHeight); 167 | job.finalScaleX = scale; 168 | job.finalScaleY = scale; 169 | job.finalTextureArea = targetTextureArea; 170 | job.iterationsPerformed = 0; 171 | 172 | /* 173 | // Scale the UV's 174 | ScaleMeshUVs(job, scale); 175 | 176 | // Read the new UV Area 177 | double newUVArea = GetAreaMeshUV(job.mesh->dagPath, &job.mesh->useUVSetName); 178 | double ratio = job.surfaceArea / newUVArea; 179 | 180 | static char text[1024]; 181 | sprintf_s(text, sizeof(text), "RESULTS: Scale:%.25f Area:%.25f Ratio:%.25f %.25f", scale, newUVArea, ratio, fabs(ratio - m_params.m_goalRatio)); 182 | MGlobal::displayInfo(text); 183 | 184 | // Scale the UV's back to original 185 | job.mesh->ResetUVs();*/ 186 | } 187 | // if it's not accurate enough, iterate to find it 188 | else 189 | { 190 | // NHKL - check with Badge this is intentionally not used, and not a bug 191 | //double threshold = m_params.m_threshold; 192 | int iterationsPerformed, totalIterations = 0; 193 | double finalScale, finalTextureArea; 194 | 195 | JobError error = ITERATION_FAILED; 196 | double power = -4.0; 197 | 198 | while (error != OK && power < 4.0) 199 | { 200 | double threshold = pow(10, power); 201 | error = FindScale(job, threshold, finalScale, finalTextureArea, iterationsPerformed); 202 | 203 | power += 1.0; 204 | totalIterations += iterationsPerformed; 205 | } 206 | 207 | if (error == OK) 208 | { 209 | job.finalScaleX = finalScale; 210 | job.finalScaleY = finalScale; 211 | job.finalTextureArea = finalTextureArea; 212 | } 213 | else 214 | { 215 | // At this point the scale wasn't found within the threshold accuracy 216 | // We can choose to fail or just pick the closest ratio 217 | bool takeBest = false; 218 | if (takeBest) 219 | { 220 | job.finalScaleX = finalScale; 221 | job.finalScaleY = finalScale; 222 | job.finalTextureArea = finalTextureArea; 223 | } 224 | else 225 | { 226 | job.error = error; 227 | job.finalScaleX = 1.0; 228 | job.finalScaleY = 1.0; 229 | job.finalTextureArea = 1.0; 230 | } 231 | } 232 | 233 | job.iterationsPerformed = totalIterations; 234 | 235 | // Scale the UV's back to original 236 | job.mesh->ResetUVs(); 237 | } 238 | } 239 | 240 | void 241 | MeshProcessor::ScaleMeshUVs(UVJob& job, double scale) 242 | { 243 | MStatus status; 244 | 245 | // copy original UV's 246 | MFloatArray uArray, vArray; 247 | uArray.copy(job.mesh->uArray); 248 | vArray.copy(job.mesh->vArray); 249 | 250 | assert(uArray.length() == vArray.length()); 251 | 252 | uint numSamples = uArray.length(); 253 | uint i = 0; 254 | 255 | switch (m_params.m_scalingAxis) 256 | { 257 | case Both: 258 | for (i=0; imodel->setUVs(uArray, vArray, &job.mesh->useUVSetName); 280 | } 281 | 282 | void 283 | MeshProcessor::ApplyScale(UVJob& job) 284 | { 285 | MStatus status; 286 | 287 | // Select the UVs 288 | status = MGlobal::clearSelectionList(); 289 | status = MGlobal::setSelectionMode(MGlobal::kSelectObjectMode); 290 | status = MGlobal::select(job.mesh->dagPath, MObject::kNullObj); 291 | status = MGlobal::executeCommand("ConvertSelectionToUVs;"); 292 | 293 | 294 | // Execute scale command 295 | static char text[1024]; 296 | /*sprintf_s(text, sizeof(text), "%lf %.25f %.32f", job.centerU, job.centerU, job.centerU); 297 | MGlobal::displayInfo(text);*/ 298 | //const char* command = "polyEditUV -relative true -pivotU %.20f -pivotV %.20f -scale true -scaleU %.20f -scaleV %.20f"; 299 | const char* command = "polyMoveUV -pivot %.20f %.20f -scale %.20f %.20f -translate %.20f %.20f"; 300 | 301 | double scaleU = job.finalScaleX; 302 | double scaleV = job.finalScaleY; 303 | switch (m_params.m_scalingAxis) 304 | { 305 | case Both: 306 | break; 307 | case Horizontal: 308 | scaleV = 1.0; 309 | break; 310 | case Vertical: 311 | scaleU = 1.0; 312 | break; 313 | } 314 | 315 | #ifdef WIN32 316 | sprintf_s(text, sizeof(text), command, job.centerU, job.centerV, scaleU, scaleV, job.offsetU, job.offsetV); 317 | #else 318 | sprintf(text, command, job.centerU, job.centerV, scaleU, scaleV, job.offsetU, job.offsetV); 319 | #endif 320 | 321 | if (m_undoHistory != NULL) 322 | { 323 | MDGModifier* modifier = new MDGModifier; 324 | m_undoHistory->push_back(modifier); 325 | status = modifier->commandToExecute(text); 326 | status = modifier->doIt(); 327 | } 328 | else 329 | { 330 | MGlobal::executeCommand(text); 331 | } 332 | 333 | job.completed = true; 334 | } 335 | 336 | -------------------------------------------------------------------------------- /UVAutoRatio/Processor.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // UVAutoRatio Maya Plugin Source Code 3 | // Copyright (C) 2007-2014 RenderHeads Ltd. 4 | // 5 | // This source is available for distribution and/or modification 6 | // only under the terms of the MIT license. All rights reserved. 7 | // 8 | // The source is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // FITNESS FOR A PARTICULAR PURPOSE. See the MIT license 11 | // for more details. 12 | // 13 | 14 | #include "MayaPCH.h" 15 | #include "Utility.h" 16 | #include "UVAutoRatioPro.h" 17 | #include "ShellProcessor.h" 18 | 19 | Mesh::Mesh() 20 | { 21 | model = NULL; 22 | error = OK; 23 | m_jobs.reserve(32); 24 | } 25 | 26 | Mesh::~Mesh() 27 | { 28 | if (model != NULL) 29 | { 30 | delete model; 31 | model = NULL; 32 | } 33 | 34 | // Delete all jobs 35 | { 36 | std::vector::reverse_iterator riter; 37 | for ( riter = m_jobs.rbegin(); riter != m_jobs.rend(); ++riter ) 38 | { 39 | delete (*riter); 40 | } 41 | m_jobs.clear(); 42 | } 43 | } 44 | 45 | void 46 | Mesh::ResetUVs() 47 | { 48 | MStatus status; 49 | status = model->setUVs(uArray, vArray, &useUVSetName); 50 | //CHECK_MSTATUS(status); 51 | } 52 | 53 | void 54 | Mesh::Gather(Processor& processor, bool isUVSetOverride, bool isFallback, const MString& UVSetName) 55 | { 56 | MStatus status; 57 | 58 | // Mesh data 59 | model = new MFnMesh(dagPath, &status); 60 | if (status != MS::kSuccess) 61 | { 62 | error = INVALID_MESH; 63 | return; 64 | } 65 | name = model->name(); 66 | 67 | // Find the UV set to use 68 | UVSetResult uvSetResult = FindUVSet(*model, isUVSetOverride, isFallback, UVSetName); 69 | if (uvSetResult == NONE) 70 | { 71 | error = UVSET_NOTFOUND; 72 | return; 73 | } 74 | else 75 | { 76 | currentUVSetName = GetCurrentUVSetName(*model); 77 | 78 | switch (uvSetResult) 79 | { 80 | case CURRENT: 81 | useUVSetName = currentUVSetName;//NULL; 82 | break; 83 | case OVERRIDE: 84 | useUVSetName = UVSetName; 85 | model->setCurrentUVSetName(useUVSetName); 86 | break; 87 | case NONE: 88 | break; 89 | } 90 | } 91 | 92 | UVAutoRatioPro::SetNumSubTasks((int)m_jobs.size(), "Jobs"); 93 | for (uint i = 0; i < m_jobs.size(); i++) 94 | { 95 | if (UVAutoRatioPro::IsProgressCancelled()) 96 | break; 97 | 98 | UVAutoRatioPro::StepJobProgress(); 99 | 100 | UVJob& job = *m_jobs[i]; 101 | processor.Gather(job); 102 | } 103 | } 104 | 105 | void 106 | Mesh::FindScale(Processor& processor, double goalRatio, double threshold) 107 | { 108 | // if an alternative uvset was used, restore the previous one 109 | if (useUVSetName != currentUVSetName) 110 | { 111 | model->setCurrentUVSetName(useUVSetName); 112 | } 113 | 114 | UVAutoRatioPro::SetNumSubTasks((int)m_jobs.size(), "Jobs"); 115 | for (uint i = 0; i < m_jobs.size(); i++) 116 | { 117 | if (UVAutoRatioPro::IsProgressCancelled()) 118 | break; 119 | 120 | UVAutoRatioPro::StepJobProgress(); 121 | 122 | UVJob& job = *m_jobs[i]; 123 | if (!job.error) 124 | { 125 | double ratio = job.surfaceArea / job.textureArea; 126 | 127 | // if we're close enough then don't operate 128 | if (fabs(ratio - goalRatio) >= threshold) 129 | { 130 | processor.FindScale(job); 131 | } 132 | } 133 | } 134 | } 135 | 136 | void 137 | Mesh::ApplyScale(Processor& processor) 138 | { 139 | UVAutoRatioPro::SetNumSubTasks((int)m_jobs.size(), "Jobs"); 140 | for (uint i = 0; i < m_jobs.size(); i++) 141 | { 142 | if (UVAutoRatioPro::IsProgressCancelled()) 143 | break; 144 | 145 | UVAutoRatioPro::StepJobProgress(); 146 | 147 | UVJob& job = *m_jobs[i]; 148 | if (!job.error) 149 | { 150 | if (job.finalScaleX != 1.0 || job.finalScaleY != 1.0 || job.offsetU != 0.0 || job.offsetV != 0.0) 151 | { 152 | processor.ApplyScale(job); 153 | } 154 | } 155 | } 156 | 157 | // if an alternative uvset was used, restore the previous one 158 | if (useUVSetName != currentUVSetName) 159 | { 160 | model->setCurrentUVSetName(currentUVSetName); 161 | } 162 | } 163 | 164 | UVJob::UVJob() 165 | { 166 | error = OK; 167 | completed = false; 168 | surfaceArea = 0.0; 169 | textureArea = 0.0; 170 | finalScaleX = finalScaleY = 1.0; 171 | finalTextureArea = 0.0; 172 | iterationsPerformed = 0; 173 | 174 | centerU = centerV = 0.0; 175 | uvWidth = uvHeight = 0.0; 176 | offsetU = offsetV = 0.0; 177 | 178 | mesh = NULL; 179 | } 180 | 181 | 182 | UVJob::~UVJob() 183 | { 184 | } 185 | 186 | MeshJob::MeshJob() : UVJob() 187 | { 188 | } 189 | 190 | MeshJob::~MeshJob() 191 | { 192 | } 193 | 194 | ShellJob::ShellJob() : UVJob() 195 | { 196 | meshShellNumber = 0; 197 | uvIndices = NULL; 198 | uvComponents = NULL; 199 | numIndices = 0; 200 | } 201 | 202 | ShellJob::~ShellJob() 203 | { 204 | if (uvIndices != NULL) 205 | { 206 | delete [] uvIndices; 207 | uvIndices = NULL; 208 | } 209 | 210 | if (uvComponents != NULL) 211 | { 212 | delete uvComponents; 213 | uvComponents = NULL; 214 | } 215 | } 216 | 217 | 218 | MString 219 | MeshJob::GetName() const 220 | { 221 | return mesh->name; 222 | } 223 | 224 | MString 225 | ShellJob::GetName() const 226 | { 227 | MString name = " shell:"; 228 | name += meshShellNumber; 229 | return name; 230 | } 231 | 232 | -------------------------------------------------------------------------------- /UVAutoRatio/ShellProcessor.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // UVAutoRatio Maya Plugin Source Code 3 | // Copyright (C) 2007-2014 RenderHeads Ltd. 4 | // 5 | // This source is available for distribution and/or modification 6 | // only under the terms of the MIT license. All rights reserved. 7 | // 8 | // The source is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // FITNESS FOR A PARTICULAR PURPOSE. See the MIT license 11 | // for more details. 12 | // 13 | 14 | #include "MayaPCH.h" 15 | #include "Utility.h" 16 | #include "Timer.h" 17 | #include "UVAutoRatioPro.h" 18 | #include "ShellProcessor.h" 19 | 20 | // Scales the mesh UV's by a factor 21 | // Note: if the mesh has history that modifies the UV's, this operation will be overridden 22 | // once the DAG updates 23 | // It's slightly faster to not scale about the center so we can use this to quickly do temporary scales 24 | // to calculate area 25 | void 26 | ShellProcessor::ScaleMeshUVs(ShellJob& job, double scale) 27 | { 28 | MStatus status; 29 | 30 | // copy original UV's 31 | MFloatArray uArray, vArray; 32 | uArray.copy(job.mesh->uArray); 33 | vArray.copy(job.mesh->vArray); 34 | assert(uArray.length() == vArray.length()); 35 | int i = 0; 36 | 37 | // scale UV's 38 | //if (!aboutCenter) 39 | { 40 | switch (m_params.m_scalingAxis) 41 | { 42 | case Both: 43 | for (i = 0; i < job.numIndices; i++) 44 | { 45 | unsigned int index = job.uvIndices[i]; 46 | assert(index < uArray.length()); 47 | 48 | uArray[index] *= (float)scale; 49 | vArray[index] *= (float)scale; 50 | } 51 | break; 52 | case Horizontal: 53 | for (i = 0; i < job.numIndices; i++) 54 | { 55 | unsigned int index = job.uvIndices[i]; 56 | assert(index < uArray.length()); 57 | 58 | uArray[index] *= (float)scale; 59 | } 60 | break; 61 | case Vertical: 62 | for (i = 0; i < job.numIndices; i++) 63 | { 64 | unsigned int index = job.uvIndices[i]; 65 | assert(index < uArray.length()); 66 | 67 | vArray[index] *= (float)scale; 68 | } 69 | break; 70 | } 71 | } 72 | /* 73 | else 74 | { 75 | for (i = 0; i < job.numIndices; i++) 76 | { 77 | unsigned int index = job.uvIndices[i]; 78 | assert(index < uArray.length()); 79 | 80 | // cast to double for more accurate operations 81 | double u = uArray[index]; 82 | double v = vArray[index]; 83 | u -= job.centerU; 84 | v -= job.centerV; 85 | u *= scale; 86 | v *= scale; 87 | u += job.centerU; 88 | v += job.centerV; 89 | uArray[index] = (float)u; 90 | vArray[index] = (float)v; 91 | } 92 | }*/ 93 | 94 | // set mesh UV's 95 | status = job.mesh->model->setUVs(uArray, vArray, &job.mesh->useUVSetName); 96 | } 97 | 98 | 99 | JobError 100 | ShellProcessor::FindScale(ShellJob& job, double threshold, double& finalScale, double& finalTextureArea, int& iterationsPerformed) 101 | { 102 | MStatus status; 103 | 104 | JobError result = OK; 105 | 106 | double minScale, maxScale; 107 | double scale = 1.0; 108 | 109 | double startRatio = job.surfaceArea / job.textureArea; 110 | 111 | if (startRatio < m_params.m_goalRatio) 112 | { 113 | // we need to scale uv's DOWN 114 | minScale = 0.00001; 115 | maxScale = 1.0; 116 | } 117 | else 118 | { 119 | // we need to scale uv's UP 120 | minScale = 1.0; 121 | maxScale = 100000.0; 122 | } 123 | 124 | // iterate until UV area is within the threshold of the goal 125 | int numIterations = 0; 126 | while (numIterations < m_params.m_maxIterations) 127 | { 128 | // Pick a midpoint between the scale ranges 129 | scale = minScale + (maxScale - minScale) * 0.5; 130 | 131 | // Scale the UV's 132 | ScaleMeshUVs(job, scale); 133 | 134 | // Read the new UV Area 135 | double newUVArea = GetAreaFacesUV(job.mesh->dagPath, job.faceComponentObject, &job.mesh->useUVSetName); 136 | 137 | double ratio = job.surfaceArea / newUVArea; 138 | 139 | // If it is within threshold, leave it and return 140 | if (fabs(ratio - m_params.m_goalRatio) < threshold) 141 | { 142 | finalScale = scale; 143 | finalTextureArea = newUVArea; 144 | break; 145 | } 146 | 147 | // Converge the min and max scale range 148 | if (ratio < m_params.m_goalRatio) 149 | { 150 | maxScale = scale; 151 | } 152 | else 153 | { 154 | minScale = scale; 155 | } 156 | 157 | // Check for impossible situation, perhaps change this to < threshold check 158 | if (minScale == maxScale) 159 | { 160 | // Exit here, otherwise this function will never exit 161 | result = ITERATION_FAILED; 162 | break; 163 | } 164 | 165 | numIterations++; 166 | } 167 | 168 | if (numIterations >= m_params.m_maxIterations) 169 | { 170 | result = RATIO_NOT_FOUND; 171 | } 172 | 173 | iterationsPerformed = numIterations; 174 | 175 | return result; 176 | } 177 | 178 | double 179 | ShellProcessor::FindScaleFactor(double shapeArea, double targetArea, double width, double height) const 180 | { 181 | double rectArea = width * height; 182 | double areaRatio = rectArea / shapeArea; // how many times bigger the square is compared to the shape, and it'll ALWAYS be bigger 183 | 184 | double targetSquareArea = targetArea * areaRatio; 185 | double rectRatio = width / height; 186 | double targetHeight = sqrt(targetSquareArea / rectRatio); 187 | //double targetWidth = targetSquareArea / targetHeight; 188 | 189 | return targetHeight / height; 190 | } 191 | 192 | double 193 | roundPrecision(double v,const double precision) 194 | { 195 | return ((double)(int((v*precision)+0.5))) / precision; 196 | } 197 | 198 | void 199 | ShellProcessor::FindScale(UVJob& uvjob) 200 | { 201 | ShellJob& job = (ShellJob&)uvjob; 202 | 203 | bool fast = true; 204 | 205 | if (m_params.m_scalingAxis != Both) 206 | fast = false; 207 | 208 | // try to quickly find the scale 209 | if (fast) 210 | { 211 | double targetTextureArea = job.surfaceArea / m_params.m_goalRatio; 212 | double scale = FindScaleFactor(job.textureArea, targetTextureArea, job.uvWidth, job.uvHeight); 213 | //scale=roundPrecision(scale, 10000.0); 214 | job.finalScaleX = scale; 215 | job.finalScaleY = scale; 216 | job.finalTextureArea = targetTextureArea; 217 | job.iterationsPerformed = 0; 218 | 219 | /* 220 | // Scale the UV's 221 | ScaleMeshUVs(job, scale); 222 | //ApplyScale(job); 223 | 224 | // Read the new UV Area 225 | double newUVArea = GetAreaFacesUV(job.mesh->dagPath, job.faceComponentObject, &job.mesh->useUVSetName); 226 | double ratio = job.surfaceArea / newUVArea; 227 | 228 | static char text[1024]; 229 | sprintf_s(text, sizeof(text), "RESULTS: Scale:%.25f Area:%.12f,%.12f Ratio:%.12f %.12f", scale, newUVArea, targetTextureArea, ratio, fabs(ratio - m_params.m_goalRatio)); 230 | MGlobal::displayInfo(text); 231 | 232 | // Scale the UV's back to original 233 | job.mesh->ResetUVs();*/ 234 | } 235 | // if it's not accurate enough, iterate to find it 236 | else 237 | { 238 | //double threshold = m_params.m_threshold; 239 | int iterationsPerformed, totalIterations = 0; 240 | double finalScale, finalTextureArea; 241 | 242 | JobError error = ITERATION_FAILED; 243 | double power = -4.0; 244 | 245 | while (error != OK && power < 4.0) 246 | { 247 | double threshold = pow(10, power); 248 | error = FindScale(job, threshold, finalScale, finalTextureArea, iterationsPerformed); 249 | 250 | power += 1.0; 251 | totalIterations += iterationsPerformed; 252 | } 253 | 254 | if (error == OK) 255 | { 256 | job.finalScaleX = finalScale; 257 | job.finalScaleY = finalScale; 258 | job.finalTextureArea = finalTextureArea; 259 | } 260 | else 261 | { 262 | job.error = error; 263 | job.finalScaleX = 1.0; 264 | job.finalScaleY = 1.0; 265 | job.finalTextureArea = 1.0; 266 | } 267 | 268 | job.iterationsPerformed = totalIterations; 269 | 270 | // Scale the UV's back to original 271 | job.mesh->ResetUVs(); 272 | } 273 | } 274 | 275 | void 276 | ShellProcessor::Gather(UVJob& uvjob) 277 | { 278 | MStatus status; 279 | 280 | ShellJob& job = (ShellJob&)uvjob; 281 | 282 | job.uvComponents = new MFnSingleIndexedComponent(job.uvComponentObject); 283 | 284 | // Get UV indices 285 | { 286 | job.numIndices = job.uvComponents->elementCount(); 287 | job.uvIndices = new int[job.numIndices]; 288 | for (int i = 0; i < job.numIndices; i++) 289 | { 290 | int index = job.uvComponents->element(i); 291 | job.uvIndices[i] = index; 292 | } 293 | } 294 | 295 | // Get face components from UV components 296 | UVToFaceComponents(job.mesh->dagPath, job.uvComponentObject, job.faceComponentObject); 297 | 298 | // Get area 299 | job.textureArea = GetAreaFacesUV(job.mesh->dagPath, job.faceComponentObject, &job.mesh->useUVSetName); 300 | job.finalTextureArea = job.textureArea; 301 | if (job.textureArea == 0.0) 302 | { 303 | job.error = ZERO_TEXTURE_AREA; 304 | return; 305 | } 306 | 307 | job.surfaceArea = GetAreaFacesSurface(job.mesh->dagPath, job.faceComponentObject, true); 308 | if (job.surfaceArea == 0.0) 309 | { 310 | job.error = ZERO_SURFACE_AREA; 311 | return; 312 | } 313 | 314 | // Get the UV's 315 | status = job.mesh->model->getUVs(job.mesh->uArray, job.mesh->vArray, &job.mesh->useUVSetName); 316 | assert(job.mesh->uArray.length() == job.mesh->vArray.length()); 317 | if (job.mesh->uArray.length() != job.mesh->vArray.length()) 318 | { 319 | job.error = U_V_LISTS_DIFFERENT_LENGTHS; 320 | return; 321 | } 322 | 323 | // Find the UV center, width & height 324 | double minU, maxU, minV, maxV; 325 | GetMinMaxValues(job.mesh->uArray, job.uvIndices, job.numIndices, minU, maxU); 326 | GetMinMaxValues(job.mesh->vArray, job.uvIndices, job.numIndices, minV, maxV); 327 | job.centerU = (minU + maxU) * 0.5; 328 | job.centerV = (minV + maxV) * 0.5; 329 | job.uvWidth = maxU - minU; 330 | job.uvHeight = maxV - minV; 331 | } 332 | 333 | void 334 | ShellProcessor::ApplyScale(UVJob& uvjob) 335 | { 336 | MStatus status; 337 | 338 | ShellJob& job = (ShellJob&)uvjob; 339 | 340 | // Select mesh object 341 | // WARNING: This may FAIL in the old version, must make sure the selection type is correct for both!! 342 | // TODO: couldn't i just select the uvComponents???? 343 | status = MGlobal::clearSelectionList(); 344 | status = MGlobal::setSelectionMode(MGlobal::kSelectComponentMode); 345 | status = MGlobal::select(job.mesh->dagPath, job.faceComponentObject); 346 | status = MGlobal::executeCommand("ConvertSelectionToUVs;"); 347 | 348 | if (UVAutoRatioPro::IsProgressCancelled()) 349 | return; 350 | 351 | // Execute UV scale MEL command 352 | //const char* command = "polyEditUV -relative true -pivotU %.20f -pivotV %.20f -scale true -scaleU %.20f -scaleV %.20f -uValue %.20f -vValue %.20f"; 353 | const char* command = "polyMoveUV -pivot %.20f %.20f -scale %.20f %.20f -translate %.20f %.20f"; 354 | 355 | double scaleU = job.finalScaleX; 356 | double scaleV = job.finalScaleY; 357 | switch (m_params.m_scalingAxis) 358 | { 359 | case Both: 360 | break; 361 | case Horizontal: 362 | scaleV = 1.0; 363 | break; 364 | case Vertical: 365 | scaleU = 1.0; 366 | break; 367 | } 368 | 369 | static char text[2048]; 370 | #ifdef WIN32 371 | sprintf_s(text, sizeof(text), command, job.centerU, job.centerV, scaleU, scaleV, job.offsetU, job.offsetV); 372 | #else 373 | sprintf(text, command, job.centerU, job.centerV, scaleU, scaleV, job.offsetU, job.offsetV); 374 | #endif 375 | 376 | if (m_undoHistory != NULL) 377 | { 378 | MDGModifier* modifier = new MDGModifier; 379 | m_undoHistory->push_back(modifier); 380 | status = modifier->commandToExecute(text); 381 | status = modifier->doIt(); 382 | } 383 | else 384 | { 385 | MGlobal::executeCommand(text); 386 | } 387 | 388 | /* 389 | if (UVAutoRatioPro::IsProgressCancelled()) 390 | return; 391 | 392 | if (job.offsetU != 0.0 || job.offsetV != 0.0) 393 | { 394 | const char* command = "polyMoveUV -tu %.20f -tv %.20f"; 395 | 396 | #ifdef WIN32 397 | sprintf_s(text, sizeof(text), command, job.offsetU, job.offsetV); 398 | #else 399 | sprintf(text, command, job.offsetU, job.offsetV); 400 | #endif 401 | 402 | if (m_undoHistory != NULL) 403 | { 404 | MDGModifier* modifier = new MDGModifier; 405 | m_undoHistory->push_back(modifier); 406 | status = modifier->commandToExecute(text); 407 | status = modifier->doIt(); 408 | } 409 | else 410 | { 411 | MGlobal::executeCommand(text); 412 | } 413 | } 414 | */ 415 | job.completed = true; 416 | } -------------------------------------------------------------------------------- /UVAutoRatio/ShellProcessor.h: -------------------------------------------------------------------------------- 1 | // 2 | // UVAutoRatio Maya Plugin Source Code 3 | // Copyright (C) 2007-2014 RenderHeads Ltd. 4 | // 5 | // This source is available for distribution and/or modification 6 | // only under the terms of the MIT license. All rights reserved. 7 | // 8 | // The source is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // FITNESS FOR A PARTICULAR PURPOSE. See the MIT license 11 | // for more details. 12 | // 13 | 14 | #ifndef SHELLPROCESSOR_H 15 | #define SHELLPROCESSOR_H 16 | 17 | #include 18 | #include 19 | 20 | enum OperationMode 21 | { 22 | ObjectLevel, 23 | UVShellLevel, 24 | }; 25 | 26 | enum ScaleDirection 27 | { 28 | Both, 29 | Horizontal, 30 | Vertical 31 | }; 32 | 33 | struct UVAutoRatioProParams 34 | { 35 | bool m_isHelp; 36 | double m_goalRatio; 37 | double m_threshold; 38 | bool m_isVerbose; 39 | bool m_isShowTiming; 40 | MString m_UVSetName; 41 | bool m_isUVSetOverride; 42 | bool m_isFallback; 43 | bool m_skipScaling; 44 | bool m_isColour; 45 | int m_maxIterations; 46 | OperationMode m_operationMode; 47 | bool m_layoutShells; 48 | bool m_normalise; 49 | bool m_normaliseKeepAspectRatio; 50 | ScaleDirection m_scalingAxis; 51 | uint m_layoutIterations; 52 | double m_layoutMinDistance; 53 | double m_layoutStep; 54 | 55 | UVAutoRatioProParams& operator = (const UVAutoRatioProParams& src) 56 | { 57 | m_isHelp = src.m_isHelp; 58 | m_goalRatio = src.m_goalRatio; 59 | m_threshold = src.m_threshold; 60 | m_isVerbose = src.m_isVerbose; 61 | m_UVSetName = src.m_UVSetName; 62 | m_isUVSetOverride = src.m_isUVSetOverride; 63 | m_isFallback = src.m_isFallback; 64 | m_skipScaling = src.m_skipScaling; 65 | m_isColour = src.m_isColour; 66 | m_maxIterations = src.m_maxIterations; 67 | m_operationMode = src.m_operationMode; 68 | m_layoutShells = src.m_layoutShells; 69 | m_layoutIterations = src.m_layoutIterations; 70 | m_scalingAxis = src.m_scalingAxis; 71 | m_layoutStep = src.m_layoutStep; 72 | 73 | m_isShowTiming = src.m_isShowTiming; 74 | m_normalise = src.m_normalise; 75 | m_normaliseKeepAspectRatio = src.m_normaliseKeepAspectRatio; 76 | m_layoutMinDistance = src.m_layoutMinDistance; 77 | 78 | return *this; 79 | } 80 | }; 81 | 82 | enum JobError 83 | { 84 | OK = 0, 85 | NO_UVSET_FOUND = 1, 86 | UVSET_NOTFOUND = 2, 87 | RATIO_NOT_FOUND = 3, 88 | INVALID_MESH = 4, 89 | U_V_LISTS_DIFFERENT_LENGTHS = 5, 90 | ITERATION_FAILED = 6, 91 | ZERO_TEXTURE_AREA = 7, 92 | ZERO_SURFACE_AREA = 8, 93 | SKIPPED = 9, 94 | }; 95 | 96 | class UVJob; 97 | class Processor; 98 | 99 | class Mesh 100 | { 101 | public: 102 | // stores mesh stuff 103 | // for each mesh that is going to be processed 104 | Mesh(); 105 | ~Mesh(); 106 | 107 | MFnMesh* model; 108 | MDagPath dagPath; 109 | MString name; 110 | 111 | MFloatArray uArray, vArray; 112 | 113 | MString currentUVSetName, useUVSetName; 114 | 115 | JobError error; 116 | 117 | std::vector m_jobs; 118 | 119 | void Gather(Processor& processor, bool isUVSetOverride, bool isFallback, const MString& UVSetName); 120 | void FindScale(Processor& processor, double goalRatio, double threshold); 121 | void ApplyScale(Processor& processor); 122 | void ResetUVs(); 123 | }; 124 | 125 | class UVJob 126 | { 127 | public: 128 | UVJob(); 129 | virtual ~UVJob(); 130 | 131 | virtual MString GetName() const=0; 132 | 133 | JobError error; 134 | 135 | double surfaceArea, textureArea; 136 | double finalScaleX, finalScaleY; 137 | double finalTextureArea; 138 | int iterationsPerformed; 139 | 140 | double centerU, centerV; 141 | double uvWidth, uvHeight; 142 | double offsetU, offsetV; 143 | 144 | Mesh* mesh; 145 | 146 | bool completed; 147 | }; 148 | 149 | class MeshJob : public UVJob 150 | { 151 | public: 152 | MeshJob(); 153 | virtual ~MeshJob(); 154 | 155 | MString GetName() const; 156 | }; 157 | 158 | class ShellJob : public UVJob 159 | { 160 | public: 161 | ShellJob(); 162 | virtual ~ShellJob(); 163 | 164 | int meshShellNumber; 165 | int* uvIndices; 166 | int numIndices; 167 | MFnSingleIndexedComponent* uvComponents; 168 | 169 | MObject uvComponentObject; 170 | MObject faceComponentObject; 171 | 172 | MString GetName() const; 173 | }; 174 | 175 | class Processor 176 | { 177 | public: 178 | UVAutoRatioProParams m_params; 179 | std::vector* m_undoHistory; 180 | 181 | virtual void Gather(UVJob& job)=0; 182 | virtual void FindScale(UVJob& job)=0; 183 | virtual void ApplyScale(UVJob& job)=0; 184 | }; 185 | 186 | class MeshProcessor : public Processor 187 | { 188 | public: 189 | void Gather(UVJob& job); 190 | void FindScale(UVJob& job); 191 | void ApplyScale(UVJob& job); 192 | 193 | private: 194 | double FindScaleFactor(double shapeArea, double targetArea, double width, double height) const; 195 | void ScaleMeshUVs(UVJob& job, double scale); 196 | JobError FindScale(MeshJob& job, double threshold, double& finalScale, double& finalTextureArea, int& iterationsPerformed); 197 | }; 198 | 199 | class ShellProcessor : public Processor 200 | { 201 | public: 202 | void Gather(UVJob& job); 203 | void FindScale(UVJob& job); 204 | void ApplyScale(UVJob& job); 205 | 206 | private: 207 | double FindScaleFactor(double shapeArea, double targetArea, double width, double height) const; 208 | void ScaleMeshUVs(ShellJob& job, double scale); 209 | JobError FindScale(ShellJob& job, double threshold, double& finalScale, double& finalTextureArea, int& iterationsPerformed); 210 | }; 211 | 212 | #endif 213 | 214 | -------------------------------------------------------------------------------- /UVAutoRatio/Timer.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // UVAutoRatio Maya Plugin Source Code 3 | // Copyright (C) 2007-2014 RenderHeads Ltd. 4 | // 5 | // This source is available for distribution and/or modification 6 | // only under the terms of the MIT license. All rights reserved. 7 | // 8 | // The source is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // FITNESS FOR A PARTICULAR PURPOSE. See the MIT license 11 | // for more details. 12 | // 13 | 14 | #define MNoVersionString 15 | #include "MayaPCH.h" 16 | #include "Timer.h" 17 | #include 18 | 19 | #ifdef WIN32 20 | 21 | Timer::Timer() 22 | { 23 | frequency = 0; 24 | performance_timer_start = 0; 25 | resolution = 0; 26 | mm_timer_start = 0; 27 | mm_timer_elapsed = 0; 28 | performance_timer_elapsed = 0; 29 | performance_timer = 0; 30 | reset(); 31 | } 32 | 33 | void Timer::reset() // Initialize Our Timer (Get It Ready) 34 | { 35 | // Check To See If A Performance Counter Is Available 36 | // If One Is Available The Timer Frequency Will Be Updated 37 | if (!QueryPerformanceFrequency((LARGE_INTEGER *) &frequency)) 38 | { 39 | // No Performance Counter Available 40 | performance_timer = FALSE; // Set Performance Timer To FALSE 41 | mm_timer_start = timeGetTime(); // Use timeGetTime() To Get Current Time 42 | resolution = 1.0f/1000.0f; // Set Our Timer Resolution To .001f 43 | frequency = 1000; // Set Our Timer Frequency To 1000 44 | mm_timer_elapsed = mm_timer_start; // Set The Elapsed Time To The Current Time 45 | } 46 | else 47 | { 48 | // Performance Counter Is Available, Use It Instead Of The Multimedia Timer 49 | // Get The Current Time And Store It In performance_timer_start 50 | QueryPerformanceCounter((LARGE_INTEGER *) &performance_timer_start); 51 | performance_timer = TRUE; // Set Performance Timer To TRUE 52 | // Calculate The Timer Resolution Using The Timer Frequency 53 | resolution = (float) (((double)1.0f)/((double)frequency)); 54 | // Set The Elapsed Time To The Current Time 55 | performance_timer_elapsed = performance_timer_start; 56 | } 57 | } 58 | 59 | float Timer::getTime() const // Get Time In Milliseconds 60 | { 61 | __int64 time; // time Will Hold A 64 Bit Integer 62 | if (performance_timer) // Are We Using The Performance Timer? 63 | { 64 | QueryPerformanceCounter((LARGE_INTEGER *) &time); // Grab The Current Performance Time 65 | // Return The Current Time Minus The Start Time Multiplied By The Resolution And 1000 (To Get MS) 66 | return ( (float) ( time - performance_timer_start) * resolution)*1000.0f; 67 | //return (int) ((time - performance_timer_start) * resolution * 1000.0f); 68 | } 69 | else 70 | { 71 | // Return The Current Time Minus The Start Time Multiplied By The Resolution And 1000 (To Get MS) 72 | return ( (float) ( timeGetTime() - mm_timer_start) * resolution)*1000.0f; 73 | //return (int) ((timeGetTime() - mm_timer_start) * resolution * 1000.0f); 74 | } 75 | } 76 | 77 | #else 78 | 79 | Timer::Timer() 80 | { 81 | _timer = new timeb; 82 | ftime((timeb*)_timer); 83 | } 84 | 85 | Timer::~Timer() 86 | { 87 | if (_timer) delete (timeb*)_timer; 88 | } 89 | 90 | void Timer::reset() 91 | { 92 | ftime((timeb*)_timer); 93 | } 94 | 95 | float Timer::getTime() const 96 | { 97 | timeb now; 98 | ftime(&now); 99 | 100 | int ds = (int)now.time - (int)((timeb*)_timer)->time; 101 | int dms = (int)now.millitm - (int)((timeb*)_timer)->millitm; 102 | 103 | return (float)(ds * 1000 + dms); 104 | } 105 | 106 | #endif -------------------------------------------------------------------------------- /UVAutoRatio/Timer.h: -------------------------------------------------------------------------------- 1 | // 2 | // UVAutoRatio Maya Plugin Source Code 3 | // Copyright (C) 2007-2014 RenderHeads Ltd. 4 | // 5 | // This source is available for distribution and/or modification 6 | // only under the terms of the MIT license. All rights reserved. 7 | // 8 | // The source is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // FITNESS FOR A PARTICULAR PURPOSE. See the MIT license 11 | // for more details. 12 | // 13 | 14 | #ifndef TIMER_H 15 | #define TIMER_H 16 | 17 | #ifdef WIN32 18 | 19 | #include 20 | #include 21 | #pragma comment(lib,"winmm.lib") 22 | // Ctime.h 23 | class Timer 24 | { 25 | private: 26 | __int64 frequency; // Timer Frequency 27 | float resolution; // Timer Resolution 28 | unsigned long mm_timer_start; // Multimedia Timer Start Value 29 | unsigned long mm_timer_elapsed; // Multimedia Timer Elapsed Time 30 | bool performance_timer; // Using The Performance Timer? 31 | __int64 performance_timer_start; // Performance Timer Start Value 32 | __int64 performance_timer_elapsed; // Performance Timer Elapsed Time 33 | 34 | public: 35 | Timer(); 36 | float getTime() const; 37 | void reset(); 38 | }; 39 | 40 | #else 41 | 42 | class Timer 43 | { 44 | public: 45 | void reset(); 46 | float getTime() const; 47 | 48 | Timer(); 49 | ~Timer(); 50 | 51 | private: 52 | void *_timer; 53 | }; 54 | 55 | #endif 56 | 57 | #endif 58 | 59 | -------------------------------------------------------------------------------- /UVAutoRatio/UVAutoRatioPlugin.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // UVAutoRatio Maya Plugin Source Code 3 | // Copyright (C) 2007-2014 RenderHeads Ltd. 4 | // 5 | // This source is available for distribution and/or modification 6 | // only under the terms of the MIT license. All rights reserved. 7 | // 8 | // The source is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // FITNESS FOR A PARTICULAR PURPOSE. See the MIT license 11 | // for more details. 12 | // 13 | 14 | #include "MayaPCH.h" 15 | #include "GetUVShellSelectionStrings.h" 16 | #include "GetSurfaceUVArea.h" 17 | #include "UVAutoRatioPro.h" 18 | #include "UVAutoRatioPlugin.h" 19 | 20 | UVAutoRatioPlugin::UVAutoRatioPlugin(const MayaPluginParams& params) : MayaPlugin(params) 21 | { 22 | m_UVAutoRatioProCreated = false; 23 | m_GetSurfaceUVAreaCreated = false; 24 | m_GetUVShellSelectionStringsCreated = false; 25 | } 26 | 27 | void 28 | UVAutoRatioPlugin::LoadUserPlugins(MFnPlugin& plugin) 29 | { 30 | MStatus status; 31 | 32 | // Register the command 33 | if (!m_UVAutoRatioProCreated) 34 | { 35 | status = plugin.registerCommand("UVAutoRatioPro", UVAutoRatioPro::creator,UVAutoRatioPro::newSyntax); 36 | if (MStatus::kSuccess != status) 37 | { 38 | status.perror("registerCommand UVAutoRatioPro failed"); 39 | } 40 | m_UVAutoRatioProCreated = true; 41 | } 42 | 43 | // Register the command 44 | if (!m_GetSurfaceUVAreaCreated) 45 | { 46 | status = plugin.registerCommand("GetSurfaceUVArea", GetSurfaceUVArea::creator, GetSurfaceUVArea::newSyntax); 47 | if (MStatus::kSuccess != status) 48 | { 49 | status.perror("registerCommand GetSurfaceUVArea failed"); 50 | } 51 | m_GetSurfaceUVAreaCreated = true; 52 | } 53 | 54 | // Register the command 55 | if (!m_GetUVShellSelectionStringsCreated) 56 | { 57 | status = plugin.registerCommand("GetUVShellSelectionStrings", GetUVShellSelectionStrings::creator); 58 | if (MStatus::kSuccess != status) 59 | { 60 | status.perror("registerCommand GetUVShellSelectionStrings failed"); 61 | } 62 | m_GetUVShellSelectionStringsCreated = true; 63 | } 64 | 65 | // 66 | //status = plugin.registerNode( Cas_checkerBoxNode::typeName, Cas_checkerBoxNode::typeId, Cas_checkerBoxNode::creator , Cas_checkerBoxNode::initialize , MPxNode::kLocatorNode ); 67 | //MCheckStatus(status,"registerCommand Cas_checkerBoxNode failed"); 68 | } 69 | 70 | void 71 | UVAutoRatioPlugin::UnloadUserPlugins(MFnPlugin& plugin) 72 | { 73 | MStatus status; 74 | 75 | // Unregister command 76 | if (m_GetUVShellSelectionStringsCreated) 77 | { 78 | status = plugin.deregisterCommand("GetUVShellSelectionStrings"); 79 | if (MStatus::kSuccess != status) 80 | { 81 | status.perror("deregisterCommand GetUVShellSelectionStrings failed"); 82 | } 83 | m_GetUVShellSelectionStringsCreated = false; 84 | } 85 | 86 | // Unregister command 87 | if (m_GetSurfaceUVAreaCreated) 88 | { 89 | status = plugin.deregisterCommand("GetSurfaceUVArea"); 90 | if (MStatus::kSuccess != status) 91 | { 92 | status.perror("deregisterCommand GetSurfaceUVArea failed"); 93 | } 94 | m_GetSurfaceUVAreaCreated = false; 95 | } 96 | 97 | // Unregister command 98 | if (m_UVAutoRatioProCreated) 99 | { 100 | status = plugin.deregisterCommand("UVAutoRatioPro"); 101 | if (MStatus::kSuccess != status) 102 | { 103 | status.perror("deregisterCommand UVAutoRatioPro failed"); 104 | } 105 | m_UVAutoRatioProCreated = false; 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /UVAutoRatio/UVAutoRatioPlugin.h: -------------------------------------------------------------------------------- 1 | // 2 | // UVAutoRatio Maya Plugin Source Code 3 | // Copyright (C) 2007-2014 RenderHeads Ltd. 4 | // 5 | // This source is available for distribution and/or modification 6 | // only under the terms of the MIT license. All rights reserved. 7 | // 8 | // The source is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // FITNESS FOR A PARTICULAR PURPOSE. See the MIT license 11 | // for more details. 12 | // 13 | 14 | #ifndef UVAUTORATIOPLUGIN_H 15 | #define UVAUTORATIOPLUGIN_H 16 | 17 | #include "MayaPlugin.h" 18 | 19 | class MFnPlugin; 20 | 21 | class UVAutoRatioPlugin : public MayaPlugin 22 | { 23 | public: 24 | UVAutoRatioPlugin(const MayaPluginParams& params); 25 | 26 | protected: 27 | void LoadUserPlugins(MFnPlugin& plugin); 28 | void UnloadUserPlugins(MFnPlugin& plugin); 29 | 30 | private: 31 | bool m_GetUVShellSelectionStringsCreated; 32 | bool m_GetSurfaceUVAreaCreated; 33 | bool m_UVAutoRatioProCreated; 34 | }; 35 | 36 | #endif 37 | 38 | -------------------------------------------------------------------------------- /UVAutoRatio/UVAutoRatioPro.h: -------------------------------------------------------------------------------- 1 | // 2 | // UVAutoRatio Maya Plugin Source Code 3 | // Copyright (C) 2007-2014 RenderHeads Ltd. 4 | // 5 | // This source is available for distribution and/or modification 6 | // only under the terms of the MIT license. All rights reserved. 7 | // 8 | // The source is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // FITNESS FOR A PARTICULAR PURPOSE. See the MIT license 11 | // for more details. 12 | // 13 | 14 | #ifndef UVAUTORATIOPRO_H 15 | #define UVAUTORATIOPRO_H 16 | 17 | #include 18 | #include 19 | #include "Timer.h" 20 | #include "ShellProcessor.h" 21 | 22 | class MeshJob; 23 | class ShellJob; 24 | class Mesh; 25 | 26 | struct ValidMesh 27 | { 28 | MDagPath dagPath; 29 | std::vector components; 30 | std::vector validShells; 31 | 32 | ValidMesh() 33 | { 34 | components.reserve(16); 35 | validShells.reserve(16); 36 | } 37 | 38 | inline bool HasShell(int index) 39 | { 40 | size_t num = validShells.size(); 41 | for (size_t i = 0; i < num; i++) 42 | { 43 | if (validShells[i] == index) 44 | return true; 45 | } 46 | return false; 47 | } 48 | }; 49 | 50 | class UVMesh; 51 | 52 | class UVAutoRatioPro : 53 | public MPxCommand 54 | { 55 | public: 56 | UVAutoRatioPro(); 57 | virtual ~UVAutoRatioPro(); 58 | 59 | // MPxCommand Implemented 60 | MStatus doIt (const MArgList& args); 61 | MStatus redoIt (); 62 | MStatus undoIt (); 63 | bool isUndoable() const; 64 | bool hasSyntax() const; 65 | static void* creator(); 66 | static MSyntax newSyntax(); 67 | 68 | static bool IsProgressCancelled(); 69 | 70 | static void SetNumSubTasks(int tasks, const MString& name); 71 | static void StepJobProgress(); 72 | 73 | void TestColourFaces(); 74 | void ColourFaces(const MDagPath& dagPath, MObject& component, const MString* uvSetName); 75 | 76 | private: 77 | // Startup 78 | MStatus Initialise(const MArgList& args); 79 | const char* ParseArguments(const MArgList& args); 80 | 81 | MStatus ProcessMeshes(); 82 | MStatus BuildDataLists(); 83 | void GatherData(); 84 | void FindScales(); 85 | void LayoutShells(); 86 | void Normalise(); 87 | void ApplyScales(); 88 | void ProcessAsObjectLevel(); 89 | void ProcessAsUVShellLevel(); 90 | 91 | // Helper 92 | void DisplayHelp() const; 93 | void OutputText(const char* text) const; 94 | void OutputText(const MString& text) const; 95 | void DisplayStats(bool showErrorsOnly); 96 | void DisplayTimingStats(); 97 | void SaveSelection(); 98 | void RestoreSelection(); 99 | const char* ErrorToString(JobError error) const; 100 | 101 | // Progress 102 | static void UpdateProgress(); 103 | static void SetProgress(int value); 104 | 105 | 106 | std::vector m_meshes; 107 | Processor* m_activeProcessor; 108 | 109 | static int m_totalJobs; 110 | static int m_subTasks, m_subTasksLeft; 111 | static double m_subTaskJump; 112 | static MString m_subTaskName; 113 | static double m_progress, m_progressStep; 114 | static MString m_progressMessage; 115 | 116 | // Input parameters 117 | UVAutoRatioProParams m_params; 118 | 119 | // Save & Restore selection 120 | MGlobal::MSelectionMode m_savedSelectionMode; 121 | MSelectionMask* m_savedObjectSelectionMask; 122 | MSelectionMask* m_savedComponentSelectionMask; 123 | MSelectionList m_savedSelection; 124 | 125 | // Profiling 126 | Timer m_timer, m_masterTimer; 127 | float m_loadTime, m_gatherTime, m_processTime, m_layoutTime, m_applyTime, m_totalTime; 128 | 129 | // Text scratchpad 130 | char m_text[2048]; 131 | 132 | // Undo & redo stack 133 | std::vector m_undos; // The stack of undo to perform. 134 | 135 | // Help static string data 136 | static const char* UVAutoRatio_Help[]; 137 | static unsigned int helpLineCount; 138 | }; 139 | 140 | #endif 141 | 142 | -------------------------------------------------------------------------------- /UVAutoRatio/UVAutoRatioPro.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 10.00 2 | # Visual Studio 2008 3 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UVAutoRatioPro", "UVAutoRatioPro.vcproj", "{681412B0-F197-4A2F-9263-DEA2E8690146}" 4 | EndProject 5 | Global 6 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 7 | Debug Maya2008|Win32 = Debug Maya2008|Win32 8 | Debug Maya2008|x64 = Debug Maya2008|x64 9 | Debug Maya2009|Win32 = Debug Maya2009|Win32 10 | Debug Maya2009|x64 = Debug Maya2009|x64 11 | Debug Maya2010|Win32 = Debug Maya2010|Win32 12 | Debug Maya2010|x64 = Debug Maya2010|x64 13 | Debug Maya2013.5|Win32 = Debug Maya2013.5|Win32 14 | Debug Maya2013.5|x64 = Debug Maya2013.5|x64 15 | Debug Maya60|Win32 = Debug Maya60|Win32 16 | Debug Maya60|x64 = Debug Maya60|x64 17 | Debug Maya65|Win32 = Debug Maya65|Win32 18 | Debug Maya65|x64 = Debug Maya65|x64 19 | Debug Maya70|Win32 = Debug Maya70|Win32 20 | Debug Maya70|x64 = Debug Maya70|x64 21 | Debug Maya80|Win32 = Debug Maya80|Win32 22 | Debug Maya80|x64 = Debug Maya80|x64 23 | Debug Maya85|Win32 = Debug Maya85|Win32 24 | Debug Maya85|x64 = Debug Maya85|x64 25 | Debug|Win32 = Debug|Win32 26 | Debug|x64 = Debug|x64 27 | Release Maya2008|Win32 = Release Maya2008|Win32 28 | Release Maya2008|x64 = Release Maya2008|x64 29 | Release Maya2009|Win32 = Release Maya2009|Win32 30 | Release Maya2009|x64 = Release Maya2009|x64 31 | Release Maya2010|Win32 = Release Maya2010|Win32 32 | Release Maya2010|x64 = Release Maya2010|x64 33 | Release Maya2011|Win32 = Release Maya2011|Win32 34 | Release Maya2011|x64 = Release Maya2011|x64 35 | Release Maya2012|Win32 = Release Maya2012|Win32 36 | Release Maya2012|x64 = Release Maya2012|x64 37 | Release Maya2013.5|Win32 = Release Maya2013.5|Win32 38 | Release Maya2013.5|x64 = Release Maya2013.5|x64 39 | Release Maya2013|Win32 = Release Maya2013|Win32 40 | Release Maya2013|x64 = Release Maya2013|x64 41 | Release Maya2014|Win32 = Release Maya2014|Win32 42 | Release Maya2014|x64 = Release Maya2014|x64 43 | Release Maya2015|Win32 = Release Maya2015|Win32 44 | Release Maya2015|x64 = Release Maya2015|x64 45 | Release Maya2016|Win32 = Release Maya2016|Win32 46 | Release Maya2016|x64 = Release Maya2016|x64 47 | Release Maya60|Win32 = Release Maya60|Win32 48 | Release Maya60|x64 = Release Maya60|x64 49 | Release Maya65|Win32 = Release Maya65|Win32 50 | Release Maya65|x64 = Release Maya65|x64 51 | Release Maya70|Win32 = Release Maya70|Win32 52 | Release Maya70|x64 = Release Maya70|x64 53 | Release Maya80|Win32 = Release Maya80|Win32 54 | Release Maya80|x64 = Release Maya80|x64 55 | Release Maya85|Win32 = Release Maya85|Win32 56 | Release Maya85|x64 = Release Maya85|x64 57 | Release|Win32 = Release|Win32 58 | Release|x64 = Release|x64 59 | EndGlobalSection 60 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 61 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Debug Maya2008|Win32.ActiveCfg = Debug Maya2008|Win32 62 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Debug Maya2008|Win32.Build.0 = Debug Maya2008|Win32 63 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Debug Maya2008|x64.ActiveCfg = Debug Maya2008|x64 64 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Debug Maya2008|x64.Build.0 = Debug Maya2008|x64 65 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Debug Maya2009|Win32.ActiveCfg = Debug Maya2009|Win32 66 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Debug Maya2009|Win32.Build.0 = Debug Maya2009|Win32 67 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Debug Maya2009|x64.ActiveCfg = Debug Maya2009|x64 68 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Debug Maya2009|x64.Build.0 = Debug Maya2009|x64 69 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Debug Maya2010|Win32.ActiveCfg = Debug Maya2010|Win32 70 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Debug Maya2010|Win32.Build.0 = Debug Maya2010|Win32 71 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Debug Maya2010|x64.ActiveCfg = Debug Maya2010|x64 72 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Debug Maya2010|x64.Build.0 = Debug Maya2010|x64 73 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Debug Maya2013.5|Win32.ActiveCfg = Debug Maya2010|Win32 74 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Debug Maya2013.5|Win32.Build.0 = Debug Maya2010|Win32 75 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Debug Maya2013.5|x64.ActiveCfg = Debug Maya2010|x64 76 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Debug Maya2013.5|x64.Build.0 = Debug Maya2010|x64 77 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Debug Maya60|Win32.ActiveCfg = Debug Maya60|Win32 78 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Debug Maya60|Win32.Build.0 = Debug Maya60|Win32 79 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Debug Maya60|x64.ActiveCfg = Debug Maya60|x64 80 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Debug Maya65|Win32.ActiveCfg = Debug Maya65|Win32 81 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Debug Maya65|Win32.Build.0 = Debug Maya65|Win32 82 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Debug Maya65|x64.ActiveCfg = Debug Maya65|x64 83 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Debug Maya70|Win32.ActiveCfg = Debug Maya70|Win32 84 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Debug Maya70|Win32.Build.0 = Debug Maya70|Win32 85 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Debug Maya70|x64.ActiveCfg = Debug Maya70|x64 86 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Debug Maya80|Win32.ActiveCfg = Debug Maya80|Win32 87 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Debug Maya80|Win32.Build.0 = Debug Maya80|Win32 88 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Debug Maya80|x64.ActiveCfg = Debug Maya80|x64 89 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Debug Maya80|x64.Build.0 = Debug Maya80|x64 90 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Debug Maya85|Win32.ActiveCfg = Debug Maya85|Win32 91 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Debug Maya85|Win32.Build.0 = Debug Maya85|Win32 92 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Debug Maya85|x64.ActiveCfg = Debug Maya85|x64 93 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Debug Maya85|x64.Build.0 = Debug Maya85|x64 94 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Debug|Win32.ActiveCfg = Debug Maya85|Win32 95 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Debug|x64.ActiveCfg = Debug Maya2008|x64 96 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya2008|Win32.ActiveCfg = Release Maya2008|Win32 97 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya2008|Win32.Build.0 = Release Maya2008|Win32 98 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya2008|x64.ActiveCfg = Release Maya2008|x64 99 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya2008|x64.Build.0 = Release Maya2008|x64 100 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya2009|Win32.ActiveCfg = Release Maya2009|Win32 101 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya2009|Win32.Build.0 = Release Maya2009|Win32 102 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya2009|x64.ActiveCfg = Release Maya2009|x64 103 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya2009|x64.Build.0 = Release Maya2009|x64 104 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya2010|Win32.ActiveCfg = Release Maya2010|Win32 105 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya2010|Win32.Build.0 = Release Maya2010|Win32 106 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya2010|x64.ActiveCfg = Release Maya2010|x64 107 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya2010|x64.Build.0 = Release Maya2010|x64 108 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya2011|Win32.ActiveCfg = Release Maya2011|Win32 109 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya2011|Win32.Build.0 = Release Maya2011|Win32 110 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya2011|x64.ActiveCfg = Release Maya2011|x64 111 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya2011|x64.Build.0 = Release Maya2011|x64 112 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya2012|Win32.ActiveCfg = Release Maya2012|Win32 113 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya2012|Win32.Build.0 = Release Maya2012|Win32 114 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya2012|x64.ActiveCfg = Release Maya2012|x64 115 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya2012|x64.Build.0 = Release Maya2012|x64 116 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya2013.5|Win32.ActiveCfg = Release Maya2013.5|Win32 117 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya2013.5|Win32.Build.0 = Release Maya2013.5|Win32 118 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya2013.5|x64.ActiveCfg = Release Maya2013.5|x64 119 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya2013.5|x64.Build.0 = Release Maya2013.5|x64 120 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya2013|Win32.ActiveCfg = Release Maya2013|Win32 121 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya2013|Win32.Build.0 = Release Maya2013|Win32 122 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya2013|x64.ActiveCfg = Release Maya2013|x64 123 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya2013|x64.Build.0 = Release Maya2013|x64 124 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya2014|Win32.ActiveCfg = Release Maya2014|Win32 125 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya2014|x64.ActiveCfg = Release Maya2014|x64 126 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya2014|x64.Build.0 = Release Maya2014|x64 127 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya2015|Win32.ActiveCfg = Release Maya2015|Win32 128 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya2015|x64.ActiveCfg = Release Maya2015|x64 129 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya2015|x64.Build.0 = Release Maya2015|x64 130 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya2016|Win32.ActiveCfg = Release Maya2016|x64 131 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya2016|x64.ActiveCfg = Release Maya2016|x64 132 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya2016|x64.Build.0 = Release Maya2016|x64 133 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya60|Win32.ActiveCfg = Release Maya60|Win32 134 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya60|Win32.Build.0 = Release Maya60|Win32 135 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya60|x64.ActiveCfg = Release Maya60|x64 136 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya65|Win32.ActiveCfg = Release Maya65|Win32 137 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya65|Win32.Build.0 = Release Maya65|Win32 138 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya65|x64.ActiveCfg = Release Maya65|x64 139 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya70|Win32.ActiveCfg = Release Maya70|Win32 140 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya70|Win32.Build.0 = Release Maya70|Win32 141 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya70|x64.ActiveCfg = Release Maya70|x64 142 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya80|Win32.ActiveCfg = Release Maya80|Win32 143 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya80|Win32.Build.0 = Release Maya80|Win32 144 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya80|x64.ActiveCfg = Release Maya80|x64 145 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya80|x64.Build.0 = Release Maya80|x64 146 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya85|Win32.ActiveCfg = Release Maya85|Win32 147 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya85|Win32.Build.0 = Release Maya85|Win32 148 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya85|x64.ActiveCfg = Release Maya85|x64 149 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release Maya85|x64.Build.0 = Release Maya85|x64 150 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release|Win32.ActiveCfg = Release Maya85|Win32 151 | {681412B0-F197-4A2F-9263-DEA2E8690146}.Release|x64.ActiveCfg = Release Maya2008|x64 152 | EndGlobalSection 153 | GlobalSection(SolutionProperties) = preSolution 154 | HideSolutionNode = FALSE 155 | EndGlobalSection 156 | EndGlobal 157 | -------------------------------------------------------------------------------- /UVAutoRatio/UVAutoRatioPro_Setup.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // UVAutoRatio Maya Plugin Source Code 3 | // Copyright (C) 2007-2014 RenderHeads Ltd. 4 | // 5 | // This source is available for distribution and/or modification 6 | // only under the terms of the MIT license. All rights reserved. 7 | // 8 | // The source is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // FITNESS FOR A PARTICULAR PURPOSE. See the MIT license 11 | // for more details. 12 | // 13 | 14 | #include "MayaPCH.h" 15 | #include "MayaUtility.h" 16 | #include "Utility.h" 17 | //#include "UVShell.h" 18 | #include "UVAutoRatioPro.h" 19 | 20 | const char* UVAutoRatioPro::UVAutoRatio_Help[] = { 21 | " UVAutoRatio PRO Help\n", 22 | "\n", 23 | " Works with selections of polygon objects\n", 24 | "\n", 25 | "\t-help (-hlp) This gets printed\n", 26 | "\t-ratio (-r) [double] Desired 2D : 3D ratio\n", 27 | "\t-uvSetName (-us) [string] The name of the UV set to use (optional)\n", 28 | "\t-fallback (-fb) If the named UV set is not found in a mesh, use the default UV set instead of skipping it (optional)\n", 29 | "\t-iterations (-it) [integer] Maximum number of iterations (optional), default 200\n", 30 | "\t-threshold (-th) [double] Accuracy threshold for ratio finder (optional), default 0.001\n", 31 | "\t-operation (-op) [integer] 0 = whole mesh, 1 = uv shell\n", 32 | "\t-verbose (-vb) Display output (optional), default false\n", 33 | "\t-layout (-lay) Layout UV shells to prevent overlapping (optional), default true\n", 34 | "\t-skipscale (-ss) Skip the scaling operation (useful if you only want to fix layout)\n", 35 | "\t-onlyScaleH (-osh) Restrict scaling of UVs to horizontal axis (optional), default false\n", 36 | "\t-onlyScaleV (-osv) Restrict scaling of UVs to vertical axis (optional), default false\n", 37 | "\n" 38 | }; 39 | 40 | unsigned int UVAutoRatioPro::helpLineCount=sizeof(UVAutoRatio_Help)/sizeof(UVAutoRatio_Help[0]); 41 | 42 | MSyntax 43 | UVAutoRatioPro::newSyntax() 44 | { 45 | MStatus status; 46 | MSyntax syntax; 47 | 48 | // flags 49 | syntax.addFlag("-hlp", "-help"); 50 | syntax.addFlag("-vb", "-verbose"); 51 | syntax.addFlag("-tim", "-showTimings"); 52 | syntax.addFlag("-fb", "-fallback"); 53 | syntax.addFlag("-r", "-ratio",MSyntax::kDouble); 54 | syntax.addFlag("-th", "-threshold",MSyntax::kDouble); 55 | syntax.addFlag("-it", "-iterations", MSyntax::kLong); 56 | syntax.addFlag("-op", "-operation", MSyntax::kLong); 57 | syntax.addFlag("-us", "-uvSetName",MSyntax::kString); 58 | syntax.addFlag("-lay", "-layout"); 59 | syntax.addFlag("-nor", "-normalise"); 60 | syntax.addFlag("-kar", "-keepAspectRatio"); 61 | syntax.addFlag("-lai", "-layoutIterations", MSyntax::kLong); 62 | syntax.addFlag("-las", "-layoutStep", MSyntax::kDouble); 63 | syntax.addFlag("-lad", "-layoutMinDistance", MSyntax::kDouble); 64 | syntax.addFlag("-ss", "-skipscale"); 65 | syntax.addFlag("-osh", "-onlyScaleH"); 66 | syntax.addFlag("-osv", "-onlyScaleV"); 67 | syntax.addFlag("-col", "-colour"); 68 | 69 | syntax.useSelectionAsDefault(false); 70 | syntax.enableQuery(false); 71 | syntax.enableEdit(false); 72 | return syntax; 73 | } 74 | 75 | const char* 76 | UVAutoRatioPro::ParseArguments(const MArgList& args) 77 | { 78 | //static const char* error_noArgs = "No parameters specified. -help for available flags."; 79 | static const char* error_noRatio = "No ratio parameter specified."; 80 | static const char* error_bothScalings = "Cannot have both scaling directions limited"; 81 | 82 | MArgDatabase argData(syntax(), args); 83 | 84 | m_params.m_isHelp = argData.isFlagSet("-help"); 85 | 86 | m_params.m_isVerbose = argData.isFlagSet("-verbose"); 87 | m_params.m_isShowTiming = argData.isFlagSet("-showTimings"); 88 | m_params.m_isFallback = argData.isFlagSet("-fallback"); 89 | m_params.m_layoutShells = argData.isFlagSet("-layout"); 90 | m_params.m_normalise = argData.isFlagSet("-normalise"); 91 | m_params.m_normaliseKeepAspectRatio = argData.isFlagSet("-keepAspectRatio"); 92 | m_params.m_skipScaling = argData.isFlagSet("-skipscale"); 93 | m_params.m_isColour = argData.isFlagSet("-colour"); 94 | 95 | if (m_params.m_layoutShells) 96 | { 97 | getArgValue(argData, "-lai", "-layoutIterations", m_params.m_layoutIterations); 98 | getArgValue(argData, "-las", "-layoutStep", m_params.m_layoutStep); 99 | getArgValue(argData, "-lad", "-layoutMinDistance", m_params.m_layoutMinDistance); 100 | m_params.m_layoutIterations = ClampUInt(1, 10000, m_params.m_layoutIterations); 101 | m_params.m_layoutStep = ClampDouble(0.00001, 0.1, m_params.m_layoutStep); 102 | m_params.m_layoutMinDistance = ClampDouble(0.0, 1000.0, m_params.m_layoutMinDistance); 103 | } 104 | 105 | if (!m_params.m_skipScaling) 106 | { 107 | if (!getArgValue(argData, "-r", "-ratio", m_params.m_goalRatio)) 108 | { 109 | return error_noRatio; 110 | } 111 | 112 | if (argData.isFlagSet("-onlyScaleH") && argData.isFlagSet("-onlyScaleV")) 113 | { 114 | return error_bothScalings; 115 | } 116 | 117 | if (argData.isFlagSet("-onlyScaleH")) 118 | m_params.m_scalingAxis = Horizontal; 119 | else 120 | if (argData.isFlagSet("-onlyScaleV")) 121 | m_params.m_scalingAxis = Vertical; 122 | 123 | getArgValue(argData, "-it", "-iterations", m_params.m_maxIterations); 124 | getArgValue(argData, "-th", "-threshold", m_params.m_threshold); 125 | 126 | m_params.m_maxIterations = ClampInt(1, 10000, m_params.m_maxIterations); 127 | m_params.m_layoutIterations = ClampUInt(1, 10000, m_params.m_layoutIterations); 128 | m_params.m_threshold = ClampDouble(0.0001, 1.0, m_params.m_threshold); 129 | } 130 | 131 | int opMode = 0; 132 | getArgValue(argData, "-op", "-operation", opMode); 133 | m_params.m_operationMode = (OperationMode)opMode; 134 | 135 | if (getArgValue(argData, "-us", "-uvSetName", m_params.m_UVSetName)) 136 | { 137 | m_params.m_isUVSetOverride = true; 138 | } 139 | 140 | return NULL; 141 | } 142 | 143 | void 144 | UVAutoRatioPro::DisplayHelp() const 145 | { 146 | for (unsigned int i=0; i::reverse_iterator riter; 211 | for ( riter = m_undos.rbegin(); riter != m_undos.rend(); ++riter ) 212 | { 213 | delete (*riter); 214 | } 215 | m_undos.clear(); 216 | } 217 | 218 | // Delete all meshes 219 | { 220 | std::vector::reverse_iterator riter; 221 | for ( riter = m_meshes.rbegin(); riter != m_meshes.rend(); ++riter ) 222 | { 223 | delete (*riter); 224 | } 225 | m_meshes.clear(); 226 | } 227 | } 228 | 229 | void* 230 | UVAutoRatioPro::creator() 231 | { 232 | return new UVAutoRatioPro; 233 | } 234 | 235 | bool 236 | UVAutoRatioPro::isUndoable() const 237 | { 238 | return true; 239 | } 240 | 241 | bool 242 | UVAutoRatioPro::hasSyntax() const 243 | { 244 | return true; 245 | } 246 | 247 | 248 | void 249 | UVAutoRatioPro::SaveSelection() 250 | { 251 | // Get the current selection 252 | m_savedSelectionMode = MGlobal::selectionMode(); 253 | m_savedObjectSelectionMask = new MSelectionMask(MGlobal::objectSelectionMask()); 254 | m_savedComponentSelectionMask = new MSelectionMask(MGlobal::componentSelectionMask()); 255 | MGlobal::getActiveSelectionList(m_savedSelection); 256 | } 257 | 258 | void 259 | UVAutoRatioPro::RestoreSelection() 260 | { 261 | MStatus status; 262 | 263 | status = MGlobal::clearSelectionList(); 264 | status = MGlobal::setSelectionMode(m_savedSelectionMode); 265 | status = MGlobal::setObjectSelectionMask(*m_savedObjectSelectionMask); 266 | status = MGlobal::setComponentSelectionMask(*m_savedComponentSelectionMask); 267 | status = MGlobal::setActiveSelectionList(m_savedSelection); 268 | } 269 | 270 | void 271 | UVAutoRatioPro::OutputText(const char* text) const 272 | { 273 | #if MAYA60 || MAYA65 274 | MGlobal::displayInfo(text); 275 | #else 276 | displayInfo(text); 277 | #endif 278 | } 279 | 280 | void 281 | UVAutoRatioPro::OutputText(const MString& text) const 282 | { 283 | #if MAYA60 || MAYA65 284 | MGlobal::displayInfo(text); 285 | #else 286 | displayInfo(text); 287 | #endif 288 | } 289 | 290 | MStatus 291 | UVAutoRatioPro::redoIt() 292 | { 293 | MStatus status = MS::kSuccess; 294 | 295 | std::vector::reverse_iterator riter; 296 | for ( riter = m_undos.rbegin(); riter != m_undos.rend(); ++riter ) 297 | { 298 | status=(*riter)->doIt(); 299 | } 300 | 301 | return status; 302 | } 303 | 304 | MStatus 305 | UVAutoRatioPro::undoIt() 306 | { 307 | MStatus status = MS::kSuccess; 308 | 309 | std::vector::reverse_iterator riter; 310 | for ( riter = m_undos.rbegin(); riter != m_undos.rend(); ++riter ) 311 | { 312 | status=(*riter)->undoIt(); 313 | } 314 | 315 | return MS::kSuccess; 316 | } 317 | 318 | -------------------------------------------------------------------------------- /UVAutoRatio/UVSpringLayout.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // UVAutoRatio Maya Plugin Source Code 3 | // Copyright (C) 2007-2014 RenderHeads Ltd. 4 | // 5 | // This source is available for distribution and/or modification 6 | // only under the terms of the MIT license. All rights reserved. 7 | // 8 | // The source is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // FITNESS FOR A PARTICULAR PURPOSE. See the MIT license 11 | // for more details. 12 | // 13 | 14 | #include "MayaPCH.h" 15 | #include 16 | #include "MayaUtility.h" 17 | #include "Utility.h" 18 | #include "UVSpringLayout.h" 19 | 20 | using namespace std; 21 | 22 | bool 23 | Box::IsConnected(const Box& box) const 24 | { 25 | for (uint i = 0; i < springs.size(); i++) 26 | { 27 | const Spring& s = *springs[i]; 28 | if (s.to == &box || s.from == &box) 29 | { 30 | return true; 31 | } 32 | } 33 | return false; 34 | } 35 | 36 | Box::Box() 37 | { 38 | width = height = 0.0; 39 | position[0] = position[1] = 0.0; 40 | velocity[0] = velocity[1] = 0.0; 41 | force[0] = force[1] = 0.0; 42 | dp[0] = dp[1] = 0.0; 43 | dv[0] = dv[1] = 0.0; 44 | springs.reserve(256); 45 | } 46 | 47 | Box::~Box() 48 | { 49 | springs.clear(); 50 | } 51 | 52 | UVSpringLayout::UVSpringLayout() 53 | { 54 | m_boxes.reserve(256); 55 | m_springs.reserve(2048); 56 | } 57 | 58 | UVSpringLayout::~UVSpringLayout() 59 | { 60 | Clear(); 61 | } 62 | 63 | void 64 | UVSpringLayout::Clear() 65 | { 66 | // Delete all boxes 67 | { 68 | std::vector::reverse_iterator riter; 69 | for ( riter = m_boxes.rbegin(); riter != m_boxes.rend(); ++riter ) 70 | { 71 | delete (*riter); 72 | } 73 | m_boxes.clear(); 74 | } 75 | 76 | // Delete all springs 77 | { 78 | std::vector::reverse_iterator riter; 79 | for ( riter = m_springs.rbegin(); riter != m_springs.rend(); ++riter ) 80 | { 81 | delete (*riter); 82 | } 83 | m_springs.clear(); 84 | } 85 | } 86 | 87 | void 88 | UVSpringLayout::AddBox(double width, double height, const double2& center) 89 | { 90 | Box* b = new Box(); 91 | b->width = width; 92 | b->height = height; 93 | b->position[0] = center[0]; 94 | b->position[1] = center[1]; 95 | m_boxes.push_back(b); 96 | } 97 | 98 | void 99 | UVSpringLayout::GetPosition(uint index, double2& position) 100 | { 101 | position[0] = m_boxes[index]->position[0]; 102 | position[1] = m_boxes[index]->position[1]; 103 | } 104 | 105 | bool 106 | UVSpringLayout::Step(double stepSize) 107 | { 108 | ConnectOverlapping(); 109 | RemoveSprings(); 110 | UpdateParticles(stepSize); 111 | 112 | size_t num = m_boxes.size(); 113 | size_t i = 0; 114 | for (i = 0; i < num; i++) 115 | { 116 | Box& box = *m_boxes[i]; 117 | if (box.springs.size() == 0) 118 | { 119 | box.velocity[0] = box.velocity[1] = 0.0; 120 | box.force[0] = box.force[1] = 0.0; 121 | } 122 | } 123 | 124 | // TODO: we could just check whether there are any springs instead of this check 125 | bool intersections = (m_springs.size() != 0); 126 | /*bool intersections = false; 127 | for (i = 0; i < num; i++) 128 | { 129 | Box& boxA = *m_boxes[i]; 130 | 131 | for (size_t j = i + 1; j < num; j++) 132 | { 133 | Box& boxB = *m_boxes[j]; 134 | if (BoxIntersect(boxA, boxB)) 135 | { 136 | intersections = true; 137 | break; 138 | } 139 | } 140 | }*/ 141 | 142 | return intersections; 143 | } 144 | 145 | bool 146 | UVSpringLayout::BoxIntersect(const Box& a, const Box& b) const 147 | { 148 | double border = 1.0 / 256.0; 149 | 150 | double aLeft = a.position[0] - (a.width * 0.5) - border; 151 | double bLeft = b.position[0] - (b.width * 0.5) - border; 152 | double aRight = a.position[0] + (a.width * 0.5) + border; 153 | double bRight = b.position[0] + (b.width * 0.5) + border; 154 | 155 | double aTop = a.position[1] - (a.height * 0.5) - border; 156 | double bTop = b.position[1] - (b.height * 0.5) - border; 157 | double aBottom = a.position[1] + (a.height * 0.5) + border; 158 | double bBottom = b.position[1] + (b.height * 0.5) + border; 159 | 160 | if (aRight <= bLeft) 161 | return false; 162 | 163 | if (aLeft >= bRight) 164 | return false; 165 | 166 | if (aBottom <= bTop) 167 | return false; 168 | 169 | if (aTop >= bBottom) 170 | return false; 171 | 172 | return true; 173 | } 174 | 175 | void 176 | UVSpringLayout::ConnectOverlapping() 177 | { 178 | size_t num = m_boxes.size(); 179 | for (size_t i = 0; i < num; i++) 180 | { 181 | Box& boxA = *m_boxes[i]; 182 | for (size_t j = i + 1; j < num; j++) 183 | { 184 | Box& boxB = *m_boxes[j]; 185 | if (BoxIntersect(boxA, boxB)) 186 | { 187 | // check if already connected 188 | if (!boxA.IsConnected(boxB)) 189 | { 190 | Spring* ss = new Spring(); 191 | ss->from = &boxA; 192 | ss->to = &boxB; 193 | ss->constant = 0.125; 194 | ss->damping = 0.01; 195 | double h1 = 0.75 * sqrt((boxA.width * boxA.width) + (boxA.height * boxA.height)); 196 | double h2 = 0.75 * sqrt((boxB.width * boxB.width) + ( boxB.height * boxB.height)); 197 | ss->restLength = h1 + h2; 198 | boxA.springs.push_back(ss); 199 | boxB.springs.push_back(ss); 200 | 201 | m_springs.push_back(ss); 202 | } 203 | } 204 | } 205 | } 206 | } 207 | 208 | void 209 | UVSpringLayout::RemoveSprings() 210 | { 211 | std::vector springstoRemove; 212 | uint i = 0; 213 | for (i = 0; i < m_springs.size(); i++) 214 | { 215 | Spring& s = *m_springs[i]; 216 | Box& boxA = *s.from; 217 | Box& boxB = *s.to; 218 | if (!BoxIntersect(boxA, boxB)) 219 | { 220 | // Try find the spring 221 | vector::iterator itA = std::find(boxA.springs.begin(), boxA.springs.end(), &s); 222 | vector::iterator itB = std::find(boxB.springs.begin(), boxB.springs.end(), &s); 223 | 224 | assert(itA != boxA.springs.end()); 225 | assert(itB != boxB.springs.end()); 226 | 227 | boxA.springs.erase(itA); 228 | boxB.springs.erase(itB); 229 | 230 | springstoRemove.push_back(&s); 231 | } 232 | } 233 | 234 | for (i = 0; i < springstoRemove.size(); i++) 235 | { 236 | Spring& s = *springstoRemove[i]; 237 | 238 | vector::iterator itA = std::find(m_springs.begin(), m_springs.end(), &s); 239 | assert(itA != m_springs.end()); 240 | m_springs.erase(itA); 241 | } 242 | } 243 | 244 | void 245 | UVSpringLayout::UpdateParticles(double dt) 246 | { 247 | CalculateForces(); 248 | CalculateDerivatives(); 249 | 250 | for (uint i = 0; i < m_boxes.size(); i++) 251 | { 252 | Box& box = *m_boxes[i]; 253 | box.position[0] += box.dp[0] * dt; 254 | box.position[1] += box.dp[1] * dt; 255 | box.velocity[0] += box.dv[0] * dt; 256 | box.velocity[1] += box.dv[1] * dt; 257 | } 258 | } 259 | 260 | void 261 | UVSpringLayout::CalculateForces() 262 | { 263 | double drag = 0.1; 264 | uint i = 0; 265 | for (i = 0; i < m_boxes.size(); i++) 266 | { 267 | Box& box = *m_boxes[i]; 268 | 269 | box.force[0] = box.force[1] = 0.0; 270 | 271 | box.force[0] -= drag * box.velocity[0]; 272 | box.force[1] -= drag * box.velocity[1]; 273 | } 274 | 275 | for (i = 0; i < m_springs.size(); i++) 276 | { 277 | Spring& s = *m_springs[i]; 278 | 279 | Box& p1 = *s.from; 280 | Box& p2 = *s.to; 281 | 282 | double len = 0.0; 283 | double2 d; 284 | d[0] = p1.position[0] - p2.position[0]; 285 | d[1] = p1.position[1] - p2.position[1]; 286 | double lensqr = (d[0] * d[0]) + (d[1] * d[1]); 287 | if (lensqr != 0.0) 288 | { 289 | len = sqrt(lensqr); 290 | d[0] /= len; 291 | d[1] /= len; 292 | } 293 | else 294 | { 295 | p1.position[0] += RandomSignedUnit() * 0.001; 296 | p1.position[1] += RandomSignedUnit() * 0.001; 297 | p2.position[0] += RandomSignedUnit() * 0.001; 298 | p2.position[1] += RandomSignedUnit() * 0.001; 299 | } 300 | 301 | double2 f; 302 | f[0] = s.constant * (len - s.restLength); 303 | f[0] += s.damping * (p1.velocity[0] - p2.velocity[0]) * d[0]; 304 | f[0] *= -d[0]; 305 | f[1] = s.constant * (len - s.restLength); 306 | f[1] += s.damping * (p1.velocity[1] - p2.velocity[1]) * d[1]; 307 | f[1] *= -d[1]; 308 | 309 | p1.force[0] += f[0]; 310 | p1.force[1] += f[1]; 311 | p2.force[0] -= f[0]; 312 | p2.force[1] -= f[1]; 313 | } 314 | } 315 | 316 | void 317 | UVSpringLayout::CalculateDerivatives() 318 | { 319 | for (uint i = 0; i < m_boxes.size(); i++) 320 | { 321 | Box& box = *m_boxes[i]; 322 | box.dp[0] = box.velocity[0]; 323 | box.dp[1] = box.velocity[1]; 324 | box.dv[0] = box.force[0]; // / box.mass; 325 | box.dv[1] = box.force[1]; // / box.mass; 326 | } 327 | } 328 | 329 | -------------------------------------------------------------------------------- /UVAutoRatio/UVSpringLayout.h: -------------------------------------------------------------------------------- 1 | // 2 | // UVAutoRatio Maya Plugin Source Code 3 | // Copyright (C) 2007-2014 RenderHeads Ltd. 4 | // 5 | // This source is available for distribution and/or modification 6 | // only under the terms of the MIT license. All rights reserved. 7 | // 8 | // The source is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // FITNESS FOR A PARTICULAR PURPOSE. See the MIT license 11 | // for more details. 12 | // 13 | 14 | #ifndef UVSPRINGLAYOUT_H 15 | #define UVSPRINGLAYOUT_H 16 | 17 | #include 18 | #include 19 | 20 | class Box; 21 | class Spring; 22 | 23 | class Box 24 | { 25 | public: 26 | Box(); 27 | ~Box(); 28 | 29 | double width, height; 30 | 31 | double2 position; 32 | double2 velocity; 33 | double2 force; 34 | double2 dp, dv; 35 | 36 | std::vector springs; 37 | 38 | bool IsConnected(const Box& box) const; 39 | }; 40 | 41 | class Spring 42 | { 43 | public: 44 | Box* from; 45 | Box* to; 46 | double constant; 47 | double damping; 48 | double restLength; 49 | }; 50 | 51 | class UVSpringLayout 52 | { 53 | public: 54 | UVSpringLayout(); 55 | ~UVSpringLayout(); 56 | 57 | void Clear(); 58 | void AddBox(double width, double height, const double2& center); 59 | bool Step(double stepSize); 60 | void GetPosition(uint index, double2& position); 61 | 62 | private: 63 | void ConnectOverlapping(); 64 | void RemoveSprings(); 65 | void UpdateParticles(double time); 66 | void CalculateForces(); 67 | void CalculateDerivatives(); 68 | 69 | bool BoxIntersect(const Box& a, const Box& b) const; 70 | 71 | std::vector m_boxes; 72 | std::vector m_springs; 73 | }; 74 | 75 | 76 | #endif 77 | 78 | -------------------------------------------------------------------------------- /UVAutoRatio/Utility.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // UVAutoRatio Maya Plugin Source Code 3 | // Copyright (C) 2007-2014 RenderHeads Ltd. 4 | // 5 | // This source is available for distribution and/or modification 6 | // only under the terms of the MIT license. All rights reserved. 7 | // 8 | // The source is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // FITNESS FOR A PARTICULAR PURPOSE. See the MIT license 11 | // for more details. 12 | // 13 | 14 | #include "MayaPCH.h" 15 | #include "Utility.h" 16 | 17 | double 18 | GetAreaMeshSurface(const MDagPath& meshDagPath, bool isWorldSpace) 19 | { 20 | return GetAreaFacesSurface(meshDagPath, MObject::kNullObj, isWorldSpace); 21 | } 22 | 23 | double 24 | GetAreaFacesSurface(const MDagPath& dagPath, MObject& component, bool isWorldSpace) 25 | { 26 | MStatus status; 27 | 28 | double result = 0.0; 29 | MItMeshPolygon iter(dagPath, component, &status); 30 | 31 | if (isWorldSpace) 32 | { 33 | for ( ; !iter.isDone(); iter.next() ) 34 | { 35 | double area = 0.0; 36 | 37 | area = 0.0; 38 | MPointArray points; 39 | MIntArray vertexList; 40 | status = iter.getTriangles(points, vertexList, MSpace::kWorld); 41 | int numTriangles = points.length() / 3; 42 | for (int i = 0; i < numTriangles; i++) 43 | { 44 | MPoint a, b, c; 45 | int indexA = (i*3+0); 46 | int indexB = (i*3+1); 47 | int indexC = (i*3+2); 48 | a = points[indexA]; 49 | b = points[indexB]; 50 | c = points[indexC]; 51 | 52 | double la = a.distanceTo(b); 53 | double lb = a.distanceTo(c); 54 | double lc = b.distanceTo(c); 55 | la = MDistance::internalToUI(la); 56 | lb = MDistance::internalToUI(lb); 57 | lc = MDistance::internalToUI(lc); 58 | double areaSquared = GetTriangleAreaSquared(la, lb, lc); 59 | if (areaSquared > 0.0) 60 | area += sqrt(areaSquared); 61 | 62 | /*float2 uv1, uv2, uv3; 63 | status = iter.getUV (a, uv1, NULL); 64 | status = iter.getUV (b, uv2, NULL); 65 | status = iter.getUV (c, uv3, NULL);*/ 66 | } 67 | 68 | result += area; 69 | } 70 | } 71 | else 72 | { 73 | for ( ; !iter.isDone(); iter.next() ) 74 | { 75 | // NOTE: This function "getArea" can only return the area in in object space 76 | // it is a limitation of Maya's API 77 | double area = 0.0; 78 | status = iter.getArea(area, MSpace::kObject); 79 | result += area; 80 | } 81 | } 82 | 83 | return result; 84 | } 85 | 86 | double 87 | GetAreaMeshUV(const MDagPath& meshDagPath, const MString* uvSetName) 88 | { 89 | return GetAreaFacesUV(meshDagPath, MObject::kNullObj, uvSetName); 90 | } 91 | 92 | double 93 | GetAreaFacesUV(const MDagPath& meshDagPath, MObject& component, const MString* uvSetName) 94 | { 95 | MStatus status; 96 | 97 | double result = 0.0; 98 | 99 | /* 100 | // There is a bug in Maya's API so we can't use this way 101 | // If a mesh has a tweak, but no history, this method doesn't return the real area 102 | MItMeshPolygon iter(meshDagPath, component, &status); 103 | for ( ; !iter.isDone(); iter.next() ) 104 | { 105 | double faceArea = 0.0; 106 | iter.getUVArea(faceArea, uvSetName); 107 | result += faceArea; 108 | }*/ 109 | 110 | { 111 | MItMeshPolygon iter(meshDagPath, component, &status); 112 | for ( ; !iter.isDone(); iter.next() ) 113 | { 114 | double faceArea = 0.0; 115 | 116 | MIntArray polygonToFaceVertexIndexMap; 117 | iter.getVertices(polygonToFaceVertexIndexMap); 118 | 119 | int numTrianglesInPoly=0; 120 | iter.numTriangles(numTrianglesInPoly); 121 | for (int j=0; j= 0 && index < (int)values.length()); 282 | 283 | #ifdef WIN32 284 | low = min(low, values[index]); 285 | hi = max(hi, values[index]); 286 | #else 287 | low = std::min(low, values[index]); 288 | hi = std::max(hi, values[index]); 289 | #endif 290 | } 291 | 292 | mmin = low; 293 | mmax = hi; 294 | } 295 | 296 | bool 297 | ContainsUVSet(const MFnMesh& mesh, const MString& uvSetName) 298 | { 299 | MStringArray uvSetNames; 300 | mesh.getUVSetNames(uvSetNames); 301 | for (uint i = 0; i < uvSetNames.length(); i++) 302 | { 303 | if (uvSetNames[i] == uvSetName) 304 | { 305 | return true; 306 | } 307 | } 308 | 309 | return false; 310 | } 311 | 312 | bool 313 | FindMeshUVSetName(const MFnMesh& mesh, bool overrideCurrentUVSet, bool fallback, const MString** desiredUVSetName) 314 | { 315 | static const char* error_noUVSets = "Mesh '%s' contains no UVSet."; 316 | static const char* error_UVSetNotFound = "Specified UVSet '%s' not found in mesh '%s', skipping operation"; 317 | 318 | static char text[2048]; 319 | 320 | // check there at least one UV set 321 | if (mesh.numUVSets() <= 0) 322 | { 323 | #ifdef WIN32 324 | sprintf_s(text, sizeof(text), error_noUVSets, mesh.name().asChar()); 325 | #else 326 | sprintf(text, error_noUVSets, mesh.name().asChar()); 327 | #endif 328 | MGlobal::displayWarning(text); 329 | return false; 330 | } 331 | 332 | // If a specific UV set is specified, verify that it exists 333 | if (overrideCurrentUVSet) 334 | { 335 | // try find the specified UV set 336 | if (!ContainsUVSet(mesh, **desiredUVSetName)) 337 | { 338 | // we can't find the specified UV set, 339 | // so if we can fallback, use the current UV set 340 | if (fallback) 341 | { 342 | *desiredUVSetName = NULL; 343 | } 344 | else 345 | { 346 | #ifdef WIN32 347 | sprintf_s(text, sizeof(text), error_UVSetNotFound, (*desiredUVSetName)->asChar(), mesh.name().asChar()); 348 | #else 349 | sprintf(text, error_UVSetNotFound, (*desiredUVSetName)->asChar(), mesh.name().asChar()); 350 | #endif 351 | MGlobal::displayWarning(text); 352 | return false; 353 | } 354 | } 355 | } 356 | else 357 | { 358 | // use the current UV set 359 | *desiredUVSetName = NULL; 360 | } 361 | 362 | return true; 363 | } 364 | 365 | // take the UV components and convert to face components 366 | bool 367 | UVToFaceComponents(const MDagPath& meshDagPath, const MObject& uvComponents, MObject& faceComponents) 368 | { 369 | MStatus status; 370 | 371 | // Create selection for UVs components 372 | MSelectionList uvSelection; 373 | uvSelection.add(meshDagPath, uvComponents); 374 | 375 | // Set UV selection in Maya 376 | status = MGlobal::clearSelectionList(); 377 | status = MGlobal::setSelectionMode(MGlobal::kSelectComponentMode); 378 | MSelectionMask uvSelectionMask(MSelectionMask::kSelectMeshUVs); 379 | status = MGlobal::setComponentSelectionMask(uvSelectionMask); 380 | status = MGlobal::setActiveSelectionList(uvSelection); 381 | 382 | // Convert selection to faces 383 | MGlobal::executeCommand("ConvertSelectionToFaces"); 384 | 385 | // Get face selection 386 | { 387 | MSelectionList faceSelection; 388 | status = MGlobal::getActiveSelectionList(faceSelection); 389 | 390 | // Verify there should only be 1 object selected 391 | if (faceSelection.length() != 1) 392 | { 393 | return false; 394 | } 395 | 396 | MDagPath meshDagPath; 397 | status = faceSelection.getDagPath(0, meshDagPath, faceComponents); 398 | } 399 | 400 | return true; 401 | } 402 | 403 | void 404 | SelectUVSet(std::vector* history, const MString& uvSetName) 405 | { 406 | MStatus status; 407 | 408 | static char text[2048]; 409 | const char* command = "polyUVSet -currentUVSet -uvSet \"%s\""; 410 | #ifdef WIN32 411 | sprintf_s(text, sizeof(text), command, uvSetName.asChar()); 412 | #else 413 | sprintf(text, command, uvSetName.asChar()); 414 | #endif 415 | 416 | if (history != NULL) 417 | { 418 | MDGModifier * modifier = new MDGModifier; 419 | history->push_back(modifier); 420 | status = modifier->commandToExecute(text); 421 | status = modifier->doIt(); 422 | } 423 | else 424 | { 425 | MGlobal::executeCommand(text); 426 | } 427 | } 428 | 429 | MString 430 | GetCurrentUVSetName(const MFnMesh& mesh) 431 | { 432 | MString status; 433 | 434 | MString currentUVSetName; 435 | #if MAYA65 || MAYA60 || MAYA70 || MAYA80 436 | status = mesh.getCurrentUVSetName(currentUVSetName); 437 | #else 438 | currentUVSetName = mesh.currentUVSetName(); 439 | #endif 440 | 441 | return currentUVSetName; 442 | } 443 | 444 | UVSetResult 445 | FindUVSet(const MFnMesh& mesh, bool overrideUVSet, bool fallbackToCurrentAllowed, const MString& overrideSetName) 446 | { 447 | UVSetResult result = NONE; 448 | 449 | // check there is at least one uvset 450 | if (mesh.numUVSets() <= 0) 451 | { 452 | result = NONE; 453 | return result; 454 | } 455 | 456 | // If we have to override which UV set to use 457 | if (overrideUVSet) 458 | { 459 | MStatus status; 460 | 461 | MString currentUVSetName = GetCurrentUVSetName(mesh); 462 | 463 | if (overrideSetName == currentUVSetName) 464 | { 465 | result = CURRENT; 466 | } 467 | else 468 | { 469 | bool hasSet = ContainsUVSet(mesh, overrideSetName); 470 | 471 | if (hasSet) 472 | { 473 | result = OVERRIDE; 474 | } 475 | else 476 | { 477 | // if we can fall back to the default UV set 478 | if (fallbackToCurrentAllowed) 479 | { 480 | result = CURRENT; 481 | } 482 | else 483 | { 484 | result = NONE; 485 | } 486 | } 487 | } 488 | } 489 | else 490 | { 491 | result = CURRENT; 492 | } 493 | 494 | return result; 495 | } 496 | 497 | -------------------------------------------------------------------------------- /UVAutoRatio/Utility.h: -------------------------------------------------------------------------------- 1 | // 2 | // UVAutoRatio Maya Plugin Source Code 3 | // Copyright (C) 2007-2014 RenderHeads Ltd. 4 | // 5 | // This source is available for distribution and/or modification 6 | // only under the terms of the MIT license. All rights reserved. 7 | // 8 | // The source is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // FITNESS FOR A PARTICULAR PURPOSE. See the MIT license 11 | // for more details. 12 | // 13 | 14 | #ifndef UTILITY_H 15 | #define UTILITY_H 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | enum UVSetResult 22 | { 23 | NONE, 24 | CURRENT, 25 | OVERRIDE, 26 | }; 27 | 28 | double GetAreaMeshUV(const MDagPath& meshDagPath, const MString* uvSetName); 29 | double GetAreaMeshSurface(const MDagPath& meshDagPath, bool isWorldSpace); 30 | double GetAreaFacesUV(const MDagPath& dagPath, MObject& component, const MString* uvSetName); 31 | double GetAreaFacesSurface(const MDagPath& dagPath, MObject& component, bool isWorldSpace); 32 | 33 | void GetMinMaxValues(const MFloatArray& values, double& mmin, double& mmax); 34 | void GetMinMaxValues(const MFloatArray& values, const int* indices, int numIndices, double& mmin, double& mmax); 35 | 36 | bool ContainsUVSet(const MFnMesh& mesh, const MString& uvSetName); 37 | bool FindMeshUVSetName(const MFnMesh& mesh, bool overrideCurrentUVSet, bool fallback, const MString** desiredUVSetName); 38 | 39 | bool UVToFaceComponents(const MDagPath& meshDagPath, const MObject& uvComponents, MObject& faceComponents); 40 | void SelectUVSet(std::vector* history, const MString& uvSetName); 41 | MString GetCurrentUVSetName(const MFnMesh& mesh); 42 | UVSetResult FindUVSet(const MFnMesh& mesh, bool overrideUVSet, bool fallbackToCurrentAllowed, const MString& overrideSetName); 43 | 44 | // Heron 3d Triangle Area algorithm 45 | // a, b, c are the lengths of the sides of the triangle 46 | // There are faster algorithms, but this will do for now 47 | inline double 48 | GetTriangleAreaSquared(const double& a, const double& b, const double& c) 49 | { 50 | double s = (a + b + c) * 0.5; 51 | double areaSquared = s * (s - a) * (s - b) * (s - c); 52 | return areaSquared; 53 | } 54 | 55 | // Very fast 2d triangle area function 56 | inline double 57 | GetTriangleArea2D(const float2& p0, const float2& p1, const float2& p2) 58 | { 59 | double s = (p1[0] - p0[0]) * (p2[1] - p0[1]); 60 | double t = (p2[0] - p0[0]) * (p1[1] - p0[1]); 61 | return fabs((s - t) * 0.5); 62 | } 63 | 64 | #endif -------------------------------------------------------------------------------- /UVAutoRatio/main.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // UVAutoRatio Maya Plugin Source Code 3 | // Copyright (C) 2007-2014 RenderHeads Ltd. 4 | // 5 | // This source is available for distribution and/or modification 6 | // only under the terms of the MIT license. All rights reserved. 7 | // 8 | // The source is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // FITNESS FOR A PARTICULAR PURPOSE. See the MIT license 11 | // for more details. 12 | // 13 | 14 | #include "MayaPCH.h" 15 | #include "UVAutoRatioPlugin.h" 16 | 17 | MayaPlugin* UvArPlugin = NULL; 18 | 19 | MStatus 20 | initializePlugin(MObject obj) 21 | { 22 | MayaPluginParams params; 23 | params.authorString = "RenderHeads Ltd"; 24 | params.productName = "UVAutoRatio 2.0 Pro"; 25 | params.productShortName = "UVAutoRatioPro"; 26 | params.versionString = "2.6.0 Pro"; 27 | UvArPlugin = new UVAutoRatioPlugin(params); 28 | 29 | UvArPlugin->Load(obj); 30 | 31 | return MStatus::kSuccess; 32 | } 33 | 34 | MStatus 35 | uninitializePlugin(MObject obj) 36 | { 37 | if (UvArPlugin) 38 | { 39 | UvArPlugin->Unload(obj); 40 | delete UvArPlugin; 41 | UvArPlugin = NULL; 42 | } 43 | 44 | return MStatus::kSuccess; 45 | } -------------------------------------------------------------------------------- /docs/UITabsExpanded_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenderHeads/MayaPlugin-UVAutoRatio/9f717c924f63eb726f63f3ebb6297e2b0e0a30ef/docs/UITabsExpanded_small.png -------------------------------------------------------------------------------- /docs/UVRatio00.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenderHeads/MayaPlugin-UVAutoRatio/9f717c924f63eb726f63f3ebb6297e2b0e0a30ef/docs/UVRatio00.jpg -------------------------------------------------------------------------------- /docs/foo.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /docs/rtt_examplecar_small.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenderHeads/MayaPlugin-UVAutoRatio/9f717c924f63eb726f63f3ebb6297e2b0e0a30ef/docs/rtt_examplecar_small.jpg -------------------------------------------------------------------------------- /module/InstallationInstructions-MacOSX.txt: -------------------------------------------------------------------------------- 1 | UVAutoRatioPro - Maya Command Plugin 2 | -------------------------------- 3 | Mac Installation Instructions 4 | 5 | 1) Open UVAutoRatio2ProModule.txt, and edit it's path to be the folder where you've installed UVAutoRatioPro. 6 | Perhaps something like /Applications/UVAutoRatioPro/ 7 | 8 | 2) Copy UVAutoRatio2ProModule.txt into the "modules" folder of Maya, which is usually found in: 9 | /Applications/Autodesk/maya2008/maya.app/Contents/modules/ 10 | 11 | To open maya.app click on the gears icon in Finder and choose "Show Package Contents". 12 | It may need to be created if it doesn't already exist 13 | 14 | 3) Run Maya 15 | 16 | 4) Type "UVAutoRatioProUI;" to launch the UI -------------------------------------------------------------------------------- /module/UVAutoRatio2ProModule.txt: -------------------------------------------------------------------------------- 1 | // 2 | // UVAutoRatio Pro Module Definition 3 | // 4 | // 1) Edit the path at the bottom of this file to point to the folder/directory where UVAutoRatio is installed 5 | // 6 | // 2) This text file must be copied into the "modules" folder of Maya, which is usually found in: 7 | // 8 | // /usr/autodesk/maya2008/modules 9 | // 10 | // It may need to be created if it doesn't already exist 11 | // 12 | // ------------------------------------------------------------------------------------------ 13 | 14 | + UVAutoRatioPro 2.6.0 ~/UVAutoRatioPro/ -------------------------------------------------------------------------------- /module/UVAutoRatio2ProWindowsModule.txt: -------------------------------------------------------------------------------- 1 | // RenderHeads UVAutoRatio Pro Module Definition for Maya 2 | // 3 | // ------------------------------------------------------------------------------------------ 4 | -------------------------------------------------------------------------------- /module/docs/manual/images/image00.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenderHeads/MayaPlugin-UVAutoRatio/9f717c924f63eb726f63f3ebb6297e2b0e0a30ef/module/docs/manual/images/image00.png -------------------------------------------------------------------------------- /module/docs/manual/images/image01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenderHeads/MayaPlugin-UVAutoRatio/9f717c924f63eb726f63f3ebb6297e2b0e0a30ef/module/docs/manual/images/image01.png -------------------------------------------------------------------------------- /module/docs/manual/images/image02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenderHeads/MayaPlugin-UVAutoRatio/9f717c924f63eb726f63f3ebb6297e2b0e0a30ef/module/docs/manual/images/image02.png -------------------------------------------------------------------------------- /module/docs/manual/images/image03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenderHeads/MayaPlugin-UVAutoRatio/9f717c924f63eb726f63f3ebb6297e2b0e0a30ef/module/docs/manual/images/image03.png -------------------------------------------------------------------------------- /module/docs/manual/images/image04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenderHeads/MayaPlugin-UVAutoRatio/9f717c924f63eb726f63f3ebb6297e2b0e0a30ef/module/docs/manual/images/image04.png -------------------------------------------------------------------------------- /module/docs/manual/images/image05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenderHeads/MayaPlugin-UVAutoRatio/9f717c924f63eb726f63f3ebb6297e2b0e0a30ef/module/docs/manual/images/image05.png -------------------------------------------------------------------------------- /module/docs/manual/images/image06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenderHeads/MayaPlugin-UVAutoRatio/9f717c924f63eb726f63f3ebb6297e2b0e0a30ef/module/docs/manual/images/image06.png -------------------------------------------------------------------------------- /module/docs/manual/images/image07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenderHeads/MayaPlugin-UVAutoRatio/9f717c924f63eb726f63f3ebb6297e2b0e0a30ef/module/docs/manual/images/image07.png -------------------------------------------------------------------------------- /module/docs/manual/images/image08.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenderHeads/MayaPlugin-UVAutoRatio/9f717c924f63eb726f63f3ebb6297e2b0e0a30ef/module/docs/manual/images/image08.png -------------------------------------------------------------------------------- /module/docs/manual/images/image09.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenderHeads/MayaPlugin-UVAutoRatio/9f717c924f63eb726f63f3ebb6297e2b0e0a30ef/module/docs/manual/images/image09.png -------------------------------------------------------------------------------- /module/docs/manual/images/image10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenderHeads/MayaPlugin-UVAutoRatio/9f717c924f63eb726f63f3ebb6297e2b0e0a30ef/module/docs/manual/images/image10.png -------------------------------------------------------------------------------- /module/docs/manual/images/image11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenderHeads/MayaPlugin-UVAutoRatio/9f717c924f63eb726f63f3ebb6297e2b0e0a30ef/module/docs/manual/images/image11.png -------------------------------------------------------------------------------- /module/docs/manual/images/image12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenderHeads/MayaPlugin-UVAutoRatio/9f717c924f63eb726f63f3ebb6297e2b0e0a30ef/module/docs/manual/images/image12.png -------------------------------------------------------------------------------- /module/docs/manual/images/image13.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenderHeads/MayaPlugin-UVAutoRatio/9f717c924f63eb726f63f3ebb6297e2b0e0a30ef/module/docs/manual/images/image13.jpg -------------------------------------------------------------------------------- /module/docs/manual/images/image14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenderHeads/MayaPlugin-UVAutoRatio/9f717c924f63eb726f63f3ebb6297e2b0e0a30ef/module/docs/manual/images/image14.png -------------------------------------------------------------------------------- /module/docs/manual/images/image15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenderHeads/MayaPlugin-UVAutoRatio/9f717c924f63eb726f63f3ebb6297e2b0e0a30ef/module/docs/manual/images/image15.png -------------------------------------------------------------------------------- /module/docs/manual/images/image16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenderHeads/MayaPlugin-UVAutoRatio/9f717c924f63eb726f63f3ebb6297e2b0e0a30ef/module/docs/manual/images/image16.png -------------------------------------------------------------------------------- /module/docs/manual/images/image17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenderHeads/MayaPlugin-UVAutoRatio/9f717c924f63eb726f63f3ebb6297e2b0e0a30ef/module/docs/manual/images/image17.png -------------------------------------------------------------------------------- /module/docs/manual/images/image18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenderHeads/MayaPlugin-UVAutoRatio/9f717c924f63eb726f63f3ebb6297e2b0e0a30ef/module/docs/manual/images/image18.png -------------------------------------------------------------------------------- /module/docs/manual/images/image19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenderHeads/MayaPlugin-UVAutoRatio/9f717c924f63eb726f63f3ebb6297e2b0e0a30ef/module/docs/manual/images/image19.png -------------------------------------------------------------------------------- /module/docs/manual/images/image20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenderHeads/MayaPlugin-UVAutoRatio/9f717c924f63eb726f63f3ebb6297e2b0e0a30ef/module/docs/manual/images/image20.png -------------------------------------------------------------------------------- /module/docs/manual/images/image21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenderHeads/MayaPlugin-UVAutoRatio/9f717c924f63eb726f63f3ebb6297e2b0e0a30ef/module/docs/manual/images/image21.png -------------------------------------------------------------------------------- /module/docs/manual/images/image22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenderHeads/MayaPlugin-UVAutoRatio/9f717c924f63eb726f63f3ebb6297e2b0e0a30ef/module/docs/manual/images/image22.png -------------------------------------------------------------------------------- /module/docs/manual/images/image23.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenderHeads/MayaPlugin-UVAutoRatio/9f717c924f63eb726f63f3ebb6297e2b0e0a30ef/module/docs/manual/images/image23.png -------------------------------------------------------------------------------- /module/docs/manual/images/image24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenderHeads/MayaPlugin-UVAutoRatio/9f717c924f63eb726f63f3ebb6297e2b0e0a30ef/module/docs/manual/images/image24.png -------------------------------------------------------------------------------- /module/docs/manual/images/image25.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenderHeads/MayaPlugin-UVAutoRatio/9f717c924f63eb726f63f3ebb6297e2b0e0a30ef/module/docs/manual/images/image25.png -------------------------------------------------------------------------------- /module/docs/manual/images/image26.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenderHeads/MayaPlugin-UVAutoRatio/9f717c924f63eb726f63f3ebb6297e2b0e0a30ef/module/docs/manual/images/image26.png -------------------------------------------------------------------------------- /module/docs/manual/images/image27.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenderHeads/MayaPlugin-UVAutoRatio/9f717c924f63eb726f63f3ebb6297e2b0e0a30ef/module/docs/manual/images/image27.png -------------------------------------------------------------------------------- /module/docs/manual/images/image28.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenderHeads/MayaPlugin-UVAutoRatio/9f717c924f63eb726f63f3ebb6297e2b0e0a30ef/module/docs/manual/images/image28.png -------------------------------------------------------------------------------- /module/docs/manual/images/image29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenderHeads/MayaPlugin-UVAutoRatio/9f717c924f63eb726f63f3ebb6297e2b0e0a30ef/module/docs/manual/images/image29.png -------------------------------------------------------------------------------- /module/docs/manual/images/image30.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenderHeads/MayaPlugin-UVAutoRatio/9f717c924f63eb726f63f3ebb6297e2b0e0a30ef/module/docs/manual/images/image30.png -------------------------------------------------------------------------------- /module/docs/manual/images/image31.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenderHeads/MayaPlugin-UVAutoRatio/9f717c924f63eb726f63f3ebb6297e2b0e0a30ef/module/docs/manual/images/image31.png -------------------------------------------------------------------------------- /module/docs/manual/images/image32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenderHeads/MayaPlugin-UVAutoRatio/9f717c924f63eb726f63f3ebb6297e2b0e0a30ef/module/docs/manual/images/image32.png -------------------------------------------------------------------------------- /module/docs/manual/images/image33.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenderHeads/MayaPlugin-UVAutoRatio/9f717c924f63eb726f63f3ebb6297e2b0e0a30ef/module/docs/manual/images/image33.png -------------------------------------------------------------------------------- /module/docs/manual/images/image34.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenderHeads/MayaPlugin-UVAutoRatio/9f717c924f63eb726f63f3ebb6297e2b0e0a30ef/module/docs/manual/images/image34.png -------------------------------------------------------------------------------- /module/icons/UVAutoRatioIcon.xpm: -------------------------------------------------------------------------------- 1 | /* XPM */ 2 | static char * UVAutioRatioIcon_xpm[] = { 3 | "32 32 219 2", 4 | " c None", 5 | ". c #FFFFFF", 6 | "+ c #F5F5F5", 7 | "@ c #E8E8E8", 8 | "# c #DCDCDC", 9 | "$ c #FAFAFA", 10 | "% c #DEDEDE", 11 | "& c #DFDFDF", 12 | "* c #EAEAEA", 13 | "= c #F2F2F2", 14 | "- c #F6F6F6", 15 | "; c #F4F4F4", 16 | "> c #F3F3F3", 17 | ", c #F1F1F1", 18 | "' c #F0F0F0", 19 | ") c #EFEFEF", 20 | "! c #EEEEEE", 21 | "~ c #EDEDED", 22 | "{ c #ECECEC", 23 | "] c #EBEBEB", 24 | "^ c #E9E9E9", 25 | "/ c #E6E6E6", 26 | "( c #E2E2E2", 27 | "_ c #DDDDDD", 28 | ": c #E7E7E7", 29 | "< c #F7F7F7", 30 | "[ c #E5E5E5", 31 | "} c #E4E4E4", 32 | "| c #6C6C6C", 33 | "1 c #555555", 34 | "2 c #9F9F9F", 35 | "3 c #7D7D7D", 36 | "4 c #535353", 37 | "5 c #8B8B8B", 38 | "6 c #919191", 39 | "7 c #575757", 40 | "8 c #5C5C5C", 41 | "9 c #B6B6B6", 42 | "0 c #646464", 43 | "a c #505050", 44 | "b c #ADADAD", 45 | "c c #E3E3E3", 46 | "d c #E1E1E1", 47 | "e c #5A5A5A", 48 | "f c #404040", 49 | "g c #939393", 50 | "h c #3E3E3E", 51 | "i c #7F7F7F", 52 | "j c #A5A5A5", 53 | "k c #545454", 54 | "l c #B0B0B0", 55 | "m c #929292", 56 | "n c #424242", 57 | "o c #494949", 58 | "p c #CCCCCC", 59 | "q c #595959", 60 | "r c #C9C9C9", 61 | "s c #696969", 62 | "t c #3D3D3D", 63 | "u c #777777", 64 | "v c #D0D0D0", 65 | "w c #737373", 66 | "x c #3C3C3C", 67 | "y c #D9D9D9", 68 | "z c #3F3F3F", 69 | "A c #878787", 70 | "B c #434343", 71 | "C c #4E4E4E", 72 | "D c #A6A6A6", 73 | "E c #E0E0E0", 74 | "F c #6B6B6B", 75 | "G c #7E7E7E", 76 | "H c #B2B2B2", 77 | "I c #4F4F4F", 78 | "J c #AFAFAF", 79 | "K c #999999", 80 | "L c #C2C2C2", 81 | "M c #5F5F5F", 82 | "N c #CFCFCF", 83 | "O c #717171", 84 | "P c #D3D3D3", 85 | "Q c #585858", 86 | "R c #E2D5D0", 87 | "S c #695F5B", 88 | "T c #3D3734", 89 | "U c #7E706B", 90 | "V c #DED0CC", 91 | "W c #414141", 92 | "X c #524B48", 93 | "Y c #A5938D", 94 | "Z c #4C4441", 95 | "` c #433C39", 96 | " . c #A7958F", 97 | ".. c #E2CAC1", 98 | "+. c #E2D1CA", 99 | "@. c #E1DFDE", 100 | "#. c #616161", 101 | "$. c #8A8A8A", 102 | "%. c #ECEBEB", 103 | "&. c #DF5221", 104 | "*. c #5E1800", 105 | "=. c #3E1000", 106 | "-. c #832200", 107 | ";. c #E3754F", 108 | ">. c #BEBEBE", 109 | ",. c #454545", 110 | "'. c #451403", 111 | "). c #621900", 112 | "!. c #3D1000", 113 | "~. c #631900", 114 | "{. c #C73300", 115 | "]. c #EB3D00", 116 | "^. c #EA4308", 117 | "/. c #E67851", 118 | "(. c #E0D1CB", 119 | "_. c #656565", 120 | ":. c #BABABA", 121 | "<. c #DFA996", 122 | "[. c #AE2D00", 123 | "}. c #461200", 124 | "|. c #982700", 125 | "1. c #E95D2C", 126 | "2. c #5B5350", 127 | "3. c #852200", 128 | "4. c #DE3900", 129 | "5. c #E85826", 130 | "6. c #DDD9D8", 131 | "7. c #B7B7B7", 132 | "8. c #4C4C4C", 133 | "9. c #6D6D6D", 134 | "0. c #6B2C16", 135 | "a. c #531500", 136 | "b. c #651A00", 137 | "c. c #C83400", 138 | "d. c #EA440A", 139 | "e. c #E7E6E6", 140 | "f. c #8C6E63", 141 | "g. c #4B1300", 142 | "h. c #A54524", 143 | "i. c #E67C56", 144 | "j. c #E86D43", 145 | "k. c #EA4005", 146 | "l. c #E2A995", 147 | "m. c #3D322E", 148 | "n. c #401000", 149 | "o. c #711E00", 150 | "p. c #C53300", 151 | "q. c #E83C00", 152 | "r. c #E6D2CA", 153 | "s. c #C4826A", 154 | "t. c #C19585", 155 | "u. c #E49174", 156 | "v. c #E49275", 157 | "w. c #EB6E43", 158 | "x. c #EA8561", 159 | "y. c #E7B7A6", 160 | "z. c #E87C56", 161 | "A. c #E2CBC3", 162 | "B. c #E57D58", 163 | "C. c #E39C83", 164 | "D. c #EBCCC1", 165 | "E. c #EA5C2A", 166 | "F. c #E8CABF", 167 | "G. c #E79C82", 168 | "H. c #E96030", 169 | "I. c #E8673A", 170 | "J. c #E86739", 171 | "K. c #E9531E", 172 | "L. c #E2CDC6", 173 | "M. c #EB7B54", 174 | "N. c #E9AA95", 175 | "O. c #E8E1DF", 176 | "P. c #EA3D00", 177 | "Q. c #E8815D", 178 | "R. c #EA450B", 179 | "S. c #EA4004", 180 | "T. c #E4A28B", 181 | "U. c #EBD7D0", 182 | "V. c #EA3F03", 183 | "W. c #E99F85", 184 | "X. c #E8A188", 185 | "Y. c #E9673A", 186 | "Z. c #E3CFC8", 187 | "`. c #E94F19", 188 | " + c #E2C7BE", 189 | ".+ c #EA8866", 190 | "++ c #EA4C15", 191 | "@+ c #E5B4A2", 192 | "#+ c #E49377", 193 | "$+ c #E86132", 194 | "%+ c #EA4207", 195 | "&+ c #E2DDDB", 196 | "*+ c #EADEDA", 197 | "=+ c #E6977C", 198 | "-+ c #E3AF9D", 199 | ";+ c #E58765", 200 | ">+ c #E5BAAA", 201 | ",+ c #EA9578", 202 | "'+ c #EA6333", 203 | ")+ c #E7B09D", 204 | "!+ c #E6B09D", 205 | "~+ c #E96B3F", 206 | "{+ c #E77B55", 207 | "]+ c #E4AD9A", 208 | "^+ c #E88F70", 209 | "/+ c #EAE4E2", 210 | "(+ c #EA4B14", 211 | "_+ c #E8B5A3", 212 | ":+ c #E69274", 213 | "<+ c #E86030", 214 | "[+ c #E1E0E0", 215 | "}+ c #E1D2CD", 216 | "|+ c #E96435", 217 | "1+ c #E9A289", 218 | "2+ c #EA5926", 219 | "3+ c #E6E5E5", 220 | "4+ c #E5A993", 221 | "5+ c #E95521", 222 | "6+ c #E8E0DD", 223 | ". . . . + @ # # # # # # # # # # # # # # # # # # # # @ + . . . . ", 224 | ". . $ % # # # # # # # # # # # # # # # # # # # # # # # # % $ . . ", 225 | ". $ # # & * = - + ; ; > = , ' ' ) ! ~ ~ { ] * * ^ / ( _ # # $ . ", 226 | ". % # : < < - + ; ; > = , , ' ) ! ~ ~ { ] * * ^ @ : : [ & # % . ", 227 | "+ # & < < - + + ; > = , , ' ) ! ! ~ { ] ] * ^ @ : : / [ } # # + ", 228 | "@ # ] < - + + ; > = = , ' ) ) ! ~ { ] ] * ^ @ @ : / [ } } & # @ ", 229 | "# # = / | 1 2 = = = @ 3 4 5 6 7 8 # ] * ^ 9 0 a b [ [ } c d # # ", 230 | "# # - } e f g = = , / | h i j k h l * ^ [ m n o p [ } c ( ( # # ", 231 | "# # - c q f g , , ' / | h i r s t u ^ ^ v w x u y } c c ( d # # ", 232 | "# # + ( q z g ' , ' [ | h i % A B C # @ 9 4 t D E c c ( d E # # ", 233 | "# # ; ( q z m ' ' ) } F h G & H I f J d K f 1 L c c ( d E E # # ", 234 | "# # ; d q z m ) ) ! c F h G & _ M h u N O x G P c ( d d E & # # ", 235 | "# # > E Q z 6 ! ! ! R S T U V ^ 5 W X Y Z ` ...+.@.d E & % # # ", 236 | "# # > d #.z $.@ ! %.&.*.=.-.;.@ >.,.'.).!.~.{.].].^./.(.& _ # # ", 237 | "# # = [ G h _.:.E <.[.}.}.|.1.@ E 2.!.=.=.3.4.].].].].5.6.% # # ", 238 | "# # , ~ 7.8.B e 9.0.a.=.b.c.d.e./ f.!.!.g.h.i.j.k.].].].l.% # # ", 239 | "# # , ' / b 8 z m.!.n.o.p.q.].r./ s.!.!.b.t.d E u.].].].v.& # # ", 240 | "# # ' ) ! ~ ~ { w.].].x.].].].y.[ z.].].].A.E E B.].].].C.d # # ", 241 | "# # ) ! ! ~ { D.].].E.F.].].].G.} H.].].].I.J.K.].].].k.L.( # # ", 242 | "# # ! ! ~ { ] M.].].N.O.P.].].Q.} R.].].].].].].].].S.T.( c # # ", 243 | "# # ! ~ { { U.V.].S.W.X.d.].].Y.Z.].].].].].].].].`. +( c } # # ", 244 | "# # ~ ~ { ] .+].].].].].].].].++@+].].].#+& $+].].%+&+c } [ # # ", 245 | "# # ~ { ] *+d.].].].].].].].].].=+].].].-+d ;+].].].>+[ / : # # ", 246 | "# # { ] * ,+].].'+)+)+!+~+].].].{+].].].A.d ]+].].].^+/ : @ # # ", 247 | "# # ] ] /+(+].]._+/ [ } :+].].].<+].].^.[+d }+].].].|+: @ ^ # # ", 248 | "# # @ * 1+].].2+3+[ } } 4+].].].R.].].1.d d c 5+].].S.6+^ : # # ", 249 | "@ # c ^ @ @ : / [ [ } c ( d E d d d d ( d c } [ / : @ ^ * c # @ ", 250 | "+ # _ @ @ : / [ [ } c ( ( E d d d d ( d c } [ / : @ ^ * @ # # + ", 251 | ". % # E : / [ [ } c c ( E ( ( d c c c } [ / : @ ^ * ] @ % # % . ", 252 | ". $ # # _ d c } c c d ( ( ( ( c c c c [ / : @ ^ * @ c # # # $ . ", 253 | ". . $ % # # # # # # # # # # # # # # # # # # # # # # # # % $ . . ", 254 | ". . . . + @ # # # # # # # # # # # # # # # # # # # # @ + . . . . "}; 255 | -------------------------------------------------------------------------------- /module/icons/UVAutoRatioIconOver.xpm: -------------------------------------------------------------------------------- 1 | /* XPM */ 2 | static char * UVAutoRatioIconOver_xpm[] = { 3 | "32 32 405 2", 4 | " c None", 5 | ". c #FFFFFF", 6 | "+ c #FAFAFC", 7 | "@ c #DDDDE6", 8 | "# c #B5B6C3", 9 | "$ c #9E9FAE", 10 | "% c #9FA0AF", 11 | "& c #EBEBF1", 12 | "* c #B2B3C1", 13 | "= c #AEAFBD", 14 | "- c #B6B7C4", 15 | "; c #C2C4CF", 16 | "> c #CBCBD6", 17 | ", c #CDCFD9", 18 | "' c #CECFD9", 19 | ") c #C3C4CF", 20 | "! c #B0B1BF", 21 | "~ c #B4B5C2", 22 | "{ c #CCCCD7", 23 | "] c #E0E0E8", 24 | "^ c #E9EAF0", 25 | "/ c #EDEEF4", 26 | "( c #EFF0F5", 27 | "_ c #EFEFF5", 28 | ": c #EEEEF4", 29 | "< c #EAEBF1", 30 | "[ c #E0E1E9", 31 | "} c #CDCDD8", 32 | "| c #B2B3C0", 33 | "1 c #D1D2DC", 34 | "2 c #EBEBF2", 35 | "3 c #F5F5F9", 36 | "4 c #F8F9FB", 37 | "5 c #FBFBFD", 38 | "6 c #F9F9FC", 39 | "7 c #F5F6F9", 40 | "8 c #ECECF2", 41 | "9 c #D2D3DD", 42 | "0 c #AAACBA", 43 | "a c #C5C6D1", 44 | "b c #E7E8EF", 45 | "c c #F6F6FA", 46 | "d c #F7F7FA", 47 | "e c #E8E9F0", 48 | "f c #C6C7D2", 49 | "g c #ABACBA", 50 | "h c #D3D3DD", 51 | "i c #D4D5DE", 52 | "j c #AFB0BD", 53 | "k c #9C9EAD", 54 | "l c #D7D8E1", 55 | "m c #DFE0E4", 56 | "n c #6B6B6D", 57 | "o c #545456", 58 | "p c #9E9FA2", 59 | "q c #F1F2F7", 60 | "r c #F2F3F8", 61 | "s c #E9EAEF", 62 | "t c #7E7E81", 63 | "u c #8D8D90", 64 | "v c #949497", 65 | "w c #59595B", 66 | "x c #5F5F61", 67 | "y c #E2E3E8", 68 | "z c #F3F4F9", 69 | "A c #BFC0C4", 70 | "B c #696A6C", 71 | "C c #545556", 72 | "D c #B6B7BB", 73 | "E c #F0F0F6", 74 | "F c #D9D9E3", 75 | "G c #B5B6C2", 76 | "H c #9C9DAC", 77 | "I c #B5B5C2", 78 | "J c #D5D5DF", 79 | "K c #DADBE0", 80 | "L c #57575A", 81 | "M c #3E3E40", 82 | "N c #909094", 83 | "O c #EDEDF4", 84 | "P c #EEEEF5", 85 | "Q c #E4E4EB", 86 | "R c #6C6C6F", 87 | "S c #7F8083", 88 | "T c #A6A6AB", 89 | "U c #545557", 90 | "V c #B3B3B9", 91 | "W c #EFEFF6", 92 | "X c #96969B", 93 | "Y c #444446", 94 | "Z c #4C4C4F", 95 | "` c #D5D5DB", 96 | " . c #ECECF3", 97 | ".. c #B6B8C3", 98 | "+. c #9B9CAB", 99 | "@. c #D9DAE1", 100 | "#. c #909195", 101 | "$. c #EDEEF5", 102 | "%. c #EEEFF6", 103 | "&. c #E4E5EC", 104 | "*. c #7F8084", 105 | "=. c #CACBD1", 106 | "-. c #6A6A6D", 107 | ";. c #79797D", 108 | ">. c #D5D6DC", 109 | ",. c #76777A", 110 | "'. c #7B7B7F", 111 | "). c #E1E2E9", 112 | "!. c #ECECF4", 113 | "~. c #D0D1DB", 114 | "{. c #B3B4C1", 115 | "]. c #AEAFBB", 116 | "^. c #CCCED8", 117 | "/. c #D5D6DF", 118 | "(. c #555659", 119 | "_. c #3C3D3F", 120 | ":. c #8D8E93", 121 | "<. c #E8E9F2", 122 | "[. c #E9EAF3", 123 | "}. c #DFE0E9", 124 | "|. c #696A6E", 125 | "1. c #3D3D3F", 126 | "2. c #7D7D82", 127 | "3. c #DBDCE4", 128 | "4. c #86868C", 129 | "5. c #434346", 130 | "6. c #4E4E51", 131 | "7. c #DDDDE5", 132 | "8. c #EAEAF3", 133 | "9. c #B8B8BF", 134 | "0. c #555558", 135 | "a. c #A9A9B0", 136 | "b. c #E6E6EF", 137 | "c. c #EAEBF3", 138 | "d. c #E7E9F1", 139 | "e. c #CDCED8", 140 | "f. c #AFB0BC", 141 | "g. c #9A9CAB", 142 | "h. c #A8A9B7", 143 | "i. c #CBCCD8", 144 | "j. c #555559", 145 | "k. c #3D3D40", 146 | "l. c #8D8E94", 147 | "m. c #E8E9F3", 148 | "n. c #E9EAF4", 149 | "o. c #DFE0EA", 150 | "p. c #7D7D83", 151 | "q. c #DDDEE7", 152 | "r. c #B1B2B9", 153 | "s. c #4F4F53", 154 | "t. c #404143", 155 | "u. c #B0B1B8", 156 | "v. c #E3E4EE", 157 | "w. c #9A9BA1", 158 | "x. c #56575A", 159 | "y. c #C7C8D0", 160 | "z. c #EAEAF4", 161 | "A. c #E7E8F2", 162 | "B. c #AAABB8", 163 | "C. c #A4A5B3", 164 | "D. c #C9CBD7", 165 | "E. c #D2D2DD", 166 | "F. c #545458", 167 | "G. c #3B3C3F", 168 | "H. c #8A8B92", 169 | "I. c #E3E4F0", 170 | "J. c #E4E5F1", 171 | "K. c #DBDCE7", 172 | "L. c #67686D", 173 | "M. c #7A7B81", 174 | "N. c #D8DAE4", 175 | "O. c #D7D9E3", 176 | "P. c #5D5E63", 177 | "Q. c #3D3E41", 178 | "R. c #76777C", 179 | "S. c #717177", 180 | "T. c #3C3C3F", 181 | "U. c #7F8086", 182 | "V. c #D5D6E0", 183 | "W. c #E5E6F1", 184 | "X. c #E3E4EF", 185 | "Y. c #CACBD7", 186 | "Z. c #A5A6B4", 187 | "`. c #9A9BAA", 188 | " + c #A0A1AF", 189 | ".+ c #C7C9D6", 190 | "++ c #D1D2DE", 191 | "@+ c #8A8B93", 192 | "#+ c #E3E4F1", 193 | "$+ c #E4E5F2", 194 | "%+ c #DBCED6", 195 | "&+ c #665C5D", 196 | "*+ c #3B3536", 197 | "=+ c #7A6E6F", 198 | "-+ c #D8CCD3", 199 | ";+ c #888991", 200 | ">+ c #404044", 201 | ",+ c #514A4C", 202 | "'+ c #A39395", 203 | ")+ c #4C4445", 204 | "!+ c #433C3D", 205 | "~+ c #A79698", 206 | "{+ c #E3CCCF", 207 | "]+ c #E5D4DA", 208 | "^+ c #E5E3EF", 209 | "/+ c #E5E5F2", 210 | "(+ c #E2E3F0", 211 | "_+ c #C8C9D6", 212 | ":+ c #A1A2B1", 213 | "<+ c #9D9EAC", 214 | "[+ c #C6C7D6", 215 | "}+ c #CECFDC", 216 | "|+ c #5A5A60", 217 | "1+ c #3A3A3E", 218 | "2+ c #81828A", 219 | "3+ c #D8DAE7", 220 | "4+ c #DFE1EE", 221 | "5+ c #DFDFEC", 222 | "6+ c #DD5428", 223 | "7+ c #5D1A02", 224 | "8+ c #3E1101", 225 | "9+ c #832503", 226 | "0+ c #DF7655", 227 | "a+ c #E0E1EE", 228 | "b+ c #B7B8C3", 229 | "c+ c #434448", 230 | "d+ c #451605", 231 | "e+ c #621B02", 232 | "f+ c #3D1101", 233 | "g+ c #631B02", 234 | "h+ c #C63705", 235 | "i+ c #EA4207", 236 | "j+ c #EA4810", 237 | "k+ c #E67C5B", 238 | "l+ c #E0D4DB", 239 | "m+ c #DEDFED", 240 | "n+ c #C7C8D6", 241 | "o+ c #9E9FAD", 242 | "p+ c #C5C6D5", 243 | "q+ c #D2D4E1", 244 | "r+ c #75767E", 245 | "s+ c #3A3B3F", 246 | "t+ c #5E5F65", 247 | "u+ c #AFB1BC", 248 | "v+ c #D4D6E3", 249 | "w+ c #D7A59B", 250 | "x+ c #AD3005", 251 | "y+ c #451302", 252 | "z+ c #461302", 253 | "A+ c #972A04", 254 | "B+ c #E76033", 255 | "C+ c #E0E2F0", 256 | "D+ c #D9DBE9", 257 | "E+ c #595153", 258 | "F+ c #852503", 259 | "G+ c #DD3E06", 260 | "H+ c #E85E30", 261 | "I+ c #DEDBE9", 262 | "J+ c #C6C7D5", 263 | "K+ c #DADBEA", 264 | "L+ c #AAACB7", 265 | "M+ c #48484D", 266 | "N+ c #3F3F43", 267 | "O+ c #55555B", 268 | "P+ c #67686F", 269 | "Q+ c #6A2D1A", 270 | "R+ c #531702", 271 | "S+ c #641C03", 272 | "T+ c #C83805", 273 | "U+ c #EA4911", 274 | "V+ c #E0E0EF", 275 | "W+ c #E0E1F0", 276 | "X+ c #896C69", 277 | "Y+ c #4B1502", 278 | "Z+ c #A4482A", 279 | "`+ c #E57E60", 280 | " @ c #E7714D", 281 | ".@ c #EA460D", 282 | "+@ c #E1ACA3", 283 | "@@ c #DBDCEB", 284 | "#@ c #D5D6E4", 285 | "$@ c #A1A1AC", 286 | "%@ c #56575D", 287 | "&@ c #3A302F", 288 | "*@ c #401201", 289 | "=@ c #712004", 290 | "-@ c #C43705", 291 | ";@ c #E74106", 292 | ">@ c #DECCD2", 293 | ",@ c #DDDFEE", 294 | "'@ c #C18172", 295 | ")@ c #BE948E", 296 | "!@ c #DEDFEE", 297 | "~@ c #E4947F", 298 | "{@ c #E2937F", 299 | "]@ c #DDDEED", 300 | "^@ c #DFE1F0", 301 | "/@ c #E76F4A", 302 | "(@ c #E68569", 303 | "_@ c #E2B5B0", 304 | ":@ c #E67E60", 305 | "<@ c #E1CCD1", 306 | "[@ c #E68164", 307 | "}@ c #E29E8E", 308 | "|@ c #DFC3C4", 309 | "1@ c #E85F32", 310 | "2@ c #DFC3C5", 311 | "3@ c #E29B8A", 312 | "4@ c #E76338", 313 | "5@ c #E76A43", 314 | "6@ c #E85727", 315 | "7@ c #EA450D", 316 | "8@ c #DDCAD1", 317 | "9@ c #E67B5B", 318 | "0@ c #E3A89D", 319 | "a@ c #E0DBE7", 320 | "b@ c #EA4208", 321 | "c@ c #E68367", 322 | "d@ c #EA4A13", 323 | "e@ c #EA450C", 324 | "f@ c #E4A497", 325 | "g@ c #DECDD3", 326 | "h@ c #EA440B", 327 | "i@ c #E29C8C", 328 | "j@ c #E29E8F", 329 | "k@ c #E94912", 330 | "l@ c #E76A42", 331 | "m@ c #E95321", 332 | "n@ c #DFC6CA", 333 | "o@ c #DCDDEC", 334 | "p@ c #E1E1F0", 335 | "q@ c #E1E2F0", 336 | "r@ c #E6886D", 337 | "s@ c #E9511D", 338 | "t@ c #E3B4AE", 339 | "u@ c #E59884", 340 | "v@ c #E8653B", 341 | "w@ c #E1DDE9", 342 | "x@ c #DFDFEE", 343 | "y@ c #DDDFEC", 344 | "z@ c #E0E1EF", 345 | "A@ c #E0D6E0", 346 | "B@ c #E49986", 347 | "C@ c #E3B2A9", 348 | "D@ c #E0E2EF", 349 | "E@ c #E58A70", 350 | "F@ c #E2B9B4", 351 | "G@ c #A0A1B0", 352 | "H@ c #E1E2EF", 353 | "I@ c #E79580", 354 | "J@ c #E9663B", 355 | "K@ c #E6B2A8", 356 | "L@ c #E86F49", 357 | "M@ c #E88060", 358 | "N@ c #E4CFD3", 359 | "O@ c #E7917A", 360 | "P@ c #A3A4B2", 361 | "Q@ c #C9CAD7", 362 | "R@ c #E1E2EE", 363 | "S@ c #E3DFE8", 364 | "T@ c #EA501B", 365 | "U@ c #E5B5AC", 366 | "V@ c #E4E5F0", 367 | "W@ c #E7957F", 368 | "X@ c #E96539", 369 | "Y@ c #EA4811", 370 | "Z@ c #E4E4F0", 371 | "`@ c #E4D7DD", 372 | " # c #E9673D", 373 | ".# c #A3A5B2", 374 | "+# c #E9A491", 375 | "@# c #EA5E2E", 376 | "## c #E8E8F3", 377 | "$# c #E8E9F4", 378 | "%# c #E9AEA1", 379 | "&# c #EA4B14", 380 | "*# c #EA6235", 381 | "=# c #EA5A2A", 382 | "-# c #E8E1E9", 383 | ";# c #B4B5C1", 384 | "># c #A2A3B1", 385 | ",# c #B0B0BD", 386 | "'# c #C4C5D0", 387 | ")# c #DDDEE8", 388 | "!# c #DEDEE8", 389 | "~# c #D6D6E0", 390 | "{# c #DCDDE5", 391 | "]# c #A4A5B4", 392 | "^# c #BEBFCA", 393 | "/# c #D2D3DC", 394 | "(# c #DCDCE5", 395 | "_# c #DFDFE8", 396 | ":# c #E0E0E9", 397 | "<# c #DFE0E8", 398 | "[# c #AEB0BC", 399 | "}# c #C3C5CF", 400 | "|# c #E4E4EC", 401 | "1# c #E5E6ED", 402 | "2# c #ABACBB", 403 | "3# c #CACBD6", 404 | "4# c #D3D4DD", 405 | "5# c #D3D4DE", 406 | "6# c #B0B1C0", 407 | "7# c #A6A7B5", 408 | "8# c #B4B4C1", 409 | ". . . + @ # $ $ % % % % % % % % % % % % % % % % $ $ # @ + . . . ", 410 | ". . & * = - ; > , ' ' ' ' ' ' ' ' ' ' ' ' ' ' , > ) - = * & . . ", 411 | ". & ! ~ { ] ^ / ( ( ( _ ( ( ( ( ( ( ( ( ( ( ( ( : < [ } # ! & . ", 412 | "+ * | 1 2 3 4 + 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 + 6 7 8 9 | * + ", 413 | "@ 0 a b c 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 d e f g @ ", 414 | "~ = h : c c c c c c c c c c c c c c c c c c c c d d d c _ i j ~ ", 415 | "k ~ l m n o p q r r s t o u v w x y z z z A B C D z z z E F G k ", 416 | "H I J K L M N O P P Q R M S T U M V W W 2 X Y Z ` W W W .l ..H ", 417 | "+.| ' @.L M #.$.%.%.&.R M *.=.-.M ;.%.%.>.,.M '.).%.%.%.!.~.{.H ", 418 | "+.].^./.(._.:.<.[.[.}.|.1.2.3.4.5.6.7.8.9.0.M a.b.c.c.c.d.e.f.+.", 419 | "g.h.i./.j.k.l.m.n.n.o.|.k.p.q.r.s.t.u.v.w.t.x.y.n.z.z.z.A.i.B.g.", 420 | "g.C.D.E.F.G.H.I.J.J.K.L.G.M.N.O.P.Q.R.e.S.T.U.V.W.W.W.W.X.Y.Z.g.", 421 | "`. +.+++F.G.@+#+$+$+%+&+*+=+-+$+;+>+,+'+)+!+~+{+]+^+/+/+(+_+:+g.", 422 | "`.<+[+}+|+1+2+3+4+5+6+7+8+9+0+a+b+c+d+e+f+g+h+i+i+j+k+l+m+n+o+`.", 423 | "`.g.p+q+r+s+t+u+v+w+x+y+z+A+B+C+D+E+f+8+8+F+G+i+i+i+i+H+I+J++.`.", 424 | "`.`.p+K+L+M+N+O+P+Q+R+8+S+T+U+V+W+X+f+f+Y+Z+`+ @.@i+i+i++@p+`.`.", 425 | "`.`.p+@@#@$@%@s+&@f+*@=@-@;@i+>@,@'@f+f+S+)@!@!@~@i+i+i+{@p+`.`.", 426 | "`.`.p+]@^@W+W+W+/@i+i+(@i+i+i+_@W+:@i+i+i+<@W+W+[@i+i+i+}@p+`.`.", 427 | "`.`.p+@@]@]@,@|@i+i+1@2@i+i+i+3@,@4@i+i+i+5@5@6@i+i+i+7@8@p+`.`.", 428 | "`.`.p+]@^@W+W+9@i+i+0@a@b@i+i+c@W+d@i+i+i+i+i+i+i+i+e@f@,@p+`.`.", 429 | "`.`.p+@@]@]@g@h@i+e@i@j@k@i+i+l@>@i+i+i+i+i+i+i+i+m@n@!@o@p+`.`.", 430 | "`.H J+m+p@q@r@i+i+i+i+i+i+i+i+s@t@i+i+i+u@q@v@i+i+j+w@q@x@J+H `.", 431 | "`.o+n+y@z@A@U+i+i+i+i+i+i+i+i+i+B@i+i+i+C@D@E@i+i+i+F@D@m+n+o+`.", 432 | "`.G@_+H@J.I@i+i+J@K@K@K@L@i+i+i+M@i+i+i+N@$+K@i+i+i+O@$+(+_+G@`.", 433 | "g.P@Q@R@S@T@i+i+U@V@V@V@W@i+i+i+X@i+i+Y@Z@J.`@i+i+i+ #J.i.Q@P@g.", 434 | "+..#D.V@+#i+i+@###$#$#$#%#i+i+i+&#i+i+*#$#$#$#=#i+i+e@-#W.| .#+.", 435 | ";#>#,#'#)#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#!#~#!#!#!#!#!#)#'#,#>#;#", 436 | "{#]#h.^#/#(#_#}.:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#:#<#/#^#h.]#{#", 437 | "+ ! >#[#}#J ] |#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#1#|#] J }#[#>#! + ", 438 | ". & 2#P@[#^#3#~.4#5#5#5#5#5#5#5#5#5#5#5#5#5#5#h ~.3#^#[#P@2#& . ", 439 | ". . & 6#7#h.f.8#................................8#f.h.7#6#& . . ", 440 | ". . . + {#~ H +.H H H H H H H H H H H H H H H H +.H ~ {#+ . . . "}; 441 | -------------------------------------------------------------------------------- /module/plug-ins/native-plugins-built-here.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RenderHeads/MayaPlugin-UVAutoRatio/9f717c924f63eb726f63f3ebb6297e2b0e0a30ef/module/plug-ins/native-plugins-built-here.txt -------------------------------------------------------------------------------- /module/scripts/UVAutoRatioBase.mel: -------------------------------------------------------------------------------- 1 | // 2 | // UVAutoRatio Maya Plugin Source Code 3 | // Copyright (C) 2007-2014 RenderHeads Ltd. 4 | // 5 | // This source is available for distribution and/or modification 6 | // only under the terms of the MIT license. All rights reserved. 7 | // 8 | // The source is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // FITNESS FOR A PARTICULAR PURPOSE. See the MIT license 11 | // for more details. 12 | // 13 | 14 | global proc 15 | UVAR_DisplayString(string $value, string $name) 16 | { 17 | // Older versions of maya do not support to -replace flag 18 | if (`exists uiRes`) 19 | { 20 | displayString -replace -value ($value) $name; 21 | } 22 | else 23 | { 24 | if (!`displayString -exists $name`) 25 | displayString -value ($value) $name; 26 | } 27 | } 28 | 29 | global proc string 30 | UVAR_uiRes( string $lookUpKey ) 31 | { 32 | string $result = "Missing"; 33 | 34 | // Older versions of Maya do not have the uiRes command 35 | if (`exists uiRes`) 36 | { 37 | if (catch($result = uiRes($lookUpKey))) 38 | { 39 | warning ("Error: string not found: " + $lookUpKey); 40 | } 41 | } 42 | else 43 | { 44 | if(!`displayString -exists $lookUpKey`) 45 | { 46 | warning ("Error: string not found: " + $lookUpKey); 47 | } 48 | else 49 | { 50 | $result = `displayString -q -value $lookUpKey`; 51 | } 52 | } 53 | 54 | return $result; 55 | } 56 | 57 | global proc string 58 | UVAR_GetMayaVersionNumber() 59 | { 60 | string $mayaVersion = `about -version`; 61 | 62 | if (startsWith($mayaVersion, "2016")) 63 | { 64 | return "2016"; 65 | } 66 | if (startsWith($mayaVersion, "2015")) 67 | { 68 | return "2015"; 69 | } 70 | if (startsWith($mayaVersion, "2014")) 71 | { 72 | return "2014"; 73 | } 74 | if (startsWith($mayaVersion, "2013")) 75 | { 76 | return "2013"; 77 | } 78 | if (startsWith($mayaVersion, "2012")) 79 | { 80 | return "2012"; 81 | } 82 | if (startsWith($mayaVersion, "2011")) 83 | { 84 | return "2011"; 85 | } 86 | if (startsWith($mayaVersion, "2010")) 87 | { 88 | return "2010"; 89 | } 90 | if (startsWith($mayaVersion, "2009")) 91 | { 92 | return "2009"; 93 | } 94 | if (startsWith($mayaVersion, "2008")) 95 | { 96 | return "2008"; 97 | } 98 | if (startsWith($mayaVersion, "8.5")) 99 | { 100 | return "85"; 101 | } 102 | if (startsWith($mayaVersion, "8.0")) 103 | { 104 | return "80"; 105 | } 106 | if (startsWith($mayaVersion, "7.0")) 107 | { 108 | return "70"; 109 | } 110 | if (startsWith($mayaVersion, "6.5")) 111 | { 112 | return "65"; 113 | } 114 | if (startsWith($mayaVersion, "6.0")) 115 | { 116 | return "60"; 117 | } 118 | 119 | if (`exists format`) 120 | { 121 | error `format -stringArg $mayaVersion (UVAR_uiRes("m_UVAutoRatioBase.kMayaVersionNotSupported"))`; 122 | } 123 | else 124 | { 125 | error ((UVAR_uiRes("m_UVAutoRatioBase.kMayaVersionNotSupportedSplit1")) + " (" + $mayaVersion + ") " + UVAR_uiRes("m_UVAutoRatioBase.kMayaVersionNotSupportedSplit2")); 126 | } 127 | 128 | return "invalid"; 129 | } 130 | 131 | global proc string 132 | UVAR_GetPluginName(string $productName) 133 | { 134 | string $version = ""; 135 | 136 | string $mayaVersion = `about -version`; 137 | 138 | $version = UVAR_GetMayaVersionNumber(); 139 | if ($version == "invalid") 140 | return "invalid"; 141 | 142 | // Mac uses universal binaries 143 | if (!`about -mac`) 144 | { 145 | if (endsWith($mayaVersion, "x64")) 146 | { 147 | $version += "x64"; 148 | } 149 | } 150 | 151 | return $productName + $version; 152 | } 153 | 154 | global proc string 155 | UVAR_GetModulePath(string $productName) 156 | { 157 | string $pluginName = UVAR_GetPluginName($productName); 158 | string $pluginPath = `pluginInfo -query -path -command $pluginName`; 159 | 160 | string $extension = ".mll"; 161 | if (!`about -windows`) 162 | { 163 | $extension = ".so"; 164 | if (!`about -linux`) 165 | { 166 | $extension = ".bundle"; 167 | if (!`about -mac`) 168 | { 169 | warning (UVAR_uiRes("m_UVAutoRatioBase.kCantDetermineModulePath")); 170 | } 171 | } 172 | } 173 | if (!endsWith($pluginPath, $extension)) 174 | { 175 | warning (UVAR_uiRes("m_UVAutoRatioBase.kCantDetermineModulePath")); 176 | } 177 | 178 | $pathPrefix = "plug-ins/" + $pluginName + $extension; 179 | return startString($pluginPath, size($pluginPath) - size($pathPrefix)); 180 | } 181 | 182 | global proc 183 | UVAR_SetVarFromFloatField(string $control, string $varName) 184 | { 185 | float $val = `floatField -query -value $control`; 186 | optionVar -floatValue $varName $val; 187 | } 188 | 189 | global proc 190 | UVAR_SetVarFromIntField(string $control, string $varName) 191 | { 192 | float $val = `intField -query -value $control`; 193 | optionVar -intValue $varName $val; 194 | } 195 | -------------------------------------------------------------------------------- /module/scripts/UVAutoRatioBase.res.mel: -------------------------------------------------------------------------------- 1 | // 2 | // UVAutoRatio Maya Plugin Source Code 3 | // Copyright (C) 2007-2014 RenderHeads Ltd. 4 | // 5 | // This source is available for distribution and/or modification 6 | // only under the terms of the MIT license. All rights reserved. 7 | // 8 | // The source is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // FITNESS FOR A PARTICULAR PURPOSE. See the MIT license 11 | // for more details. 12 | // 13 | 14 | // Versioning 15 | UVAR_DisplayString "Version of Maya (^1s) not supported by this plugin" m_UVAutoRatioBase.MayaVersionNotSupported; 16 | UVAR_DisplayString "Version of Maya" m_UVAutoRatioBase.kMayaVersionNotSupportedSplit1; 17 | UVAR_DisplayString "not supported by this plugin" m_UVAutoRatioBase.kMayaVersionNotSupportedSplit2; 18 | UVAR_DisplayString "Cannot determine module path" m_UVAutoRatioBase.kCantDetermineModulePath; -------------------------------------------------------------------------------- /module/scripts/UVAutoRatioPro.res.mel: -------------------------------------------------------------------------------- 1 | // 2 | // UVAutoRatio Maya Plugin Source Code 3 | // Copyright (C) 2007-2014 RenderHeads Ltd. 4 | // 5 | // This source is available for distribution and/or modification 6 | // only under the terms of the MIT license. All rights reserved. 7 | // 8 | // The source is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // FITNESS FOR A PARTICULAR PURPOSE. See the MIT license 11 | // for more details. 12 | // 13 | // Non-UI 14 | UVAR_DisplayString "UVAutoRatio Pro is up to date!" m_UVAutoRatioPro.kIsUpToDate; 15 | 16 | // Main 17 | UVAR_DisplayString "UVAutoRatio" m_UVAutoRatioPro.kTabTitleUVAutoratio; 18 | UVAR_DisplayString "Settings" m_UVAutoRatioPro.kTabTitleSettings; 19 | UVAR_DisplayString "About" m_UVAutoRatioPro.kTabTitleAbout; 20 | 21 | // Main Tab 22 | UVAR_DisplayString "Ratio Tool" m_UVAutoRatioPro.kRatioFrameTitle; 23 | UVAR_DisplayString "Current Ratio:" m_UVAutoRatioPro.kCurrentRatio; 24 | UVAR_DisplayString "Set Ratio from Selection" m_UVAutoRatioPro.kSetRatioFromSelection; 25 | UVAR_DisplayString "Apply to Objects" m_UVAutoRatioPro.kApplyToObjects; 26 | UVAR_DisplayString "Apply to Shells" m_UVAutoRatioPro.kApplyToShells; 27 | UVAR_DisplayString "Other Tools" m_UVAutoRatioPro.kExtraFrameTitle; 28 | UVAR_DisplayString "Fix Shell Overlaps" m_UVAutoRatioPro.kFixShellOverlaps; 29 | UVAR_DisplayString "Normalise" m_UVAutoRatioPro.kNormalise; 30 | UVAR_DisplayString "Aspect Ratio" m_UVAutoRatioPro.kNormaliseKeepAspectRatio; 31 | UVAR_DisplayString "Auto-Select UV Shells" m_UVAutoRatioPro.kUVShellSelectionAutoSelect; 32 | 33 | // Main Tab - Ratio Presets 34 | UVAR_DisplayString "Open Presets Menu" m_UVAutoRatioPro.kPresetButton; 35 | UVAR_DisplayString "Use Preset" m_UVAutoRatioPro.kUsePreset; 36 | UVAR_DisplayString "Add Preset..." m_UVAutoRatioPro.kSavePreset; 37 | UVAR_DisplayString "Delete Presets..." m_UVAutoRatioPro.kEditPresets; 38 | UVAR_DisplayString "Save Presets..." m_UVAutoRatioPro.kSavePresetFile; 39 | UVAR_DisplayString "Load Presets..." m_UVAutoRatioPro.kLoadPresetsFile; 40 | UVAR_DisplayString "Save Ratio Preset" m_UVAutoRatioPro.kSaveRatioWindowTitle; 41 | UVAR_DisplayString "Descriptive Name:" m_UVAutoRatioPro.kSaveRatioWindowMessage; 42 | UVAR_DisplayString "Edit Ratio Presets" m_UVAutoRatioPro.kEditPresetsWindowsTitle; 43 | UVAR_DisplayString "Close" m_UVAutoRatioPro.kClose; 44 | UVAR_DisplayString "Delete" m_UVAutoRatioPro.kDelete; 45 | 46 | // Main Tab - UV Shell Finder 47 | UVAR_DisplayString "UV Shell Finder Tool" m_UVAutoRatioPro.kUVShellFinderFrameTitle; 48 | UVAR_DisplayString "Update UV Shell List from Selection" m_UVAutoRatioPro.kUVShellFinderUpdateButton; 49 | 50 | // Main Tab - UV Tools 51 | UVAR_DisplayString "UV Tools" m_UVAutoRatioPro.kUVToolsFrameTitle; 52 | UVAR_DisplayString "Ratio Inspector" m_UVAutoRatioPro.kUVToolsRatioInspector; 53 | UVAR_DisplayString "Texture View" m_UVAutoRatioPro.kUVToolsTextureView; 54 | UVAR_DisplayString "Unfold" m_UVAutoRatioPro.kUVToolsUnfold; 55 | UVAR_DisplayString "Layout" m_UVAutoRatioPro.kUVToolsLayout; 56 | UVAR_DisplayString "Merge" m_UVAutoRatioPro.kUVToolsMerge; 57 | UVAR_DisplayString "Cut Edges" m_UVAutoRatioPro.kUVToolsCutUVEdges; 58 | 59 | // About Tab - License 60 | UVAR_DisplayString "License" m_UVAutoRatioPro.kAboutTabLicenseFrameTitle; 61 | UVAR_DisplayString "Registered to:" m_UVAutoRatioPro.kAboutTabLicenseFrameRegisteredTo; 62 | UVAR_DisplayString "UNREGISTERED" m_UVAutoRatioPro.kAboutTabLicenseFrameUnregistered; 63 | UVAR_DisplayString "Enter New Key" m_UVAutoRatioPro.kAboutTabLicenseEnterNewKey; 64 | UVAR_DisplayString "Purchase Key" m_UVAutoRatioPro.kAboutTabLicensePurchaseKey; 65 | 66 | // About Tab - Plugin Info 67 | UVAR_DisplayString "Plugin Info" m_UVAutoRatioPro.kAboutTabPluginInfoFrameTitle; 68 | UVAR_DisplayString "Name: " m_UVAutoRatioPro.kAboutTabPluginInfoName; 69 | UVAR_DisplayString "Version: " m_UVAutoRatioPro.kAboutTabPluginInfoVersion; 70 | UVAR_DisplayString "Built: " m_UVAutoRatioPro.kAboutTabPluginInfoBuilt; 71 | UVAR_DisplayString "Vendor: " m_UVAutoRatioPro.kAboutTabPluginInfoVendor; 72 | UVAR_DisplayString "Path: " m_UVAutoRatioPro.kAboutTabPluginInfoPath; 73 | 74 | 75 | // About Tab - Links 76 | UVAR_DisplayString "Links" m_UVAutoRatioPro.kAboutTabLinksFrameTitle; 77 | UVAR_DisplayString "Documentation" m_UVAutoRatioPro.kAboutTabLinksDocumentation; 78 | UVAR_DisplayString "External Websites:" m_UVAutoRatioPro.kAboutLinksExternalWebsites; 79 | UVAR_DisplayString "UVAutoRatio Home" m_UVAutoRatioPro.kAboutLinksUVAutoRatioHome; 80 | UVAR_DisplayString "UVAutoRatio Forum" m_UVAutoRatioPro.kAboutLinksUVAutoRatioForum; 81 | 82 | // About Tab - Credits 83 | UVAR_DisplayString "Credits" m_UVAutoRatioPro.kAboutTabCreditsFrameTitle; 84 | UVAR_DisplayString "Real-time graphics software and tools" m_UVAutoRatioPro.kAboutTabCreditsRenderHeadsServices; 85 | UVAR_DisplayString "Special thanks: Saehoon Lee" m_UVAutoRatioPro.kAboutTabCreditsThanksSaehoonLee; 86 | UVAR_DisplayString "Email: plugin@renderheads.com" m_UVAutoRatioPro.kAboutTabCreditsRenderHeadsEmail; 87 | 88 | // Settings Tab - UV Set 89 | UVAR_DisplayString "UV Set" m_UVAutoRatioPro.kSettingsTabUVSetFrameTitle; 90 | UVAR_DisplayString "Use current UV Set" m_UVAutoRatioPro.kSettingsTabUseCurrentUVSet; 91 | UVAR_DisplayString "Manually select UV Set" m_UVAutoRatioPro.kSettingsTabManualUVSet; 92 | UVAR_DisplayString "Select UV Set:" m_UVAutoRatioPro.kSettingsTabSelectUVSet; 93 | UVAR_DisplayString "Update UV Set List from Selection" m_UVAutoRatioPro.kSettingsTabUpdateUVSetFromSelection; 94 | UVAR_DisplayString "If the UV Set doesn't exist:" m_UVAutoRatioPro.kSettingsTabIFUVSetNotExist; 95 | UVAR_DisplayString "Skip mesh" m_UVAutoRatioPro.kSettingsTabSkipMesh; 96 | UVAR_DisplayString "Process using it's current UV Set" m_UVAutoRatioPro.kSettingsTabProcessCurrentUVSet; 97 | 98 | // Settings Tab - Display Options 99 | UVAR_DisplayString "Display Options" m_UVAutoRatioPro.kSettingsTabDisplayOptionsFrameTitle; 100 | UVAR_DisplayString "Force UV Shell Selection Display To:" m_UVAutoRatioPro.kSettingsTabDisplayForceSelectionDisplay; 101 | UVAR_DisplayString "UVs" m_UVAutoRatioPro.kSettingsTabDisplayUVs; 102 | UVAR_DisplayString "Faces" m_UVAutoRatioPro.kSettingsTabDisplayFaces; 103 | 104 | // Settings Tab - Layout Options 105 | UVAR_DisplayString "Layout Options" m_UVAutoRatioPro.kSettingsTabLayoutFrameTitle; 106 | UVAR_DisplayString "After scaling UV shells:" m_UVAutoRatioPro.kSettingsTabAfterScalingShells; 107 | UVAR_DisplayString "Do nothing" m_UVAutoRatioPro.kSettingsTabDoNothing; 108 | UVAR_DisplayString "Move shells to fix overlaps" m_UVAutoRatioPro.kSettingsTabMoveShells; 109 | UVAR_DisplayString "Iterations:" m_UVAutoRatioPro.kSettingsTabIterations; 110 | UVAR_DisplayString "Step Size:" m_UVAutoRatioPro.kSettingsTabStepSize; 111 | UVAR_DisplayString "Padding:" m_UVAutoRatioPro.kSettingsTabPadding; 112 | UVAR_DisplayString "Apply to Shells in Selection Now" m_UVAutoRatioPro.kSettingsTabApplyOverlapFixNow; 113 | 114 | // Settings Tab - Misc Options 115 | UVAR_DisplayString "Misc Options" m_UVAutoRatioPro.kSettingsTabMiscOptionsFrameTitle; 116 | UVAR_DisplayString "Limit Scaling to:" m_UVAutoRatioPro.kSettingsTabLimitScalingTo; 117 | UVAR_DisplayString "None" m_UVAutoRatioPro.kSettingsTabLimitScalingNone; 118 | UVAR_DisplayString "Horizontal" m_UVAutoRatioPro.kSettingsTabLimitScalingHorizontal; 119 | UVAR_DisplayString "Vertical" m_UVAutoRatioPro.kSettingsTabLimitScalingVertical; 120 | UVAR_DisplayString "Hide UV Editor during operations" m_UVAutoRatioPro.kSettingsTabAutoHideUVEditor; 121 | UVAR_DisplayString "Verbose Output" m_UVAutoRatioPro.kSettingsTabVerboseOutput; 122 | UVAR_DisplayString "Show Timings" m_UVAutoRatioPro.kSettingsTabShowTimings; 123 | UVAR_DisplayString "Reset Settings on Startup" m_UVAutoRatioPro.kSettingsTabResetSettingsStartup; 124 | UVAR_DisplayString "Add To Shelf" m_UVAutoRatioPro.kSettingsTabAddToShelf; 125 | UVAR_DisplayString "Reset Settings to Defaults" m_UVAutoRatioPro.kSettingsTabResetToDefaults; 126 | 127 | // Settings Tab - Auto-Update Options 128 | UVAR_DisplayString "Auto-Update Options" m_UVAutoRatioPro.kSettingsTabAutoUpdateFrameTitle; 129 | UVAR_DisplayString "Check for New Version on Startup" m_UVAutoRatioPro.kSettingsTabCheckVersionOnStartup; 130 | UVAR_DisplayString "Check for New Version Now" m_UVAutoRatioPro.kSettingsTabCheckNewVersionNow; -------------------------------------------------------------------------------- /module/scripts/UVAutoRatioProUI_AboutTab.mel: -------------------------------------------------------------------------------- 1 | // 2 | // UVAutoRatio Maya Plugin Source Code 3 | // Copyright (C) 2007-2014 RenderHeads Ltd. 4 | // 5 | // This source is available for distribution and/or modification 6 | // only under the terms of the MIT license. All rights reserved. 7 | // 8 | // The source is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // FITNESS FOR A PARTICULAR PURPOSE. See the MIT license 11 | // for more details. 12 | // 13 | proc 14 | UVAutoRatioProUI_CreateLicenseFrame() 15 | { 16 | // 17 | // Frame: License 18 | // 19 | frameLayout -label (UVAR_uiRes("m_UVAutoRatioPro.kAboutTabLicenseFrameTitle")) 20 | -labelIndent 4 21 | -borderStyle "etchedIn" 22 | -collapsable true 23 | -collapse false 24 | -marginWidth 4 25 | -marginHeight 4; 26 | 27 | columnLayout -columnAlign "center" -adjustableColumn true -rowSpacing 4; 28 | 29 | string $licType = "Freeware"; 30 | 31 | //rowColumnLayout -numberOfColumns 2 -columnAttach 1 "right" 0 32 | // -columnWidth 1 65 -columnWidth 2 135; 33 | textField -editable false -text $licType; 34 | 35 | if (`about -mac`) 36 | { 37 | //separator -style "single"; 38 | } 39 | else 40 | { 41 | separator -style "none"; 42 | } 43 | 44 | setParent ..; 45 | 46 | setParent ..; 47 | } 48 | 49 | proc 50 | UVAutoRatioProUI_CreatePluginFrame() 51 | { 52 | // 53 | // Frame: Plugin Info 54 | // 55 | frameLayout -label (UVAR_uiRes("m_UVAutoRatioPro.kAboutTabPluginInfoFrameTitle")) 56 | -labelIndent 4 57 | -borderStyle "etchedIn" 58 | -collapsable true 59 | -collapse true 60 | -marginWidth 4 61 | -marginHeight 4; 62 | 63 | columnLayout -columnAlign "center" -adjustableColumn true -rowSpacing 2; 64 | 65 | string $pluginName = `UVAR_GetPluginName("UVAutoRatioPro")`; 66 | int $isLoaded = `pluginInfo -query -loaded -command $pluginName`; 67 | string $vendor, $path, $buildtime, $version; 68 | if ($isLoaded > 0) 69 | { 70 | $vendor = `pluginInfo -query -vendor -command $pluginName`; 71 | $path = `pluginInfo -query -path -command $pluginName`; 72 | 73 | string $buffer[]; 74 | string $versiondata = `pluginInfo -query -version -command $pluginName`; 75 | $numTokens = `tokenize $versiondata "," $buffer`; 76 | if ($numTokens == 2) 77 | { 78 | $version = $buffer[0]; 79 | $buildtime = $buffer[1]; 80 | } 81 | } 82 | 83 | rowLayout -numberOfColumns 2 -adjustableColumn 2 -columnWidth2 45 175 -columnAlign 1 "right"; 84 | text -label (UVAR_uiRes("m_UVAutoRatioPro.kAboutTabPluginInfoName")) -width 45; 85 | textField -editable false -text $pluginName; 86 | setParent ..; 87 | rowLayout -numberOfColumns 2 -adjustableColumn 2 -columnWidth2 45 175 -columnAlign 1 "right"; 88 | text -label (UVAR_uiRes("m_UVAutoRatioPro.kAboutTabPluginInfoVersion")) -width 45; 89 | textField -editable false -text $version; 90 | setParent ..; 91 | rowLayout -numberOfColumns 2 -adjustableColumn 2 -columnWidth2 45 175 -columnAlign 1 "right"; 92 | text -label (UVAR_uiRes("m_UVAutoRatioPro.kAboutTabPluginInfoBuilt")) -width 45; 93 | textField -editable false -text $buildtime; 94 | setParent ..; 95 | rowLayout -numberOfColumns 2 -adjustableColumn 2 -columnWidth2 45 175 -columnAlign 1 "right"; 96 | text -label (UVAR_uiRes("m_UVAutoRatioPro.kAboutTabPluginInfoVendor")) -width 45; 97 | textField -editable false -text $vendor; 98 | setParent ..; 99 | rowLayout -numberOfColumns 2 -adjustableColumn 2 -columnWidth2 45 175 -columnAlign 1 "right"; 100 | text -label (UVAR_uiRes("m_UVAutoRatioPro.kAboutTabPluginInfoPath")) -width 45; 101 | textField -editable false -text $path; 102 | setParent ..; 103 | 104 | // These buttons are for development purposes only 105 | //rowLayout -adjustableColumn 2 -numberOfColumns 2 -columnOffset2 2 2 -columnAlign2 "center" "center" -columnAttach2 "both" "both"; 106 | // button -label "Load" -command "UVAutoRatioProUI_Load"; 107 | // button -label "Unload" -command "UVAutoRatioProUI_Unload"; 108 | //setParent ..; 109 | 110 | setParent ..; 111 | 112 | setParent ..; 113 | } 114 | 115 | 116 | proc 117 | UVAutoRatioProUI_CreateLinksFrame() 118 | { 119 | // 120 | // Frame: Links 121 | // 122 | frameLayout -label (UVAR_uiRes("m_UVAutoRatioPro.kAboutTabLinksFrameTitle")) 123 | -labelIndent 4 124 | -borderStyle "etchedIn" 125 | -collapsable true 126 | -marginWidth 4 127 | -marginHeight 4; 128 | 129 | columnLayout -columnAlign "center" -adjustableColumn true -rowSpacing 4; 130 | 131 | //string $pluginName = `UVAR_GetPluginName("UVAutoRatioPro")`; 132 | //int $isLoaded = `pluginInfo -query -loaded -command $pluginName`; 133 | //if ($isLoaded > 0) 134 | { 135 | $manualPath = UVAR_GetModulePath("UVAutoRatioPro") + "docs/manual/index.html"; 136 | button -label (UVAR_uiRes("m_UVAutoRatioPro.kAboutTabLinksDocumentation")) -command ("showHelp -absolute \"" + $manualPath + "\""); 137 | } 138 | 139 | if (`about -mac`) 140 | { 141 | } 142 | else 143 | { 144 | separator -style "none"; 145 | } 146 | 147 | text -align "left" -label (UVAR_uiRes("m_UVAutoRatioPro.kAboutLinksExternalWebsites")); 148 | button -label (UVAR_uiRes("m_UVAutoRatioPro.kAboutLinksUVAutoRatioHome")) -command ("showHelp -absolute \"http://www.renderheads.com/\""); 149 | setParent ..; 150 | 151 | setParent ..; 152 | } 153 | 154 | proc 155 | UVAutoRatioProUI_CreateCreditsFrame() 156 | { 157 | // 158 | // Frame: Credits 159 | // 160 | frameLayout -label (UVAR_uiRes("m_UVAutoRatioPro.kAboutTabCreditsFrameTitle")) 161 | -labelIndent 4 162 | -borderStyle "etchedIn" 163 | -collapsable true 164 | -marginWidth 4 165 | -marginHeight 4; 166 | 167 | columnLayout -columnAlign "left" -adjustableColumn true -rowSpacing 0 -columnAttach "both" 0; 168 | 169 | iconTextButton -align "left" -style "iconOnly" -image1 "RenderHeads1.xpm" -highlightImage "RenderHeads2.xpm" -label "RenderHeads" -command ("showHelp -absolute \"http://www.renderheads.com/\""); 170 | text -align "left" -label (UVAR_uiRes("m_UVAutoRatioPro.kAboutTabCreditsRenderHeadsServices")); 171 | 172 | if (`about -mac`) 173 | { 174 | // separator -style "single"; 175 | } 176 | else 177 | { 178 | separator -style "none"; 179 | separator -style "none"; 180 | separator -style "none"; 181 | } 182 | text -align "left" -label (UVAR_uiRes("m_UVAutoRatioPro.kAboutTabCreditsThanksSaehoonLee")); 183 | if (`about -mac`) 184 | { 185 | // separator -style "single"; 186 | } 187 | else 188 | { 189 | separator -style "none"; 190 | separator -style "none"; 191 | } 192 | text -align "left" -label (UVAR_uiRes("m_UVAutoRatioPro.kAboutTabCreditsRenderHeadsEmail")); 193 | 194 | setParent ..; 195 | setParent ..; 196 | } 197 | 198 | global proc string 199 | UVAutoRatioProUI_CreateAboutTab() 200 | { 201 | $layout = `scrollLayout -horizontalScrollBarThickness 0 -childResizable true`; 202 | columnLayout -columnAlign "center" -adjustableColumn true -rowSpacing 0 -columnAttach "both" 0; 203 | 204 | UVAutoRatioProUI_CreateCreditsFrame; 205 | UVAutoRatioProUI_CreateLicenseFrame; 206 | UVAutoRatioProUI_CreatePluginFrame; 207 | UVAutoRatioProUI_CreateLinksFrame; 208 | 209 | // End of columnLayout layout 210 | setParent ..; 211 | setParent ..; 212 | 213 | return $layout; 214 | } 215 | -------------------------------------------------------------------------------- /module/scripts/UVAutoRatioProUI_RatioPresets.mel: -------------------------------------------------------------------------------- 1 | // 2 | // UVAutoRatio Maya Plugin Source Code 3 | // Copyright (C) 2007-2014 RenderHeads Ltd. 4 | // 5 | // This source is available for distribution and/or modification 6 | // only under the terms of the MIT license. All rights reserved. 7 | // 8 | // The source is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // FITNESS FOR A PARTICULAR PURPOSE. See the MIT license 11 | // for more details. 12 | // 13 | 14 | global proc 15 | BuildRatioPresetsMenu(string $parent, string $TextRatio) 16 | { 17 | setParent -menu $parent; 18 | 19 | $command = "UVAutoRatioProUI_SaveRatioPresetWindow;"; 20 | $command += "menu -e -deleteAllItems \"" + $parent + "\";"; 21 | $command += "BuildRatioPresetsMenu(\"" + $parent + "\", \"" + $TextRatio + "\");"; 22 | $PresetSave = `menuItem -ecr false -label (UVAR_uiRes("m_UVAutoRatioPro.kSavePreset")) -c $command`; 23 | 24 | $command = "UVAutoRatioProUI_EditRatioPresetsWindow(\"" + $parent + "\", \"" + $TextRatio + "\");"; 25 | $command += "menu -e -deleteAllItems \"" + $parent + "\";"; 26 | $command += "BuildRatioPresetsMenu(\"" + $parent + "\", \"" + $TextRatio + "\");"; 27 | menuItem -ecr false -label (UVAR_uiRes("m_UVAutoRatioPro.kEditPresets")) -c $command; 28 | 29 | menuItem -d true; 30 | 31 | if (`optionVar -exists "UVAutoRatioProUI_RatioPresets"`) 32 | { 33 | string $presets[] = `optionVar -query "UVAutoRatioProUI_RatioPresets"`; 34 | for ($preset in $presets) 35 | { 36 | if (size($preset) > 0) 37 | { 38 | string $buffer[]; 39 | $numTokens = `tokenize $preset "===" $buffer`; 40 | if (size($buffer) == 2) 41 | { 42 | string $name = $buffer[0]; 43 | string $ratio = $buffer[1]; 44 | string $display = ($name + ": " + $ratio); 45 | //string $display = $ratio + " (" + $name + ")"; 46 | 47 | string $command = "optionVar -floatValue UVAutoRatioProUI_Ratio " + $ratio + ";"; 48 | $command += "floatField -e -value " + $ratio + " " + $TextRatio + ";"; 49 | menuItem -ecr false -label $display -c $command; 50 | } 51 | } 52 | } 53 | } 54 | 55 | menuItem -d true; 56 | 57 | $command = "UVAutoRatioProUI_SavePresetToFile();"; 58 | menuItem -ecr false -label (UVAR_uiRes("m_UVAutoRatioPro.kSavePresetFile")) -c $command; 59 | 60 | $command = "UVAutoRatioProUI_LoadPresetFile();"; 61 | $command += "menu -e -deleteAllItems \"" + $parent + "\";"; 62 | $command += "BuildRatioPresetsMenu(\"" + $parent + "\", \"" + $TextRatio + "\");"; 63 | menuItem -ecr false -label (UVAR_uiRes("m_UVAutoRatioPro.kLoadPresetsFile")) -c $command; 64 | 65 | setParent -menu ..; 66 | } 67 | 68 | global proc 69 | UVAutoRatioProUI_SavePresetFile(string $filename) 70 | { 71 | if (`optionVar -exists "UVAutoRatioProUI_RatioPresets"`) 72 | { 73 | string $presets[] = `optionVar -query "UVAutoRatioProUI_RatioPresets"`; 74 | 75 | int $fileId=`fopen $filename "w"`; 76 | fprint $fileId "UVAR-Presets\n"; 77 | 78 | fprint $fileId `size($presets)`; 79 | fprint $fileId "\n"; 80 | 81 | for ($preset in $presets) 82 | { 83 | if (size($preset) > 0) 84 | { 85 | string $buffer[]; 86 | $numTokens = `tokenize $preset "===" $buffer`; 87 | if (size($buffer) == 2) 88 | { 89 | string $name = $buffer[0]; 90 | string $ratio = $buffer[1]; 91 | fprint $fileId $name; 92 | fprint $fileId " "; 93 | fprint $fileId $ratio; 94 | fprint $fileId "\n"; 95 | } 96 | } 97 | } 98 | 99 | fclose $fileId; 100 | } 101 | } 102 | 103 | global string $RH_UVARPRO_Preset_OldSaveFilename; 104 | 105 | // NOTE: Older versions of Maya don't support the -mode switch on fileDialog, so we must use this older way of saving 106 | global proc int 107 | UVAutoRatioProUI_SavePresetToFile_OldSave( string $filename, string $fileType ) 108 | { 109 | global string $RH_UVARPRO_Preset_OldSaveFilename; 110 | 111 | $RH_UVARPRO_Preset_OldSaveFilename = $filename; 112 | return 1; 113 | } 114 | 115 | global proc 116 | UVAutoRatioProUI_SavePresetToFile() 117 | { 118 | global string $RH_UVARPRO_Preset_OldSaveFilename; 119 | 120 | if (`optionVar -exists "UVAutoRatioProUI_RatioPresets"`) 121 | { 122 | string $filename; 123 | // NOTE: Older versions of Maya don't support the -mode switch 124 | int $version = UVAR_GetMayaVersionNumber(); 125 | if ($version <= 70) 126 | { 127 | fileBrowserDialog -m 1 -dialogStyle 1 -fc "UVAutoRatioProUI_SavePresetToFile_OldSave" -an "Save"; 128 | $filename = $RH_UVARPRO_Preset_OldSaveFilename; 129 | } 130 | else 131 | $filename = `fileDialog -dm "*.*" -mode 1`; 132 | 133 | if (size($filename) > 0) 134 | { 135 | UVAutoRatioProUI_SavePresetFile($filename); 136 | } 137 | } 138 | } 139 | 140 | global proc 141 | UVAutoRatioProUI_LoadPresetFile() 142 | { 143 | // NOTE: Older versions of Maya don't support the -mode switch 144 | int $version = UVAR_GetMayaVersionNumber(); 145 | if ($version <= 70) 146 | $filename = toNativePath(`fileDialog -dm "*.*"`); 147 | else 148 | $filename = toNativePath(`fileDialog -dm "*.*" -mode 0`); 149 | 150 | if (size($filename) > 0) 151 | { 152 | if (`filetest -r $filename`) 153 | { 154 | $fileId=`fopen $filename "r"`; 155 | 156 | if ("UVAR-Presets" == `fgetword $fileId`) 157 | { 158 | int $numPresets = `fgetword $fileId`; 159 | 160 | if ($numPresets > 0) 161 | { 162 | optionVar -clearArray "UVAutoRatioProUI_RatioPresets"; 163 | for ($i=0; $i<$numPresets; $i++) 164 | { 165 | string $presetName = `fgetword $fileId`; 166 | float $presetValue = `fgetword $fileId`; 167 | string $text = $presetName + "===" + $presetValue; 168 | optionVar -stringValueAppend "UVAutoRatioProUI_RatioPresets" $text; 169 | } 170 | } 171 | } 172 | 173 | fclose $fileId; 174 | } 175 | } 176 | } 177 | 178 | global proc 179 | UVAutoRatioProUI_EditRatioPresetsWindow(string $presetMenuParent, string $TextRatio) 180 | { 181 | if (!`window -exists UVAR_EditRatioPresetsWindow` ) 182 | { 183 | window -t (UVAR_uiRes("m_UVAutoRatioPro.kEditPresetsWindowsTitle")) -w 150 -h 250 UVAR_EditRatioPresetsWindow; 184 | formLayout fl; 185 | 186 | setParent -m ..; 187 | 188 | $PresetList = `textScrollList -allowMultiSelection true psetList`; 189 | separator -horizontal true shelfSeparator; 190 | $command = "UVAutoRatioProUI_EditRatioPresetsDeleteSelected " + $PresetList + ";"; 191 | $command += "menu -e -deleteAllItems \"" + $presetMenuParent + "\";"; 192 | $command += "BuildRatioPresetsMenu(\"" + $presetMenuParent + "\", \"" + $TextRatio + "\");"; 193 | button 194 | -label (UVAR_uiRes("m_UVAutoRatioPro.kDelete")) 195 | -c $command 196 | deleteButton; 197 | button 198 | -label (UVAR_uiRes("m_UVAutoRatioPro.kClose")) 199 | -c ("window -e -visible false UVAR_EditRatioPresetsWindow") 200 | closeButton; 201 | 202 | 203 | formLayout -e 204 | -af shelfSeparator "left" 0 205 | -af shelfSeparator "right" 0 206 | -ac shelfSeparator "bottom" 5 closeButton 207 | 208 | -af psetList "top" 5 209 | -af psetList "left" 5 210 | -af psetList "right" 5 211 | -ac psetList "bottom" 5 shelfSeparator 212 | 213 | -af deleteButton "left" 5 214 | -af deleteButton "bottom" 5 215 | -ap deleteButton "right" 3 50 216 | -an deleteButton "top" 217 | 218 | -ap closeButton "left" 2 50 219 | -af closeButton "bottom" 5 220 | -af closeButton "right" 5 221 | -an closeButton "top" 222 | fl; 223 | 224 | UVAutoRatioProUI_EditRatioPresetsPopulate($PresetList); 225 | } 226 | 227 | showWindow UVAR_EditRatioPresetsWindow; 228 | } 229 | 230 | global proc 231 | UVAutoRatioProUI_SaveRatioPresetWindow() 232 | { 233 | float $targetRatio = `optionVar -query "UVAutoRatioProUI_Ratio"`; 234 | 235 | string $text; 236 | string $result = `promptDialog 237 | -title (UVAR_uiRes("m_UVAutoRatioPro.kSaveRatioWindowTitle")) 238 | -message (UVAR_uiRes("m_UVAutoRatioPro.kSaveRatioWindowMessage")) 239 | -button "OK" -button "Cancel" 240 | -defaultButton "OK" -cancelButton "Cancel" 241 | -dismissString "Cancel"`; 242 | 243 | if ($result == "OK") 244 | { 245 | $text = `promptDialog -query -text` + "===" + $targetRatio; 246 | 247 | optionVar -stringValueAppend "UVAutoRatioProUI_RatioPresets" $text; 248 | } 249 | } 250 | 251 | global proc 252 | UVAutoRatioProUI_EditRatioPresetsPopulate(string $PresetList) 253 | { 254 | textScrollList -e -removeAll $PresetList; 255 | if (`optionVar -exists "UVAutoRatioProUI_RatioPresets"`) 256 | { 257 | string $presets[] = `optionVar -query "UVAutoRatioProUI_RatioPresets"`; 258 | for ($preset in $presets) 259 | { 260 | if (size($preset) > 0) 261 | { 262 | string $buffer[]; 263 | $numTokens = `tokenize $preset "===" $buffer`; 264 | if (size($buffer) == 2) 265 | { 266 | string $name = $buffer[0]; 267 | string $ratio = $buffer[1]; 268 | string $display = ($name + ": " + $ratio); 269 | 270 | textScrollList -e -append $display $PresetList; 271 | } 272 | } 273 | } 274 | } 275 | } 276 | 277 | global proc 278 | UVAutoRatioProUI_EditRatioPresetsDeleteSelected(string $PresetList) 279 | { 280 | if (`optionVar -exists "UVAutoRatioProUI_RatioPresets"`) 281 | { 282 | string $presets[] = `optionVar -query "UVAutoRatioProUI_RatioPresets"`; 283 | int $indices[] = `textScrollList -q -sii $PresetList`; 284 | for ($index in $indices) 285 | { 286 | $presets[$index-1] = ""; 287 | } 288 | optionVar -clearArray "UVAutoRatioProUI_RatioPresets"; 289 | for ($preset in $presets) 290 | { 291 | if (size($preset) > 0) 292 | optionVar -stringValueAppend "UVAutoRatioProUI_RatioPresets" $preset; 293 | } 294 | UVAutoRatioProUI_EditRatioPresetsPopulate($PresetList); 295 | } 296 | } -------------------------------------------------------------------------------- /module/scripts/UVAutoRatioPro_Inspector.mel: -------------------------------------------------------------------------------- 1 | // 2 | // UVAutoRatio Maya Plugin Source Code 3 | // Copyright (C) 2007-2014 RenderHeads Ltd. 4 | // 5 | // This source is available for distribution and/or modification 6 | // only under the terms of the MIT license. All rights reserved. 7 | // 8 | // The source is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // FITNESS FOR A PARTICULAR PURPOSE. See the MIT license 11 | // for more details. 12 | // 13 | global proc 14 | UVAutoRatioPro_GetSelectionStats(string $surfaceAreaText, string $uvAreaText, string $ratioText) 15 | { 16 | // Convert selection to a single string 17 | // string $selectionString = `UVAutoRatioProUI_GetSelectionAsString`; 18 | // float $areas[] = `GetSurfaceUVArea $selectionString`; 19 | 20 | string $command = "GetSurfaceUVArea "; 21 | int $useUVSet = `optionVar -query "UVAutoRatioProUI_UseUVSet"`; 22 | if ($useUVSet > 0) 23 | { 24 | string $UVSetName = `optionVar -query "UVAutoRatioProUI_UVSetName"`; 25 | if (size($UVSetName)>0) 26 | { 27 | $command += " -uvSetName " + $UVSetName; 28 | 29 | int $skip = `optionVar -query "UVAutoRatioProUI_Skip"`; 30 | if ($skip == 0) 31 | { 32 | $command += " -fallback"; 33 | } 34 | } 35 | } 36 | 37 | float $areas[] = eval($command); 38 | float $totalSurfaceArea = $areas[0]; 39 | float $totalUVArea = $areas[1]; 40 | float $ratio = $areas[2]; 41 | 42 | /*// Prevent divide-by-zero 43 | if ($totalUVArea != 0.0 && $totalSurfaceArea != 0.0) 44 | { 45 | $ratio = ($totalSurfaceArea / $totalUVArea); 46 | }*/ 47 | 48 | textField -e -text $totalSurfaceArea $surfaceAreaText; 49 | textField -e -text $totalUVArea $uvAreaText; 50 | textField -e -text $ratio $ratioText; 51 | } 52 | 53 | global proc 54 | UVAutoRatioProUI_CreateInspector(string $parentName, string $surfaceAreaText, string $uvAreaText, string $ratioText) 55 | { 56 | // Create the scriptjob 57 | string $command = "UVAutoRatioPro_GetSelectionStats " + $surfaceAreaText + " " + $uvAreaText + " " + $ratioText; 58 | int $jobNum = `scriptJob -parent $parentName -event SelectionChanged $command`; 59 | 60 | // Setup the checkbox to kill the job when it is unchecked 61 | //string $command = "scriptJob -kill " + $jobNum; 62 | //checkBox -e -offCommand $command $parentName; 63 | 64 | // Run the scriptjob once incase we already have a selection 65 | UVAutoRatioPro_GetSelectionStats($surfaceAreaText, $uvAreaText, $ratioText); 66 | } 67 | 68 | proc 69 | UVAutoRatioProUI_CreateInspectorFrame() 70 | { 71 | // 72 | // Frame: Inspector 73 | // 74 | frameLayout -label "Selection Inspector" 75 | -labelIndent 4 76 | -borderStyle "etchedIn" 77 | -collapsable false 78 | -collapse false 79 | -marginWidth 4 80 | -marginHeight 4; 81 | 82 | UVAutoRatioProUI_CreateInspectorControls(false); 83 | 84 | setParent ..; 85 | } 86 | 87 | global proc 88 | UVAutoRatioProUI_CreateInspectorControls(int $enabled) 89 | { 90 | $ParentLayout = `columnLayout`; 91 | 92 | columnLayout 93 | -columnAlign "center" 94 | -rowSpacing 4 -columnWidth 200 -adjustableColumn false; 95 | 96 | rowLayout -numberOfColumns 3 -columnWidth3 75 80 40 -columnAlign 1 "right"; 97 | text -align "left" -label "Surface Area:" -width 75; 98 | $TextSurfaceArea = `textField -text "None" -editable false -width 80 -font "boldLabelFont"`; 99 | text -align "left" -label (`eval("currentUnit -q -linear")` + " squared"); 100 | setParent..; 101 | rowLayout -numberOfColumns 3 -columnWidth3 75 80 40 -columnAlign 1 "right"; 102 | text -align "left" -label "Texture Area:" -width 75; 103 | $TextUVArea = `textField -text "None" -editable false -width 80 -font "boldLabelFont"`; 104 | text -align "left" -label "units squared"; 105 | setParent..; 106 | rowLayout -numberOfColumns 2 -columnWidth2 75 80 -columnAlign 1 "right"; 107 | text -align "left" -label "Ratio:" -font "boldLabelFont" -width 75; 108 | $TextRatio = `textField -text "0.0" -editable false -width 80 -font "boldLabelFont"`; 109 | setParent..; 110 | setParent ..; 111 | 112 | setParent ..; 113 | 114 | // checking = create the script and setup to kill the script with that scriptjob 115 | $command = "UVAutoRatioProUI_CreateInspector " + $ParentLayout + " " + $TextSurfaceArea + " " + $TextUVArea + " " + $TextRatio; 116 | eval($command); 117 | } 118 | 119 | global proc 120 | UVAutoRatioProUI_InspectorWindow() 121 | { 122 | if (`window -exists "RH_UVAutoRatioProInspectorWindow"`) 123 | { 124 | deleteUI -window "RH_UVAutoRatioProInspectorWindow"; 125 | return; 126 | } 127 | 128 | string $UVAutoRatio_Window = `window 129 | -title "Ratio Inspector" 130 | -widthHeight 235 115 131 | -maximizeButton false 132 | -minimizeButton true 133 | -resizeToFitChildren true 134 | -sizeable true RH_UVAutoRatioProInspectorWindow`; 135 | 136 | UVAutoRatioProUI_CreateInspectorControls(true); 137 | 138 | window -e -widthHeight 235 115 $UVAutoRatio_Window; 139 | window -e -resizeToFitChildren true $UVAutoRatio_Window; 140 | window -e -resizeToFitChildren false $UVAutoRatio_Window; 141 | 142 | showWindow $UVAutoRatio_Window; 143 | } -------------------------------------------------------------------------------- /module/scripts/UVAutoRatioPro_Utility.mel: -------------------------------------------------------------------------------- 1 | // 2 | // UVAutoRatio Maya Plugin Source Code 3 | // Copyright (C) 2007-2014 RenderHeads Ltd. 4 | // 5 | // This source is available for distribution and/or modification 6 | // only under the terms of the MIT license. All rights reserved. 7 | // 8 | // The source is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // FITNESS FOR A PARTICULAR PURPOSE. See the MIT license 11 | // for more details. 12 | // 13 | 14 | global proc string[] 15 | UVAutoRatioProUI_GetDAGNodeNamesFromSelection() 16 | { 17 | string $nodes[]; 18 | $nodes = `selectedNodes`; 19 | 20 | // Return dag objects only 21 | string $dagnodes[]; 22 | $dagnodes = `selectedNodes -dagObjects`; 23 | 24 | return $dagnodes; 25 | } 26 | 27 | global proc string 28 | UVAutoRatioProUI_GetSelectionAsString() 29 | { 30 | string $selectionList[] = `ls -selection`; 31 | if (size($selectionList)>0) 32 | { 33 | return stringArrayToString($selectionList, " "); 34 | } 35 | 36 | return ""; 37 | } 38 | 39 | global proc 40 | UVAutoRatioProUI_AddToShelf() 41 | { 42 | global string $gShelfTopLevel; 43 | if (`tabLayout -exists $gShelfTopLevel`) 44 | { 45 | string $currentShelf = `tabLayout -query -selectTab $gShelfTopLevel`; 46 | setParent $currentShelf; 47 | 48 | // Create the shelf button on the current shelf. 49 | shelfButton 50 | -label "Launch UVAutoRatioPro UI" 51 | -command "UVAutoRatioProUI" 52 | -annotation "Launch UVAutoRatioPro UI" 53 | -image1 "UVAutoRatioIcon.xpm" 54 | -highlightImage "UVAutoRatioIconOver.xpm" 55 | -style `shelfLayout -query -style $currentShelf` 56 | -width `shelfLayout -query -cellWidth $currentShelf` 57 | -height `shelfLayout -query -cellHeight $currentShelf`; 58 | } 59 | } 60 | --------------------------------------------------------------------------------