//Name: acMoveUV.mel //Author: Allen Curtis //Date: May 2008 //THIS WAS CREATED FROM THE ACMATCHPOINTS SCRIPT. //PURPOSE: TO MOVE UV POINTS IN THE TEXTURE EDITOR VIEW. string $getCurrentSelected[]; float $positionNow[]; global proc acMoveUV(){ if(`window -exists acMoveUVWindow`) deleteUI acMoveUVWindow; window -title "Move UV" -widthHeight 235 476 acMoveUVWindow; columnLayout -columnOffset "left" 15 -rs 5 ColumnLayout; //Controls for viewing position of current selection. text -label "Selection" -m 1 SelectionLabel; text -label "u:" -align "left" labelX; text -label "v:" -align "left" labelY; text -label "Point Position" -align "left" labelPointMessage; button -label "Point Position" -command "updateUVSelection" CurrentSelButton; button -label "Align End Points" -command "alignXYZ" AlignButton; text -label "_________________________________" -align "left";//hack for spacing checkBox -label "U axis" -value 1 checkX; checkBox -label "V axis" checkY; radioButtonGrp -numberOfRadioButtons 2 -columnAlign 1 "left" -columnWidth 1 60 -columnWidth 2 80 -label "Position:" -labelArray2 "Absolute" "Relative" -sl 2 radioCoordinates; //Layout inside another layout. formLayout -nd 100 xyzLayout; button -label "u" -width 20 -c "inputX" xButton; button -label "v" -width 20 -c "inputY" yButton; text -label "- From Selected" fromSelected; columnLayout -parent ColumnLayout textLayout; //For user input. textField -width 80 PositionField; columnLayout -parent ColumnLayout buttonLayout; button -label "Move" -width 80 -command "moveUV" MoveXButton; //These floatFieldGrp's are invisible. Their only purpose here is //to use their precision flag as a round-off function for text labels. //-m/manage flag used for invisibility. floatFieldGrp -v1 0.0 -precision 6 -m 0 RoundOffU; floatFieldGrp -v1 0.0 -precision 6 -m 0 RoundOffV; floatFieldGrp -v1 0.0 -precision 6 -m 0 RoundOffZ; formLayout -edit -attachForm xButton "top" 5 -attachForm xButton "left" 5 -attachForm yButton "top" 5 -attachControl yButton "left" 10 xButton -attachForm fromSelected "top" 5 -attachControl fromSelected "left" 5 yButton xyzLayout; window -edit -widthHeight 235 400 acMoveUVWindow; showWindow acMoveUVWindow; } //Aligns selected points to same xyz values as last Point Position setting. global proc alignXYZ(){ string $alignToPt[]; float $x; string $xvalue = `text -q -label labelX`; //Tokenize separates the string into an array. string $token = `tokenize $xvalue ":" $alignToPt`; //Could have made an extra float variable here, but string automatically casts (converts) to //a float value. $x = $alignToPt[1]; polyEditUV -relative false -uValue $x; $xvalue = `text -q -label labelY`; $token = `tokenize $xvalue ":" $alignToPt`; $x = $alignToPt[1]; polyEditUV -relative false -vValue $x; } global proc inputX(){ string $inputSel[]; float $x; string $xvalue = `text -q -label labelX`; //Tokenize separates the string into an array. string $token = `tokenize $xvalue ":" $inputSel`; $x = $inputSel[1]; textField -edit -tx $x PositionField; } global proc inputY(){ string $inputSel[]; float $x; string $xvalue = `text -q -label labelY`; //Tokenize separates the string into an array. string $token = `tokenize $xvalue ":" $inputSel`; $x = $inputSel[1]; textField -edit -tx $x PositionField; } //Move position based on textfield's user input. global proc moveUV(){ string $getText = `textField -q -tx PositionField`; float $x = $getText; int $coordinates = `radioButtonGrp -q -sl radioCoordinates`; int $checkValX=`checkBox -query -value checkX`; //Move absolute U value. if(($checkValX==1)&&($coordinates==1)){ polyEditUV -relative false -uValue $x; //Move relative U value. }else if(($checkValX==1)&&($coordinates==2)){ polyEditUV -relative true -uValue $x; } //Move absolute V value. int $checkValY=`checkBox -query -value checkY`; if(($checkValY==1)&&($coordinates==1)){ polyEditUV -relative false -vValue $x; //Move relative V value. }else if(($checkValY==1)&&($coordinates==2)){ polyEditUV -relative true -vValue $x; } } //Show current selection and position. If more than one vertex is selected, //only the first in the selection list is shown. global proc updateUVSelection(){ $getCurrentSelected =`ls -sl`; //Filter selected through selection masks (-sm). if(size(`filterExpand -sm 22 -sm 23 -sm 24 -sm 28 -sm 30 -sm 31 -sm 35 -sm 36 -sm 39 -sm 40 -sm 41 -sm 42 -sm 46 -sm 47 -sm 49 -sm 50 -sm 51 -sm 73`)>0){ //Create position variables; $positionNow = `polyEditUV -query $getCurrentSelected[0]`; floatFieldGrp -edit -v1 $positionNow[0] RoundOffU; string $posXNow=`floatFieldGrp -q -v1 RoundOffU`; floatFieldGrp -edit -v1 $positionNow[1] RoundOffV; string $posYNow=`floatFieldGrp -q -v1 RoundOffV`; text -edit -label $getCurrentSelected[0] SelectionLabel; text -edit -label ("u: " + $posXNow) labelX; text -edit -label ("v: " + $posYNow) labelY; //Can move some of these selection masks to next statement below //for object center to display if needed. }else if(size(`filterExpand -sm 0 -sm 1 -sm 2 -sm 3 -sm 4 -sm 5 -sm 6 -sm 7 -sm 8 -sm 9 -sm 10 -sm 11 -sm 13 -sm 14 -sm 15 -sm 16 -sm 17 -sm 18 -sm 19 -sm 20 -sm 21 -sm 25 -sm 26 -sm 27 -sm 29 -sm 32 -sm 33 -sm 34 -sm 37 -sm 38 -sm 43 -sm 44 -sm 45 -sm 48 -sm 52 -sm 53 -sm 54 -sm 55 -sm 56 -sm 57 -sm 67 -sm 69 -sm 70 -sm 71 -sm 72`)>0){ text -edit -label $getCurrentSelected[0] SelectionLabel; text -edit -label ("u:") labelX; text -edit -label ("v:") labelY; floatFieldGrp -edit -l "N/A" RoundOffU; }else if(size(`filterExpand -sm 12 -sm 68`)>0){ $positionNow = `objectCenter($getCurrentSelected[0])`; text -edit -label $getCurrentSelected[0] SelectionLabel; floatFieldGrp -edit -v1 $positionNow[0] RoundOffU; string $posXNow=`floatFieldGrp -q -v1 RoundOffU`; floatFieldGrp -edit -v1 $positionNow[1] RoundOffV; string $posYNow=`floatFieldGrp -q -v1 RoundOffV`; text -edit -label ("u:" + $posXNow) labelX; text -edit -label ("v:" + $posYNow) labelY; } }