├── License.md ├── curveLength.mel ├── alphaSlider.mel ├── averageCurves.mel ├── massUVTransfer.mel ├── randomComps.mel ├── groupN.mel ├── pointDistance.mel ├── supportCurves.mel ├── displayTexture.mel ├── proxyUV.mel ├── offsetCV.mel ├── reSource.mel ├── massPointLights.mel ├── vertexLevels.mel ├── massRename.mel ├── massConstrain.mel ├── sceneCleanUp.mel ├── pivotMatcher.mel ├── vertexNoise.mel ├── distributeOnCurve.mel ├── massReplicate.mel ├── curveTube.mel ├── README.md ├── vertexTone.mel ├── batchProcessor.mel ├── ParentToParticles.mel └── uniToolBox.mel /License.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Edvard Toth 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 | -------------------------------------------------------------------------------- /curveLength.mel: -------------------------------------------------------------------------------- 1 | 2 | //================================= 3 | // curveLength v1.0 (08/2004) 4 | // by Edvard Toth 5 | // 6 | // The script is freeware. Non-commercial redistribution is permitted as long as this header remains included and unmodified. 7 | // Your feedback is always appreciated - if you find the script useful or if you have questions, comments, suggestions, requests, 8 | // bug-reports, if you created an updated version, to check for updates or to make a donation please contact me at: 9 | // 10 | // http://www.edvardtoth.com 11 | // 12 | //================================== 13 | // INSTALLATION: Copy the script into your Maya script-directory and start it with the curveLength; command. 14 | // 15 | // COMPATIBILITY NOTE: Tested with Maya 4.0 - 4.5 - 5.0 - 6.0 - 7.0 16 | // 17 | // DESCRIPTION: 18 | // This tiny but very straightforward utility measures the length of a curve without all the hassle that comes with 19 | // using Maya's implementation of the "Arc Length Tool". 20 | // 21 | 22 | global proc curveLength () 23 | { 24 | 25 | string $CL_curve[] = `ls -sl`; 26 | 27 | if (size($CL_curve[0]) == 0) 28 | { 29 | confirmDialog -t "Oops..." -m "Please select a valid curve." -b Continue; 30 | return; 31 | } 32 | 33 | string $CL_curvea[] = `ls -l $CL_curve[0]`; 34 | string $CL_curveb[] = `listRelatives -f -ni -s $CL_curvea[0]`; 35 | 36 | if (nodeType($CL_curveb[0])!="nurbsCurve") 37 | { 38 | confirmDialog -t "Oops..." -m "Please select a valid curve." -b Continue; 39 | return; 40 | } 41 | 42 | int $CL_spans = `getAttr ($CL_curve[0] + ".spans")`; 43 | 44 | string $CL_arclengthnode = `arcLengthDimension ($CL_curve[0] + ".u[" + $CL_spans + "]")`; 45 | string $CL_nodeparent[] = `listRelatives -p $CL_arclengthnode`; 46 | 47 | float $CL_curvelength = `getAttr ($CL_arclengthnode + ".al")`; 48 | 49 | delete $CL_nodeparent; 50 | 51 | confirmDialog -t $CL_curve[0] -m ("curvelength: " + $CL_curvelength) -b OK; 52 | } 53 | -------------------------------------------------------------------------------- /alphaSlider.mel: -------------------------------------------------------------------------------- 1 | 2 | //============================= 3 | // alphaSlider v1.0 (12/2002) 4 | // by Edvard Toth 5 | // 6 | // The script is freeware. Non-commercial redistribution is permitted as long as this header remains included and unmodified. 7 | // Your feedback is always appreciated - if you find the script useful or if you have questions, comments, suggestions, requests, 8 | // bug-reports or if you created an updated version, please contact me at: 9 | // 10 | // http://www.edvardtoth.com 11 | // 12 | //============================= 13 | // INSTALLATION: Copy the script into your Maya script-directory and start it with the alphaSlider; command. 14 | // 15 | // COMPATIBILITY NOTE: Tested only with Maya4.0 16 | // 17 | // DESCRIPTION: 18 | // A very simple script that creates a slider to interactively adjust vertex-alpha values. 19 | // The changes are instantly visible if the slider is dragged. 20 | // 21 | // The script automatically converts existing selections into Vertices, providing additional versatility. (You can use 22 | // it to modify alpha-values of the entire object if no components are selected, or to adjust alpha-values of a previously 23 | // selected contiguous edge-loop, etc.) 24 | // 25 | // Note: on some configurations it may be necessary to use the "Apply Color" Maya-function at least once prior to 26 | // using the script in order to force Maya to display the resulting alpha-values properly. 27 | // 28 | 29 | global proc alphaSlider() 30 | { 31 | 32 | if ( `window -exists alphaSlider` == true ) 33 | deleteUI alphaSlider; 34 | 35 | window -wh 250 50 -t "alphaSlider" -mxb 0 -mnb 1 -s 1 -rtf 1 -mb 0 -mbv 0 alphaSlider; 36 | 37 | columnLayout -w 250 -adjustableColumn false -columnWidth 250 -columnAlign "center" -rowSpacing 5 -cat "left" 3 AlphaColumn; 38 | 39 | floatSliderGrp -cw 1 40 -cw 2 50 -l "Alpha" -f 1 -v 1 -pre 4 -min 0 -max 1 -cc "doAlpha()" AlphaValue; 40 | 41 | showWindow alphaSlider; 42 | } 43 | 44 | 45 | global proc doAlpha() 46 | { 47 | PolySelectConvert 3; 48 | float $alpha = `floatSliderGrp -q -v AlphaValue`; 49 | polyColorPerVertex -a $alpha; 50 | } 51 | -------------------------------------------------------------------------------- /averageCurves.mel: -------------------------------------------------------------------------------- 1 | 2 | //============================== 3 | // averageCurves v1.0 (07/2003) 4 | // by Edvard Toth 5 | // 6 | // The script is freeware. Non-commercial redistribution is permitted as long as this header remains included and unmodified. 7 | // Your feedback is always appreciated - if you find the script useful or if you have questions, comments, suggestions, 8 | // requests, bug-reports, if you created an updated version, or to check for updates please contact us at: 9 | // 10 | // http://www.edvardtoth.com 11 | // 12 | //============================== 13 | // INSTALLATION: Copy the script into your Maya script-directory and start it with the averageCurves; command. 14 | // 15 | // COMPATIBILITY NOTE: Tested only with Maya4.0 16 | // 17 | // DESCRIPTION: 18 | // The script generates an averaged, intermediary curve between two selected curves. Particularly useful for terrain-modeling 19 | // or adding new cross-section curves for lofting surfaces. 20 | // 21 | 22 | global proc averageCurves() 23 | { 24 | 25 | string $AC_selA[] = `ls -sl`; 26 | string $AC_selB[] = `ls -sl`; 27 | 28 | if (`size $AC_selA` < 2) 29 | { 30 | confirmDialog -t "Oops..." -m "Please select at least 2 curves." -b Continue; 31 | return; 32 | } 33 | 34 | string $AC_curveCheckA[] = `listRelatives -f -ni -s $AC_selA[0]`; 35 | string $AC_curveCheckB[] = `listRelatives -f -ni -s $AC_selA[1]`; 36 | 37 | if (nodeType ($AC_curveCheckA[0]) != "nurbsCurve" || nodeType ($AC_curveCheckB[0]) != "nurbsCurve") 38 | { 39 | confirmDialog -t "Oops..." -m "Please select only curves." -b Continue; 40 | return; 41 | } 42 | 43 | duplicate $AC_selA[0]; 44 | 45 | int $AC_spans = `getAttr ($AC_selA[0] + ".spans")`; 46 | int $AC_spans = $AC_spans + 2; 47 | 48 | for ($i=0; $i<=$AC_spans; $i++) 49 | { 50 | string $AC_curveA = $AC_selA[0] + ".cv[" + $i + "]"; 51 | string $AC_curveB = $AC_selA[1] + ".cv[" + $i + "]"; 52 | 53 | select -r $AC_curveA ; 54 | float $AC_CVA[] = `pointPosition -w`; 55 | select -r $AC_curveB; 56 | float $AC_CVB[] = `pointPosition -w`; 57 | 58 | float $AC_newCVX = ($AC_CVA[0] + $AC_CVB[0]) / 2; 59 | float $AC_newCVY = ($AC_CVA[1] + $AC_CVB[1]) / 2; 60 | float $AC_newCVZ = ($AC_CVA[2] + $AC_CVB[2]) / 2; 61 | 62 | string $AC_selCV = $AC_selB[0] + ".cv[" + $i + "]"; 63 | select -r $AC_selCV; 64 | 65 | move -a -ws $AC_newCVX $AC_newCVY $AC_newCVZ; 66 | } 67 | select $AC_selB[0]; 68 | xform -cp; 69 | } -------------------------------------------------------------------------------- /massUVTransfer.mel: -------------------------------------------------------------------------------- 1 | //============================== 2 | // massUVTransfer v1.0 (06/2003) 3 | // by Edvard Toth 4 | // 5 | // The script is freeware. Non-commercial redistribution is permitted as long as this header remains included and unmodified. 6 | // Your feedback is always appreciated - if you find the script useful or if you have questions, comments, suggestions, 7 | // requests, bug-reports, if you created an updated version, or to check for updates please contact me at: 8 | // 9 | // http://www.edvardtoth.com 10 | // 11 | //============================== 12 | // INSTALLATION: Copy the script into your Maya script-directory and start it with the massUVTransfer; command. 13 | // 14 | // COMPATIBILITY NOTE: Tested only with Maya4.0 15 | // 16 | // DESCRIPTION: 17 | // The script transfers the UV coordinates of a specified object to any number of other objects of identical topology in one pass, 18 | // eliminating the need to select individual object-pairs for the transfer. 19 | // 20 | 21 | global proc massUVTransfer() 22 | 23 | { 24 | 25 | global string $MUVwin = "massUVTransfer"; 26 | global string $MUV_theobject; 27 | 28 | if (`window -ex $MUVwin`) 29 | { 30 | deleteUI $MUVwin; 31 | } 32 | 33 | window -t "massUVTransfer" -rtf 1 -w 100 -h 100 -s 1 -mnb 1 -mxb 0 $MUVwin; 34 | 35 | columnLayout -w 100 -columnWidth 100 -adjustableColumn false -cal "center" -rowSpacing 10 -cat "left" 10 MainColumn; 36 | 37 | button -w 100 -label "Specify Object" -command "MUV_specify()" -annotation "Specifies an object to transfer UVs from."; 38 | 39 | text -w 100 -al "center" -fn "smallBoldLabelFont" -l ($MUV_theobject) -annotation "This is the object currently specified to transfer UVs from."; 40 | 41 | button -w 100 -label "Transfer UVs" -command "MUV_transfer()" -annotation "Transfers the UVs of the specified object to any number of selected objects."; 42 | 43 | showWindow; 44 | } 45 | 46 | 47 | // *** SPECIFY ORIGIN-OBJECT 48 | 49 | global proc MUV_specify() 50 | 51 | { 52 | string $MUV_original[] = `ls -sl -tr`; 53 | 54 | if ( size ($MUV_original[0]) == 0 ) 55 | { 56 | confirmDialog -t "Oops..." -m "Specify an object to transfer UVs from." -b Continue; 57 | return; 58 | } 59 | 60 | global string $MUV_theobject; 61 | 62 | $MUV_theobject = $MUV_original[0]; 63 | 64 | massUVTransfer; 65 | } 66 | 67 | 68 | // *** TRANSFER UVs 69 | 70 | global proc MUV_transfer() 71 | 72 | { 73 | 74 | global string $MUV_theobject; 75 | string $MUV_selection[] = `ls -sl -tr`; 76 | 77 | int $MUV_objectnum; 78 | 79 | $MUV_objectnum = size ($MUV_selection); 80 | 81 | 82 | if ( size ($MUV_selection[0]) == 0 ) 83 | { 84 | confirmDialog -t "Oops..." -m "Select objects to transfer UVs to." -b Continue; 85 | return; 86 | } 87 | 88 | 89 | for ($i = 0; $i < $MUV_objectnum; $i++) 90 | { 91 | polyTransfer -vc 0 -uv 1 -v 0 -ao $MUV_theobject $MUV_selection[$i]; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /randomComps.mel: -------------------------------------------------------------------------------- 1 | 2 | //============================== 3 | // randomComps v1.0 (10/2003) 4 | // by Edvard Toth 5 | // 6 | // The script is freeware. Non-commercial redistribution is permitted as long as this header remains included and unmodified. 7 | // Your feedback is always appreciated - if you find the script useful or if you have questions, comments, suggestions, 8 | // requests, bug-reports, if you created an updated version, or to check for updates please contact us at: 9 | // 10 | // http://www.edvardtoth.com 11 | // 12 | //============================== 13 | // INSTALLATION: Copy the script into your Maya script-directory and start it with the randomComps; command. 14 | // 15 | // COMPATIBILITY NOTE: Tested only with Maya 4.0 - 4.5 - 5.0 - 6.0 16 | // 17 | // DESCRIPTION: 18 | // The script makes it possible to randomly select a certain percentage of components (vertices, faces, edges and UVs) 19 | // on selected objects. 20 | // The script's area of effect can also be limited/tuned even further by using it on an existing component-level selection. 21 | 22 | 23 | global proc randomComps() 24 | { 25 | 26 | global string $RC_window = "randomComps"; 27 | 28 | if (`window -ex $RC_window`) 29 | { 30 | deleteUI $RC_window; 31 | } 32 | 33 | window -t "randomComps V1.0" -w 260 -h 100 -rtf 1 -s 1 -mnb 1 -mxb 0 $RC_window; 34 | columnLayout -w 260 -adjustableColumn false -columnWidth 260 -columnAlign "center" -rowSpacing 4 -cat "both" 3 DistColumn; 35 | 36 | intSliderGrp -cw3 65 30 120 -l "Percentage" -ann "Defines what percentage of the available components is going to get randomly selected." -field true -min 0 -max 100 -v 1 -s 1 Percentage; 37 | 38 | radioButtonGrp -numberOfRadioButtons 4 -cw4 70 70 70 70 -annotation "The four component-types available for selection." -labelArray4 "Vertices" "Faces" "Edges" "UVs" -sl 1 Component; 39 | 40 | button -w 100 -label "Randomly Select Components" -command "doRandomComps()"; 41 | 42 | showWindow ; 43 | 44 | } 45 | 46 | global proc doRandomComps() 47 | { 48 | int $RC_component = `radioButtonGrp -q -sl Component`; 49 | 50 | switch ($RC_component) 51 | { 52 | case 1: 53 | PolySelectConvert 3; 54 | break; 55 | 56 | case 2: 57 | PolySelectConvert 1; 58 | break; 59 | 60 | case 3: 61 | PolySelectConvert 2; 62 | break; 63 | 64 | case 4: 65 | PolySelectConvert 4; 66 | break; 67 | } 68 | 69 | string $RC_comps[]; 70 | $RC_comps = `ls -sl -fl`; 71 | 72 | int $RC_size; 73 | $RC_size = `size ($RC_comps)`; 74 | 75 | int $RC_count = 0; 76 | 77 | int $RC_percentage = `intSliderGrp -q -v Percentage`; 78 | 79 | select -cl; 80 | 81 | for( $i=0; $i<($RC_size);$i++) 82 | { 83 | int $RC_random = rand (0, 100); 84 | 85 | if ($RC_random <= $RC_percentage) 86 | { 87 | select -add $RC_comps[$i]; 88 | $RC_count++; 89 | } 90 | } 91 | 92 | print ("\n=========="); 93 | print ("\nSelected "+$RC_count+" out of "+$RC_size+" potential components.\n\n"); 94 | 95 | } -------------------------------------------------------------------------------- /groupN.mel: -------------------------------------------------------------------------------- 1 | 2 | //============================== 3 | // groupN v1.0 (10/2003) 4 | // by Edvard Toth 5 | // 6 | // The script is freeware. Non-commercial redistribution is permitted as long as this header remains included and unmodified. 7 | // Your feedback is always appreciated - if you find the script useful or if you have questions, comments, suggestions, 8 | // requests, bug-reports, if you created an updated version, or to check for updates please contact us at: 9 | // 10 | // http://www.edvardtoth.com 11 | // 12 | //============================== 13 | // INSTALLATION: Copy the script into your Maya script-directory and start it with the groupN; command. 14 | // 15 | // COMPATIBILITY NOTE: Tested only with Maya4.0 16 | // 17 | // DESCRIPTION: 18 | // The script creates a small pop-up window that contains grouping-preferences and a text-field that makes it possible 19 | // to properly name new groups in advance: this removes the extra step of having to rename them after the grouping is performed. 20 | // Provides an useful alternative to the default "group" (CTRL+G) command. 21 | // (Please also note that the NumPad "Enter" key has the same function as the "Group" button.) 22 | // 23 | 24 | global proc groupN() 25 | { 26 | 27 | global string $GN_window = "groupN"; 28 | 29 | if (`window -ex $GN_window`) 30 | { 31 | deleteUI $GN_window; 32 | } 33 | 34 | window -t "groupN V1.0" -w 185 -h 100 -rtf 1 -s 1 -mnb 1 -mxb 0 $GN_window; 35 | columnLayout -w 185 -adjustableColumn false -columnWidth 185 -columnAlign "center" -rowSpacing 3 -cat "both" 5 MainColumn; 36 | 37 | textField -w 185 -tx "groupname" -ec "groupN_perform()" GroupName; 38 | 39 | radioButtonGrp -numberOfRadioButtons 2 -cw3 70 55 55 -annotation "" -label "Group Under" -labelArray2 "Parent" "World" -sl 1 GroupUnder; 40 | radioButtonGrp -numberOfRadioButtons 2 -cw3 70 55 55 -annotation "" -label "Group Pivot" -labelArray2 "Center" "Origin" -sl 2 GroupPivot; 41 | 42 | button -w 185 -label "Group" -command "groupN_perform()"; 43 | 44 | showWindow ; 45 | 46 | } 47 | 48 | global proc groupN_perform() 49 | { 50 | 51 | global string $GN_window; 52 | string $GN_groupname = `textField -q -tx GroupName`; 53 | int $GN_groupunder = `radioButtonGrp -q -sl GroupUnder`; 54 | int $GN_grouppivot = `radioButtonGrp -q -sl GroupPivot`; 55 | 56 | string $GN_objects[] = `ls -sl`; 57 | string $GN_parents[] = `listRelatives -p $GN_objects[0]`; 58 | 59 | switch ($GN_groupunder) 60 | { 61 | case 1: 62 | if ($GN_parents[0] != "") 63 | { 64 | group -p $GN_parents[0] -n $GN_groupname; 65 | } 66 | else 67 | { 68 | group -w -n $GN_groupname; 69 | } 70 | break; 71 | 72 | case 2: 73 | group -w -n $GN_groupname; 74 | break; 75 | } 76 | 77 | if ($GN_grouppivot == 2) 78 | { 79 | xform -os -piv 0 0 0; 80 | } 81 | 82 | deleteUI $GN_window; 83 | } -------------------------------------------------------------------------------- /pointDistance.mel: -------------------------------------------------------------------------------- 1 | 2 | //============================= 3 | // pointDistance v2.1 (03/2004) 4 | // by Edvard Toth 5 | // 6 | // The script is freeware. Non-commercial redistribution is permitted as long as this header remains included and unmodified. 7 | // Your feedback is always appreciated - if you find the script useful or if you have questions, comments, suggestions, requests, 8 | // bug-reports or if you created an updated version, please contact me at: 9 | // 10 | // http://www.edvardtoth.com 11 | // 12 | //============================= 13 | // INSTALLATION: 14 | // Copy the script into your Maya script-directory and start it with the pointDistance; command. 15 | // Please note that running the script repeatedly will function as an ON/OFF toggle. 16 | // 17 | // COMPATIBILITY NOTE: Tested with Maya 4.0 - 4.5 - 5.0 - 6.0 18 | // 19 | // DESCRIPTION: 20 | // The script creates a persistent and dynamically updated HeadsUpDisplay-overlay that displays the direct distance 21 | // between 2 selected points. 22 | // 23 | // Only point-like entities (vertices, CVs, curve-points, particles, lights, etc.) are evaluated, all other 24 | // types within the selection are ignored. 25 | // Distance-information is shown only if exactly 2 items are selected, otherwise the display resets to "0". 26 | // 27 | // Please note that even though the display dynamically updates with each new selection, it won't automatically 28 | // update if the distance between the two selected items changes (e.g. two vertices are scaled). 29 | // In this case the two items have to be re-selected to get the accurate new distance-reading. 30 | // 31 | // Hint: The script can be an extremely useful tool for modeling game-environments, where using certain specific 32 | // distances is usually a key factor required by gameplay. 33 | 34 | global proc pointDistance() 35 | 36 | { 37 | 38 | if (`headsUpDisplay -ex pointDistanceHUD`) 39 | { 40 | headsUpDisplay -rem pointDistanceHUD; 41 | return; 42 | } 43 | 44 | headsUpDisplay -section 2 45 | -block 0 46 | -blockSize "medium" 47 | -label "PointDistance" 48 | -labelFontSize "small" 49 | -dataFontSize "small" 50 | -command "pointDistanceCalc()" 51 | -event "SelectionChanged" 52 | -nodeChanges "attributeChange" 53 | pointDistanceHUD; 54 | } 55 | 56 | global proc float pointDistanceCalc() 57 | 58 | { 59 | float $PD_coord1[3]; 60 | float $PD_coord2[3]; 61 | float $PD_distance; 62 | 63 | string $PD_points[] = `filterExpand -ex true -sm 4 -sm 5 -sm 22 -sm 28 -sm 30 -sm 31 -sm 39 -sm 40 -sm 41 -sm 42 -sm 47`; 64 | 65 | if (size ($PD_points) !=2 ) 66 | { 67 | $PD_distance = 0; 68 | headsUpDisplay -e -l "" pointDistanceHUD; 69 | return $PD_distance; 70 | } 71 | else 72 | { 73 | $PD_coord1 = `pointPosition $PD_points[0]`; 74 | $PD_coord2 = `pointPosition $PD_points[1]`; 75 | 76 | $PD_distance = sqrt( (($PD_coord1[0] - $PD_coord2[0]) * ($PD_coord1[0] - $PD_coord2[0])) + (($PD_coord1[1] - $PD_coord2[1]) * ($PD_coord1[1] - $PD_coord2[1]))+(($PD_coord1[2] - $PD_coord2[2]) * ($PD_coord1[2] - $PD_coord2[2]))); 77 | 78 | headsUpDisplay -e -l "PointDistance:" pointDistanceHUD; 79 | return $PD_distance; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /supportCurves.mel: -------------------------------------------------------------------------------- 1 | //============================= 2 | // supportCurves v1.0 (12/2002) 3 | // by Edvard Toth 4 | // 5 | // The script is freeware. Non-commercial redistribution is permitted as long as this header remains included and unmodified. 6 | // Your feedback is always appreciated - if you find the script useful or if you have questions, comments, suggestions, requests, 7 | // bug-reports or if you created an updated version, please contact me at: 8 | // 9 | // http://www.edvardtoth.com 10 | // 11 | //============================= 12 | // INSTALLATION: Copy the script into your Maya script-directory and start it with the supportCurves; command. 13 | // 14 | // COMPATIBILITY NOTE: Tested only with Maya4.0 15 | // 16 | // DESCRIPTION: 17 | // Select a curve (preferably a non-planar one with vertices distributed on the Y-axis), enter an offset (e.g. 2) and 18 | // press the "Create Curve" button. The resulting new curve is offset by 2 units in XZ-space, but its CVs inherit their 19 | // Y-axis position from the CVs of the original curve. 20 | // 21 | // The script was created to provide a workaround to the problem of tilting/banking of slide/ribbon-like extruded surfaces. 22 | // Using the script to create offset support-curves it becomes very easy to generate (loft or birail) 23 | // surfaces that maintain horizontal planarity at every subdivision. 24 | // 25 | // NOTES: 26 | // Make sure the original curve has frozen transformations to avoid unexpected results. 27 | // The script deletes all construction history. 28 | // 29 | 30 | global proc supportCurves() 31 | { 32 | 33 | global string $SupWin = "supportCurves"; 34 | 35 | if (`window -ex $SupWin`) 36 | { 37 | deleteUI $SupWin; 38 | } 39 | 40 | window -t "supportCurves" -w 150 -h 50 -rtf 1 -s 1 -mnb 1 -mxb 0 $SupWin; 41 | columnLayout -w 150 -adjustableColumn false -columnWidth 200 -columnAlign "center" -rowSpacing 2 -cat "left" 5 CVColumn; 42 | floatFieldGrp -cw 1 50 -cat 1 "left" 30 -cw 2 100 -cat 2 "left" 20 -numberOfFields 1 -l "Offset" -pre 4 -v1 0 offset; 43 | 44 | separator -h 5 -st "none"; 45 | 46 | button -w 150 -label "Create Curve" -command "makeSupportCurve"; 47 | 48 | showWindow; 49 | } 50 | 51 | global proc makeSupportCurve() 52 | { 53 | 54 | global string $SupWin; 55 | global float $offset; 56 | 57 | global float $originalY[]; 58 | 59 | $offset = `floatFieldGrp -q -v1 ($SupWin+"|CVColumn|offset")`; 60 | 61 | string $curvename[] = `ls -sl`; 62 | 63 | int $i = 0; 64 | int $j = 0; 65 | 66 | if (objExists($curvename[0])&&(nodeType($curvename[0])=="transform")) 67 | { 68 | select $curvename[0]; 69 | 70 | int $degree = `getAttr ($curvename[0]+".degree")`; 71 | int $spans = `getAttr ($curvename[0]+".spans")`; 72 | 73 | int $CVs = ($degree + $spans); 74 | 75 | 76 | for ($i = 0; $i<$CVs; $i++) 77 | { 78 | select ($curvename[0]+".cv["+$i+"]"); 79 | 80 | float $xyzA[] = `getAttr ($curvename[0]+".cv["+$i+"]")`; 81 | 82 | $originalY[$i] = $xyzA[1]; 83 | } 84 | 85 | offsetCurve -ch on -rn false -cb 0 -st true -cl false -d $offset -tol 0.3 -sd 5 -ugn false $curvename[0]; 86 | 87 | DeleteAllHistory; 88 | 89 | string $newselect[] = `ls -sl`; 90 | 91 | select $newselect[0]; 92 | 93 | for ($j = 0; $j<$CVs; $j++) 94 | { 95 | select ($newselect[0]+"_1.cv["+$j+"]"); 96 | 97 | float $xyzB[] = `getAttr ($newselect[0]+"_1.cv["+$j+"]")`; 98 | 99 | move -ws $xyzB[0] $originalY[$j] $xyzB[2]; 100 | } 101 | 102 | return; 103 | } 104 | confirmDialog -m "Please select a curve." -b "Continue"; 105 | } 106 | -------------------------------------------------------------------------------- /displayTexture.mel: -------------------------------------------------------------------------------- 1 | //============================== 2 | // displayTexture v1.0 (01/2003) 3 | // by Edvard Toth 4 | // 5 | // The script is freeware. Non-commercial redistribution is permitted as long as this header remains included and unmodified. 6 | // Your feedback is always appreciated - if you find the script useful or if you have questions, comments, suggestions, 7 | // requests, bug-reports, if you created an updated version, or to check for updates please contact me at: 8 | // 9 | // http://www.edvardtoth.com 10 | // 11 | //============================== 12 | // INSTALLATION: Copy the script into your Maya script-directory and start it with the displayTexture; command. 13 | // 14 | // COMPATIBILITY NOTE: Tested with Maya 4.0 - 5.0 - 6.0 - 6.5 15 | // 16 | // DESCRIPTION: 17 | // The script makes it possible to view the bitmap-texture assigned to a selected polygonal face with a single click, 18 | // using any external image-viewer that accepts command-line input (fcheck, ACDSee, IrfanView etc.) 19 | // 20 | // The location of the image-viewer application has to be specified in the "DT_viewer" variable below. 21 | // 22 | // The way the script works is: 23 | // 1. Select a face (no multiple face-selection is allowed). 24 | // 2. Apply the script (HINT: For quick access it's recommended to create a shelf-button/menu-item for the script). 25 | // 3. The specified viewer displays the texture applied to the selected face. 26 | // 27 | // The script also shows the name and full path of the viewed texture-file in the "Command Feedback" line at the bottom 28 | // of the screen, and provides additional details about the texture in the "Script Editor" window. 29 | // 30 | 31 | global proc displayTexture () 32 | { 33 | 34 | // ===================================================== 35 | string $DT_viewer = "C:/Program Files/ACD Systems/ACDSee/ACDSee.exe"; 36 | // 37 | // SET THE LOCATION OF THE EXTERNAL VIEWER ABOVE 38 | // MAKE SURE TO USE "/" INSTEAD OF "\" 39 | // DO NOT USE SPACES 40 | //====================================================== 41 | 42 | 43 | string $DT_selection[] = `ls -flatten -sl`; 44 | 45 | if ( size ($DT_selection) < 1) 46 | { 47 | confirmDialog -t "Oops..." -m "No faces selected." -b Continue; 48 | return; 49 | } 50 | 51 | if ( size ($DT_selection) > 1) 52 | { 53 | confirmDialog -t "Oops..." -m "Multiple faces selected." -b Continue; 54 | return; 55 | } 56 | 57 | 58 | string $DT_array[] = `listSets -type 1 -o $DT_selection[0]`; 59 | 60 | if (size ($DT_array) < 1) 61 | { 62 | confirmDialog -t "Oops..." -m "No faces selected." -b Continue; 63 | return; 64 | } 65 | 66 | string $DT_preshader = `connectionInfo -sfd ($DT_array[0] + ".surfaceShader")`; 67 | string $DT_arraysplit[]; 68 | $numTokens = `tokenize $DT_preshader "." $DT_arraysplit`; 69 | 70 | $DT_shader = $DT_arraysplit[0]; 71 | 72 | 73 | string $DT_files[] = `listConnections -t file $DT_shader`; 74 | 75 | if ( size ($DT_files[0]) < 1) 76 | { 77 | confirmDialog -t "Oops..." -m "No texture to display." -b Continue; 78 | return; 79 | } 80 | 81 | string $DT_TheTexture = `getAttr ($DT_files[0] + ".fileTextureName")`; 82 | 83 | 84 | print ("\n" + "--------------------" + "\n"); 85 | print (" VIEWER LOCATION: " + $DT_viewer + "\n\n"); 86 | print (" SELECTED FACE: " + $DT_selection[0] + "\n"); 87 | print (" SHADING GROUP: " + $DT_array[0] + "\n"); 88 | print (" SHADER: " + $DT_shader + "\n"); 89 | print (" FILE: " + $DT_files[0] + "\n"); 90 | print (" TEXTURE: " + $DT_TheTexture + "\n\n"); 91 | 92 | 93 | // LAUNCH EXTERNAL VIEWER 94 | 95 | system ("start " + $DT_viewer + " " + $DT_TheTexture); 96 | } 97 | -------------------------------------------------------------------------------- /proxyUV.mel: -------------------------------------------------------------------------------- 1 | 2 | //============================== 3 | // proxyUV v1.0 (09/2003) 4 | // by Edvard Toth 5 | // 6 | // The script is freeware. Non-commercial redistribution is permitted as long as this header remains included and unmodified. 7 | // Your feedback is always appreciated - if you find the script useful or if you have questions, comments, suggestions, 8 | // requests, bug-reports, if you created an updated version, or to check for updates please contact us at: 9 | // 10 | // http://www.edvardtoth.com 11 | // 12 | //============================== 13 | // INSTALLATION: Copy the script into your Maya script-directory and start it with the proxyUV; command. 14 | // 15 | // COMPATIBILITY NOTE: Tested only with Maya4.0 16 | // 17 | // DESCRIPTION: 18 | // The script uses a "proxy" NURBS-surface to project UV-coordinates onto a polygonal mesh: it offers a simple and very 19 | // effective approach to texturing complex polygonal meshes, greatly reducing problems associated with overlapping and uneven, 20 | // severely stretched UVs. 21 | // 22 | // The basic steps of the workflow are: 23 | // 1. Create the polygonal mesh. 24 | // 2. Create a very simple NURBS-surface that roughly follows / covers the surface of the mesh (although a more accurate 25 | // NURBS-representation provides better results.) 26 | // 3. Select the mesh, then select the NURBS proxy. 27 | // 4. Run the script: the NURBS-surface will project its UVs onto the polygonal mesh, covering it with evenly laid out, almost 28 | // completely planar UVs. 29 | // 30 | // Note: even though several other scripts also utilize the "closestPointOnSurface" node to achieve similar results, 31 | // I belive this version is a simplified and highly streamlined implementation of this technique. 32 | // 33 | 34 | global proc proxyUV () 35 | 36 | { 37 | string $UV_sel[]; 38 | string $UV_mesh; 39 | string $UV_nurbs; 40 | 41 | int $UV_meshsize[]; 42 | int $UV_vertsize; 43 | 44 | float $UV_vertpos[]; 45 | float $UV_posU; 46 | float $UV_posV; 47 | 48 | $UV_sel = `ls -sl`; 49 | 50 | if (size ($UV_sel) < 2) 51 | { 52 | confirmDialog -t "Oops..." -m "Please select a polygon mesh and a NURBS surface." -b Continue; 53 | return; 54 | } 55 | 56 | $UV_mesh = $UV_sel[0]; 57 | $UV_nurbs = $UV_sel[1]; 58 | 59 | string $UV_meshcheck[] = `listRelatives -f -ni -s $UV_mesh`; 60 | string $UV_nurbscheck[] = `listRelatives -f -ni -s $UV_nurbs`; 61 | 62 | 63 | if (nodeType($UV_meshcheck[0]) != "mesh") 64 | { 65 | confirmDialog -t "Oops..." -m "The first selected item is not a polygon mesh." -b Continue; 66 | return; 67 | } 68 | 69 | if (nodeType($UV_nurbscheck[0]) != "nurbsSurface") 70 | { 71 | confirmDialog -t "Oops..." -m "The second selected item is not a NURBS surface." -b Continue; 72 | return; 73 | } 74 | waitCursor -state on; 75 | 76 | if (`objExists proxyUVnode`) 77 | { 78 | delete proxyUVnode; 79 | } 80 | 81 | createNode "closestPointOnSurface" -n "proxyUVnode"; 82 | 83 | connectAttr -f ($UV_nurbs + ".worldSpace[0]") proxyUVnode.inputSurface; 84 | 85 | $UV_meshsize = `polyEvaluate -v $UV_mesh`; 86 | $UV_vertsize = $UV_meshsize[0]; 87 | 88 | for ($i=0; $i < $UV_vertsize; $i++) 89 | { 90 | 91 | $UV_vertpos = `pointPosition -w ($UV_mesh + ".vtx[" + $i + "]")`; 92 | 93 | setAttr "proxyUVnode.inPositionX" $UV_vertpos[0]; 94 | setAttr "proxyUVnode.inPositionY" $UV_vertpos[1]; 95 | setAttr "proxyUVnode.inPositionZ" $UV_vertpos[2]; 96 | 97 | $UV_posU = `getAttr proxyUVnode.parameterU`; 98 | $UV_posV = `getAttr proxyUVnode.parameterV`; 99 | 100 | $UV_sel = `polyListComponentConversion -fv -tuv ($UV_mesh + ".vtx[" + $i + "]")`; 101 | 102 | for ($j=0; $j < size($UV_sel); $j++) 103 | { 104 | polyEditUV -r 0 -u $UV_posU -v $UV_posV $UV_sel[$j]; 105 | } 106 | } 107 | delete proxyUVnode; 108 | waitCursor -state off; 109 | } -------------------------------------------------------------------------------- /offsetCV.mel: -------------------------------------------------------------------------------- 1 | 2 | //============================================ 3 | // offsetCV v2.0 (12/2002) 4 | // by Edvard Toth 5 | // 6 | // The script is freeware. Non-commercial redistribution is permitted as long as this header remains included and unmodified. 7 | // Your feedback is always appreciated - if you find the script useful or if you have questions, comments, suggestions, requests 8 | // or bug-reports please contact me at: 9 | // 10 | // http://www.edvardtoth.com 11 | // 12 | // Thanks to Alex Carbonero for the original code-snippet. 13 | //============================================ 14 | // INSTALLATION: Copy the script into your Maya script-directory and start it with the offsetCV; command. 15 | // 16 | // COMPATIBILITY NOTE: Tested only with Maya4.0 17 | // 18 | // DESCRIPTION: 19 | // The script places/spreads the CVs of a curve evenly along the Y axis. 20 | // The placement of CVs can be determined by the OFFSET (the Y-distance between each CV) or the SPAN 21 | // (the total Y-distance between the first and last CV of the curve). 22 | // The starting Y-position for the first CV can also be specified. 23 | // 24 | // (All values handled as negative/positive floating values with 4-digit precision.) 25 | // 26 | // Hint: useful for creating accurate roller-coaster or slide-like surfaces. 27 | // 28 | 29 | global proc offsetCV() 30 | { 31 | 32 | global string $CVwin = "offsetCV"; 33 | global string $offsetType; 34 | 35 | if (`window -ex $CVwin`) 36 | { 37 | deleteUI $CVwin; 38 | } 39 | 40 | window -t "offsetCV" -w 300 -h 100 -rtf 1 -s 1 -mnb 1 -mxb 0 $CVwin; 41 | columnLayout -w 300 -adjustableColumn false -columnWidth 300 -columnAlign "center" -rowSpacing 2 -cat "both" 5 CVColumn; 42 | 43 | separator -h 5 -st "none"; 44 | 45 | $offsetType = `radioButtonGrp -numberOfRadioButtons 2 -l "" -labelArray2 "Based On Offset" "Based On Span" -cw 1 50 -cw 2 110 -sl 1` ; 46 | 47 | separator -h 5 -st "none"; 48 | 49 | floatFieldGrp -annotation "Starting Y-position for the first CV of the curve." -numberOfFields 1 -l "Starting Y-Position" -pre 4 -v1 0 Ypos; 50 | 51 | separator -h 5 -st "none"; 52 | 53 | floatFieldGrp -annotation "The distance between each CV of the curve." -numberOfFields 1 -l "Y-Axis Offset" -pre 4 -v1 0 offset; 54 | text -l "or"; 55 | floatFieldGrp -annotation "The total distance between the first and last CV of the curve." -numberOfFields 1 -l "Y-Axis Span" -pre 4 -v1 0 spread; 56 | 57 | separator -h 5 -st "none"; 58 | 59 | button -label "Apply" -command "offsetProcess"; 60 | 61 | showWindow ; 62 | } 63 | 64 | global proc offsetProcess() 65 | { 66 | 67 | global string $CVwin; 68 | global string $offsetType; 69 | 70 | global float $offsetA; 71 | global float $spread; 72 | 73 | global float $YposA; 74 | global float $YposB; 75 | 76 | $offsetA = `floatFieldGrp -q -v1 ($CVwin+"|CVColumn|offset")`; 77 | $spread = `floatFieldGrp -q -v1 ($CVwin+"|CVColumn|spread")`; 78 | 79 | $YposA = `floatFieldGrp -q -v1 ($CVwin+"|CVColumn|Ypos")`; 80 | $YposB = `floatFieldGrp -q -v1 ($CVwin+"|CVColumn|Ypos")`; 81 | 82 | int $Button = `radioButtonGrp -q -sl $offsetType`; 83 | 84 | 85 | string $curvename[] = `ls -sl`; 86 | 87 | int $i = 0; 88 | 89 | if (objExists($curvename[0])&&(nodeType($curvename[0])=="transform")) 90 | { 91 | select $curvename[0]; 92 | 93 | int $degree = `getAttr ($curvename[0]+".degree")`; 94 | int $spans = `getAttr ($curvename[0]+".spans")`; 95 | 96 | int $CVs = ($degree + $spans); 97 | float $offsetB = $spread / ($CVs-1); 98 | 99 | for ($i = 0; $i<$CVs; $i++) 100 | { 101 | select ($curvename[0]+".cv["+$i+"]"); 102 | 103 | float $xyz[] = `getAttr ($curvename[0]+".cv["+$i+"]")`; 104 | 105 | //MOVE BASED ON OFFSET 106 | if ($Button == 1) 107 | { 108 | move -a -ws $xyz[0] $YposA $xyz[2] ; 109 | $YposA = ($offsetA + $YposA); 110 | } 111 | 112 | //MOVE BASED ON SPAN 113 | if ($Button == 2) 114 | { 115 | move -a -ws $xyz[0] $YposB $xyz[2] ; 116 | $YposB = ($offsetB + $YposB); 117 | } 118 | } 119 | return; 120 | } 121 | confirmDialog -m "Please select a curve." -b "Continue"; 122 | } 123 | -------------------------------------------------------------------------------- /reSource.mel: -------------------------------------------------------------------------------- 1 | 2 | //================================= 3 | // reSource v1.0 (07/2004) 4 | // by Edvard Toth 5 | // 6 | // The script is freeware / donationware. Non-commercial redistribution is permitted as long as this header remains included and unmodified. 7 | // Your feedback is always appreciated - if you find the script useful or if you have questions, comments, suggestions, requests, 8 | // bug-reports, if you created an updated version, to check for updates or to make a donation please contact me at: 9 | // 10 | // http://www.edvardtoth.com 11 | // 12 | //================================== 13 | // INSTALLATION: Copy the script into your Maya script-directory and start it with the reSource; command. 14 | // 15 | // COMPATIBILITY NOTE: Tested with Maya 4.0 - 4.5 - 5.0 - 6.0 - 7.0 16 | // 17 | // DESCRIPTION: The script is a very handy script-development utility: it allows you to repeatedly source and execute a script-file with a click of a button, 18 | // greatly simplifying the testing-process. 19 | // Both the filename (including the full path) and the command-name (including any potential parameters) can be specified either manually or through a browser-window. 20 | // In addition, these settings are stored as persistent variables and don't have to be re-entered, even if Maya is restarted. 21 | // 22 | 23 | global proc reSource() 24 | { 25 | global string $RS_window = "reSource"; 26 | 27 | if (`window -ex $RS_window`) 28 | { 29 | deleteUI -window $RS_window; 30 | } 31 | 32 | window -wh 250 120 -rtf 1 -s 1 -mnb 1 -mxb 0 -title "reSource V1.0" $RS_window; 33 | 34 | string $RS_recentSource = `optionVar -q "RS_recentSource"`; 35 | string $RS_recentCommand = `optionVar -q "RS_recentCommand"`; 36 | 37 | if ($RS_recentSource == "0") 38 | { 39 | $RS_recentSource = ""; 40 | } 41 | 42 | if ($RS_recentCommand == "0") 43 | { 44 | $RS_recentCommand = ""; 45 | } 46 | 47 | string $RS_form = `formLayout -numberOfDivisions 100 RS_form`; 48 | 49 | columnLayout -w 250 -adjustableColumn 1 -rowSpacing 1 -cal "center" -co "both" 2 RS_column; 50 | 51 | separator -height 2 -st "none"; 52 | 53 | text -l "File to source:" -align "left"; 54 | 55 | textField -w 250 -text $RS_recentSource RS_sourceFile; 56 | 57 | text -l "Command to execute:" -align "left"; 58 | 59 | textField -w 250 -text $RS_recentCommand RS_sourceCommand; 60 | 61 | 62 | setParent..; 63 | 64 | string $RS_browseButton = `button -w 100 -h 20 -label "Browse" -command "RS_browse()"`; 65 | string $RS_sourceButton = `button -w 150 -h 20 -label "Source / Execute" -command "RS_execute()"`; 66 | 67 | 68 | formLayout -edit 69 | 70 | -attachForm RS_column "left" 2 71 | -attachForm RS_column "right" 2 72 | -attachForm RS_column "top" 2 73 | 74 | -attachControl $RS_browseButton "top" 2 RS_column 75 | -attachForm $RS_browseButton "left" 2 76 | 77 | -attachControl $RS_sourceButton "top" 2 RS_column 78 | -attachControl $RS_sourceButton "left" 2 $RS_browseButton 79 | -attachForm $RS_sourceButton "right" 2 80 | 81 | $RS_form; 82 | 83 | 84 | showWindow $RS_window; 85 | } 86 | 87 | 88 | global proc RS_execute() 89 | { 90 | string $RS_file = `textField -q -text RS_sourceFile`; 91 | string $RS_command = `textField -q -text RS_sourceCommand`; 92 | 93 | optionVar -sv "RS_recentSource" $RS_file; 94 | optionVar -sv "RS_recentCommand" $RS_command; 95 | 96 | if (size ($RS_file) == 0) 97 | { 98 | confirmDialog -t "Oops..." -m "No file is specified." -b Continue; 99 | return; 100 | } 101 | 102 | string $RS_source = ("source \""+$RS_file+"\""); 103 | 104 | eval ($RS_source); 105 | eval ($RS_command); 106 | } 107 | 108 | global proc RS_browse() 109 | { 110 | string $RS_tokens[]; 111 | string $RS_pickedFile = `fileDialog -dm "*.mel"`; 112 | string $RS_filenameonly = match ( "[^/\\]*$", $RS_pickedFile ); 113 | 114 | tokenize $RS_filenameonly "." $RS_tokens; 115 | 116 | string $RS_commandnameonly = $RS_tokens[0]; 117 | 118 | textField -e -text $RS_pickedFile RS_sourceFile; 119 | textField -e -text $RS_commandnameonly RS_sourceCommand; 120 | } 121 | 122 | 123 | -------------------------------------------------------------------------------- /massPointLights.mel: -------------------------------------------------------------------------------- 1 | 2 | //============================= 3 | // massPointLights v1.0 (01/2004) 4 | // by Edvard Toth 5 | // 6 | // The script is freeware. Non-commercial redistribution is permitted as long as this header remains included and unmodified. 7 | // Your feedback is always appreciated - if you find the script useful or if you have questions, comments, suggestions, requests, 8 | // bug-reports or if you created an updated version, please contact me at: 9 | // 10 | // http://www.edvardtoth.com 11 | //============================= 12 | // INSTALLATION: Copy the script into your Maya script-directory and start it with the massPointLights; command. 13 | // 14 | // COMPATIBILITY NOTE: Tested only with Maya4.0 15 | // 16 | // DESCRIPTION: 17 | // The script creates a customizable pointLight at the origins of any number of selected objects, and each pointLight is 18 | // generated with an adjustable intensity-curve to control its falloff (use the Attribute-Editor to modify falloff-settings 19 | // after the lights are created). 20 | // The script offers a workaround to the problem of losing the intensity-curve when duplicating/instancing lights of this type, 21 | // and provides a fast and effective method of placing a large number of these lights at specific positions within a 22 | // scene (especially when used together with locators to define the placement). 23 | 24 | 25 | global proc massPointLights () 26 | { 27 | 28 | if (`window -exists PL_win`) 29 | deleteUI PL_win; 30 | 31 | window -widthHeight 300 120 -rtf 1 -s 1 -mnb 1 -mxb 0 -t "massPointLights v1.0" PL_win; 32 | 33 | columnLayout -w 300 -columnWidth 300 -adjustableColumn false -cal "center" -rowSpacing 1 -cat "left" 1 PL_column; 34 | 35 | separator -w 200 -height 5 -style "none"; 36 | 37 | colorSliderGrp -cw 1 80 -cw 2 45 -cw 3 100 -l "Light Color" -rgb 1.0 1.0 1.0 PL_color; 38 | 39 | separator -w 200 -height 5 -style "none"; 40 | 41 | floatSliderGrp -field 1 -v 1 -cw 1 80 -cw 2 45 -cw 3 100 -ann "Defines the intensity of the lights at the source." -l "Start Intensity" -min 0 -max 50 -pre 2 PL_startint; 42 | floatSliderGrp -field 1 -v 0 -cw 1 80 -cw 2 45 -cw 3 100 -ann "Defines the intensity to which the lights ramp up/down to." -l "End Intensity" -min 0 -max 50 -pre 2 PL_endint; 43 | floatSliderGrp -field 1 -v 10 -cw 1 80 -cw 2 45 -cw 3 100 -ann "Sets the distance in which the start intensity changes into the end intensity." -l "Falloff Range" -min 0 -max 500 -pre 2 PL_range; 44 | 45 | separator -w 200 -height 5 -style "none"; 46 | 47 | checkBoxGrp -ncb 1 -v1 0 -cw2 135 30 -ann "Check to automatically delete the selected objects after assigning pointlights to their position." -l "Delete Selected Objects" PL_delete; 48 | 49 | separator -w 200 -height 5 -style "none"; 50 | 51 | button -l "Assign PointLights To Selected Objects" -w 300 -h 25 -c "PL_makeLights" PL_button; 52 | 53 | showWindow; 54 | } 55 | 56 | 57 | global proc PL_makeLights () 58 | { 59 | 60 | string $PL_selected[] = `ls -sl`; 61 | int $PL_selsize = `size ($PL_selected)`; 62 | 63 | if ($PL_selsize == 0) 64 | { 65 | confirmDialog -t "Oops..." -m "Please make a selection first." -b Continue; 66 | return; 67 | } 68 | 69 | float $PL_color[] = `colorSliderGrp -q -rgb PL_color`; 70 | float $PL_startint = `floatSliderGrp -q -value PL_startint`; 71 | float $PL_endint = `floatSliderGrp -q -value PL_endint`; 72 | float $PL_range = `floatSliderGrp -q -value PL_range`; 73 | 74 | string $PL_delete = `checkBoxGrp -q -v1 PL_delete`; 75 | 76 | string $PL_pointlights[]; 77 | 78 | select -cl; 79 | 80 | for ($i = 0; $i < $PL_selsize ; $i++ ) 81 | { 82 | 83 | float $PL_selpos[] = `xform -ws -q -t $PL_selected[$i]`; 84 | 85 | $PL_pointlights[$i] = `pointLight -rgb $PL_color[0] $PL_color[1] $PL_color[2]`; 86 | 87 | setKeyframe -at "intensity" -itt "linear" -ott "linear" -v $PL_startint -f 0; 88 | setKeyframe -at "intensity" -itt "linear" -ott "linear" -v $PL_endint -f $PL_range; 89 | 90 | $PL_lightinfo = `shadingNode -asTexture -asUtility lightInfo`; 91 | 92 | connectAttr -f ($PL_pointlights[$i] + ".worldMatrix[0]") ($PL_lightinfo + ".worldMatrix"); 93 | connectAttr -f ($PL_lightinfo + ".sampleDistance") ($PL_pointlights[$i] + "_intensity.input"); 94 | 95 | select -r $PL_pointlights[$i]; 96 | move -a -ws $PL_selpos[0] $PL_selpos[1] $PL_selpos[2]; 97 | } 98 | 99 | if ($PL_delete == 1) 100 | { 101 | select -r $PL_selected; 102 | delete $PL_selected; 103 | } 104 | select -r $PL_pointlights; 105 | } -------------------------------------------------------------------------------- /vertexLevels.mel: -------------------------------------------------------------------------------- 1 | 2 | //============================= 3 | // vertexLevels v1.0 (09/2003) 4 | // by Edvard Toth 5 | // based on "pickvertex" by Becky Chow (becky.chow@ea.com) 6 | // 7 | // The script is freeware. Non-commercial redistribution is permitted as long as this header remains included and unmodified. 8 | // Your feedback is always appreciated - if you find the script useful or if you have questions, comments, suggestions, requests, 9 | // bug-reports or if you created an updated version, please contact me at: 10 | // 11 | // http://www.edvardtoth.com 12 | // 13 | //============================= 14 | // INSTALLATION: Copy the script into your Maya script-directory and start it with the vertexLevels; command. 15 | // 16 | // COMPATIBILITY NOTE: Tested only with Maya4.0 17 | // 18 | // DESCRIPTION: 19 | // The script selects vertices based on their vertex colors, also taking an adjustable selection-threshold value into account. 20 | // The selection works on entire scenes, across multiple objects. The resulting set of selected vertices can be 21 | // adjusted using separate basic RGB-controls. 22 | // (Potential uses could include selecting and brightening up dark areas in a level without having to prelight the entire scene 23 | // and possibly lose manual vertex-color tweaks.) 24 | // 25 | 26 | global proc vertexLevels () 27 | { 28 | 29 | if (`window -exists VL_win`) 30 | deleteUI VL_win; 31 | 32 | window -widthHeight 280 120 -rtf 1 -s 1 -mnb 1 -mxb 0 -t "vertexLevels v1.0" VL_win; 33 | 34 | columnLayout -w 280 -columnWidth 280 -adjustableColumn false -cal "center" -rowSpacing 1 -cat "left" 1 VL_column; 35 | 36 | separator -w 200 -height 5 -style "none"; 37 | 38 | colorSliderGrp -cw 1 66 -cw 2 36 -cw 3 100 -l "Basecolor" -rgb 0.5 0.5 0.5 slider1; 39 | 40 | separator -w 200 -height 5 -style "none"; 41 | 42 | floatSliderGrp -field 1 -v 0 -cw 1 65 -cw 2 35 -cw 3 100 -ann "The selection threshold: leave it at 0 to select base-color values ONLY." -l "Threshold" -min 0 -max 1 -pre 2 VL_threshold; 43 | floatSliderGrp -field 1 -v 0 -cw 1 65 -cw 2 35 -cw 3 100 -label "R Modifier" -min -1 -max 1 -pre 2 VL_modred; 44 | floatSliderGrp -field 1 -v 0 -cw 1 65 -cw 2 35 -cw 3 100 -label "G Modifier" -min -1 -max 1 -pre 2 VL_modgreen; 45 | floatSliderGrp -field 1 -v 0 -cw 1 65 -cw 2 35 -cw 3 100 -label "B Modifier" -min -1 -max 1 -pre 2 VL_modblue; 46 | 47 | separator -w 200 -height 5 -style "none"; 48 | 49 | button -l "Select and Modify Vertex Colors" -w 260 -h 25 -c "VL_doit" button1; 50 | 51 | showWindow; 52 | } 53 | 54 | global proc VL_doit( ) 55 | { 56 | 57 | waitCursor -state on; 58 | 59 | PolySelectConvert 3; 60 | 61 | float $VL_modred = `floatSliderGrp -q -value VL_modred`; 62 | float $VL_modgreen = `floatSliderGrp -q -value VL_modgreen`; 63 | float $VL_modblue = `floatSliderGrp -q -value VL_modblue`; 64 | 65 | float $VL_threshold = `floatSliderGrp -q -value VL_threshold`; 66 | 67 | float $VL_rgb[2] ; 68 | float $VL_rgbbase[2] ; 69 | float $VL_rgbup[2]; 70 | float $VL_rgbdn[2]; 71 | 72 | string $VL_vertsA[]; 73 | int $VL_vertsize; 74 | int $i = 0; 75 | int $j = 0; 76 | 77 | $VL_verts = `ls -sl -fl`; 78 | $VL_vertsize = size ($VL_verts); 79 | 80 | if ($VL_vertsize == 0) 81 | { 82 | confirmDialog -t "Oops..." -m "Please make a selection first." -b Continue; 83 | waitCursor -state off; 84 | return; 85 | } 86 | 87 | $VL_rgbbase = `colorSliderGrp -q -rgb slider1`; 88 | 89 | $VL_rgbup[0] = (($VL_rgbbase[0]+$VL_threshold) >= 1) ? 1: ($VL_rgbbase[0]+$VL_threshold); 90 | $VL_rgbdn[0] = (($VL_rgbbase[0]-$VL_threshold) <= 0) ? 0: ($VL_rgbbase[0]-$VL_threshold); 91 | 92 | $VL_rgbup[1] = (($VL_rgbbase[1]+$VL_threshold) >= 1) ? 1: ($VL_rgbbase[1]+$VL_threshold); 93 | $VL_rgbdn[1] = (($VL_rgbbase[1]-$VL_threshold) <= 0) ? 0: ($VL_rgbbase[1]-$VL_threshold); 94 | 95 | $VL_rgbup[2] = (($VL_rgbbase[2]+$VL_threshold) >= 1) ? 1: ($VL_rgbbase[2]+$VL_threshold); 96 | $VL_rgbdn[2] = (($VL_rgbbase[2]-$VL_threshold) <= 0) ? 0: ($VL_rgbbase[2]-$VL_threshold); 97 | 98 | for ($i = 0; $i < $VL_vertsize ; $i++ ) 99 | { 100 | select -r $VL_verts[$i]; 101 | $VL_rgb = `polyColorPerVertex -q -rgb`; 102 | 103 | if (($VL_rgb[0]>=$VL_rgbdn[0]) && ($VL_rgb[0]<=$VL_rgbup[0]) && ($VL_rgb[1]>=$VL_rgbdn[1]) && ($VL_rgb[1]<=$VL_rgbup[1]) && ($VL_rgb[2]>=$VL_rgbdn[2]) && ($VL_rgb[2]<=$VL_rgbup[2])) 104 | { 105 | $VL_vertsA[$j] = $VL_verts[$i]; 106 | $j++ ; 107 | } 108 | } 109 | 110 | int $VL_vertsAsize = size ($VL_vertsA); 111 | 112 | select -cl; 113 | 114 | for ($i = 0; $i < $VL_vertsAsize ; $i++ ) 115 | { 116 | select -r $VL_vertsA[$i]; 117 | polyColorPerVertex -rel -r $VL_modred -g $VL_modgreen -b $VL_modblue; 118 | } 119 | 120 | select -cl; 121 | select $VL_vertsA; 122 | 123 | waitCursor -state off; 124 | } -------------------------------------------------------------------------------- /massRename.mel: -------------------------------------------------------------------------------- 1 | 2 | //============================== 3 | // massRename v1.2 (02/2003) 4 | // by Edvard Toth 5 | // 6 | // The script is freeware. Non-commercial redistribution is permitted as long as this header remains included and unmodified. 7 | // Your feedback is always appreciated - if you find the script useful or if you have questions, comments, suggestions, 8 | // requests, bug-reports, if you created an updated version, or to check for updates please contact me at: 9 | // 10 | // http://www.edvardtoth.com 11 | // 12 | //============================== 13 | // INSTALLATION: Copy the script into your Maya script-directory and start it with the massRename; command. 14 | // 15 | // COMPATIBILITY NOTE: Tested only with Maya4.0 16 | // 17 | // DESCRIPTION: 18 | // The script provides a very easy-to-use solution for renaming a large number of nodes. 19 | // 20 | // It features an adjustable starting-number and padding for the renamed nodes, two options for a divider character that 21 | // separates the new node-name from the node-number and a reorder-function that sorts the nodes into ascending 22 | // order. 23 | // It also works even when nodes from multiple levels of the node-hierarchy are selected at the same time. 24 | // 25 | 26 | global proc massRename() 27 | { 28 | 29 | global string $MRN_Win = "massRename"; 30 | 31 | if (`window -ex $MRN_Win`) 32 | { 33 | deleteUI $MRN_Win; 34 | } 35 | 36 | window -t "massRename v1.2" -rtf 1 -s 1 -mnb 1 -mxb 0 $MRN_Win; 37 | 38 | string $MRN_form = `formLayout -numberOfDivisions 100 MRN_Form`; 39 | 40 | 41 | rowLayout -w 260 -h 70 -nc 2 -cw2 100 160 -ct2 "both" "both" MRN_Row; 42 | 43 | columnLayout -adjustableColumn false -columnWidth 100 -h 70 -columnAlign "left" -rowSpacing 4 -cat "left" 5 MRN_Column1; 44 | 45 | separator -h 1 -st "none"; 46 | text -l "New name" -ann "This string is what the nodes are going to be renamed to."; 47 | text -l "Starting number" -ann "The number of the first renamed node (e.g. `newname_19`)."; 48 | text -l "Padding" -ann "The amount of digits the node-number is going to be formatted to (e.g. a value of 4 will generate `newname_0019` instead of `newname_19`)."; 49 | text -l "Divider character" -ann "The character that separates the name of the node from the number of the node."; 50 | 51 | setParent MRN_Row; 52 | 53 | columnLayout -adjustableColumn false -columnWidth 160 -h 70 -columnAlign "left" -rowSpacing 2 -cat "left" 5 MRN_Column2; 54 | 55 | textField -w 150 -tx "newname" MRN_newname; 56 | intField -w 30 -v 0 -min 0 -max 999 -s 1 MRN_startcount; 57 | intField -w 30 -v 0 -min 0 -max 8 -s 1 MRN_padding; 58 | radioButtonGrp -nrb 2 -cw2 80 70 -ct2 "left" "left" -cl2 "left" "left" -labelArray2 "underscore" "nothing" -sl 1 MRN_divider; 59 | 60 | 61 | setParent MRN_Row; 62 | 63 | setParent ..; 64 | 65 | string $MRN_renamebutton = `button -w 150 -h 25 -label "Rename Nodes" -ann "Performs the renaming operation." -command "MRN_doTheRename"`; 66 | string $MRN_reorderbutton = `button -w 95 -h 25 -label "Reorder Nodes" -ann "Sorts the selected nodes into ascending order and moves them to the bottom of the node-list." -command "MRN_doTheReorder"`; 67 | 68 | formLayout -edit 69 | 70 | -attachForm MRN_Row "top" 5 71 | -attachForm MRN_Row "left" 5 72 | -attachForm MRN_Row "right" 5 73 | 74 | -attachControl $MRN_renamebutton "top" 5 MRN_Row 75 | -attachForm $MRN_renamebutton "left" 10 76 | 77 | -attachControl $MRN_reorderbutton "top" 5 MRN_Row 78 | -attachControl $MRN_reorderbutton "left" 5 $MRN_renamebutton 79 | 80 | $MRN_form; 81 | setParent ..; 82 | 83 | 84 | showWindow; 85 | } 86 | 87 | global proc MRN_doTheRename () 88 | { 89 | string $MRN_newname = `textField -q -tx MRN_newname`; 90 | int $MRN_startcount = `intField -q -v MRN_startcount`; 91 | int $MRN_padding = `intField -q -v MRN_padding`; 92 | 93 | int $MRN_divstatus = `radioButtonGrp -q -sl MRN_divider`; 94 | string $MRN_divider; 95 | 96 | switch ($MRN_divstatus) 97 | { 98 | case 1: 99 | string $MRN_newname = $MRN_newname + "_"; 100 | break; 101 | 102 | case 2: 103 | string $MRN_newname = $MRN_newname + ""; 104 | break; 105 | } 106 | 107 | string $MRN_selected[]; 108 | clear $MRN_selected; 109 | 110 | string $MRN_selected[] = `ls -sl`; 111 | int $MRN_count = size ($MRN_selected); 112 | 113 | 114 | if ( $MRN_count == 0) 115 | { 116 | confirmDialog -t "Oops..." -m "Please select nodes to rename." -b Continue; 117 | return; 118 | } 119 | 120 | for($i = 0 ; $i<$MRN_count ; $i++) 121 | { 122 | 123 | string $MRN_selected[] = `ls -sl`; // REFRESH NODE-LIST 124 | 125 | string $MRN_name = ""; 126 | 127 | int $MRN_number = $i + $MRN_startcount; 128 | 129 | string $MRN_padstring = ""; 130 | 131 | for ($j=1; $j < $MRN_padding; ++$j) 132 | { 133 | if ($MRN_number < pow(10, $j) ) 134 | $MRN_padstring += "0"; 135 | } 136 | 137 | $MRN_name = ($MRN_newname + $MRN_padstring + $MRN_number); 138 | 139 | 140 | rename $MRN_selected[$i] $MRN_name; 141 | } 142 | 143 | clear $MRN_selected; 144 | } 145 | 146 | 147 | global proc MRN_doTheReorder () 148 | { 149 | 150 | string $MRN_nodes[] = `ls -sl`; 151 | 152 | for($node in $MRN_nodes) 153 | { 154 | reorder -b $node; 155 | } 156 | sort $MRN_nodes; 157 | 158 | } -------------------------------------------------------------------------------- /massConstrain.mel: -------------------------------------------------------------------------------- 1 | //============================= 2 | // massConstrain v1.1 (12/2002) 3 | // by Edvard Toth 4 | // 5 | // The script is freeware. Non-commercial redistribution is permitted as long as this header remains included and unmodified. 6 | // Your feedback is always appreciated - if you find the script useful or if you have questions, comments, suggestions, requests, 7 | // bug-reports or if you created an updated version, please contact me at: 8 | // 9 | // http://www.edvardtoth.com 10 | // 11 | //============================= 12 | // INSTALLATION: Copy the script into your Maya script-directory and start it with the massConstrain; command. 13 | // 14 | // COMPATIBILITY NOTE: Tested only with Maya4.0 15 | // 16 | // DESCRIPTION: 17 | // The script constrains any number of selected objects to the normals and/or geometry of a specified target surface. 18 | // 19 | // First select an object and use the "Specify Target Surface" button to make it the target surface. 20 | // Then select any number of objects, set the mode(s) of constraint (Normals/Geometry), the "Aim Vector" attribute that defines which 21 | // axis of the objects is going to be constrained to the normals of the target surface, and press the "Constrain Objects" button. 22 | // 23 | // The script can leave behind the normal/geometry constraint nodes on each individual selected object so they can be manually 24 | // adjusted while they maintain their alignment (they "stick") to the normals and/or geometry of the target surface. 25 | // 26 | // (Hint: useful for tasks such as properly orienting / arranging a large number of leaves to tree-branches. 27 | // Works well together with the ParentToParticles and massReplicate scripts.) 28 | 29 | 30 | global proc massConstrain() 31 | 32 | { 33 | global string $MC_conswin = "massConstrain"; 34 | 35 | if (`window -ex $MC_conswin`) 36 | { 37 | deleteUI $MC_conswin; 38 | } 39 | 40 | global string $MC_TargetName; 41 | 42 | 43 | window -t "massConstrain" -widthHeight 200 80 -rtf 1 -s 1 -mnb 1 -mxb 0 $MC_conswin; 44 | 45 | columnLayout -w 200 -columnWidth 200 -adjustableColumn false -cal "center" -rowSpacing 5 -cat "both" 10 ConsColumn; 46 | 47 | 48 | button -w 100 -label "Specify Target Surface" -command "MC_setTarget()" -annotation "Select an object and use this button to specify it as the target surface."; 49 | 50 | text -w 200 -al "center" -fn "smallBoldLabelFont" -l ($MC_TargetName) -annotation "This is the currently selected target object/surface."; 51 | 52 | separator -height 5 -st "none"; 53 | 54 | checkBoxGrp -ncb 1 -v1 1 -cw2 160 30 -label "Constrain To Surface Normals" NormalConstrain; 55 | checkBoxGrp -ncb 1 -v1 1 -cw2 160 30 -label "Constrain To Surface Geometry" GeoConstrain; 56 | checkBoxGrp -ncb 1 -v1 1 -cw2 160 30 -label "Delete Constrain Nodes" DeleteConstrain; 57 | 58 | separator -height 5 -st "none"; 59 | 60 | radioButtonGrp -numberOfRadioButtons 3 -cw4 80 30 30 30 -annotation "Defines which axis of the objects is going to be constrained to the normals of the target surface." -label "Aim Vector" -labelArray3 "x" "y" "z" -sl 2 AimVector; 61 | 62 | separator -height 5 -st "none"; 63 | 64 | button -w 100 -label "Constrain Objects" -command "doConstrain()"; 65 | 66 | showWindow; 67 | } 68 | 69 | global proc MC_setTarget() 70 | 71 | { 72 | string $MC_TheTarget[] = `ls -sl`; 73 | 74 | if ( size ($MC_TheTarget[0]) == 0 ) 75 | { 76 | confirmDialog -t "Oops..." -m "Select the target surface." -b "Continue"; 77 | return; 78 | } 79 | 80 | global string $MC_TargetName; 81 | $MC_TargetName = $MC_TheTarget[0]; 82 | 83 | print "Now select any number of objects to constrain to the target surface."; 84 | 85 | massConstrain; 86 | } 87 | 88 | 89 | global proc doConstrain() 90 | 91 | { 92 | global string $MC_TargetName; 93 | 94 | string $MC_AimButton = `radioButtonGrp -q -sl AimVector`; 95 | string $MC_NormalButton = `checkBoxGrp -q -v1 NormalConstrain`; 96 | string $MC_GeoButton = `checkBoxGrp -q -v1 GeoConstrain`; 97 | string $MC_DeleteButton = `checkBoxGrp -q -v1 DeleteConstrain`; 98 | 99 | string $MC_Selection[] = `ls -sl`; 100 | 101 | if ( size ($MC_TargetName) == 0 ) 102 | { 103 | confirmDialog -t "Oops..." -m "Please specify a target-surface first." -b "Continue"; 104 | return; 105 | } 106 | 107 | if ( size ($MC_Selection[0]) == 0 ) 108 | { 109 | confirmDialog -t "Oops..." -m "Select objects to constrain to the target surface." -b "Continue"; 110 | return; 111 | } 112 | 113 | int $i; 114 | int $MC_objectnum; 115 | $MC_objectnum = size ($MC_Selection); 116 | 117 | for ($i = 0; $i < $MC_objectnum; $i++) 118 | { 119 | 120 | if ($MC_NormalButton == 1) 121 | { 122 | if ($MC_AimButton == 1) 123 | { 124 | normalConstraint -aimVector 1 0 0 -wut "vector" $MC_TargetName $MC_Selection[$i]; 125 | } 126 | 127 | if ($MC_AimButton == 2) 128 | { 129 | normalConstraint -aimVector 0 1 0 -wut "vector" $MC_TargetName $MC_Selection[$i]; 130 | } 131 | 132 | if ($MC_AimButton == 3) 133 | { 134 | normalConstraint -aimVector 0 0 1 -wut "vector" $MC_TargetName $MC_Selection[$i]; 135 | } 136 | } 137 | if ($MC_GeoButton == 1) 138 | { 139 | geometryConstraint $MC_TargetName $MC_Selection[$i]; 140 | } 141 | 142 | if ($MC_DeleteButton == 1) 143 | { 144 | delete -cn; 145 | } 146 | 147 | } 148 | return; 149 | } 150 | -------------------------------------------------------------------------------- /sceneCleanUp.mel: -------------------------------------------------------------------------------- 1 | 2 | //============================== 3 | // sceneCleanUp v1.1 (07/2003) 4 | // by Alex Carbonero & Edvard Toth 5 | // 6 | // The script is freeware. Non-commercial redistribution is permitted as long as this header remains included and unmodified. 7 | // Your feedback is always appreciated - if you find the script useful or if you have questions, comments, suggestions, 8 | // requests, bug-reports, if you created an updated version, or to check for updates please contact us at: 9 | // 10 | // http://www.edvardtoth.com 11 | // http://www.alexcarbonero.com 12 | // 13 | //============================== 14 | // INSTALLATION: Copy the script into your Maya script-directory and start it with the sceneCleanUp; command. 15 | // 16 | // COMPATIBILITY NOTE: Tested only with Maya4.0 17 | // 18 | // DESCRIPTION: 19 | // The script deletes numerous leftover nodes (links, brush-nodes, script-nodes, unconnected intermediate objects etc.) 20 | // normally unaffected by deleting history or optimizing the scene. It also eliminates excess "stacked" vertex-color data. 21 | // While individual results will vary depending on application, in many cases the script can drastically reduce the 22 | // size of large scenes. 23 | // 24 | 25 | global proc sceneCleanUp() 26 | { 27 | waitCursor -state on; 28 | 29 | string $SC_listOS[] = `listConnections -s 1 -p 1 defaultObjectSet.message`; 30 | string $SC_listLS[] = `listConnections -s 1 -p 1 defaultLightSet.message`; 31 | string $SC_listMes[] = `listConnections -s 1 -p 1 initialShadingGroup.message`; 32 | string $SC_scriptnodes[] = `ls -type script`; 33 | 34 | string $SC_discnodes[]; 35 | string $SC_delscripts[]; 36 | 37 | int $i=0; 38 | 39 | 40 | // DISCONNECT AND DELETE NODES 41 | 42 | 43 | for ( $SC_os in $SC_listOS ) 44 | 45 | { 46 | disconnectAttr defaultObjectSet.message $SC_os; 47 | $SC_discnodes[$i] = $SC_os; 48 | $i++; 49 | } 50 | 51 | for ( $SC_ls in $SC_listLS ) 52 | 53 | { 54 | disconnectAttr defaultLightSet.message $SC_ls; 55 | $SC_discnodes[$i] = $SC_ls; 56 | $i++; 57 | } 58 | 59 | 60 | for ( $SC_mes in $SC_listMes ) 61 | 62 | { 63 | disconnectAttr initialShadingGroup.message $SC_mes; 64 | $SC_discnodes[$i] = $SC_mes; 65 | $i++; 66 | } 67 | 68 | int $i=0; 69 | 70 | for ($SC_script in $SC_scriptnodes) 71 | { 72 | if ((`getAttr ($SC_script+".scriptType")`) == 0); 73 | { 74 | delete $SC_script; 75 | $SC_delscripts[$i] = $SC_script; 76 | } 77 | } 78 | 79 | 80 | // DELETE INTERMEDIATE OBJECTS 81 | 82 | string $SC_selection[] = `ls -l -type "mesh" -type "nurbsSurface"` ; 83 | string $SC_intobjs[]; 84 | int $i=0; 85 | for ($SC_obj in $SC_selection) 86 | { 87 | string $SC_listcons[] = `listConnections -sh 1 $SC_obj`; 88 | 89 | if ( `size $SC_listcons` <= 1 ) 90 | { 91 | if ( `size $SC_listcons` == 0 && (`getAttr ($SC_obj + ".intermediateObject")` ) == 1) 92 | { 93 | delete $SC_obj; 94 | $SC_intobjs[$i] = $SC_obj; 95 | $i++; 96 | } 97 | else 98 | { 99 | 100 | if ( `nodeType $SC_listcons[0] `== "displayLayer" ) 101 | { 102 | delete $SC_obj; 103 | $SC_intobjs[$i] = $SC_obj; 104 | $i++; 105 | } 106 | } 107 | } 108 | } 109 | 110 | // DELETE BRUSH-NODES 111 | 112 | string $SC_brushnodes[] = `ls -typ brush`; 113 | 114 | for ($SC_brush in $SC_brushnodes) 115 | { 116 | delete $SC_brush; 117 | } 118 | 119 | // OPTIMIZE VERTEX-COLOR INFORMATION 120 | 121 | string $SC_meshes[] = `ls -type mesh`; 122 | select $SC_meshes; 123 | 124 | PolySelectConvert 3; 125 | 126 | string $SC_vertices[] = `ls -sl -fl`; 127 | int $SC_vertexnum = `size($SC_vertices)`; 128 | 129 | 130 | if (`size $SC_meshes` != 0) 131 | { 132 | 133 | float $SC_red[]; 134 | 135 | $SC_red = `polyColorPerVertex -q -r`; 136 | 137 | float $SC_green[]; 138 | 139 | $SC_green = `polyColorPerVertex -q -g`; 140 | 141 | float $SC_blue[]; 142 | 143 | $SC_blue = `polyColorPerVertex -q -b`; 144 | 145 | float $SC_alpha[]; 146 | 147 | $SC_alpha = `polyColorPerVertex -q -a`; 148 | 149 | 150 | polyColorPerVertex -r 0 -g 0 -b 0 -a 1; 151 | 152 | delete -all -constructionHistory; 153 | 154 | select -cl; 155 | 156 | for ($i = 0; $i < ($SC_vertexnum); $i++) 157 | { 158 | select $SC_vertices[$i]; 159 | polyColorPerVertex -r $SC_red[$i] -g $SC_green[$i] -b $SC_blue[$i] -a $SC_alpha[$i]; 160 | } 161 | } 162 | 163 | select -cl; 164 | 165 | 166 | // PRINT RESULTS 167 | 168 | print "\n\nB E G I N C L E A N U P"; 169 | print "\n====================\n"; 170 | print ("Disconnected attributes of "+ (`size $SC_discnodes`) + " nodes.\n"); 171 | print $SC_discnodes; 172 | 173 | print "====================\n"; 174 | print ("Deleted "+ (`size $SC_delscripts`) + " script-nodes.\n"); 175 | print $SC_delscripts; 176 | 177 | print "====================\n"; 178 | print ("Deleted "+ (`size $SC_intobjs`) + " intermediate objects.\n"); 179 | print $SC_intobjs; 180 | 181 | print "====================\n"; 182 | print ("Deleted "+ (`size $SC_brushnodes`) + " brush-nodes.\n"); 183 | 184 | print "====================\n"; 185 | 186 | 187 | if (`size $SC_meshes` == 0) 188 | { 189 | print ("Skipped vertex-color optimization - no relevant geometry found.\n"); 190 | } 191 | 192 | else 193 | { 194 | print ("Optimized the vertex-color data of " + ($SC_vertexnum) + " vertices.\n"); 195 | } 196 | 197 | print "====================\n"; 198 | print "E N D C L E A N U P\n\n"; 199 | 200 | waitCursor -state off; 201 | 202 | confirmDialog -t "sceneCleanUp" -m "Cleanup process complete. Please refer to the script-editor for details." -b Continue; 203 | } 204 | -------------------------------------------------------------------------------- /pivotMatcher.mel: -------------------------------------------------------------------------------- 1 | //============================== 2 | // pivotMatcher v1.0 (12/2003) 3 | // by Edvard Toth 4 | // 5 | // The script is freeware. Non-commercial redistribution is permitted as long as this header remains included and unmodified. 6 | // Your feedback is always appreciated - if you find the script useful or if you have questions, comments, suggestions, 7 | // requests, bug-reports, if you created an updated version, or to check for updates please contact me at: 8 | // 9 | // http://www.edvardtoth.com 10 | // 11 | //============================== 12 | // INSTALLATION: Copy the script into your Maya script-directory and start it with the pivotMatcher; command. 13 | // 14 | // COMPATIBILITY NOTE: Tested only with Maya4.0 15 | // 16 | // DESCRIPTION: 17 | // 18 | // The script makes it possible to match the pivots of any number of selected objects to either the pivots of the same 19 | // number of target objects, or to the pivot of one selected target object. 20 | // The selection-order is taken into account during the process. 21 | // 22 | 23 | global proc pivotMatcher () 24 | { 25 | 26 | global string $PMwin = "pivotMatcher"; 27 | global string $PM_selection; 28 | 29 | if (`window -ex $PMwin`) 30 | { 31 | deleteUI $PMwin; 32 | } 33 | 34 | window -t "pivotMatcher V1.0" -rtf 1 -w 200 -h 100 -s 1 -mnb 1 -mxb 0 $PMwin; 35 | 36 | string $PM_form = `formLayout -numberOfDivisions 100 PM_Form`; 37 | 38 | 39 | columnLayout -w 200 -columnWidth 200 -adjustableColumn false -cal "center" -rowSpacing 5 -cat "left" 1 MainColumn; 40 | 41 | button -w 200 -label "Select Original Objects" -command "PM_select()" -annotation "Select object to move the pivots of."; 42 | 43 | text -w 200 -al "center" -fn "smallBoldLabelFont" -l ($PM_selection) -annotation "Status line."; 44 | 45 | setParent ..; 46 | 47 | string $PM_xbutton = `button -w 100 -label "X to X" -command "PM_match()" -annotation "Match X number of original pivots to X number of selected target pivots."`; 48 | string $PM_obutton = `button -w 100 -label "X to 1" -command "PM_matchone()" -annotation "Match X number of original pivots to the first selected target pivot."`; 49 | 50 | formLayout -edit 51 | 52 | -attachForm MainColumn "top" 1 53 | -attachForm MainColumn "left" 1 54 | -attachForm MainColumn "right" 1 55 | 56 | -attachControl $PM_xbutton "top" 1 MainColumn 57 | -attachForm $PM_xbutton "left" 1 58 | 59 | -attachControl $PM_obutton "top" 1 MainColumn 60 | -attachControl $PM_obutton "left" 1 $PM_xbutton 61 | 62 | $PM_form; 63 | setParent ..; 64 | 65 | showWindow; 66 | } 67 | 68 | 69 | global proc PM_select() 70 | 71 | { 72 | global string $PM_origin[]; 73 | $PM_origin = `ls -sl`; 74 | 75 | global int $PM_osize; 76 | $PM_osize = `size $PM_origin`; 77 | 78 | if ( $PM_osize == 0 ) 79 | { 80 | confirmDialog -t "Oops..." -m "Please make a selection." -b Continue; 81 | return; 82 | } 83 | 84 | global string $PM_selection; 85 | 86 | $PM_selection = ($PM_osize + " original objects selected."); 87 | print "Now please select either an equal number of target objects, or one single target object.\n"; 88 | 89 | pivotMatcher; 90 | } 91 | 92 | global proc PM_match() 93 | { 94 | 95 | global string $PM_origin[]; 96 | global int $PM_osize; 97 | global string $PM_selection; 98 | 99 | string $PM_target[] = `ls -sl`; 100 | 101 | int $PM_tsize = `size $PM_target`; 102 | 103 | 104 | if ( $PM_osize == 0 ) 105 | { 106 | confirmDialog -t "Oops..." -m "Please select original objects first." -b Continue; 107 | return; 108 | } 109 | 110 | if ( $PM_tsize != $PM_osize ) 111 | { 112 | confirmDialog -ma center -t "Oops..." -m ("Number of original and target objects don't match.\n\n You have " + $PM_tsize + " target objects selected.") -b Continue; 113 | return; 114 | } 115 | 116 | for ($i = 0; $i < $PM_tsize; $i++) 117 | { 118 | 119 | float $PM_tpivot[] = `xform -q -ws -rp $PM_target[$i]`; 120 | xform -ws -piv $PM_tpivot[0] $PM_tpivot[1] $PM_tpivot[2] $PM_origin[$i]; 121 | 122 | print ("\nMatched the pivot of " + $PM_origin[$i] + " to the pivot of " + $PM_target[$i] +"."); 123 | } 124 | 125 | clear $PM_origin; 126 | clear $PM_target; 127 | $PM_osize = 0; 128 | $PM_tsize = 0; 129 | 130 | $PM_selection = "Matching completed."; 131 | print "\n"; 132 | 133 | pivotMatcher; 134 | } 135 | 136 | 137 | global proc PM_matchone() 138 | { 139 | 140 | global string $PM_origin[]; 141 | global int $PM_osize; 142 | global string $PM_selection; 143 | 144 | string $PM_target[] = `ls -sl`; 145 | 146 | int $PM_tsize = `size $PM_target`; 147 | 148 | if ( $PM_osize == 0 ) 149 | { 150 | confirmDialog -t "Oops..." -m "Please select original objects first." -b Continue; 151 | return; 152 | } 153 | 154 | if ( $PM_tsize == 0 ) 155 | { 156 | confirmDialog -ma center -t "Oops..." -m "Please select at least one target object." -b Continue; 157 | return; 158 | } 159 | 160 | float $PM_tpivot[] = `xform -q -ws -rp $PM_target[0]`; 161 | 162 | for ($i = 0; $i < $PM_osize; $i++) 163 | { 164 | 165 | xform -ws -piv $PM_tpivot[0] $PM_tpivot[1] $PM_tpivot[2] $PM_origin[$i]; 166 | 167 | print ("\nMatched the pivot of " + $PM_origin[$i] + " to the pivot of " + $PM_target[0] +"."); 168 | } 169 | 170 | clear $PM_origin; 171 | clear $PM_target; 172 | $PM_osize = 0; 173 | $PM_tsize = 0; 174 | 175 | $PM_selection = "Matching completed."; 176 | print "\n"; 177 | 178 | pivotMatcher; 179 | } 180 | -------------------------------------------------------------------------------- /vertexNoise.mel: -------------------------------------------------------------------------------- 1 | 2 | //============================= 3 | // vertexNoise v1.0 (12/2002) 4 | // by Edvard Toth 5 | // 6 | // The script is freeware. Non-commercial redistribution is permitted as long as this header remains included and unmodified. 7 | // Your feedback is always appreciated - if you find the script useful or if you have questions, comments, suggestions, requests, 8 | // bug-reports or if you created an updated version, please contact me at: 9 | // 10 | // http://www.edvardtoth.com 11 | // 12 | //============================= 13 | // INSTALLATION: Copy the script into your Maya script-directory and start it with the vertexNoise; command. 14 | // 15 | // COMPATIBILITY NOTE: Tested only with Maya4.0 16 | // 17 | // DESCRIPTION: 18 | // The script applies fully adjustable random noise to selected vertices, even across multiple objects. 19 | // The type of the noise can either be uniform (based on the vertex-normals) or directional (based on the XYZ-axes). 20 | // 21 | // A smoothing function with adjustable intensity is also available for fine-tuning purposes. 22 | // 23 | // Since the original vertex-selection is retained, the noise/smooth operations can be applied repeatedly until 24 | // the desired result is reached. 25 | // 26 | // Note: the smoothing-operation doesn't work if vertices on multiple objects are selected. 27 | 28 | 29 | global proc vertexNoise() 30 | { 31 | 32 | global string $VertexWin = "vertexNoise"; 33 | global string $noiseType; 34 | 35 | if (`window -ex $VertexWin`) 36 | { 37 | deleteUI $VertexWin; 38 | } 39 | 40 | window -t "vertexNoise v1.0" -rtf 1 -s 1 -mnb 1 -mxb 0 $VertexWin; 41 | 42 | string $form = `formLayout -numberOfDivisions 100 VertexForm`; 43 | 44 | columnLayout -adjustableColumn false -columnWidth 300 -columnAlign "left" -rowSpacing 2 -cat "both" 2 VertexColumn; 45 | 46 | separator -h 5 -st "none"; 47 | 48 | $noiseType = `radioButtonGrp -numberOfRadioButtons 2 -l "" -labelArray2 "Normal-Based Noise" "Axis-Based Noise" -cw 1 20 -cw 2 130 -sl 1` ; 49 | 50 | separator -h 5 -st "none"; 51 | 52 | floatSliderGrp -field 1 -cw 1 70 -cw 2 40 -l "Normal Min" -pre 1 -min -10 -max 10 -v 0 umin; 53 | floatSliderGrp -field 1 -cw 1 70 -cw 2 40 -l "Normal Max" -pre 1 -min -10 -max 10 -v 0 umax; 54 | 55 | separator -h 8 -st "none"; 56 | 57 | floatSliderGrp -field 1 -cw 1 70 -cw 2 40 -l "X-Axis Min" -pre 1 -min -10 -max 10 -v 0 xmin; 58 | floatSliderGrp -field 1 -cw 1 70 -cw 2 40 -l "X-Axis Max" -pre 1 -min -10 -max 10 -v 0 xmax; 59 | 60 | floatSliderGrp -field 1 -cw 1 70 -cw 2 40 -l "Y-Axis Min" -pre 1 -min -10 -max 10 -v 0 ymin; 61 | floatSliderGrp -field 1 -cw 1 70 -cw 2 40 -l "Y-Axis Max" -pre 1 -min -10 -max 10 -v 0 ymax; 62 | 63 | floatSliderGrp -field 1 -cw 1 70 -cw 2 40 -l "Z-Axis Min" -pre 1 -min -10 -max 10 -v 0 zmin; 64 | floatSliderGrp -field 1 -cw 1 70 -cw 2 40 -l "Z-Axis Max" -pre 1 -min -10 -max 10 -v 0 zmax; 65 | 66 | separator -h 8 -st "none"; 67 | 68 | intSliderGrp -field 1 -cw 1 70 -cw 2 40 -l "Smoothing" -min 1 -max 50 -v 1 smoothit; 69 | 70 | setParent..; 71 | 72 | string $noisebutton = `button -w 150 -h 25 -label "Apply Noise" -command "doVertexNoise"`; 73 | string $smoothbutton = `button -w 50 -h 25 -label "Smooth" -command "smoothVertexNoise"`; 74 | string $resetbutton = `button -w 50 -h 25 -label "Reset" -command "vertexNoise"`; 75 | 76 | formLayout -edit 77 | 78 | -attachControl $noisebutton "top" 5 VertexColumn 79 | -attachForm $noisebutton "left" 10 80 | 81 | -attachControl $smoothbutton "top" 5 VertexColumn 82 | -attachControl $smoothbutton "left" 5 $noisebutton 83 | 84 | -attachControl $resetbutton "top" 5 VertexColumn 85 | -attachControl $resetbutton "left" 5 $smoothbutton 86 | 87 | $form; 88 | setParent ..; 89 | 90 | 91 | showWindow; 92 | } 93 | 94 | 95 | global proc doVertexNoise() 96 | { 97 | 98 | global string $VertexWin; 99 | global string $noiseType; 100 | 101 | int $Button = `radioButtonGrp -q -sl $noiseType`; 102 | 103 | float $umin= `floatSliderGrp -q -v ($VertexWin+"|VertexForm|VertexColumn|umin")`; 104 | float $umax= `floatSliderGrp -q -v ($VertexWin+"|VertexForm|VertexColumn|umax")`; 105 | 106 | float $Xmin= `floatSliderGrp -q -v ($VertexWin+"|VertexForm|VertexColumn|xmin")`; 107 | float $Xmax= `floatSliderGrp -q -v ($VertexWin+"|VertexForm|VertexColumn|xmax")`; 108 | float $Ymin= `floatSliderGrp -q -v ($VertexWin+"|VertexForm|VertexColumn|ymin")`; 109 | float $Ymax= `floatSliderGrp -q -v ($VertexWin+"|VertexForm|VertexColumn|ymax")`; 110 | float $Zmin= `floatSliderGrp -q -v ($VertexWin+"|VertexForm|VertexColumn|zmin")`; 111 | float $Zmax= `floatSliderGrp -q -v ($VertexWin+"|VertexForm|VertexColumn|zmax")`; 112 | 113 | string $AllSelection[] = `ls -hl`; 114 | string $selectedObjects[] = `ls -hl -o`; 115 | 116 | sets -n NoiseVerts; 117 | 118 | for ($selection in $AllSelection) 119 | 120 | { 121 | select $selection; 122 | 123 | int $VertexCount[] = `polyEvaluate -v`; 124 | 125 | for ( $i = 0; $i < $VertexCount[0]; $i++) 126 | { 127 | $PartOfSet = `sets -im NoiseVerts ($selection + ".vtx[" + $i + "]")`; 128 | 129 | if ( $PartOfSet == 1 ) 130 | 131 | { 132 | 133 | // GENERATE NORMAL-BASED NOISE 134 | 135 | if ($Button == 1) 136 | { 137 | float $noiseUni = `rand $umin $umax`; 138 | 139 | select ($selection + ".vtx[" + $i + "]"); 140 | 141 | moveVertexAlongDirection -n $noiseUni; 142 | } 143 | 144 | // GENERATE AXIS-BASED NOISE 145 | 146 | if ($Button == 2) 147 | { 148 | float $noiseX = `rand $Xmin $Xmax`; 149 | float $noiseY = `rand $Ymin $Ymax`; 150 | float $noiseZ = `rand $Zmin $Zmax`; 151 | 152 | select ($selection + ".vtx[" + $i + "]"); 153 | 154 | move -r $noiseX $noiseY $noiseZ; 155 | } 156 | } 157 | } 158 | } 159 | // RESTORE SELECTION 160 | 161 | select $selectedObjects; 162 | hilite $selectedObjects; 163 | changeSelectMode -component; 164 | select -add NoiseVerts; 165 | delete NoiseVerts; 166 | } 167 | 168 | global proc smoothVertexNoise() 169 | { 170 | 171 | global string $VertexWin; 172 | 173 | int $smoothit= `intSliderGrp -q -v ($VertexWin+"|VertexForm|VertexColumn|smoothit")`; 174 | polyAverageVertex -i $smoothit -ch 0; 175 | } -------------------------------------------------------------------------------- /distributeOnCurve.mel: -------------------------------------------------------------------------------- 1 | 2 | //================================= 3 | // distributeOnCurve v2.0 (03/2004) 4 | // by Edvard Toth 5 | // 6 | // The script is freeware. Non-commercial redistribution is permitted as long as this header remains included and unmodified. 7 | // Your feedback is always appreciated - if you find the script useful or if you have questions, comments, suggestions, requests 8 | // or bug-reports please contact me at: 9 | // 10 | // http://www.edvardtoth.com 11 | // 12 | //================================= 13 | // INSTALLATION: Copy the script into your Maya script-directory and start it with the distributeOnCurve; command. 14 | // 15 | // COMPATIBILITY NOTE: Tested with Maya 4.0 - 4.5 - 5.0 - 6.0 - 7.0 16 | // 17 | // DESCRIPTION: 18 | // The script makes it possible to create a number of duplicates/instances of a specified object, and distribute them 19 | // along a curve. 20 | // The distribution can also be randomized, and the "Orient Objects To Curve Flow" function can constrain the orientation 21 | // of the selected objects to follow the tangency of the curve using the axis specified in the "Aim Vector" setting. 22 | // (For example, this could be useful for properly orienting wooden planks in a winding walkway.) 23 | // 24 | // Checking the "Auto-Delete Constrain Nodes" checkbox or using the "Clean Residual Constrain Nodes" button will remove 25 | // all leftover nodes created by the constrain-operation. 26 | 27 | 28 | global proc distributeOnCurve() 29 | { 30 | 31 | global string $DC_TheObj[]; 32 | 33 | 34 | global string $DC_window = "distributeOnCurve"; 35 | 36 | if (`window -ex $DC_window`) 37 | { 38 | deleteUI $DC_window; 39 | } 40 | 41 | window -t "distributeOnCurve V2.0" -w 300 -h 100 -rtf 1 -s 1 -mnb 1 -mxb 0 $DC_window; 42 | 43 | string $DC_form = `formLayout -numberOfDivisions 100 DC_form`; 44 | 45 | columnLayout -w 300 -adjustableColumn false -columnWidth 300 -columnAlign "center" -rowSpacing 4 -cat "both" 5 DistColumn; 46 | 47 | intSliderGrp -cw3 85 40 100 -l "Object Amount" -ann "Defines the number of objects to be created." -field true -min 2 -max 2000 -v 10 -s 1 ObjNum; 48 | floatSliderGrp -cw3 95 30 100 -l "Random Min" -ann "Defines the randomness of object-distribution along the curve." -field true -min 0 -max 2 -v 1 -pre 1 rndA; 49 | floatSliderGrp -cw3 95 30 100 -l "Random Max" -ann "Defines the randomness of object-distribution along the curve." -field true -min 0 -max 2 -v 1 -pre 1 rndB; 50 | 51 | separator -h 2 -st "none" ; 52 | 53 | radioButtonGrp -numberOfRadioButtons 2 -label "Mode" -labelArray2 "Duplicate" "Instance" -cw 1 85 -cw 2 85 -sl 1 DupType; 54 | 55 | checkBoxGrp -ncb 1 -v1 1 -cw2 200 30 -label "Orient Objects To Curve Flow" -ann "Aligns and constrains the orientation of the selected objects to follow the tangency of the curve." TangentConstrain; 56 | checkBoxGrp -ncb 1 -v1 0 -cw2 200 30 -label "Auto-Delete Constrain Nodes" -ann "Automatically deletes the residual nodes created by the constrain-operation." DeleteConstrain; 57 | 58 | 59 | radioButtonGrp -numberOfRadioButtons 3 -cw4 130 30 30 30 -annotation "Defines which axis of the objects is going to be constrained to the tangency of the target curve." -label "Aim Vector" -labelArray3 "x" "y" "z" -sl 2 AimVector; 60 | 61 | separator -h 2 -st "none" ; 62 | 63 | setParent..; 64 | 65 | string $DC_objectbutton = `button -w 100 -h 20 -label "Specify Object" -command "DCspecifyObj" -ann "Specifies the object to be duplicated and distributed on a curve."`; 66 | string $DC_applybutton = `button -w 190 -h 20 -label "Distribute Objects On Curve" -command "doDistributeOnCurve()" -ann "Distributes the specified object on the selected curve."`; 67 | string $DC_cleanbutton = `button -w 292 -h 20 -label "Clean Residual Constrain Nodes" -command "delete -all -cn;" -ann "Deletes the residual nodes created by the constrain-operation."`; 68 | 69 | 70 | formLayout -edit 71 | 72 | -attachControl $DC_objectbutton "top" 3 DistColumn 73 | -attachForm $DC_objectbutton "left" 2 74 | 75 | -attachControl $DC_applybutton "top" 3 DistColumn 76 | -attachControl $DC_applybutton "left" 2 $DC_objectbutton 77 | 78 | -attachControl $DC_cleanbutton "top" 3 $DC_objectbutton 79 | -attachForm $DC_cleanbutton "left" 2 80 | 81 | $DC_form; 82 | 83 | showWindow $DC_window; 84 | 85 | } 86 | 87 | 88 | global proc doDistributeOnCurve() 89 | { 90 | 91 | global string $DC_TheObj[]; 92 | 93 | if ( size ($DC_TheObj [0]) == 0 ) 94 | { 95 | confirmDialog -t "Oops..." -m "Please specify an object first." -b Continue; 96 | return; 97 | } 98 | 99 | int $DC_objnum = `intSliderGrp -q -v ObjNum`; 100 | float $DC_rndmin = `floatSliderGrp -q -v rndA`; 101 | float $DC_rndmax = `floatSliderGrp -q -v rndB`; 102 | 103 | int $DC_DupType = `radioButtonGrp -q -sl DupType`; 104 | 105 | string $DC_TangentButton = `checkBoxGrp -q -v1 TangentConstrain`; 106 | string $DC_DeleteButton = `checkBoxGrp -q -v1 DeleteConstrain`; 107 | int $DC_AimButton = `radioButtonGrp -q -sl AimVector`; 108 | 109 | string $DC_NewItem[]; 110 | global string $DC_Result[]; 111 | 112 | 113 | string $DC_curve[] = `ls -sl`; 114 | 115 | if (size($DC_curve[0]) == 0) 116 | { 117 | confirmDialog -t "Oops..." -m "Please select a valid curve." -b Continue; 118 | return; 119 | } 120 | 121 | string $DC_curvea[]=`ls -l $DC_curve[0]`; 122 | string $DC_curveb[]=`listRelatives -f -ni -s $DC_curvea[0]`; 123 | 124 | if (nodeType($DC_curveb[0])!="nurbsCurve") 125 | { 126 | confirmDialog -t "Oops..." -m "Please select a valid curve." -b Continue; 127 | return; 128 | } 129 | 130 | for($i=0;$i<($DC_objnum);$i++) 131 | { 132 | 133 | select $DC_TheObj[0]; 134 | 135 | 136 | // DUPLICATION 137 | if ($DC_DupType == 1) 138 | { 139 | $DC_NewItem= `duplicate -rr`; 140 | $DC_Result[$i]= $DC_NewItem[0]; 141 | } 142 | 143 | if ($DC_DupType == 2) 144 | { 145 | $DC_NewItem= `instance`; 146 | $DC_Result[$i]= $DC_NewItem[0]; 147 | } 148 | 149 | float $DC_rnd=rand ($DC_rndmin,$DC_rndmax); 150 | float $DC_div=((float)$i)/($DC_objnum-1); 151 | float $DC_finalcalc=$DC_div*$DC_rnd; 152 | 153 | 154 | float $DC_point[]=`pointOnCurve -pr $DC_finalcalc -top 1 -p $DC_curve[0]`; 155 | xform -a -ws -t $DC_point[0] $DC_point[1] $DC_point[2] $DC_Result[$i]; 156 | 157 | 158 | if ($DC_TangentButton == 1) 159 | { 160 | switch ($DC_AimButton) 161 | { 162 | case 0: 163 | tangentConstraint -aim 1.0 0.0 0.0 -wut "scene" $DC_curve[0] $DC_Result[$i]; 164 | break; 165 | 166 | case 1: 167 | tangentConstraint -aim 0.0 1.0 0.0 -wut "scene" $DC_curve[0] $DC_Result[$i]; 168 | break; 169 | 170 | case 2: 171 | tangentConstraint -aim 0.0 0.0 1.0 -wut "scene" $DC_curve[0] $DC_Result[$i]; 172 | break; 173 | } 174 | 175 | if ($DC_DeleteButton == 1) 176 | { 177 | delete -cn; 178 | } 179 | } 180 | } 181 | select -cl; 182 | } 183 | 184 | 185 | // *** SPECIFY OBJECT 186 | 187 | global proc DCspecifyObj() 188 | 189 | { 190 | string $DC_selection[] = `ls - sl`; 191 | 192 | if ( size ($DC_selection [0]) == 0 ) 193 | { 194 | confirmDialog -t "Oops..." -m "Please specify an object." -b Continue; 195 | return; 196 | } 197 | 198 | global string $DC_TheObj[]; 199 | $DC_TheObj = $DC_selection; 200 | 201 | confirmDialog -t "DONE" -m ("The specified object is: " + $DC_TheObj[0]) -b "Continue"; 202 | } 203 | -------------------------------------------------------------------------------- /massReplicate.mel: -------------------------------------------------------------------------------- 1 | 2 | //============================= 3 | // massReplicate v2.1 (01/2003) 4 | // by Edvard Toth 5 | // 6 | // The script is freeware. Non-commercial redistribution is permitted as long as this header remains included and unmodified. 7 | // Your feedback is always appreciated - if you find the script useful or if you have questions, comments, suggestions, requests, 8 | // bug-reports, if you created an updated version, or to check for updates please contact me at: 9 | // 10 | // http://www.edvardtoth.com 11 | // 12 | //============================= 13 | // INSTALLATION: Copy the script into your Maya script-directory and start it with the massReplicate; command. 14 | // 15 | // COMPATIBILITY NOTE: Tested only with Maya4.0 16 | // 17 | // DESCRIPTION: 18 | // The script creates an interface to mass-duplicate/instance a specified object, and provides randomizable 19 | // rotation/scaling on all axes for the object-iterations. 20 | // 21 | // The resulting duplicates/instances can either be scattered randomly in an area, or placed at regular intervals 22 | // using XYZ offsets. 23 | // 24 | // The object (polygonal mesh, NURBS surface, curve, group, etc. ) can be specified by selecting it and clicking the "Specify Object" button. 25 | // 26 | 27 | 28 | global proc massReplicate() 29 | 30 | { 31 | global string $masswin = "massReplicate"; 32 | 33 | if (`window -ex $masswin`) 34 | { 35 | deleteUI $masswin; 36 | } 37 | 38 | window -t "massReplicate V2.1" -rtf 1 -w 400 -h 100 -s 1 -mnb 1 -mxb 0 $masswin; 39 | 40 | formLayout MR_ButtonForm; 41 | 42 | scrollLayout -cr 1 Scroll; 43 | 44 | columnLayout -w 300 -columnWidth 300 -adjustableColumn false -cal "center" -rowSpacing 5 -cat "left" 10 MainColumn; 45 | 46 | 47 | // *** OPTIONS FRAME 48 | 49 | frameLayout -label "Main Options" -collapse false -collapsable true -bs "etchedOut" ReplicationFrame; 50 | columnLayout -w 300 -columnWidth 300 -adjustableColumn false -cal "center" -rowSpacing 2 -cat "left" 5 ReplicationColumn; 51 | 52 | global string $MR_ReplType; 53 | global string $MR_PlaceType; 54 | global string $MR_ScaleType; 55 | 56 | separator -h 10 -st "none" ; 57 | 58 | $MR_ReplType = `radioButtonGrp -numberOfRadioButtons 2 -label "Mode" -labelArray2 "Duplicate" "Instance" -cw 1 80 -cw 2 80 -sl 1` ; 59 | 60 | intSliderGrp -cw 1 80 -cw 2 40 -l "Iterations" -field true -min 0 -max 500 -v 10 -annotation "Sets the number of duplicates/instances of the original object." iterations ; 61 | 62 | separator -h 10 -st "none" ; 63 | 64 | $MR_PlaceType = `radioButtonGrp -numberOfRadioButtons 2 -label "Placement" -labelArray2 "Area" "Offset" -cw 1 80 -cw 2 80 -sl 1 -annotation "Determines how the object-iterations are going to be scattered."` ; 65 | 66 | intSliderGrp -cw 1 80 -cw 2 40 -l "Area Size" -field true -min 0 -max 500 -v 50 -annotation "The size of the scattering area." radius ; 67 | 68 | separator -h 10 -st "none" ; 69 | 70 | intSliderGrp -cw 1 80 -cw 2 40 -l "Offset X" -field true -min 0 -max 100 -v 1 MR_offsetX ; 71 | intSliderGrp -cw 1 80 -cw 2 40 -l "Offset Y" -field true -min 0 -max 100 -v 1 MR_offsetY ; 72 | intSliderGrp -cw 1 80 -cw 2 40 -l "Offset Z" -field true -min 0 -max 100 -v 1 MR_offsetZ ; 73 | 74 | setParent MainColumn; 75 | 76 | // *** ROTATION FRAME 77 | 78 | frameLayout -label "Rotation Options" -collapse false -collapsable true -bs "etchedOut" RotationFrame; 79 | columnLayout -w 300 -columnWidth 300 -adjustableColumn false -cal "center" -rowSpacing 2 -cat "left" 5 RotationColumn; 80 | 81 | separator -h 5 -st "none" ; 82 | 83 | text -l "Random rotation boundary-values are in degrees."; 84 | 85 | separator -h 5 -st "none" ; 86 | 87 | 88 | intSliderGrp -cw 1 80 -cw 2 40 -l "X-Axis Min" -field true -min -360 -max 360 -v 0 MR_rotminx ; 89 | intSliderGrp -cw 1 80 -cw 2 40 -l "X-Axis Max" -field true -min -360 -max 360 -v 0 MR_rotmaxx ; 90 | 91 | intSliderGrp -cw 1 80 -cw 2 40 -l "Y-Axis Min" -field true -min -360 -max 360 -v 0 MR_rotminy ; 92 | intSliderGrp -cw 1 80 -cw 2 40 -l "Y-Axis Max" -field true -min -360 -max 360 -v 0 MR_rotmaxy ; 93 | 94 | intSliderGrp -cw 1 80 -cw 2 40 -l "Z-Axis Min" -field true -min -360 -max 360 -v 0 MR_rotminz ; 95 | intSliderGrp -cw 1 80 -cw 2 40 -l "Z-Axis Max" -field true -min -360 -max 360 -v 0 MR_rotmaxz ; 96 | 97 | setParent MainColumn; 98 | 99 | 100 | // *** SCALING FRAME 101 | 102 | frameLayout -label "Scaling Options" -collapse false -collapsable true -bs "etchedOut" ScalingFrame; 103 | columnLayout -w 300 -columnWidth 300 -adjustableColumn false -cal "center" -rowSpacing 2 -cat "left" 5 ScalingColumn; 104 | 105 | separator -h 5 -st "none" ; 106 | 107 | text -l "Scaling-factor values are multipliers of the original scale."; 108 | 109 | separator -h 5 -st "none" ; 110 | 111 | $MR_ScaleType = `radioButtonGrp -numberOfRadioButtons 2 -label "Scaling Mode" -labelArray2 "Uniform" "Non-Uniform" -cw 1 80 -cw 2 80 -sl 1` ; 112 | 113 | separator -h 10 -st "none" ; 114 | 115 | floatSliderGrp -cw 1 80 -cw 2 40 -l "Uniform Min" -field true -min 0 -max 10 -v 1 MR_unimin ; 116 | floatSliderGrp -cw 1 80 -cw 2 40 -l "Uniform Max" -field true -min 0 -max 10 -v 1 MR_unimax ; 117 | 118 | separator -h 10 -st "none" ; 119 | 120 | floatSliderGrp -cw 1 80 -cw 2 40 -l "X-Scale Min" -field true -min 0 -max 10 -v 1 MR_scalminx ; 121 | floatSliderGrp -cw 1 80 -cw 2 40 -l "X-Scale Max" -field true -min 0 -max 10 -v 1 MR_scalmaxx ; 122 | 123 | floatSliderGrp -cw 1 80 -cw 2 40 -l "Y-Scale Min" -field true -min 0 -max 10 -v 1 MR_scalminy ; 124 | floatSliderGrp -cw 1 80 -cw 2 40 -l "Y-Scale Max" -field true -min 0 -max 10 -v 1 MR_scalmaxy ; 125 | 126 | floatSliderGrp -cw 1 80 -cw 2 40 -l "Z-Scale Min" -field true -min 0 -max 10 -v 1 MR_scalminz ; 127 | floatSliderGrp -cw 1 80 -cw 2 40 -l "Z-Scale Max" -field true -min 0 -max 10 -v 1 MR_scalmaxz ; 128 | 129 | separator -h 5 -st "none" ; 130 | 131 | setParent MainColumn; 132 | 133 | setParent -top; 134 | 135 | $MR_specbutton= `button -h 30 -label "Specify Object" -command "MRspecifyObj()" -annotation "Use this button to specify the object to be duplicated/instanced."`; 136 | $MR_replbutton= `button -h 30 -label "Perform Replication" -command "doTheReplicate()"`; 137 | $MR_resetbutton= `button -h 30 -label "Reset Values" -command "massReplicate()"`; 138 | 139 | formLayout -edit 140 | 141 | -attachForm $MR_specbutton "left" 2 142 | -attachForm $MR_specbutton "bottom" 2 143 | -attachPosition $MR_specbutton "right" 0 25 144 | 145 | -attachControl $MR_replbutton "left" 2 $MR_specbutton 146 | -attachForm $MR_replbutton "bottom" 2 147 | -attachPosition $MR_replbutton "right" 0 75 148 | 149 | -attachControl $MR_resetbutton "left" 2 $MR_replbutton 150 | -attachForm $MR_resetbutton "bottom" 2 151 | -attachForm $MR_resetbutton "right" 2 152 | 153 | -attachForm Scroll "top" 1 154 | -attachForm Scroll "left" 1 155 | -attachForm Scroll "right" 1 156 | -attachControl Scroll "bottom" 2 $MR_specbutton 157 | 158 | MR_ButtonForm; 159 | 160 | showWindow; 161 | } 162 | 163 | // *** THE REPLICATION PROCESS 164 | 165 | global proc doTheReplicate() 166 | 167 | { 168 | global string $MR_ReplType; 169 | global string $MR_PlaceType; 170 | global string $MR_ScaleType; 171 | 172 | int $MR_RadioButton = `radioButtonGrp -q -sl $MR_ReplType`; 173 | int $MR_ScaleButton = `radioButtonGrp -q -sl $MR_ScaleType`; 174 | int $MR_PlaceButton = `radioButtonGrp -q -sl $MR_PlaceType`; 175 | 176 | int $MR_itr = `intSliderGrp -q -v iterations`; 177 | 178 | int $MR_radius = `intSliderGrp -q -v radius`; 179 | 180 | int $MR_offsX = `intSliderGrp -q -v MR_offsetX`; 181 | int $MR_offsY = `intSliderGrp -q -v MR_offsetY`; 182 | int $MR_offsZ = `intSliderGrp -q -v MR_offsetZ`; 183 | 184 | int $MR_rotminx = `intSliderGrp -q -v MR_rotminx`; 185 | int $MR_rotmaxx = `intSliderGrp -q -v MR_rotmaxx`; 186 | int $MR_rotminy = `intSliderGrp -q -v MR_rotminy`; 187 | int $MR_rotmaxy = `intSliderGrp -q -v MR_rotmaxy`; 188 | int $MR_rotminz = `intSliderGrp -q -v MR_rotminz`; 189 | int $MR_rotmaxz = `intSliderGrp -q -v MR_rotmaxz`; 190 | 191 | float $MR_unimin = `floatSliderGrp -q -v MR_unimin`; 192 | float $MR_unimax = `floatSliderGrp -q -v MR_unimax`; 193 | 194 | float $MR_scalminx = `floatSliderGrp -q -v MR_scalminx`; 195 | float $MR_scalmaxx = `floatSliderGrp -q -v MR_scalmaxx`; 196 | float $MR_scalminy = `floatSliderGrp -q -v MR_scalminy`; 197 | float $MR_scalmaxy = `floatSliderGrp -q -v MR_scalmaxy`; 198 | float $MR_scalminz = `floatSliderGrp -q -v MR_scalminz`; 199 | float $MR_scalmaxz = `floatSliderGrp -q -v MR_scalmaxz`; 200 | 201 | global string $MR_TheObj[]; 202 | 203 | int $i; 204 | int $MR_posX; 205 | int $MR_posY; 206 | int $MR_posZ; 207 | 208 | for ($i = 0; $i < $MR_itr; $i++) 209 | { 210 | 211 | float $MR_radiusX = rand (0-$MR_radius, $MR_radius); 212 | float $MR_radiusZ = rand (0-$MR_radius, $MR_radius); 213 | 214 | int $MR_rotX = rand ($MR_rotminx, $MR_rotmaxx); 215 | int $MR_rotY = rand ($MR_rotminy, $MR_rotmaxy); 216 | int $MR_rotZ = rand ($MR_rotminz, $MR_rotmaxz); 217 | 218 | float $MR_uni = rand ($MR_unimin, $MR_unimax); 219 | 220 | float $MR_scalX = rand ($MR_scalminx, $MR_scalmaxx); 221 | float $MR_scalY = rand ($MR_scalminy, $MR_scalmaxy); 222 | float $MR_scalZ = rand ($MR_scalminz, $MR_scalmaxz); 223 | 224 | select $MR_TheObj[0]; 225 | 226 | if ($MR_RadioButton == 1) 227 | { 228 | duplicate -rr; 229 | } 230 | if ($MR_RadioButton == 2) 231 | { 232 | instance; 233 | } 234 | if ($MR_PlaceButton == 1) 235 | { 236 | move -r -x $MR_radiusX -z $MR_radiusZ; 237 | } 238 | if ($MR_PlaceButton == 2) 239 | { 240 | move -ws $MR_posX $MR_posY $MR_posZ; 241 | } 242 | 243 | rotate -os $MR_rotX $MR_rotY $MR_rotZ; 244 | $MR_posX=$MR_posX+$MR_offsX; 245 | $MR_posY=$MR_posY+$MR_offsY; 246 | $MR_posZ=$MR_posZ+$MR_offsZ; 247 | if ($MR_ScaleButton == 1) 248 | { 249 | scale -r $MR_uni $MR_uni $MR_uni; 250 | } 251 | if ($MR_ScaleButton == 2) 252 | { 253 | scale -r $MR_scalX $MR_scalY $MR_scalZ; 254 | } 255 | } 256 | } 257 | 258 | // *** SPECIFY OBJECT 259 | 260 | global proc MRspecifyObj() 261 | 262 | { 263 | string $MR_selection[] = `ls - sl`; 264 | 265 | if ( size ($MR_selection [0]) == 0 ) 266 | { 267 | confirmDialog -t "Oops..." -m "Specify an object to replicate." -b Continue; 268 | return; 269 | } 270 | 271 | global string $MR_TheObj[]; 272 | 273 | $MR_TheObj = $MR_selection; 274 | print (" SPECIFIED OBJECT: " + $MR_TheObj[0] + "\n"); 275 | } 276 | -------------------------------------------------------------------------------- /curveTube.mel: -------------------------------------------------------------------------------- 1 | //================================= 2 | // curveTube V1.11 (10/2005) 3 | // by Edvard Toth 4 | // 5 | // All Rights Reserved. 6 | // 7 | // The script is freeware. Non-commercial redistribution is permitted as long as this header remains included and unmodified. 8 | // Your feedback is always appreciated - if you find the script useful or if you have questions, comments, suggestions, requests, 9 | // bug-reports, if you created an updated version, or to check for updates please contact me at: 10 | // 11 | // http://www.edvardtoth.com 12 | // 13 | //================================== 14 | // INSTALLATION: Copy the script into your Maya script-directory and start it with the curveTube; command. 15 | // 16 | // COMPATIBILITY NOTE: Tested with Maya 4.0 / 4.5 / 5.0 / 6.0 / 6.5 / 7.0 17 | // 18 | 19 | 20 | global proc curveTube () 21 | { 22 | 23 | 24 | global string $CT_window = "curveTube"; 25 | 26 | if (`window -ex $CT_window`) 27 | { 28 | deleteUI $CT_window; 29 | } 30 | 31 | window -t "curveTube V1.11" -w 300 -h 100 -rtf 1 -s 1 -mnb 1 -mxb 0 $CT_window; 32 | 33 | 34 | // SET PROPER NURBS-TO-POLY CONVERSION FOR LOFTING 35 | nurbsToPolygonsPref -f 3; 36 | 37 | 38 | // FORM 39 | string $CT_form = `formLayout -numberOfDivisions 100 CT_form`; 40 | 41 | // BUTTONS 42 | string $CT_dobutton = `button -w 200 -h 25 -label "Generate Hull Geometry" -command "do_curvetube" -ann ""`; 43 | string $CT_selectbutton = `button -w 144 -h 20 -label "Select Section Curves" -command "if (`objExists $CT_circles[0]`) {select -r ($CT_circles);}" -ann "" CT_selectcurves`; 44 | string $CT_selectbutton2 = `button -w 145 -h 20 -label "Select Hull Geometry" -command "if (`objExists $CT_surfaces[0]`) {select -r ($CT_surfaces);}" -ann "" CT_selecthull`; 45 | 46 | // TABS 47 | string $CT_tabs = `tabLayout -innerMarginWidth 2 -innerMarginHeight 10 CT_tablayout`; 48 | 49 | 50 | // OPTIONS TAB 51 | string $CT_tab1 = `columnLayout -w 300 -adjustableColumn false -columnWidth 300 -columnAlign "center" -rowSpacing 2 -cat "both" 2 OptColumn`; 52 | 53 | separator -height 2 -st "none"; 54 | 55 | intSliderGrp -cw3 85 40 100 -l "Number of sides" -ann "Sets the number of sides/sections for the output geometry." -field true -min 3 -max 128 -v 16 -s 1 CTnumsides; 56 | intSliderGrp -cw3 85 40 100 -l "Section subdivs" -ann "Determines the additional number of subdivisions between each cross-section." -field true -min 1 -max 32 -v 1 -s 1 CTnumsubdivs; 57 | floatSliderGrp -cw3 95 30 100 -l "Slimming factor" -ann "Specifies how closely will the geometry follow the control-curve. Higher values result in more smoothing/less precision." -field true -min 1 -max 5 -v 1 -pre 1 CTsmoothing; 58 | 59 | separator -h 2 -st "none" ; 60 | 61 | radioButtonGrp -numberOfRadioButtons 2 -on2 "checkBoxGrp -e -v1 0 CTautomerge" -label "Geometry" -labelArray2 "Polygons" "NURBS" -ann "Determines the type of output geometry." -cw 1 100 -cw 2 75 -sl 1 CTgeotype; 62 | checkBoxGrp -ncb 1 -v1 1 -cw2 215 30 -label "AutoDelete Section Curves / History" -ann "Automatically deletes all extra construction-geometry/history." CTautodelete; 63 | checkBoxGrp -ncb 1 -v1 1 -cw2 215 30 -on1 "radioButtonGrp -e -sl 1 CTgeotype" -label "AutoMerge Hull Geometry" -ann "Automatically merges geometry-slices into one contiguous mesh." CTautomerge; 64 | 65 | setParent..; 66 | 67 | 68 | // HELP TAB 69 | string $CT_tab2 = `columnLayout -w 300 -adjustableColumn false -columnWidth 300 -columnAlign "center" -rowSpacing 2 -cat "both" 2 TabColumn`; 70 | 71 | string $CT_abouttext = "curveTube V1.0 by Edvard Toth\n"; 72 | $CT_abouttext += "http://www.edvardtoth.com\n\n"; 73 | 74 | $CT_abouttext += "The script offers a way of rapidly creating extruded/lofted tubular geometry with precisely controllable width at every cross-section using only two slightly offset curves of identical CV-counts.\n"; 75 | $CT_abouttext += "The primary curve is used to define the path of the extrusion, and the control (secondary) curve outlines the hull of the extrusion along the primary curve.\n\n"; 76 | $CT_abouttext += "In other words, at any given CV the width/thickness of the resulting extruded geometry cross-section is going to be determined by the distance between the CV of the primary curve and the corresponding CV of the control curve.\n"; 77 | 78 | scrollField -w 250 -h 150 -ww 1 -ed 0 -fn "smallPlainLabelFont" -text $CT_abouttext; 79 | 80 | setParent ..; 81 | 82 | 83 | formLayout -edit 84 | 85 | -attachForm $CT_tabs "top" 1 86 | -attachForm $CT_tabs "left" 1 87 | -attachControl $CT_tabs "bottom" 1 $CT_dobutton 88 | -attachForm $CT_tabs "right" 1 89 | 90 | -attachNone $CT_dobutton "top" 91 | -attachForm $CT_dobutton "left" 1 92 | -attachForm $CT_dobutton "right" 1 93 | -attachControl $CT_dobutton "bottom" 1 $CT_selectbutton 94 | 95 | -attachNone $CT_selectbutton "top" 96 | -attachForm $CT_selectbutton "left" 1 97 | -attachForm $CT_selectbutton "bottom" 1 98 | -attachPosition $CT_selectbutton "right" 1 50 99 | 100 | -attachNone $CT_selectbutton2 "top" 101 | -attachControl $CT_selectbutton2 "left" 1 $CT_selectbutton 102 | -attachForm $CT_selectbutton2 "bottom" 1 103 | -attachForm $CT_selectbutton2 "right" 1 104 | 105 | $CT_form; 106 | 107 | tabLayout -e -tabLabel $CT_tab1 "Options" -tabLabel $CT_tab2 "Help" $CT_tabs; 108 | 109 | showWindow $CT_window; 110 | 111 | } 112 | 113 | 114 | global proc do_curvetube () 115 | { 116 | 117 | // PARAMETERS 118 | 119 | int $CT_numsides = `intSliderGrp -q -v CTnumsides`; 120 | int $CT_numsubdivs = `intSliderGrp -q -v CTnumsubdivs`; 121 | float $CT_smoothing = `floatSliderGrp -q -v CTsmoothing`; 122 | 123 | int $CT_geotype = `radioButtonGrp -q -sl CTgeotype`; 124 | int $CT_autodelete = `checkBoxGrp -q -v1 CTautodelete`; 125 | int $CT_automerge = `checkBoxGrp -q -v1 CTautomerge`; 126 | 127 | 128 | if ($CT_geotype == 2) 129 | { 130 | $CT_geotype = 0; 131 | } 132 | 133 | // CHECK CURVES 134 | 135 | string $CT_curves[] = `ls -sl`; 136 | 137 | if (size($CT_curves) != 2) 138 | { 139 | confirmDialog -t "Oops..." -m "Please select two curves." -b Continue; 140 | return; 141 | } 142 | 143 | string $CT_curvecheckA[] = `ls -l $CT_curves[0]`; 144 | string $CT_curvecheckB[] = `ls -l $CT_curves[1]`; 145 | 146 | string $CT_curvenodeA[] = `listRelatives -f -ni -s $CT_curvecheckA[0]`; 147 | string $CT_curvenodeB[] = `listRelatives -f -ni -s $CT_curvecheckB[0]`; 148 | 149 | if (nodeType($CT_curvenodeA[0]) != "nurbsCurve" || nodeType($CT_curvenodeB[0]) != "nurbsCurve") 150 | { 151 | confirmDialog -t "Oops..." -m "Please make sure both selected objects are curves." -b Continue; 152 | return; 153 | } 154 | 155 | // CHECK CV COUNT 156 | 157 | select -r $CT_curves[0]; 158 | int $CT_cvnumA = `getAttr ($CT_curves[0] + ".spans")` + `getAttr ($CT_curves[0] + ".degree")`; 159 | 160 | select -r $CT_curves[1]; 161 | int $CT_cvnumB = `getAttr ($CT_curves[1] + ".spans")` + `getAttr ($CT_curves[1] + ".degree")`; 162 | 163 | if ($CT_cvnumA != $CT_cvnumB) 164 | { 165 | confirmDialog -t "Oops..." -m "Please make sure the two selected curves have an identical number of CVs." -b Continue; 166 | return; 167 | } 168 | 169 | // GET DISTANCES BETWEEN CORRESPONDING CVs 170 | // CREATE CIRCLES WITH THE PROPER RADIUS, POSITION AND ALIGN THEM 171 | 172 | float $CT_distance[]; 173 | float $CT_coord1[3]; 174 | float $CT_coord2[3]; 175 | 176 | string $CT_circle[]; 177 | global string $CT_circles[]; 178 | 179 | string $CT_surface[]; 180 | global string $CT_surfaces[]; 181 | 182 | 183 | for ($i=0 ; $i < $CT_cvnumA ; $i++) 184 | { 185 | 186 | $CT_coord1 = `pointPosition ($CT_curves[0] + ".cv[" + $i + "]")`; 187 | $CT_coord2 = `pointPosition ($CT_curves[1] + ".cv[" + $i + "]")`; 188 | 189 | $CT_distance[$i] = sqrt( (($CT_coord1[0] - $CT_coord2[0]) * ($CT_coord1[0] - $CT_coord2[0])) + (($CT_coord1[1] - $CT_coord2[1]) * ($CT_coord1[1] - $CT_coord2[1]))+(($CT_coord1[2] - $CT_coord2[2]) * ($CT_coord1[2] - $CT_coord2[2]))); 190 | 191 | 192 | $CT_circle = `circle -c 0 0 0 -nr 0 1 0 -sw 360 -r ($CT_distance[$i] / $CT_smoothing) -d 3 -ut 0 -tol 0.01 -s $CT_numsides -ch 0`; // MIND THE DAMPENER 193 | 194 | $CT_circles[$i] = $CT_circle[0]; 195 | 196 | xform -a -ws -t $CT_coord1[0] $CT_coord1[1] $CT_coord1[2] $CT_circles[$i]; 197 | 198 | tangentConstraint -weight 1 -aimVector 0 1 0 -upVector 0 1 0 -worldUpType "vector" -worldUpVector 0 1 0 $CT_curves[0] $CT_circles[$i]; 199 | 200 | } 201 | 202 | // LOFT THE CIRCLES 203 | 204 | for ($j=0 ; $j < ($CT_cvnumA-1) ; $j++) 205 | { 206 | 207 | $CT_surface = `loft -ch 1 -u 1 -c 0 -ar 1 -d 1 -ss $CT_numsubdivs -rn 0 -po $CT_geotype -rsn true $CT_circles[$j] $CT_circles[$j+1]`; 208 | $CT_surfaces[$j] = $CT_surface[0]; 209 | } 210 | 211 | 212 | // AUTODELETE - AUTOMERGE 213 | 214 | if ($CT_autodelete == 1) 215 | { 216 | select $CT_surfaces; 217 | delete -ch; 218 | select $CT_circles; 219 | delete -cn; 220 | delete $CT_circles; 221 | select $CT_surfaces; 222 | 223 | button -e -en 0 CT_selectcurves; 224 | } 225 | 226 | else 227 | { 228 | select $CT_circles; 229 | delete -cn; 230 | 231 | button -e -en 1 CT_selectcurves; 232 | } 233 | 234 | 235 | if ($CT_automerge == 1) 236 | { 237 | 238 | string $CT_hull[]; 239 | string $CT_hullvertices[]; 240 | 241 | $CT_hull = `polyUnite -ch 0 $CT_surfaces`; 242 | 243 | select $CT_hull; 244 | PolySelectConvert 3; 245 | 246 | $CT_hullvertices = `ls -sl -fl`; 247 | int $CT_hullvertexnum = size ($CT_hullvertices); 248 | 249 | string $CT_hullmerge = $CT_hull[0] + (".vtx[0:" + ($CT_hullvertexnum-1) + "]"); 250 | 251 | polyMergeVertex -d 0.01 -ch 0 $CT_hullmerge; 252 | 253 | select $CT_hull; 254 | PolySelectConvert 2; 255 | polySoftEdge -a 180 -ch 0; 256 | 257 | $CT_surfaces = $CT_hull; // MERGED HULL REPLACES SEGMENTS 258 | 259 | select $CT_hull; 260 | } 261 | 262 | } 263 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #MEL Scripts 2 | 3 | A collection of legacy MEL scripts for Maya done between 2002-2006 by **Edvard Toth** (http://edvardtoth.com) 4 | 5 | Apart from my confidential, proprietary game-development scripting work I also created a number of freely available, more generic scripts which in their heyday managed to accumulate well over 80.000 total combined downloads. I even received the honor of being included in Pixel Magazine’s "World’s Best Maya Developers" feature. 6 | 7 | Please note that even though the scripts **are not supported or updated anymore**, they may still prove to be useful. Please always refer to the script-headers for more thorough documentation. 8 | 9 | Contents 10 | ---------- 11 | 12 | * **curveTube [V1.11 01/2006]** The script offers a way of rapidly creating extruded/lofted tubular geometry with precisely controllable width at every cross-section using only two slightly offset curves of identical CV-counts. 13 | 14 | * **uniToolBox [V2.0 01/2006]** The script creates a Swiss Army-knife style unified, dockable interface featuring contols grouped in collapsible frames for a number of functions and operations. It includes a comprehensive collection of display-property controls, selection conversion, UV-mapping, prelighting and layer-commands. Useful for having all these frequently used functions in one customizable place without sacrificing precious hotkeys on them. V2.0 adds color-coded tabs, saved tab-states, numerous small fixes, a “Shading” tab and a customizable “User” tab. 15 | 16 | * **batchProcessor [V1.0 01/2005]** The script is a highly versatile batch-processing utility which offers a way to apply virtually any single MEL-command, code-snippet or standalone script to entire directories of Maya-files. It provides comprehensive options to control how the files are identified, opened and saved, and it generates a detailed log to help track down any potential processing-interruptions due to command errors or other problems. It is very useful for performing repetitive tasks on a large number of individual files. Please refer to the ‘About’-panel for more detailed information. 17 | 18 | * **curveLength [V1.0 08/2004]** This tiny but very straightforward utility measures the length of a curve without all the hassle that comes with using Maya’s implementation of the “Arc Length Tool”. 19 | 20 | * **reSource [V1.0 07/2004]** The script is a very handy script-development utility: it allows you to repeatedly source and execute a script-file with a click of a button, greatly simplifying the testing-process. Both the filename (including the full path) and the command-name (including any potential parameters) can be specified either manually or through a browser-window. In addition, these settings are stored as persistent variables and don’t have to be re-entered, even if Maya is restarted. 21 | 22 | * **ParentToParticles [V3.0 07/2004]** The script offers a potential way to rapidly and precisely place and adjust a large number of objects using particles as placement-proxies. (It’s particularly useful for tasks like placing rocks or plant-life on uneven terrain without excessive manual tweaking.) V3.0 represents a major overhaul: significantly updated interface and button-set with direct access to supporting Maya-tools, ability to place objects and constrain them to a target-surface in one quick pass, faster operation, more extensive error-checking, etc. 23 | 24 | * **pointDistance [V2.1 03/2004]** The script creates a persistent and dynamically updated HeadsUpDisplay-overlay that displays the direct distance between 2 selected points. Only point-like entities (vertices, CVs, curve-points, particles, lights, etc.) are evaluated, all other types within the selection are ignored. Distance-information is shown only if exactly 2 items are selected, otherwise the display resets to “0”. The script can be an extremely useful tool for modeling game-environments, where using certain specific distances is usually a key factor required by gameplay. 25 | 26 | * **distributeOnCurve [V2.0 03/2004]** The script makes it possible to create a number of duplicates/instances of a specified object, and distribute them along a curve. The distribution can also be randomized, and the orientation of the selected objects can be constrained to follow the tangency of the curve (For example, this could be useful for properly orienting wooden planks in a winding walkway.) New in V2.0: option to duplicate/instance, now all objects are generated from a single original template, better control of constraints. 27 | 28 | * **massPointLights [V1.0 01/2004]** The script creates a customizable pointLight at the origins of any number of selected objects, and each pointLight is generated with an adjustable intensity-curve to control its falloff. The script offers a workaround to the problem of losing the intensity-curve when duplicating/instancing lights of this type, and provides an effective method of placing a large number of these lights at specific positions within a scene (especially when used together with locators to define the placement). 29 | 30 | * **pivotMatcher [V1.0 12/2003]** The script makes it possible to match the pivots of any number of selected objects to either the pivots of the same number of target objects, or to the pivot of one selected target object.The selection-order is taken into account during the process. 31 | 32 | * **vertexTone [V2.1 12/2003]** The script is a comprehensive global adjustment utility for vertex-color / vertex-alpha values. It performs brightness, contrast, dodge/burn and saturation operations on the colors of selected vertices and features controls to independently modify each RGB-channel. Now it works on pre-defined / sampled vertex-selections to allow fine-tuning, it also works across multiple objects and takes advantage of the functionality offered by Maya’s built-in color editor / color picker tool. 33 | 34 | * **randomComps [V1.0 10/2003]** The script makes it possible to randomly select a certain percentage of components (vertices, faces, edges and UVs) on selected objects. Its area of effect can also be limited/tuned even further by using it on an existing component-level selection. 35 | 36 | * **groupN [V1.0 10/2003]** The script creates a small pop-up window that contains grouping-preferences and a text-field that makes it possible to properly name new groups in advance: this removes the extra step of having to rename them after the grouping is performed. Provides an useful alternative to the default “group” (CTRL+G) command. 37 | 38 | * **proxyUV [V1.0 09/2003]** The script uses a “proxy” NURBS-surface to project UV-coordinates onto a polygonal mesh: it offers a simple and very effective approach to texturing complex polygonal meshes, greatly reducing problems associated with overlapping and uneven, severely stretched UVs. (Even though several other scripts out there utilize a similar method, I believe this version is a simplified and highly streamlined implementation of this technique.) 39 | 40 | * **vertexNoise [V1.0 12/2002]** The script applies fully adjustable random noise to selected vertices, even across multiple objects. The type of the noise can either be uniform (based on the vertex-normals) or directional (based on the XYZ-axes). A smoothing function with adjustable intensity is also available for fine-tuning purposes. Since the original vertex-selection is retained, the noise/smooth operations can be applied repeatedly until the desired result is reached. 41 | 42 | * **vertexLevels [V1.0 09/2003]** The script selects vertices based on their vertex colors, also taking an adjustable selection-threshold value into account. The selection works on entire scenes, across multiple objects. The resulting set of selected vertices can be adjusted using separate basic RGB-controls. Potential uses could include selecting and brightening up dark areas in a level without having to prelight the entire scene and possibly lose manual vertex-color tweaks.) 43 | 44 | * **massReplicate [V2.1 01/2003]** The script creates an interface to mass-duplicate/instance a specified object, and provides randomizable rotation / scaling on all axes for the object-iterations. V2.1 now has a completely redesigned and optimized interface, and adds the option of either randomly scattering the duplicates/instances in an area or placing them at regular intervals using XYZ offsets, plus minor bug-fixes. 45 | 46 | * **massConstrain [V1.1 12/2002]** The script constrains any number of selected objects to the normals and/or geometry of a specified target surface. It also leaves behind the normal/geometry constraint nodes on each individual selected object so they can be manually adjusted while they maintain their alignment (they “stick”) to the normals and/or geometry of the target surface. Hint: useful for tasks such as properly orienting / arranging a large number of leaves to tree-branches. Works well together with the ParentToParticles and massReplicate scripts. 47 | 48 | * **massUVTransfer [V1.0 06/2003]** The script transfers the UV coordinates of a specified object to any number of other objects of identical topology in one pass, eliminating the need to select individual object-pairs for the transfer. 49 | massRename [V1.2 02/2003] The script provides a very easy-to-use solution for renaming a large number of nodes. It features adjustable starting-number and padding for the renamed nodes, two options for a divider character that separates the new node-name from the node-number and a reorder-function that sorts the nodes into ascending order. The script – unlike other renamers – keeps working even when nodes from multiple levels of the node-hierarchy are selected at the same time. 50 | 51 | * **displayTexture [V1.0 01/2003]** The script makes it possible to view the bitmap-texture assigned to a selected polygonal face with a single click, using any external image-viewer that accepts command-line input (fcheck, ACDSee, IrfanView etc.) The location of the image-viewer application has to be specified in the “DT_viewer” variable. The script also shows the name and full path of the viewed texture-file in the “Command Feedback” line at the bottom of the screen, and provides additional details about the texture in the “Script Editor” window. 52 | 53 | * **offsetCV [V2.0 12/2002]** The script places/spreads the CVs of a curve evenly along the Y axis. The placement of CVs can be determined by the offset (the Y-distance between each CV) or the span(the total Y-distance between the first and last CV of the curve). The starting Y-position for the first CV can also be specified. All values handled as negative/positive floating values with 4-digit precision. Hint: useful for creating accurate roller-coaster or slide-like surfaces. 54 | 55 | * **averageCurves [V2.0 07/2003]** The script generates an averaged, intermediary curve between two selected curves. Particularly useful for terrain or water-surface modeling since it’s adding new cross-section curves for lofting / bi-railing surfaces. 56 | 57 | * **supportCurves [V1.0 12/2002]** The script creates a new curve that is offset in XZ-space, but its CVs inherit their Y-axis position from the CVs of the original curve. It was created to provide a workaround to the problem of tilting/banking of slide/ribbon-like extruded surfaces. Using the script to create offset support-curves it becomes very easy to generate (loft or birail) surfaces that maintain horizontal planarity at every subdivision. Works well together with the offsetCV script. 58 | 59 | * **sceneCleanUp [V1.1 07/2003]** The script deletes numerous leftover nodes (links, brush-nodes, script-nodes, unconnected intermediate objects etc.) normally unaffected by deleting history or optimizing the scene. It also eliminates excess “stacked” vertex-color data. While individual results will vary depending on application, in many cases the script can drastically reduce the size of large scenes. (This script is the result of a joint effort with Alex Carbonero.) 60 | 61 | * **alphaSlider [V1.0 12/2002]** A very simple script that creates a slider to interactively adjust vertex-alpha values. The changes are instantly visible if the slider is dragged. The script automatically converts existing selections into Vertices, providing additional versatility. (See script-header for more details.) 62 | -------------------------------------------------------------------------------- /vertexTone.mel: -------------------------------------------------------------------------------- 1 | 2 | //============================== 3 | // vertexTone v2.1 (12/2003) 4 | // by Edvard Toth 5 | // 6 | // The script is freeware. Non-commercial redistribution is permitted as long as this header remains included and unmodified. 7 | // Your feedback is always appreciated - if you find the script useful or if you have questions, comments, suggestions, 8 | // requests, bug-reports, if you created an updated version, or to check for updates please contact me at: 9 | // 10 | // http://www.edvardtoth.com 11 | // 12 | //============================== 13 | // INSTALLATION: Copy the script into your Maya script-directory and start it with the vertexTone; command. 14 | // 15 | // COMPATIBILITY NOTE: Tested only with Maya4.0 16 | // 17 | // DESCRIPTION: 18 | // 19 | // The script is a comprehensive global adjustment utility for vertex-color / vertex-alpha values. 20 | // It performs brightness, contrast, dodge/burn, saturation operations on the colors of selected vertices and features controls 21 | // to independently modify each RGB-channel. 22 | // 23 | // It works on pre-defined vertex-selections, and the sampled color-information of the selections also serves as basis 24 | // for any subsequent modification. This eliminates the "compounding" effect of the sliders: the original state can be 25 | // restored by resetting the values. Modified colors can be re-sampled to establish a set of new base-values. 26 | // 27 | // It also retains vertex-selections to allow fine-tuning, it works across multiple objects and takes 28 | // advantage of the functionality offered by Maya's built-in color editor / color picker tool. 29 | // 30 | // NOTE: on some hardware-configurations it may be necessary to use Maya's native "Apply Color" function at least once 31 | // prior to using the script in order to have Maya display the resulting vertex-color / vertex-alpha values properly. 32 | // 33 | 34 | 35 | global proc vertexTone() 36 | { 37 | global string $VTwin = "vertexTone"; 38 | 39 | if (`window -ex $VTwin`) 40 | { 41 | deleteUI $VTwin; 42 | } 43 | 44 | window -wh 300 120 -t "vertexTone v2.1" -mnb 1 -mxb 0 -s 1 -rtf 1 $VTwin; 45 | 46 | string $VT_form = `formLayout -numberOfDivisions 100 VertexToneForm`; 47 | 48 | columnLayout -w 300 -columnWidth 300 -adjustableColumn 0 -cal "center" -rowSpacing 1 -cat "left" 5 MainColumn; 49 | 50 | separator -h 2 -st "none"; 51 | 52 | floatSliderGrp -l "Brightness" -field true -cw3 70 35 200 -cc "doVertexTone 0" -pre 2 -v 0 -min -1 -max 1 VT_BrightnessValue; 53 | 54 | floatSliderGrp -l "Contrast" -field true -cw3 70 35 200 -cc "doVertexTone 1" -pre 2 -v 0 -min -1 -max 1 VT_ContrastValue; 55 | 56 | floatSliderGrp -l "Dodge/Burn" -field true -cw3 70 35 200 -cc "doVertexTone 2" -pre 2 -v 0 -min -1 -max 1 VT_DodgeValue; 57 | 58 | separator -h 5 -st "none"; 59 | 60 | floatSliderGrp -l "Red" -field true -cw3 70 35 200 -cc "doVertexTone 3" -pre 2 -v 0 -min -1 -max 1 VT_RedValue; 61 | 62 | floatSliderGrp -l "Green" -field true -cw3 70 35 200 -cc "doVertexTone 4" -pre 2 -v 0 -min -1 -max 1 VT_GreenValue; 63 | 64 | floatSliderGrp -l "Blue" -field true -cw3 70 35 200 -cc "doVertexTone 5" -pre 2 -v 0 -min -1 -max 1 VT_BlueValue; 65 | 66 | separator -h 5 -st "none"; 67 | 68 | floatSliderGrp -l "Saturation" -field true -cw3 70 35 200 -cc "doVertexTone 6" -pre 2 -v 0 -min -1 -max 1 VT_SatValue; 69 | 70 | floatSliderGrp -l "Alpha" -field true -cw3 70 35 200 -cc "doVertexTone 7" -pre 2 -v 1 -min 0 -max 1 VT_AlphaValue; 71 | 72 | 73 | setParent..; 74 | 75 | 76 | string $VT_definebutton = `button -w 260 -h 25 -label "DEFINE SELECTION / SAMPLE BASE COLORS" -command "defineSelection" -ann "Defines the selection-area and uses its colors as basis for all modifications."`; 77 | string $VT_colorbutton = `button -w 70 -h 20 -label "Color Picker" -command "colorEditor" -ann "Displays the built-in color-picker window."`; 78 | string $VT_applybutton = `button -w 100 -h 20 -label "Apply Picked Color" -command "doVertexToneApplyColor" -ann "Applies the color selected in the color-picker to currently selected vertices."`; 79 | string $VT_optionsbutton = `button -w 44 -h 20 -label "Options" -command "PolygonApplyColorOptions;" -ann "Displays Apply Color Options."`; 80 | string $VT_resetbutton = `button -w 40 -h 20 -label "Reset" -command "vertexTone;" -ann "Resets all sliders to their default values."`; 81 | 82 | 83 | formLayout -edit 84 | 85 | -attachControl $VT_definebutton "top" 5 MainColumn 86 | -attachForm $VT_definebutton "left" 5 87 | 88 | -attachControl $VT_colorbutton "top" 5 $VT_definebutton 89 | -attachForm $VT_colorbutton "left" 5 90 | 91 | -attachControl $VT_applybutton "top" 5 $VT_definebutton 92 | -attachControl $VT_applybutton "left" 2 $VT_colorbutton 93 | 94 | -attachControl $VT_optionsbutton "top" 5 $VT_definebutton 95 | -attachControl $VT_optionsbutton "left" 2 $VT_applybutton 96 | 97 | -attachControl $VT_resetbutton "top" 5 $VT_definebutton 98 | -attachControl $VT_resetbutton "left" 2 $VT_optionsbutton 99 | 100 | 101 | $VT_form; 102 | setParent ..; 103 | 104 | showWindow $VTwin; 105 | } 106 | 107 | 108 | global proc defineSelection () 109 | { 110 | PolySelectConvert 3; 111 | 112 | global string $VT_VertexSel[]; 113 | $VT_VertexSel = `ls -sl -fl`; 114 | 115 | if (size ($VT_VertexSel) == 0) 116 | { 117 | confirmDialog -t "Oops..." -m "Please make a selection first." -b Continue; 118 | return; 119 | } 120 | 121 | global float $VT_Red[]; 122 | global float $VT_Green[]; 123 | global float $VT_Blue[]; 124 | global float $VT_Alpha[]; 125 | 126 | $VT_Red = `polyColorPerVertex -q -r`; 127 | $VT_Green = `polyColorPerVertex -q -g`; 128 | $VT_Blue = `polyColorPerVertex -q -b`; 129 | $VT_Alpha = `polyColorPerVertex -q -a`; 130 | 131 | print "New selection defined."; 132 | vertexTone; 133 | } 134 | 135 | 136 | global proc doVertexTone (int $VT_cases) 137 | { 138 | waitCursor -state on; 139 | 140 | global string $VT_VertexSel[]; 141 | 142 | if (size ($VT_VertexSel) == 0) 143 | { 144 | warning "Please define a selection first."; 145 | } 146 | 147 | select -r $VT_VertexSel; 148 | 149 | global float $VT_Red[]; 150 | global float $VT_Green[]; 151 | global float $VT_Blue[]; 152 | global float $VT_Alpha[]; 153 | 154 | global float $VT_RedM[]; 155 | global float $VT_GreenM[]; 156 | global float $VT_BlueM[]; 157 | global float $VT_AlphaM[]; 158 | 159 | $VT_RedM = `polyColorPerVertex -q -r`; 160 | $VT_GreenM = `polyColorPerVertex -q -g`; 161 | $VT_BlueM = `polyColorPerVertex -q -b`; 162 | $VT_AlphaM = `polyColorPerVertex -q -a`; 163 | 164 | int $VT_VertexNum = size($VT_VertexSel); 165 | 166 | float $HSV[]; 167 | float $RGB[]; 168 | 169 | switch ($VT_cases) 170 | 171 | { 172 | 173 | case 0: 174 | //BRIGHTNESS 175 | 176 | float $VT_Modifier = `floatSliderGrp -q -v VT_BrightnessValue`; 177 | 178 | for ($i = 0; $i < ($VT_VertexNum); $i++) 179 | { 180 | 181 | $VT_RedM[$i] = ($VT_Red[$i] + $VT_Modifier); 182 | $VT_GreenM[$i] = ($VT_Green[$i] + $VT_Modifier); 183 | $VT_BlueM[$i] = ($VT_Blue[$i] + $VT_Modifier); 184 | 185 | 186 | if ($VT_RedM[$i] > 1.0) 187 | {$VT_RedM[$i] = 1;} 188 | if ($VT_GreenM[$i] > 1.0) 189 | {$VT_GreenM[$i] = 1;} 190 | if ($VT_BlueM[$i] > 1.0) 191 | {$VT_BlueM[$i] = 1;} 192 | 193 | if ($VT_RedM[$i] < 0) 194 | {$VT_RedM[$i] = 0;} 195 | if ($VT_GreenM[$i] < 0) 196 | {$VT_GreenM[$i] = 0;} 197 | if ($VT_BlueM[$i] < 0) 198 | {$VT_BlueM[$i] = 0;} 199 | 200 | } 201 | 202 | break; 203 | 204 | case 1: 205 | 206 | // CONTRAST 207 | 208 | float $VT_Modifier = `floatSliderGrp -q -v VT_ContrastValue`; 209 | $VT_Modifier = ($VT_Modifier + 1); 210 | 211 | 212 | for ($i = 0; $i < ($VT_VertexNum); $i++) 213 | { 214 | 215 | if ($VT_Modifier > 1) 216 | { 217 | $VT_RedM[$i] = `pow $VT_Red[$i] $VT_Modifier`; 218 | $VT_GreenM[$i] = `pow $VT_Green[$i] $VT_Modifier`; 219 | $VT_BlueM[$i] = `pow $VT_Blue[$i] $VT_Modifier`; 220 | 221 | 222 | if ($VT_RedM[$i] > 1.0) 223 | {$VT_RedM[$i] = 1;} 224 | if ($VT_GreenM[$i] > 1.0) 225 | {$VT_GreenM[$i] = 1;} 226 | if ($VT_BlueM[$i] > 1.0) 227 | {$VT_BlueM[$i] = 1;} 228 | 229 | if ($VT_RedM[$i] < 0) 230 | {$VT_RedM[$i] = 0;} 231 | if ($VT_GreenM[$i] < 0) 232 | {$VT_GreenM[$i] = 0;} 233 | if ($VT_BlueM[$i] < 0) 234 | {$VT_BlueM[$i] = 0;} 235 | } 236 | 237 | 238 | 239 | if ($VT_Modifier < 1) 240 | { 241 | float $Rr = (0.5 - $VT_Red[$i]); 242 | $VT_RedM[$i] = ($VT_Red[$i]+($Rr *(1-$VT_Modifier))); 243 | float $Gr = (0.5 - $VT_Green[$i]); 244 | $VT_GreenM[$i] = ($VT_Green[$i]+($Gr *(1-$VT_Modifier))); 245 | float $Br = (0.5 - $VT_Blue[$i]); 246 | $VT_BlueM[$i] = ($VT_Blue[$i]+($Br *(1-$VT_Modifier))); 247 | 248 | } 249 | 250 | } 251 | break; 252 | 253 | 254 | case 2: 255 | //DODGE 256 | 257 | float $VT_Modifier = `floatSliderGrp -q -v VT_DodgeValue`; 258 | $VT_Modifier = ($VT_Modifier + 1); 259 | 260 | for ($i = 0; $i < ($VT_VertexNum); $i++) 261 | { 262 | 263 | $VT_RedM[$i] = ($VT_Red[$i] * $VT_Modifier); 264 | $VT_GreenM[$i] = ($VT_Green[$i] * $VT_Modifier); 265 | $VT_BlueM[$i] = ($VT_Blue[$i] * $VT_Modifier); 266 | 267 | 268 | if ($VT_RedM[$i] > 1.0) 269 | {$VT_RedM[$i] = 1;} 270 | if ($VT_GreenM[$i] > 1.0) 271 | {$VT_GreenM[$i] = 1;} 272 | if ($VT_BlueM[$i] > 1.0) 273 | {$VT_BlueM[$i] = 1;} 274 | 275 | if ($VT_RedM[$i] < 0) 276 | {$VT_RedM[$i] = 0;} 277 | if ($VT_GreenM[$i] < 0) 278 | {$VT_GreenM[$i] = 0;} 279 | if ($VT_BlueM[$i] < 0) 280 | {$VT_BlueM[$i] = 0;} 281 | 282 | } 283 | break; 284 | 285 | case 3: 286 | //RED 287 | $VT_Modifier = `floatSliderGrp -q -v VT_RedValue`; 288 | 289 | for ($i = 0; $i < ($VT_VertexNum); $i++) 290 | { 291 | $VT_RedM[$i] = ($VT_Red[$i] + $VT_Modifier); 292 | 293 | if ($VT_RedM[$i] < 0) 294 | {$VT_RedM[$i] = 0;} 295 | if ($VT_RedM[$i] > 1) 296 | {$VT_RedM[$i] = 1;} 297 | } 298 | break; 299 | 300 | case 4: 301 | //GREEN 302 | 303 | $VT_Modifier = `floatSliderGrp -q -v VT_GreenValue`; 304 | 305 | for ($i = 0; $i < ($VT_VertexNum); $i++) 306 | { 307 | $VT_GreenM[$i] = ($VT_Green[$i] + $VT_Modifier); 308 | 309 | if ($VT_GreenM[$i] < 0) 310 | {$VT_GreenM[$i] = 0;} 311 | if ($VT_GreenM[$i] > 1) 312 | {$VT_GreenM[$i] = 1;} 313 | } 314 | break; 315 | 316 | case 5: 317 | 318 | //BLUE 319 | 320 | $VT_Modifier = `floatSliderGrp -q -v VT_BlueValue`; 321 | 322 | for ($i = 0; $i < ($VT_VertexNum); $i++) 323 | { 324 | $VT_BlueM[$i] = ($VT_Blue[$i] + $VT_Modifier); 325 | 326 | if ($VT_BlueM[$i] < 0) 327 | {$VT_BlueM[$i] = 0;} 328 | if ($VT_BlueM[$i] > 1) 329 | {$VT_BlueM[$i] = 1;} 330 | } 331 | break; 332 | 333 | case 6: 334 | 335 | //SATURATION 336 | 337 | shadingNode -asUtility rgbToHsv -name VT_rgb2hsv; 338 | shadingNode -asUtility hsvToRgb -name VT_hsv2rgb; 339 | 340 | 341 | float $VT_Modifier = `floatSliderGrp -q -v VT_SatValue`; 342 | 343 | for ($i = 0; $i < ($VT_VertexNum); $i++) 344 | { 345 | 346 | setAttr "VT_rgb2hsv.inRgb" -type double3 $VT_Red[$i] $VT_Green[$i] $VT_Blue[$i]; 347 | $HSV = `getAttr "VT_rgb2hsv.outHsv"`; 348 | 349 | $HSV[1] = $HSV[1] + $VT_Modifier; 350 | 351 | setAttr "VT_hsv2rgb.inHsv" -type double3 $HSV[0] $HSV[1] $HSV[2]; 352 | $RGB = `getAttr "VT_hsv2rgb.outRgb"`; 353 | 354 | $VT_RedM[$i] = $RGB[0]; 355 | $VT_GreenM[$i] = $RGB[1]; 356 | $VT_BlueM[$i] = $RGB[2]; 357 | 358 | if ($VT_RedM[$i] > 1.0) 359 | {$VT_RedM[$i] = 1;} 360 | if ($VT_GreenM[$i] > 1.0) 361 | {$VT_GreenM[$i] = 1;} 362 | if ($VT_BlueM[$i] > 1.0) 363 | {$VT_BlueM[$i] = 1;} 364 | 365 | if ($VT_RedM[$i] < 0) 366 | {$VT_RedM[$i] = 0;} 367 | if ($VT_GreenM[$i] < 0) 368 | {$VT_GreenM[$i] = 0;} 369 | if ($VT_BlueM[$i] < 0) 370 | {$VT_BlueM[$i] = 0;} 371 | 372 | } 373 | 374 | delete VT_rgb2hsv; 375 | delete VT_hsv2rgb; 376 | 377 | break; 378 | 379 | case 7: 380 | 381 | //ALPHA 382 | float $VT_Modifier = `floatSliderGrp -q -v VT_AlphaValue`; 383 | 384 | for ($i = 0; $i < ($VT_VertexNum); $i++) 385 | { 386 | $VT_AlphaM[$i] = $VT_Modifier; 387 | } 388 | 389 | break; 390 | 391 | } 392 | 393 | 394 | // APPLY SETTINGS TO THE VERTEX-COLORS 395 | 396 | 397 | for ($i = 0; $i < ($VT_VertexNum); $i++) 398 | { 399 | select $VT_VertexSel[$i]; 400 | polyColorPerVertex -r $VT_RedM[$i] -g $VT_GreenM[$i] -b $VT_BlueM[$i] -a $VT_AlphaM[$i]; 401 | } 402 | 403 | select -r $VT_VertexSel; 404 | clear $VT_RedM; 405 | clear $VT_GreenM; 406 | clear $VT_BlueM; 407 | 408 | waitCursor -state off; 409 | } 410 | 411 | 412 | // APPLY COLOR FROM THE COLOR EDITOR 413 | 414 | global proc doVertexToneApplyColor() 415 | { 416 | float $VT_EdColors[] = `colorEditor -q -rgb`; 417 | if (`colorEditor -query -result` == 1) 418 | { 419 | polyColorPerVertex -r $VT_EdColors[0] -g $VT_EdColors[1] -b $VT_EdColors[2]; 420 | return; 421 | } 422 | confirmDialog -t "Oops..." -m "Please pick a color first." -b Continue; 423 | } 424 | 425 | -------------------------------------------------------------------------------- /batchProcessor.mel: -------------------------------------------------------------------------------- 1 | //================================= 2 | // batchProcessor V1.0 (01/2005) 3 | // by Edvard Toth 4 | // 5 | // All Rights Reserved. 6 | // 7 | // The script is freeware. Non-commercial redistribution is permitted as long as this header remains included and unmodified. 8 | // Your feedback is always appreciated - if you find the script useful or if you have questions, comments, suggestions, requests, 9 | // bug-reports, if you created an updated version, or to check for updates please contact me at: 10 | // 11 | // http://www.edvardtoth.com 12 | // 13 | //================================== 14 | // INSTALLATION: Copy the script into your Maya script-directory and start it with the batchProcessor; command. 15 | // 16 | // COMPATIBILITY NOTE: Tested with Maya 4.0 / 4.5 / 5.0 / 6.0 / 7.0 17 | // 18 | 19 | global proc batchProcessor () 20 | { 21 | global string $BP_window = "batchProcessor"; 22 | global string $BP_log; 23 | 24 | // GET MOST RECENT DIRECTORY 25 | string $BP_recentdirectory = `optionVar -q "BP_recentdirectory"`; 26 | 27 | if ($BP_recentdirectory == "0") 28 | { 29 | $BP_recentdirectory = ""; 30 | } 31 | 32 | if (`window -ex $BP_window`) 33 | { 34 | deleteUI $BP_window; 35 | } 36 | 37 | window -t "batchProcessor V1.0" -rtf 1 -w 350 -s 1 -mnb 1 -mxb 0 $BP_window; 38 | 39 | 40 | // ==== FORM 41 | string $BP_form = `formLayout -nd 100`; 42 | 43 | // HEADER 44 | string $BP_header = `text -rs 0 -w 350 -al "center" -fn "smallPlainLabelFont" -l "Processing Commands / Script"`; 45 | 46 | // COMMANDFIELD 47 | string $BP_commandfield = `scrollField -w 350 -h 50 -ww 1 -ed 1 -fn "smallPlainLabelFont" -text "" -ann "" BP_commandfield`; 48 | 49 | // STATUSLINE 50 | string $BP_statusline = `progressBar -h 10 BP_status`; 51 | 52 | // STARTBUTTON 53 | string $BP_startbutton = `button -h 25 -label "Process Files" -command "BP_process"`; 54 | 55 | // RESETBUTTON 56 | string $BP_resetbutton = `button -h 25 -label "Reset" -ann "Reset if processing is interrupted due to command-errors or other problems, then check the log for details." -command "batchProcessor()"`; 57 | 58 | 59 | 60 | // ==== TABS 61 | string $BP_tabs = `tabLayout -sc "scrollField -e -text $BP_log BP_logfield" -innerMarginWidth 2 -innerMarginHeight 10 BP_tablayout`; 62 | 63 | // OPTIONS 64 | string $BP_tab1 = `columnLayout -w 350 -columnWidth 350 -adjustableColumn 0 -cal "center" -rowSpacing 0 -cat "both" 5 OptionsColumn`; 65 | 66 | textFieldButtonGrp -cw3 70 220 50 -l "Directory" -bc "BP_browse()" -bl " Select " -ann "Sets the directory in which Maya-files are going to be processed (example: C:/myfiles/maya/)" -text $BP_recentdirectory BP_directory; 67 | separator -height 15 -st "none"; 68 | 69 | radioButtonGrp -cw3 70 60 120 -l "Filter pattern" -nrb 2 -l1 "All files" -l2 "Use wildcard" -sl 1 -offCommand1 "textFieldGrp -e -en 1 BP_wildcard" -onCommand1 "textFieldGrp -e -en 0 BP_wildcard" BP_filter; 70 | textFieldGrp -en 0 -cw2 70 220 -l "Wildcard" -text "" -ann "Defines the wildcard-string to filter the files with (examples: *ground* or *.ma)" BP_wildcard; 71 | separator -height 10 -st "none"; 72 | 73 | radioButtonGrp -cw4 70 75 75 100 -l "Saving" -nrb 3 -l1 "Overwrite" -l2 "Add prefix" -l3 "Add suffix" -sl 1 -offCommand1 "textFieldGrp -e -en 1 BP_prefixsuffix" -onCommand1 "textFieldGrp -e -en 0 BP_prefixsuffix" BP_saving; 74 | textFieldGrp -en 0 -cw2 70 220 -l "Prefix/Suffix" -text "" -ann "Defines the prefix/suffix string to be attached to the name of processed files for saving (examples: new- or _test)" BP_prefixsuffix; 75 | 76 | setParent ..; 77 | 78 | // LOG 79 | string $BP_tab2 = `columnLayout -w 350 -columnWidth 350 -adjustableColumn 0 -cal "center" -rowSpacing 0 -cat "both" 5 LogColumn`; 80 | text -rs 0 -w 350 -al "center" -fn "smallPlainLabelFont" -l "Recent Processing Log"; 81 | separator -height 5 -st "none"; 82 | scrollField -w 350 -h 150 -ww 1 -ed 0 -cc "scrollField -e -text $BP_log BP_logfield" -fn "smallPlainLabelFont" -text "" BP_logfield; 83 | popupMenu -p BP_logfield; 84 | menuItem -label "Refresh log" -c "scrollField -e -text $BP_log BP_logfield"; 85 | 86 | setParent ..; 87 | 88 | // ABOUT 89 | string $BP_tab3 = `columnLayout -w 350 -columnWidth 350 -adjustableColumn 0 -cal "center" -rowSpacing 0 -cat "both" 5 AboutColumn`; 90 | 91 | string $BP_abouttext; 92 | 93 | $BP_abouttext = $BP_abouttext + "\nbatchProcessor V1.0 (01/2005 - All Rights Reserved)"; 94 | $BP_abouttext = $BP_abouttext + "\nby Edvard Toth"; 95 | $BP_abouttext = $BP_abouttext + "\nhttp://www.edvardtoth.com"; 96 | $BP_abouttext = $BP_abouttext + "\n======================"; 97 | 98 | $BP_abouttext = $BP_abouttext + "\nThe script is a highly versatile batch-processing utility which offers a way to apply virtually any single MEL-command, code-snippet or script to entire directories of Maya-files."; 99 | $BP_abouttext = $BP_abouttext + "\nIt provides comprehensive options to control how the files are identified, opened and saved, and it generates a detailed log to help track down any potential processing-interruptions due to command errors or other problems."; 100 | 101 | $BP_abouttext = $BP_abouttext + "\n\nA simple example: let's say we would like to scale all the contents of every file containing the word 'cube' in the directory C:/myfiles/maya/ by a factor of 5 on the Y axis, then save the resulting modified files with the '_scaled' suffix attached to them."; 102 | $BP_abouttext = $BP_abouttext + "\n\nThe settings for this process would be as follows:"; 103 | $BP_abouttext = $BP_abouttext + "\n Directory: C:/myfiles/maya/"; 104 | $BP_abouttext = $BP_abouttext + "\n File pattern: 'Use wildcard' selected"; 105 | $BP_abouttext = $BP_abouttext + "\n Wildcard: *cube*"; 106 | $BP_abouttext = $BP_abouttext + "\n Saving: 'Add suffix' selected"; 107 | $BP_abouttext = $BP_abouttext + "\n Prefix/suffix: _scaled"; 108 | 109 | $BP_abouttext = $BP_abouttext + "\n\nThe field reserved for the processing commands would contain the following commands to perform the Y-axis scaling:"; 110 | 111 | $BP_abouttext = $BP_abouttext + "\n\n select -cl;"; 112 | $BP_abouttext = $BP_abouttext + "\n select -all;"; 113 | $BP_abouttext = $BP_abouttext + "\n xform -r -os -s 1 5 1;"; 114 | 115 | $BP_abouttext = $BP_abouttext + "\n\nGiven that the files exist and everything is set up correctly, this should do it."; 116 | $BP_abouttext = $BP_abouttext + "\nOf course there are no rules regarding how simple or how complex the processing commands are: entire standalone scripts (procedures) could also be used for this purpose."; 117 | 118 | $BP_abouttext = $BP_abouttext + "\n\nAdditional tips:"; 119 | $BP_abouttext = $BP_abouttext + "\n- If the processing doesn't complete all they way through, use the Reset button to reset the script, and check the log to identify the stage at which the processing stopped."; 120 | $BP_abouttext = $BP_abouttext + "\n- Right-click on the log-field to refresh the contents of the log."; 121 | $BP_abouttext = $BP_abouttext + "\n- The most recently used directory is saved as a persistent variable, it's preserved even if Maya is restarted. The rest of the settings are not saved in this manner to prevent accidental (and potentially damaging) processing."; 122 | $BP_abouttext = $BP_abouttext + "\n- The directory can be set by browsing and selecting any of the Maya-files residing in the directory.\n"; 123 | 124 | scrollField -w 350 -h 171 -ww 1 -ed 0 -fn "smallPlainLabelFont" -text $BP_abouttext BP_aboutfield; 125 | 126 | setParent ..; 127 | 128 | 129 | 130 | formLayout -edit 131 | 132 | -attachForm $BP_tabs "top" 0 133 | -attachForm $BP_tabs "left" 0 134 | -attachNone $BP_tabs "bottom" 135 | -attachForm $BP_tabs "right" 0 136 | 137 | -attachControl $BP_header "top" 3 $BP_tabs 138 | -attachForm $BP_header "left" 0 139 | -attachForm $BP_header "right" 0 140 | -attachNone $BP_header "bottom" 141 | 142 | -attachControl $BP_commandfield "top" 3 $BP_header 143 | -attachForm $BP_commandfield "left" 0 144 | -attachForm $BP_commandfield "right" 0 145 | -attachControl $BP_commandfield "bottom" 3 $BP_statusline 146 | 147 | -attachNone $BP_statusline "top" 148 | -attachForm $BP_statusline "left" 0 149 | -attachForm $BP_statusline "right" 0 150 | -attachControl $BP_statusline "bottom" 3 $BP_startbutton 151 | 152 | -attachNone $BP_startbutton "top" 153 | -attachForm $BP_startbutton "left" 0 154 | -attachPosition $BP_startbutton "right" 0 85 155 | -attachForm $BP_startbutton "bottom" 0 156 | 157 | -attachNone $BP_resetbutton "top" 158 | -attachControl $BP_resetbutton "left" 0 $BP_startbutton 159 | -attachForm $BP_resetbutton "right" 0 160 | -attachForm $BP_resetbutton "bottom" 0 161 | 162 | 163 | 164 | $BP_form; 165 | 166 | tabLayout -e -tabLabel $BP_tab1 "Options" -tabLabel $BP_tab2 "Log" -tabLabel $BP_tab3 "About" $BP_tabs; 167 | 168 | 169 | showWindow; 170 | } 171 | 172 | 173 | // ==== PROCESS 174 | 175 | global proc BP_process () 176 | { 177 | 178 | int $BP_unsaved = `file -q -mf`; 179 | 180 | if ($BP_unsaved == 1) 181 | { 182 | confirmDialog -t "Oops..." -m ("Your current file contains unsaved changes. Please save the file first.") -b "Continue"; 183 | return; 184 | } 185 | 186 | // CLEAR LOG 187 | global string $BP_log; 188 | $BP_log = ""; 189 | scrollField -e -cl BP_logfield; 190 | 191 | string $BP_path = `textFieldButtonGrp -q -text BP_directory`; 192 | string $BP_file; 193 | 194 | string $BP_filelist[]; 195 | string $BP_filelistmb[]; 196 | string $BP_filteredlist[]; 197 | 198 | string $BP_wildcard; 199 | int $BP_wildcardmatch; 200 | 201 | int $BP_saving = `radioButtonGrp -q -sl BP_saving`; 202 | string $BP_prefixsuffix = `textFieldGrp -q -text BP_prefixsuffix`; 203 | 204 | string $BP_command = `scrollField -q -text BP_commandfield`; 205 | int $BP_commandsize = `size $BP_command`; 206 | 207 | string $BP_errorcheck; 208 | 209 | 210 | // PUT TOGETHER .MA AND .MB FILES 211 | $BP_filelist = `getFileList -fld $BP_path -fs "*.ma"`; 212 | $BP_filelistmb = `getFileList -fld $BP_path -fs "*.mb"`; 213 | appendStringArray ($BP_filelist, $BP_filelistmb, size($BP_filelistmb)); 214 | 215 | int $BP_filter = `radioButtonGrp -q -sl BP_filter`; 216 | 217 | // FILTER THE FILELIST USING THE WILDCARD STRING 218 | if ($BP_filter == 2) 219 | { 220 | int $j = 0; 221 | $BP_wildcard = `textFieldGrp -q -text BP_wildcard`; 222 | 223 | if (size ($BP_wildcard) == 0) 224 | { 225 | confirmDialog -t "Oops..." -m ("Please specify a wildcard string.") -b "Continue"; 226 | return; 227 | } 228 | int $BP_listsize = size ($BP_filelist); 229 | 230 | for ($i=0; $i < $BP_listsize; $i++) 231 | { 232 | $BP_wildcardmatch = `gmatch $BP_filelist[$i] $BP_wildcard`; 233 | 234 | if ($BP_wildcardmatch == 1) 235 | { 236 | $BP_filteredlist[$j] = $BP_filelist[$i]; 237 | $j++; 238 | } 239 | } 240 | 241 | $BP_filelist = $BP_filteredlist; 242 | } 243 | 244 | int $BP_listsize = size ($BP_filelist); 245 | 246 | if ($BP_listsize == 0) 247 | { 248 | confirmDialog -t "Oops..." -m ("Directory [" + $BP_path + "] contains no matching files to process.") -b "Continue"; 249 | return; 250 | } 251 | 252 | 253 | // CHECK PREFIXSUFFIX FOR SIZE AND ILLEGAL CHARACTERS 254 | if ($BP_saving == 2 || $BP_saving == 3) 255 | { 256 | if (size ($BP_prefixsuffix) == 0) 257 | { 258 | confirmDialog -t "Oops..." -m ("Please specify a prefix/suffix string.") -b "Continue"; 259 | return; 260 | } 261 | else 262 | { 263 | string $BP_prefixsuffixcheck = `match "[@#$%&*?\\/.;:|~]" $BP_prefixsuffix`; 264 | 265 | if (size ($BP_prefixsuffixcheck) != 0) 266 | { 267 | confirmDialog -t "Oops..." -m ("The prefix/suffix contains illegal characters.") -b "Continue"; 268 | return; 269 | } 270 | } 271 | } 272 | 273 | progressBar -e -beginProgress -maxValue $BP_listsize BP_status; 274 | 275 | // === OPENING / SAVING FILES 276 | 277 | $BP_log = ($BP_log + "\n === Starting processing in path " + $BP_path); 278 | 279 | for ($i=0; $i < $BP_listsize; $i++) 280 | { 281 | progressBar -e -step 1 BP_status; 282 | 283 | $BP_file = $BP_path + $BP_filelist[$i]; 284 | $BP_log = ($BP_log + "\n\n Opening file " + ($i+1) + " / " + $BP_listsize + ": " + $BP_filelist[$i]); 285 | 286 | // ========================== 287 | file -prompt 0 -open $BP_file; 288 | $BP_log = ($BP_log + "\n File opened."); 289 | 290 | // EXECUTE COMMAND 291 | if ($BP_commandsize != 0) 292 | { 293 | $BP_log = ($BP_log + "\n Executing processing commands..."); 294 | $BP_errorcheck = `eval $BP_command`; 295 | $BP_log = ($BP_log + "\n Commands executed."); 296 | } 297 | 298 | switch ($BP_saving) 299 | { 300 | // OVERWRITE 301 | case 1: 302 | $BP_log = ($BP_log + "\n Saving file as: " + $BP_filelist[$i]); 303 | file -prompt 0 -save; 304 | $BP_log = ($BP_log + "\n File saved."); 305 | break; 306 | 307 | // PREFIX 308 | case 2: 309 | string $BP_modifiedfile = $BP_path + $BP_prefixsuffix + $BP_filelist[$i]; 310 | $BP_log = ($BP_log + "\n Saving file as: " + $BP_prefixsuffix + $BP_filelist[$i]); 311 | file -rn $BP_modifiedfile; 312 | file -prompt 0 -save; 313 | $BP_log = ($BP_log + "\n File saved."); 314 | break; 315 | 316 | // SUFFIX 317 | case 3: 318 | string $BP_filenamesplit[]; 319 | int $BP_tokens = `tokenize $BP_filelist[$i] "." $BP_filenamesplit`; 320 | string $BP_modifiedfile = ($BP_path + $BP_filenamesplit[0] + $BP_prefixsuffix + "." + $BP_filenamesplit[1]); 321 | $BP_log = ($BP_log + "\n Saving file as: " + $BP_filenamesplit[0] + $BP_prefixsuffix + "." + $BP_filenamesplit[1]); 322 | file -rn $BP_modifiedfile; 323 | file -prompt 0 -save; 324 | $BP_log = ($BP_log + "\n File saved."); 325 | break; 326 | } 327 | } 328 | // =========================== 329 | 330 | progressBar -e -endProgress BP_status; 331 | 332 | $BP_log = ($BP_log + "\n\n === Successfully processed " + $BP_listsize + " files.\n"); 333 | 334 | scrollField -e -text $BP_log BP_logfield; 335 | } 336 | 337 | 338 | 339 | // ==== BROWSE 340 | 341 | global proc BP_browse () 342 | 343 | { 344 | string $BP_pickedfile = `fileDialog -dm "*.mb; *.ma"`; 345 | string $BP_dirname = `dirname $BP_pickedfile`; 346 | 347 | if (size ($BP_dirname) == 0) 348 | { 349 | confirmDialog -t "Oops..." -m "Please pick a valid file to identify working directory." -b "Continue"; 350 | return; 351 | } 352 | 353 | $BP_dirname = $BP_dirname + "/"; 354 | 355 | optionVar -sv "BP_recentdirectory" $BP_dirname; 356 | textFieldButtonGrp -e -text $BP_dirname BP_directory; 357 | } -------------------------------------------------------------------------------- /ParentToParticles.mel: -------------------------------------------------------------------------------- 1 | 2 | //================================= 3 | // ParentToParticles v3.0 (07/2004) 4 | // by Edvard Toth 5 | // (special thanks to Alex Carbonero) 6 | // 7 | // The script is freeware. Non-commercial redistribution is permitted as long as this header remains included and unmodified. 8 | // Your feedback is always appreciated - if you find the script useful or if you have questions, comments, suggestions, requests, 9 | // bug-reports, if you created an updated version, to check for updates or to make a donation please contact me at: 10 | // 11 | // http://www.edvardtoth.com 12 | // 13 | //================================== 14 | // INSTALLATION: Copy the script into your Maya script-directory and start it with the ParentToParticles; command. 15 | // 16 | // COMPATIBILITY NOTE: Tested with Maya 4.0 - 4.5 - 5.0 - 6.0 17 | // 18 | 19 | global proc ParentToParticles() 20 | 21 | { 22 | global string $PP_window = "ParentToParticles"; 23 | 24 | if (`window -ex $PP_window`) 25 | { 26 | deleteUI $PP_window; 27 | } 28 | 29 | window -t "ParentToParticles V3.0" -rtf 1 -w 320 -s 1 -mnb 1 -mxb 0 $PP_window; 30 | 31 | formLayout PP_ButtonForm; 32 | 33 | scrollLayout -cr 1 Scroll; 34 | 35 | columnLayout -w 200 -columnWidth 200 -adjustableColumn 0 -cal "center" -rowSpacing 0 -cat "left" 5 MainColumn; 36 | 37 | 38 | // OPTIONS FRAME 39 | 40 | frameLayout -label "Main Options" -collapse 0 -collapsable 1 -bs "etchedOut" OptionsFrame; 41 | columnLayout -adjustableColumn 0 -cal "center" -rowSpacing 1 -cat "left" 5 OptionsColumn; 42 | 43 | global string $PP_TheObject; 44 | global string $PP_TheTarget; 45 | 46 | global string $PP_DupMode; 47 | global string $PP_ScaleMode; 48 | 49 | separator -h 3 -st "none" ; 50 | 51 | $PP_DupMode = `radioButtonGrp -nrb 2 -label "Mode" -labelArray2 "Duplicate" "Instance" -cw 1 60 -cw 2 70 -sl 1` ; 52 | 53 | separator -height 3 -st "none"; 54 | 55 | checkBoxGrp -ncb 1 -v1 0 -cw2 170 30 -label "Use Constraints?" UseConstrain; 56 | 57 | separator -height 2 -st "none"; 58 | 59 | checkBoxGrp -ncb 1 -v1 1 -cw2 170 30 -label "Constrain To Surface Normals" NormalConstrain; 60 | checkBoxGrp -ncb 1 -v1 1 -cw2 170 30 -label "Constrain To Surface Geometry" GeoConstrain; 61 | checkBoxGrp -ncb 1 -v1 0 -cw2 170 30 -label "Auto-Delete Constrain Nodes" DeleteConstrain; 62 | 63 | separator -height 3 -st "none"; 64 | 65 | radioButtonGrp -numberOfRadioButtons 3 -cw4 100 30 30 30 -annotation "Defines which axis of the objects is going to be constrained to the normals of the target surface." -label "Aim Vector" -labelArray3 "x" "y" "z" -sl 2 AimVector; 66 | 67 | setParent MainColumn; 68 | 69 | 70 | // ROTATION FRAME 71 | 72 | frameLayout -label "Rotation Options" -collapse 0 -collapsable 1 -bs "etchedOut" RotationFrame; 73 | columnLayout -adjustableColumn 0 -cal "center" -rowSpacing 0 -cat "left" 5 RotationColumn; 74 | 75 | separator -h 3 -st "none" ; 76 | 77 | intSliderGrp -cw3 50 30 100 -l "X Min" -field 1 -min -360 -max 360 -v 0 PP_rotminx ; 78 | intSliderGrp -cw3 50 30 100 -l "X Max" -field 1 -min -360 -max 360 -v 0 PP_rotmaxx ; 79 | 80 | intSliderGrp -cw3 50 30 100 -l "Y Min" -field 1 -min -360 -max 360 -v 0 PP_rotminy ; 81 | intSliderGrp -cw3 50 30 100 -l "Y Max" -field 1 -min -360 -max 360 -v 0 PP_rotmaxy ; 82 | 83 | intSliderGrp -cw3 50 30 100 -l "Z Min" -field 1 -min -360 -max 360 -v 0 PP_rotminz ; 84 | intSliderGrp -cw3 50 30 100 -l "Z Max" -field 1 -min -360 -max 360 -v 0 PP_rotmaxz ; 85 | 86 | separator -h 3 -st "none" ; 87 | 88 | setParent MainColumn; 89 | 90 | 91 | // SCALING FRAME 92 | 93 | frameLayout -label "Scaling Options" -collapse 0 -collapsable 1 -bs "etchedOut" ScalingFrame; 94 | columnLayout -adjustableColumn 0 -cal "center" -rowSpacing 0 -cat "left" 5 ScalingColumn; 95 | 96 | separator -h 3 -st "none" ; 97 | 98 | $PP_ScaleMode = `radioButtonGrp -numberOfRadioButtons 2 -label "Scaling" -labelArray2 "Uniform" "Non-Uniform" -cw 1 60 -cw 2 70 -sl 2` ; 99 | 100 | separator -h 3 -st "none" ; 101 | 102 | floatSliderGrp -cw3 50 30 100 -l "Uni Min" -field 1 -min 0 -max 10 -v 1 PP_unimin ; 103 | floatSliderGrp -cw3 50 30 100 -l "Uni Max" -field 1 -min 0 -max 10 -v 1 PP_unimax ; 104 | 105 | separator -h 5 -st "none" ; 106 | 107 | floatSliderGrp -cw3 50 30 100 -l "X Min" -field 1 -min 0 -max 10 -v 1 PP_scalminx ; 108 | floatSliderGrp -cw3 50 30 100 -l "X Max" -field 1 -min 0 -max 10 -v 1 PP_scalmaxx ; 109 | 110 | floatSliderGrp -cw3 50 30 100 -l "Y Min" -field 1 -min 0 -max 10 -v 1 PP_scalminy ; 111 | floatSliderGrp -cw3 50 30 100 -l "Y Max" -field 1 -min 0 -max 10 -v 1 PP_scalmaxy ; 112 | 113 | floatSliderGrp -cw3 50 30 100 -l "Z Min" -field 1 -min 0 -max 10 -v 1 PP_scalminz ; 114 | floatSliderGrp -cw3 50 30 100 -l "Z Max" -field 1 -min 0 -max 10 -v 1 PP_scalmaxz ; 115 | 116 | separator -h 3 -st "none" ; 117 | 118 | setParent MainColumn; 119 | 120 | // ABOUT FRAME 121 | 122 | frameLayout -label "About" -collapse true -collapsable true -bs "etchedOut" AboutFrame; 123 | columnLayout -adjustableColumn false -cal "left" -rowSpacing 0 -cat "left" 5 AboutColumn; 124 | 125 | string $PP_abouttext = "ParentToParticles V3.0 (07/2004)\n"; 126 | $PP_abouttext += "by Edvard Toth\n"; 127 | $PP_abouttext += "http://www.edvardtoth.com\n\n"; 128 | 129 | $PP_abouttext += "The script offers a potential way to rapidly and precisely place and adjust a large number of objects using particles as placement-proxies.\n"; 130 | $PP_abouttext += "Try the following steps as a quick tutorial:\n"; 131 | $PP_abouttext += "- Create a cube, select it and press the 'Set object' button.\n"; 132 | $PP_abouttext += "- Create a sphere that's much larger than the cube, select it, and press the 'Set target surface' button.\n"; 133 | $PP_abouttext += "- With the sphere selected, hit the 'Make Live' button. The sphere turns wireframe.\n"; 134 | $PP_abouttext += "- Press the 'Particle Tool' button (or right-click on it for options): now you can paint particles directly onto the surface of the sphere.\n"; 135 | $PP_abouttext += "- Press 'Enter' to finish placing particles, and select the resulting particle-field.\n"; 136 | $PP_abouttext += "- Make sure all checkboxes at the top except 'Auto-Delete Constrain Nodes' are checked.\n"; 137 | $PP_abouttext += "- Set some random scaling-values (rotation is meaningful only when no constraints are used).\n"; 138 | $PP_abouttext += "- Press the 'Perform Placement' button.\n\n"; 139 | $PP_abouttext += "A randomly scaled duplicate/instance of the original cube is placed at every particle, and each one is constrained to the surface of the sphere."; 140 | $PP_abouttext += "Even if you move the cubes around they will 'stick' and maintain their orientation to the normals of the sphere-surface. To break the constraints use the 'Delete All Constraints' button."; 141 | $PP_abouttext += "Feel free to experiment with other combinations of settings, e.g. using only normal-constraints, different aim-vectors, using no constraints at all, changing rotation/scaling settings, or the particle-tool."; 142 | $PP_abouttext += "The script is particularly useful for tasks like placing rocks or plant-life on uneven terrain without excessive manual tweaking. \nEnjoy.\n"; 143 | 144 | separator -height 3 -st "none"; 145 | 146 | scrollField -w 240 -h 150 -ww 1 -ed 0 -fn "smallPlainLabelFont" -text $PP_abouttext; 147 | 148 | separator -height 3 -st "none"; 149 | 150 | setParent MainColumn; 151 | 152 | 153 | // USER INTERFACE 154 | 155 | setParent -top; 156 | 157 | $PP_objectbutton= `button -h 20 -label "Set Object" -command "PP_setobject()" -ann "Sets an object to be duplicated/instanced."`; 158 | $PP_surfacebutton= `button -h 20 -label "Set Target Surface" -command "PP_settarget()" -ann "Sets an object as the target surface for the constrain-operations."`; 159 | $PP_makelivebutton= `button -h 20 -label "Make Live" -command "MakeLive" -ann "Turns the selected object Live to make particles stick to its surface."`; 160 | $PP_particlebutton= `button -h 20 -label "ParticleTool" -command "ParticleTool" -ann "Activate the particle placement tool."`; 161 | 162 | $PP_placementbutton= `button -h 30 -label "Perform Placement" -command "PP_placement()"`; 163 | 164 | $PP_deletebutton= `button -h 20 -label "Delete All Constraints" -command "delete -all -cn" -ann "Deletes any residual constrain-nodes."`; 165 | $PP_resetbutton= `button -h 20 -label "Reset" -command "ndiShrubber()"`; 166 | 167 | formLayout -edit 168 | 169 | -attachForm $PP_deletebutton "left" 1 170 | -attachForm $PP_deletebutton "bottom" 1 171 | -attachPosition $PP_deletebutton "right" 0 70 172 | 173 | -attachControl $PP_resetbutton "left" 1 $PP_deletebutton 174 | -attachForm $PP_resetbutton "bottom" 1 175 | -attachForm $PP_resetbutton "right" 1 176 | 177 | -attachForm $PP_placementbutton "left" 1 178 | -attachControl $PP_placementbutton "bottom" 1 $PP_deletebutton 179 | -attachForm $PP_placementbutton "right" 1 180 | 181 | 182 | -attachForm $PP_makelivebutton "left" 1 183 | -attachControl $PP_makelivebutton "bottom" 1 $PP_placementbutton 184 | -attachPosition $PP_makelivebutton "right" 0 50 185 | 186 | -attachControl $PP_particlebutton "left" 1 $PP_makelivebutton 187 | -attachControl $PP_particlebutton "bottom" 1 $PP_placementbutton 188 | -attachForm $PP_particlebutton "right" 1 189 | 190 | 191 | -attachForm $PP_objectbutton "left" 1 192 | -attachControl $PP_objectbutton "bottom" 1 $PP_makelivebutton 193 | -attachPosition $PP_objectbutton "right" 0 50 194 | 195 | -attachControl $PP_surfacebutton "left" 1 $PP_objectbutton 196 | -attachControl $PP_surfacebutton "bottom" 1 $PP_particlebutton 197 | -attachForm $PP_surfacebutton "right" 1 198 | 199 | -attachForm Scroll "top" 1 200 | -attachForm Scroll "left" 1 201 | -attachForm Scroll "right" 1 202 | -attachControl Scroll "bottom" 1 $PP_objectbutton 203 | 204 | PP_ButtonForm; 205 | 206 | popupMenu -p $PP_particlebutton; 207 | menuItem -label "Particle Tool Options" -c "ParticleToolOptions"; 208 | 209 | popupMenu -p $PP_objectbutton; 210 | menuItem -label "Select Current Object" -c "select -r $PP_TheObject"; 211 | 212 | popupMenu -p $PP_surfacebutton; 213 | menuItem -label "Select Current Target Surface" -c "select -r $PP_TheTarget"; 214 | 215 | 216 | showWindow; 217 | } 218 | 219 | 220 | // THE PLACEMENT PROCESS 221 | 222 | global proc PP_placement() 223 | 224 | { 225 | global string $PP_TheObject; 226 | global string $PP_TheTarget; 227 | 228 | // Do we have an object set? 229 | if ( size ($PP_TheObject) == 0 ) 230 | { 231 | confirmDialog -t "Oops..." -m "Please set an object first." -b "Continue"; 232 | return; 233 | } 234 | 235 | // Are constraints used? Do we have a target surface set? 236 | string $PP_UseButton = `checkBoxGrp -q -v1 UseConstrain`; 237 | 238 | if ($PP_UseButton == 1) 239 | { 240 | if ( size ($PP_TheTarget) == 0 ) 241 | { 242 | confirmDialog -t "Oops..." -m "Please set a target surface first, or disable the use of constraints." -b "Continue"; 243 | return; 244 | } 245 | } 246 | 247 | // Do we have something selected? If yes, are they particles? 248 | string $PP_objects[] = `ls -sl`; 249 | 250 | if ( size ($PP_objects) == 0 ) 251 | { 252 | confirmDialog -t "Oops..." -m "Nothing is selected to define placement." -b "Continue"; 253 | return; 254 | } 255 | string $PP_particleCheckA[]=`ls -l $PP_objects[0]`; 256 | string $PP_particleCheckB[]=`listRelatives -f -ni -s $PP_particleCheckA[0]`; 257 | 258 | if (nodeType($PP_particleCheckB[0])!="particle") 259 | { 260 | confirmDialog -t "Oops..." -m "Only particles can be used to define placement." -b Continue; 261 | return; 262 | } 263 | 264 | 265 | global string $PP_DupMode; 266 | global string $PP_ScaleMode; 267 | 268 | string $PP_NormalButton = `checkBoxGrp -q -v1 NormalConstrain`; 269 | string $PP_GeoButton = `checkBoxGrp -q -v1 GeoConstrain`; 270 | string $PP_DeleteButton = `checkBoxGrp -q -v1 DeleteConstrain`; 271 | int $PP_AimButton = `radioButtonGrp -q -sl AimVector`; 272 | 273 | global string $PP_TheResult[]; 274 | 275 | string $PP_NewItem[]; 276 | 277 | int $PP_RadioButton = `radioButtonGrp -q -sl $PP_DupMode`; 278 | int $PP_ScaleButton = `radioButtonGrp -q -sl $PP_ScaleMode`; 279 | 280 | int $PP_rotminx = `intSliderGrp -q -v PP_rotminx`; 281 | int $PP_rotmaxx = `intSliderGrp -q -v PP_rotmaxx`; 282 | int $PP_rotminy = `intSliderGrp -q -v PP_rotminy`; 283 | int $PP_rotmaxy = `intSliderGrp -q -v PP_rotmaxy`; 284 | int $PP_rotminz = `intSliderGrp -q -v PP_rotminz`; 285 | int $PP_rotmaxz = `intSliderGrp -q -v PP_rotmaxz`; 286 | 287 | float $PP_unimin = `floatSliderGrp -q -v PP_unimin`; 288 | float $PP_unimax = `floatSliderGrp -q -v PP_unimax`; 289 | 290 | float $PP_scalminx = `floatSliderGrp -q -v PP_scalminx`; 291 | float $PP_scalmaxx = `floatSliderGrp -q -v PP_scalmaxx`; 292 | float $PP_scalminy = `floatSliderGrp -q -v PP_scalminy`; 293 | float $PP_scalmaxy = `floatSliderGrp -q -v PP_scalmaxy`; 294 | float $PP_scalminz = `floatSliderGrp -q -v PP_scalminz`; 295 | float $PP_scalmaxz = `floatSliderGrp -q -v PP_scalmaxz`; 296 | 297 | 298 | for ($obj in $PP_objects) 299 | { 300 | 301 | select $obj; 302 | 303 | int $PP_ParticleCount = `particle -count -q`; 304 | 305 | int $i; 306 | 307 | for ($i = 0; $i < $PP_ParticleCount; $i++) 308 | { 309 | select -r ($obj + ".pt[" + $i + "]") ; 310 | float $PP_WorldPos[3] = `particle -at worldPosition -or $i -q`; 311 | 312 | int $PP_rotX = rand ($PP_rotminx, $PP_rotmaxx); 313 | int $PP_rotY = rand ($PP_rotminy, $PP_rotmaxy); 314 | int $PP_rotZ = rand ($PP_rotminz, $PP_rotmaxz); 315 | 316 | float $PP_uni = rand ($PP_unimin, $PP_unimax); 317 | 318 | float $PP_scalX = rand ($PP_scalminx, $PP_scalmaxx); 319 | float $PP_scalY = rand ($PP_scalminy, $PP_scalmaxy); 320 | float $PP_scalZ = rand ($PP_scalminz, $PP_scalmaxz); 321 | 322 | select $PP_TheObject; 323 | 324 | if ($PP_RadioButton == 1) 325 | { 326 | $PP_NewItem= `duplicate -rr`; 327 | $PP_TheResult[$i]= $PP_NewItem[0]; 328 | } 329 | 330 | if ($PP_RadioButton == 2) 331 | { 332 | $PP_NewItem= `instance`; 333 | $PP_TheResult[$i]= $PP_NewItem[0]; 334 | } 335 | 336 | move -ws $PP_WorldPos[0] $PP_WorldPos[1] $PP_WorldPos[2]; 337 | rotate -os $PP_rotX $PP_rotY $PP_rotZ; 338 | 339 | switch ($PP_ScaleButton) 340 | { 341 | case 1: 342 | scale -r $PP_uni $PP_uni $PP_uni; 343 | break; 344 | 345 | case 2: 346 | scale -r $PP_scalX $PP_scalY $PP_scalZ; 347 | break; 348 | } 349 | 350 | 351 | if ($PP_UseButton == 1) 352 | { 353 | if ($PP_NormalButton == 1) 354 | { 355 | switch ($PP_AimButton) 356 | { 357 | case 1: 358 | normalConstraint -aimVector 1 0 0 -wut "vector" $PP_TheTarget $PP_NewItem[0]; 359 | break; 360 | 361 | case 2: 362 | normalConstraint -aimVector 0 1 0 -wut "vector" $PP_TheTarget $PP_NewItem[0]; 363 | break; 364 | 365 | case 3: 366 | normalConstraint -aimVector 0 0 1 -wut "vector" $PP_TheTarget $PP_NewItem[0]; 367 | break; 368 | } 369 | } 370 | if ($PP_GeoButton == 1) 371 | { 372 | geometryConstraint $PP_TheTarget $PP_NewItem[0]; 373 | } 374 | } 375 | 376 | } 377 | 378 | if ($PP_DeleteButton == 1) 379 | { 380 | select -r $PP_TheResult; 381 | delete -cn; 382 | } 383 | } 384 | clear $PP_NewItem; 385 | select -r $PP_TheResult; 386 | } 387 | 388 | 389 | 390 | // SET OBJECT 391 | 392 | global proc PP_setobject() 393 | 394 | { 395 | string $PP_preObject[] = `ls -sl`; 396 | 397 | if ( size ($PP_preObject [0]) == 0 ) 398 | { 399 | confirmDialog -t "Oops..." -m "Please select an object." -b Continue; 400 | return; 401 | } 402 | 403 | global string $PP_TheObject; 404 | $PP_TheObject = $PP_preObject[0]; 405 | 406 | confirmDialog -t "Yeah!" -m ("The selected object is: " + $PP_preObject[0]) -b "Continue"; 407 | } 408 | 409 | 410 | // SET TARGET SURFACE 411 | 412 | global proc PP_settarget() 413 | 414 | { 415 | string $PP_preTarget[] = `ls -sl`; 416 | 417 | if ( size ($PP_preTarget[0]) == 0 ) 418 | { 419 | confirmDialog -t "Oops..." -m "Please select a target surface." -b "Continue"; 420 | return; 421 | } 422 | 423 | global string $PP_TheTarget; 424 | $PP_TheTarget = $PP_preTarget[0]; 425 | 426 | confirmDialog -t "Yeah!" -m ("The selected target surface is: " + $PP_preTarget[0]) -b "Continue"; 427 | } 428 | 429 | -------------------------------------------------------------------------------- /uniToolBox.mel: -------------------------------------------------------------------------------- 1 | //===================================== 2 | // uniToolBox v2.0 (01/2006) 3 | // by Edvard Toth 4 | // 5 | // The script is freeware. Non-commercial redistribution is permitted as long as this header remains included and unmodified. 6 | // Your feedback is always appreciated - if you find the script useful or if you have questions, comments, suggestions, requests 7 | // or bug-reports please contact me at: 8 | // 9 | // http://www.edvardtoth.com 10 | // 11 | //===================================== 12 | // INSTALLATION: Copy the script into your Maya script-directory and start it with the "uniToolBox X;" command, where "X" represents 13 | // an integer value between 0 and 3, which determines how the script's user interface is rendered. The possible values are: 14 | // 15 | // uniToolBox 0; - the script UI is opened in its own window 16 | // uniToolBox 1; - the script UI is docked at the top of the Channels/Layers panel 17 | // uniToolBox 2; - the script UI is docked at the middle of the Channels/Layers panel 18 | // uniToolBox 3; - the script UI is docked at the bottom of the Channels/Layers panel 19 | // 20 | // COMPATIBILITY NOTE: Tested with Maya 4 - 5 - 6 - 6.5 - 7 21 | // 22 | // DESCRIPTION: 23 | // The script creates a Swiss Army-knife style unified interface featuring contols grouped in collapsible frames 24 | // for a number of functions and operations. It includes a comprehensive collection of display-property and shading controls, 25 | // selection conversion, UV-mapping, prelighting and layer commands. 26 | // The status of the collapsible frames is always remembered, even between Maya-restarts. 27 | // 28 | // Please note that right-clicking on darker gray buttons will bring up additional sub-commands and/or options. 29 | // (Important: the buttons will always execute their assigned command using the most recent settings for that particular command. 30 | // You can access the command's options-window and modify its settings by right-clicking on the button or by locating its option-box 31 | // within the standard Maya-interface. 32 | // 33 | // THE USER TAB: The buttons in this tab are configurable by the user through a configuration file called "uniToolBoxUser.txt" which 34 | // should be placed in the same directory (parsed by Maya at startup) where the uniToolBox.mel script itself is located. 35 | // The file should contain button-listings in the following format: 36 | // 37 | // buttonname1,"buttoncommand1" 38 | // buttonname2,"buttoncommand2" 39 | // buttonname3,"buttoncommand3" 40 | // etc. 41 | // 42 | // Watch for unwanted extra spaces or line breaks when creating the configuration file, as they can generate 43 | // additional non-functioning buttons. 44 | // 45 | // And finally, after executing the script the subroutines can be accessed individually, or even hotkeyed: 46 | // 47 | // UTB_toggleWOS; 48 | // UTB_toggleXRay; 49 | // UTB_toggleLocators; 50 | // UTB_toggleVIS; 51 | // UTB_triangleCount; 52 | // UTB_reloadTextures; 53 | // UTB_centerToView; 54 | // UTB_selectedLayerOnly; 55 | // UTB_dispLayers 0 or 1; 56 | // UTB_toggleLayers; 57 | // UTB_addToLayer; 58 | // UTB_selectLayerObjects; 59 | // UTB_disconnectLightLinker; 60 | 61 | 62 | global proc uniToolBox (int $UTB_switch) 63 | { 64 | 65 | if ($UTB_switch < 0 || $UTB_switch > 3) 66 | { 67 | confirmDialog -t "Oops..." -m "Please use one of the following startup-attributes:\nuniToolBox 0; - the script UI is opened in its own window.\nuniToolBox 1; - the script UI is docked at the top of the Channels/Layers panel.\nuniToolBox 2; - the script UI is docked at the middle of the Channels/Layers panel.\nuniToolBox 3; - the script UI is docked at the bottom of the Channels/Layers panel." 68 | -b Continue; 69 | return; 70 | } 71 | 72 | int $UTB_switchdisplay = `optionVar -q "UTB_switchdisplay"`; 73 | int $UTB_switchshading = `optionVar -q "UTB_switchshading"`; 74 | int $UTB_switchnormals = `optionVar -q "UTB_switchnormals"`; 75 | int $UTB_switchedges = `optionVar -q "UTB_switchedges"`; 76 | int $UTB_switchtriangles = `optionVar -q "UTB_switchtriangles"`; 77 | int $UTB_switchuv = `optionVar -q "UTB_switchuv"`; 78 | int $UTB_switchprelight = `optionVar -q "UTB_switchprelight"`; 79 | int $UTB_switchselection = `optionVar -q "UTB_switchselection"`; 80 | int $UTB_switchlayers = `optionVar -q "UTB_switchlayers"`; 81 | int $UTB_switchuser = `optionVar -q "UTB_switchuser"`; 82 | 83 | 84 | global string $UTB_win = "uniToolBox"; 85 | global string $UTB_aboutwin = "UTB_About"; 86 | 87 | if (`window -ex $UTB_win`) 88 | { 89 | deleteUI $UTB_win; 90 | } 91 | if (`window -ex $UTB_aboutwin`) 92 | { 93 | deleteUI $UTB_aboutwin; 94 | } 95 | 96 | if (`layout -ex UniForm`) 97 | { 98 | deleteUI UniForm; 99 | paneLayout -e -configuration horizontal2 ChannelsLayersPaneLayout; 100 | 101 | setParent ChannelsLayersPaneLayout; 102 | 103 | global string $gChannelBoxForm; 104 | global string $gLayerEditorForm; 105 | 106 | setParent ChannelsLayersPaneLayout; 107 | 108 | columnLayout $gChannelBoxForm; 109 | columnLayout $gLayerEditorForm; 110 | 111 | paneLayout -e -setPane $gChannelBoxForm 1 ChannelsLayersPaneLayout; 112 | paneLayout -e -setPane $gLayerEditorForm 2 ChannelsLayersPaneLayout; 113 | } 114 | 115 | 116 | if (!`isUIComponentVisible("Channel Box / Layer Editor")`) 117 | { 118 | toggleUIComponentVisibility("Channel Box / Layer Editor"); 119 | } 120 | 121 | 122 | switch ($UTB_switch) 123 | { 124 | 125 | case 0: 126 | window -t "uniToolBox V2.0" -rtf 1 -w 100 -h 100 -s 1 -mnb 1 -mxb 0 $UTB_win; 127 | break; 128 | case 1: 129 | case 2: 130 | case 3: 131 | setParent ChannelsLayersPaneLayout; 132 | break; 133 | } 134 | 135 | 136 | formLayout UniForm; 137 | scrollLayout -hst 8 -vst 8 -cr 1 Scroll; 138 | 139 | columnLayout -w 100 -columnWidth 100 -rowSpacing 1 -columnAlign "center" -co "both" 2 MainColumn; 140 | 141 | 142 | /// DISPLAY 143 | 144 | frameLayout -label " Display" 145 | -bv 1 -bs "etchedOut" 146 | -bgc 0.8 0.6 0.6 -mw 4 -mh 4 147 | -collapse $UTB_switchdisplay -collapsable true 148 | -cc "UTB_framestateupdate" 149 | -ec "UTB_framestateupdate" 150 | DisplayFrame; 151 | columnLayout -adjustableColumn false -rowSpacing 0 DisplayColumn; 152 | 153 | button -w 100 -h 18 -label "CenterToView" -command "UTB_centerToView()"; 154 | 155 | separator -h 4 -w 100 -bgc 0.8 0.6 0.6 -st "none"; 156 | 157 | button -w 100 -h 18 -label "Grid" -bgc 0.74 0.74 0.74 -command "ToggleGrid"; 158 | popupMenu; 159 | 160 | menuItem -label "Grid Options" -c "performGridOptions 1"; 161 | 162 | button -w 100 -h 18 -label "WireOnShaded" -command "UTB_toggleWOS()"; 163 | button -w 100 -h 18 -label "XRay" -command "UTB_toggleXRay()"; 164 | button -w 100 -h 18 -label "Locators" -command "UTB_toggleLocators()"; 165 | 166 | separator -h 4 -w 100 -bgc 0.8 0.6 0.6 -st "none"; 167 | 168 | text -w 100 -label "BackFaceCulling" -bgc 0.8 0.6 0.6; 169 | popupMenu; 170 | menuItem -label "BackFaceCulling On" -c "polyOptions -fb"; 171 | menuItem -label "BackFaceCulling Off" -c "polyOptions -bc"; 172 | 173 | text -w 100 -label "MiscDisplayItems" -bgc 0.8 0.6 0.6; 174 | popupMenu; 175 | menuItem -label "Vertices" -command "polyOptions -r -dv false"; 176 | menuItem -label "NurbsCVs" -command "ToggleCVs"; 177 | menuItem -label "TextureBorders" -command "polyOptions -r -dmb false"; 178 | menuItem -label "NonPlanarFaces" -command "polyOptions -r -dw false"; 179 | menuItem -label "FaceCenters" -command "TogglePolygonFaceCenters;"; 180 | menuItem -label "LatticePoints" -command "ToggleLatticePoints;"; 181 | 182 | text -w 100 -label "Show/Hide" -bgc 0.8 0.6 0.6; 183 | popupMenu; 184 | menuItem -label "ToggleVisibility" -command "UTB_toggleVIS()"; 185 | menuItem -label "ShowSelection" -command "ShowSelectedObjects"; 186 | menuItem -label "HideSelection" -command "HideSelectedObjects"; 187 | menuItem -label "ShowLastHidden" -command "ShowLastHidden"; 188 | menuItem -label "HideUnselected" -command "HideUnselectedObjects"; 189 | 190 | 191 | setParent MainColumn; 192 | 193 | 194 | /// SHADING 195 | 196 | frameLayout -label " Shading" 197 | -bv 1 -bs "etchedOut" 198 | -bgc 0.8 0.6 0.6 -mw 4 -mh 4 199 | -collapse $UTB_switchshading -collapsable true 200 | -cc "UTB_framestateupdate" 201 | -ec "UTB_framestateupdate" 202 | ShadingFrame; 203 | columnLayout -adjustableColumn false -rowSpacing 0 ShadingColumn; 204 | 205 | button -w 100 -h 18 -label "Wireframe" -command "UTB_shading 0"; 206 | button -w 100 -h 18 -label "Smooth" -command "UTB_shading 1"; 207 | button -w 100 -h 18 -label "Textures" -command "UTB_shading 2"; 208 | button -w 100 -h 18 -label "VertexColors" -command "UTB_shading 3"; 209 | button -w 100 -h 18 -label "VtxCol/Txt" -command "UTB_shading 4"; 210 | button -w 100 -h 18 -label "VtxCol/Txt/Lights" -command "UTB_shading 5"; 211 | 212 | separator -h 4 -w 100 -bgc 0.8 0.6 0.6 -st "none"; 213 | 214 | button -w 100 -h 18 -label "NoLights" -command "UTB_shading 6"; 215 | button -w 100 -h 18 -label "DefaultLights" -command "UTB_shading 7"; 216 | button -w 100 -h 18 -label "ActiveLights" -command "UTB_shading 8"; 217 | button -w 100 -h 18 -label "AllLights" -command "UTB_shading 9"; 218 | 219 | setParent MainColumn; 220 | 221 | 222 | /// NORMALS 223 | 224 | frameLayout -label " Normals" 225 | -bv 1 -bs "etchedOut" 226 | -bgc 0.6 0.7 0.8 -mw 4 -mh 4 227 | -collapse $UTB_switchnormals -collapsable true 228 | -cc "UTB_framestateupdate" 229 | -ec "UTB_framestateupdate" 230 | NormalFrame; 231 | columnLayout -adjustableColumn false -rowSpacing 0 NormalColumn; 232 | 233 | button -w 100 -h 18 -label "FaceNormals" -bgc 0.74 0.74 0.74 -command "polyOptions -r -dn false -f"; 234 | popupMenu; 235 | menuItem -label "Short Normals" -c "setNormalsSize .16"; 236 | menuItem -label "Medium Normals" -c "setNormalsSize .4"; 237 | menuItem -label "Long Normals" -c "setNormalsSize 1"; 238 | 239 | button -w 100 -h 18 -label "VertexNormals" -bgc 0.74 0.74 0.74 -command "polyOptions -r -dn false -pt"; 240 | popupMenu; 241 | 242 | menuItem -label "Short Normals" -c "setNormalsSize .16"; 243 | menuItem -label "Medium Normals" -c "setNormalsSize .4"; 244 | menuItem -label "Long Normals" -c "setNormalsSize 1"; 245 | 246 | button -w 100 -h 18 -label "ReverseNormals" -command "polyNormal -normalMode 3 -ch 1"; 247 | button -w 100 -h 18 -label "AverageNormals" -bgc 0.74 0.74 0.74 -command "performPolyAverageNormal 0"; 248 | popupMenu; 249 | 250 | menuItem -label "AverageNormals Options" -command "performPolyAverageNormal 1"; 251 | 252 | button -w 100 -h 18 -label "UnlockNormals" -command "polyNormalPerVertex -ufn true"; 253 | 254 | setParent MainColumn; 255 | 256 | /// EDGES 257 | 258 | frameLayout -label " Edges" 259 | -bv 1 -bs "etchedOut" 260 | -bgc 0.6 0.7 0.8 -mw 4 -mh 4 261 | -collapse $UTB_switchedges -collapsable true 262 | -cc "UTB_framestateupdate" 263 | -ec "UTB_framestateupdate" 264 | EdgeFrame; 265 | columnLayout -adjustableColumn false -rowSpacing 0 EdgeColumn; 266 | 267 | button -w 100 -h 18 -label "MakeHardEdges" -command "polySoftEdge -a 0 -ch 1"; 268 | button -w 100 -h 18 -label "MakeSoftEdges" -command "polySoftEdge -a 180 -ch 1"; 269 | 270 | separator -h 4 -w 100 -st "none" -bgc 0.6 0.7 0.8; 271 | 272 | text -w 100 -label "EdgeDisplay" -bgc 0.6 0.7 0.8; 273 | popupMenu; 274 | menuItem -label "DisplayAllEdges" -command "polyOptions -ae"; 275 | menuItem -label "DisplayHardEdges" -command "polyOptions -he"; 276 | menuItem -label "DisplaySoftEdges" -command "polyOptions -se"; 277 | 278 | setParent MainColumn; 279 | 280 | 281 | /// TRIANGLES 282 | 283 | frameLayout -label " Triangles" 284 | -bv 1 -bs "etchedOut" 285 | -bgc 0.6 0.7 0.8 -mw 4 -mh 4 286 | -collapse $UTB_switchtriangles -collapsable true 287 | -cc "UTB_framestateupdate" 288 | -ec "UTB_framestateupdate" 289 | TriangleFrame; 290 | columnLayout -adjustableColumn false -rowSpacing 0 TriangleColumn; 291 | 292 | button -w 100 -h 18 -label "DisplayTriangles" -command "polyOptions -r -dt false"; 293 | button -w 100 -h 18 -label "Triangulate" -command "polyTriangulate -ch 1"; 294 | button -w 100 -h 18 -label "Quadrangulate" -bgc 0.74 0.74 0.74 -command "performPolyQuadrangulate 0"; 295 | popupMenu; 296 | menuItem -label "Quadrangulate Options" -command "performPolyQuadrangulate 1"; 297 | 298 | button -w 100 -h 18 -label "FlipTriangleEdge" -command "polyFlipEdge"; 299 | 300 | separator -h 4 -w 100 -bgc 0.6 0.7 0.8 -st "none"; 301 | 302 | button -w 100 -h 18 -label "TriangleCount" -command "UTB_triangleCount()"; 303 | 304 | setParent MainColumn; 305 | 306 | /// UV MAPPING 307 | 308 | frameLayout -label " UV Mapping" 309 | -bv 1 -bs "etchedOut" 310 | -bgc 0.7 0.6 0.5 -mw 4 -mh 4 311 | -collapse $UTB_switchuv -collapsable true 312 | -cc "UTB_framestateupdate" 313 | -ec "UTB_framestateupdate" 314 | UVFrame; 315 | columnLayout -adjustableColumn false -rowSpacing 0 UVColumn; 316 | 317 | button -w 100 -h 18 -label "PlanarMapping" -bgc 0.74 0.74 0.74 -command "UTB_projPlanar"; 318 | popupMenu; 319 | menuItem -label "PlanarMapping Options" -command "UTB_projPlanarO"; 320 | 321 | button -w 100 -h 18 -label "CylindricalMapping" -bgc 0.74 0.74 0.74 -command "UTB_projCylindrical"; 322 | popupMenu; 323 | menuItem -label "CylindricalMapping Options" -command "UTB_projCylindricalO"; 324 | 325 | button -w 100 -h 18 -label "AutomaticMapping" -bgc 0.74 0.74 0.74 -command "performPolyAutoProj 0"; 326 | popupMenu; 327 | menuItem -label "AutomaticMapping Options" -command "performPolyAutoProj 1"; 328 | 329 | separator -h 4 -w 100 -bgc 0.7 0.6 0.5 -st "none"; 330 | 331 | button -w 100 -h 18 -label "LayoutUVs" -bgc 0.74 0.74 0.74 -command "performPolyLayoutUV 0;"; 332 | popupMenu; 333 | menuItem -label "LayoutUVs Options" -command "performPolyLayoutUV 1;"; 334 | 335 | button -w 100 -h 18 -label "RelaxUVs" -bgc 0.74 0.74 0.74 -command "performPolyUntangleUV relax 0"; 336 | popupMenu; 337 | menuItem -label "RelaxUVs Options" -command "performPolyUntangleUV relax 1"; 338 | 339 | button -w 100 -h 18 -label "NormalizeUVs" -bgc 0.74 0.74 0.74 -command "performPolyForceUV normalize 0"; 340 | popupMenu; 341 | menuItem -label "NormalizeUVs Options" -command "performPolyForceUV normalize 1"; 342 | 343 | button -w 100 -h 18 -label "UnitizeUVs" -command "polyForceUV -unitize"; 344 | 345 | separator -h 4 -w 100 -bgc 0.7 0.6 0.5 -st "none"; 346 | 347 | button -w 100 -h 18 -label "FlipUVs" -bgc 0.74 0.74 0.74 -command "performPolyForceUV flip 0"; 348 | popupMenu; 349 | menuItem -label "FlipUVs Options" -command "performPolyForceUV flip 1"; 350 | 351 | button -w 100 -h 18 -label "RotateUVs" -bgc 0.74 0.74 0.74 -command "performPolyRotateUVs 0"; 352 | popupMenu; 353 | menuItem -label "RotateUVs Options" -command "performPolyRotateUVs 1"; 354 | 355 | button -w 100 -h 18 -label "CutUVs" -command "polyPerformAction polyMapCut e 0"; 356 | 357 | button -w 100 -h 18 -label "MergeUVs" -bgc 0.74 0.74 0.74 -command "performPolyMergeUV 0"; 358 | popupMenu; 359 | menuItem -label "MergeUVs Options" -command "performPolyMergeUV 1"; 360 | 361 | button -w 100 -h 18 -label "MoveAndSewUVs" -bgc 0.74 0.74 0.74 -command "performPolyMapSewMove 0"; 362 | popupMenu; 363 | menuItem -label "MoveAndSewUVs Options" -command "performPolyMapSewMove 1"; 364 | 365 | separator -h 4 -w 100 -bgc 0.7 0.6 0.5 -st "none"; 366 | 367 | button -w 100 -h 18 -label "ReloadTextures" -command "UTB_reloadTextures"; 368 | 369 | setParent MainColumn; 370 | 371 | /// PRELIGHTING 372 | 373 | frameLayout -label " Prelighting" 374 | -bv 1 -bs "etchedOut" 375 | -bgc 0.7 0.6 0.5 -mw 4 -mh 4 376 | -collapse $UTB_switchprelight -collapsable true 377 | -cc "UTB_framestateupdate" 378 | -ec "UTB_framestateupdate" 379 | PrelightFrame; 380 | columnLayout -adjustableColumn false -rowSpacing 0 PrelightColumn; 381 | 382 | button -w 100 -h 18 -label "Prelight" -bgc 0.74 0.74 0.74 -command "performPrelight 0"; 383 | popupMenu; 384 | menuItem -label "Prelight Options" -command "performPrelight 1"; 385 | 386 | button -w 100 -h 18 -label "ApplyColor" -bgc 0.74 0.74 0.74 -command "performApplyColor 0"; 387 | popupMenu; 388 | menuItem -label "ApplyColor Options" -command "performApplyColor 1"; 389 | 390 | button -w 100 -h 18 -label "BreakLightLinks" -command "BreakLightLinks"; 391 | 392 | button -w 100 -h 18 -label "MakeLightLinks" -command "MakeLightLinks"; 393 | 394 | button -w 100 -h 18 -label "Disconnect Linker" -command "UTB_disconnectLightLinker"; 395 | 396 | setParent MainColumn; 397 | 398 | /// SELECTION 399 | 400 | frameLayout -label " Selection" 401 | -bv 1 -bs "etchedOut" 402 | -bgc 0.5 0.7 0.6 -mw 4 -mh 4 403 | -collapse $UTB_switchselection -collapsable true 404 | -cc "UTB_framestateupdate" 405 | -ec "UTB_framestateupdate" 406 | SelectionFrame; 407 | columnLayout -adjustableColumn false -rowSpacing 0 SelectionColumn; 408 | 409 | button -w 100 -h 18 -label "Extract" -bgc 0.74 0.74 0.74 -command "ExtractFace"; 410 | popupMenu; 411 | menuItem -label "Extract Options" -command "ExtractFaceOptions"; 412 | menuItem -label "Separate" -command "SeparatePolygon"; 413 | 414 | button -w 100 -h 18 -label "SelectContEdges" -bgc 0.74 0.74 0.74 -command "performSelContiguousEdges 0"; 415 | popupMenu; 416 | menuItem -label "SelectContEdges Options" -command "performSelContiguousEdges 1"; 417 | 418 | separator -h 4 -w 100 -bgc 0.5 0.7 0.6 -st "none"; 419 | 420 | text -w 100 -label "ConvertSelectionTo" -bgc 0.5 0.7 0.6; 421 | popupMenu; 422 | 423 | menuItem -label "Faces" -command "PolySelectConvert 1"; 424 | menuItem -label "Edges" -command "PolySelectConvert 2"; 425 | menuItem -label "Vertices" -command "PolySelectConvert 3"; 426 | menuItem -label "UVs" -command "PolySelectConvert 4"; 427 | menuItem -label "Shell" -command "polySelectBorderShell 0"; 428 | menuItem -label "Border" -command "polySelectBorderShell 1"; 429 | menuItem -label "Boundary" -command "SelectPolygonSelectionBoundary;"; 430 | 431 | setParent MainColumn; 432 | 433 | 434 | /// LAYERS 435 | 436 | frameLayout -label " Layers" 437 | -bv 1 -bs "etchedOut" 438 | -bgc 0.5 0.7 0.6 -mw 4 -mh 4 439 | -collapse $UTB_switchlayers -collapsable true 440 | -cc "UTB_framestateupdate" 441 | -ec "UTB_framestateupdate" 442 | LayerFrame; 443 | columnLayout -adjustableColumn false -rowSpacing 0 LayerColumn; 444 | 445 | button -w 100 -h 18 -label "SelectedLayerOnly" -command "UTB_selectedLayerOnly"; 446 | button -w 100 -h 18 -label "ShowAllLayers" -command "UTB_dispLayers 1"; 447 | button -w 100 -h 18 -label "HideAllLayers" -command "UTB_dispLayers 0"; 448 | button -w 100 -h 18 -label "ToggleAllLayers" -command "UTB_toggleLayers"; 449 | 450 | separator -h 4 -w 100 -bgc 0.5 0.7 0.6 -st "none"; 451 | 452 | button -w 100 -h 18 -label "AddObjectsToLayer" -command "UTB_addToLayer"; 453 | button -w 100 -h 18 -label "SelectLayerObjects" -command "UTB_selectLayerObjects"; 454 | 455 | 456 | setParent MainColumn; 457 | 458 | 459 | /// USER 460 | 461 | frameLayout -label " User" 462 | -bv 1 -bs "etchedOut" 463 | -bgc 0.7 0.6 0.7 -mw 4 -mh 4 464 | -collapse $UTB_switchuser -collapsable true 465 | -cc "UTB_framestateupdate" 466 | -ec "UTB_framestateupdate" 467 | userFrame; 468 | columnLayout -adjustableColumn false -rowSpacing 0 UserColumn; 469 | 470 | string $UTB_tokens[]; 471 | string $UTB_unitokens[]; 472 | string $UTB_loctokens[]; 473 | 474 | int $UTB_eof; 475 | 476 | // DETERMINE LOCATION OF UNITOOLBOX 477 | string $UTB_location = ""; 478 | 479 | string $UTB_unipath = `whatIs uniToolBox`; 480 | int $UTB_numTokens = `tokenize $UTB_unipath " " $UTB_unitokens`; 481 | 482 | for ( $i = 4; $i < $UTB_numTokens; $i++ ) 483 | { 484 | $UTB_location = $UTB_location + $UTB_unitokens[$i]; 485 | 486 | if ( $i < $UTB_numTokens ) 487 | { 488 | $UTB_location = $UTB_location + " "; 489 | } 490 | } 491 | 492 | string $UTB_dirname = `dirname $UTB_location`; 493 | 494 | // FINAL CONFIG LOCATION 495 | string $UTB_configname = ($UTB_dirname + "/uniToolBoxUser.txt"); 496 | 497 | print ("\n\n config: " +$UTB_configname); 498 | 499 | // ATTEMPT TO OPEN CONFIG 500 | int $UTB_filetest = `filetest -r $UTB_configname`; 501 | 502 | // CHECK IF FILE EXISTS 503 | if ($UTB_filetest == 0) 504 | { 505 | text -w 100 -label "Could not find\nuniToolBoxUser.txt\nconfiguration file.\n" -bgc 0.7 0.6 0.7; 506 | } 507 | 508 | else 509 | { 510 | 511 | $UTB_configID = `fopen $UTB_configname "r"`; 512 | 513 | 514 | // LOOP UNTIL END OF FILE IS REACHED 515 | while ( `feof $UTB_configID` == 0) 516 | { 517 | 518 | // GET NEXT LINE OF DATA 519 | string $UTB_nextline = `fgetline $UTB_configID`; 520 | 521 | // DOUBLECHECK END OF FILE AFTER FGETLINE 522 | if ( `feof $UTB_configID` != 0) 523 | { 524 | $UTB_eof = 1; 525 | break; 526 | } 527 | 528 | // TOKENIZE LINE VALUES AND GET RID OF SPACES 529 | if ($UTB_eof == 0) 530 | { 531 | tokenize $UTB_nextline "," $UTB_tokens; 532 | evalEcho ("button -w 100 -h 18 -label " + $UTB_tokens[0] + " -command " + $UTB_tokens[1]); 533 | } 534 | } 535 | 536 | fclose $UTB_configID; 537 | } 538 | 539 | 540 | 541 | separator -h 4 -w 100 -bgc 0.7 0.6 0.7 -st "none"; 542 | 543 | button -w 100 -h 18 -label "About/Help" -command "UTB_about"; 544 | 545 | 546 | setParent MainColumn; 547 | 548 | 549 | setParent -top; 550 | 551 | formLayout -edit 552 | 553 | -attachForm Scroll "top" 1 554 | -attachForm Scroll "left" 1 555 | -attachForm Scroll "right" 1 556 | -attachForm Scroll "bottom" 1 557 | 558 | UniForm; 559 | 560 | 561 | 562 | // SET UP APPEARANCE 563 | 564 | switch ($UTB_switch) 565 | { 566 | 567 | case 0: 568 | showWindow $UTB_win; 569 | break; 570 | case 1: 571 | case 2: 572 | case 3: 573 | paneLayout -e -cn "horizontal3" -setPane UniForm $UTB_switch ChannelsLayersPaneLayout; 574 | break; 575 | } 576 | 577 | } 578 | 579 | // =================================== PROCEDURES ================================ 580 | 581 | 582 | // TOGGLEWOS 583 | 584 | global proc UTB_toggleWOS() 585 | { 586 | string $myWindow = `getPanel -withFocus`; 587 | { 588 | int $wostoggle = `modelEditor -q -wos $myWindow`; 589 | switch ($wostoggle) 590 | { 591 | case 0: modelEditor -e -wos true $myWindow; 592 | break; 593 | case 1: modelEditor -e -wos false $myWindow; 594 | break; 595 | default: break; 596 | } 597 | } 598 | } 599 | 600 | 601 | // TOGGLEXRAY 602 | 603 | global proc UTB_toggleXRay() 604 | { 605 | string $myWindow = `getPanel -withFocus`; 606 | { 607 | int $xraytoggle = `modelEditor -q -xray $myWindow`; 608 | switch ($xraytoggle) 609 | { 610 | case 0: modelEditor -e -xray true $myWindow; 611 | break; 612 | case 1: modelEditor -e -xray false $myWindow; 613 | break; 614 | default: break; 615 | } 616 | } 617 | } 618 | 619 | // TOGGLELOCATOR 620 | 621 | global proc UTB_toggleLocators() 622 | { 623 | string $myWindow = `getPanel -withFocus`; 624 | { 625 | int $loctoggle = `modelEditor -q -locators $myWindow`; 626 | switch ($loctoggle) 627 | { 628 | case 0: modelEditor -e -locators true $myWindow; 629 | break; 630 | case 1: modelEditor -e -locators false $myWindow; 631 | break; 632 | default: break; 633 | } 634 | } 635 | } 636 | 637 | 638 | // TOGGLEVISIBILITY 639 | 640 | global proc UTB_toggleVIS () 641 | { 642 | string $selection[] = `ls -sl`; 643 | string $item; 644 | 645 | for ($item in $selection) 646 | { 647 | setAttr ($item + ".visibility") (!`getAttr ($item + ".visibility")`); 648 | } 649 | } 650 | 651 | 652 | // TRIANGLECOUNT 653 | 654 | global proc UTB_triangleCount() 655 | { 656 | 657 | string $UTB_mesh[] = `ls -v -type mesh`; 658 | 659 | if (size ($UTB_mesh) == 0) 660 | { 661 | confirmDialog -t "Done..." -m "This scene contains no visible triangle-meshes." -b "Continue"; 662 | return; 663 | } 664 | 665 | int $UTB_numtriangles[] = `polyEvaluate -triangle $UTB_mesh`; 666 | 667 | confirmDialog -t "Done..." -m ("The scene has " + $UTB_numtriangles[0] + " visible triangles.") -b "Continue"; 668 | } 669 | 670 | 671 | // TEXTURE RELOAD 672 | 673 | global proc UTB_reloadTextures () 674 | { 675 | 676 | print "\nReloading the following textures: \n------"; 677 | 678 | string $textures [] = `ls -tex`; 679 | for ($i=0; $i