Render layers in 2018
Use groups in collections, this way you can easily swap out geo without having to update stuff each time someone changes something.
If a sub object needs changing, it could be worth putting that in a sub group too.
Use shader overrides rather than material overrides.
Wednesday, 18 April 2018
more UV crap
last post is a bit redundant in the age of UV-editing mode of Maya 2018, but with heavy meshes, the uv editor is dog slow.
polyEditUV -u 1 -v0 -scaleU 1.2 -scaleV 1;
Also this.
polyEditUV -u 1 -v0 -scaleU 1.2 -scaleV 1;
Also this.
Monday, 16 April 2018
scaling UV code, around the centre of selection instead of 0,0
Original code stolen from
http://polycount.com/discussion/172364/maya-mel-scale-uv-shells-locally-script-for-anyone-that-wants-it
//store uvs into array
float $uvvalues[] =`polyEditUV -q`;
int $selSize = `size ($uvvalues)`;
//split array into U and V
float $Uarray[];
float $Varray[];
//copy U and V arrays with values
for($u = 0; $u < $selSize; $u++) {
$Uarray[size($Uarray)] = $uvvalues[$u];
$u=$u+1;
}
for($v = 1; $v < $selSize; $v++) {
$Varray[size($Varray)] = $uvvalues[$v];
$v=$v+1;
}
//sort arrays by coords and get size of array
$Uarray = `sort $Uarray`;
$Varray = `sort $Varray`;
int $UarraySize = `size ($Uarray)`;
//get max values
float $maxNuU = $Uarray[$UarraySize-1];
float $maxNuV = $Varray[$UarraySize-1];
//get min values
float $minNuU = $Uarray[0];
float $minNuV = $Varray[0];
//calculate centre values
float $middleU = ($maxNuU + $minNuU)/2;
float $middleV = ($maxNuV + $minNuV)/2;
polyEditUV -pu $middleU -pv $middleV -su .2 -sv .2;
http://polycount.com/discussion/172364/maya-mel-scale-uv-shells-locally-script-for-anyone-that-wants-it
//store uvs into array
float $uvvalues[] =`polyEditUV -q`;
int $selSize = `size ($uvvalues)`;
//split array into U and V
float $Uarray[];
float $Varray[];
//copy U and V arrays with values
for($u = 0; $u < $selSize; $u++) {
$Uarray[size($Uarray)] = $uvvalues[$u];
$u=$u+1;
}
for($v = 1; $v < $selSize; $v++) {
$Varray[size($Varray)] = $uvvalues[$v];
$v=$v+1;
}
//sort arrays by coords and get size of array
$Uarray = `sort $Uarray`;
$Varray = `sort $Varray`;
int $UarraySize = `size ($Uarray)`;
//get max values
float $maxNuU = $Uarray[$UarraySize-1];
float $maxNuV = $Varray[$UarraySize-1];
//get min values
float $minNuU = $Uarray[0];
float $minNuV = $Varray[0];
//calculate centre values
float $middleU = ($maxNuU + $minNuU)/2;
float $middleV = ($maxNuV + $minNuV)/2;
polyEditUV -pu $middleU -pv $middleV -su .2 -sv .2;
Monday, 9 April 2018
some rapid rig specific scripts..sin waves on the leg/arm micro curves.
//used in Nike jelly legs
//CONTROLLER SETUP
//select controller for attributes to be added to, one by one. eg. left foot ctrl. then right.
string $footCtrl[]=`ls -sl`;
print $footCtrl[0];
//upper controls
addAttr -ln "o" -at "enum" -en "--------" -keyable 1 $footCtrl[0];
setAttr -lock true ($footCtrl[0]+".o");
addAttr -ln "upper_amp" -keyable 1 -at double -dv 1 $footCtrl[0];
addAttr -ln "upper_sinPhase" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "upper_transY" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "upper_transZ" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "upper_rotoX" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "upper_rotoY" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "upper_rotoZ" -keyable 1 -at double -dv 0 $footCtrl[0];
//lower controls
addAttr -ln "oo" -at "enum" -en "--------" -keyable 1 $footCtrl[0];
setAttr -lock true ($footCtrl[0]+".oo");
addAttr -ln "lower_amp" -keyable 1 -at double -dv 1 $footCtrl[0];
addAttr -ln "lower_sinPhase" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "lower_transY" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "lower_transZ" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "lower_rotoX" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "lower_rotoY" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "lower_rotoZ" -keyable 1 -at double -dv 0 $footCtrl[0];
//upper offsets
addAttr -ln "ooo" -at "enum" -en "--------" -keyable 1 $footCtrl[0];
setAttr -lock true ($footCtrl[0]+".ooo");
addAttr -ln "upper_y_sinOffset" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "upper_z_sinOffset" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "upper_xRot_sinOffset" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "upper_yRot_sinOffset" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "upper_zRot_sinOffset" -keyable 1 -at double -dv 0 $footCtrl[0];
//lower offsets
addAttr -ln "oooo" -at "enum" -en "--------" -keyable 1 $footCtrl[0];
setAttr -lock true ($footCtrl[0]+".oooo");
addAttr -ln "lower_y_sinOffset" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "lower_z_sinOffset" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "lower_xRot_sinOffset" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "lower_yRot_sinOffset" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "lower_zRot_sinOffset" -keyable 1 -at double -dv 0 $footCtrl[0];
___________________________________________________________________________
//CONNECT CONTROLLER TO THE MICRO CURVES
//select the micro curves, can select them all, set the leftLeg and rightLeg strings!
string $ctrlNameSel[]=`ls -sl`;
print $ctrlNameSel[0];
float $ctrlOffset=0;
float $ctrlAmp=1;
string $leftLeg="abc_lLegSwitchC";
string $rightLeg="abc_rLegSwitchC";
string $ctrlUse="none";
string $region="none";
//looping
for ($ctrl in $ctrlNameSel){
if(`gmatch $ctrl "*1C*"`){
//top Node, set offsetVal
$ctrlOffset=0;
$ctrlAmp=0.55;
}
else if(`gmatch $ctrl "*2C*"`){
//middle Node, set offsetVal
$ctrlOffset=1.65;
$ctrlAmp=1;
}
else if (`gmatch $ctrl "*3C*"`){
//bottom Node, set offsetVal
$ctrlOffset=2.2;
$ctrlAmp=0.4;
}
//WHICH PART
if(`gmatch $ctrl "*_rLower*"`){
$ctrlUse=$rightLeg;
$region="lower";
}
else if(`gmatch $ctrl "*_rUpper*"`){
$ctrlUse=$rightLeg;
$region="upper";
}
if(`gmatch $ctrl "*_lLower*"`){
$ctrlUse=$leftLeg;
$region="lower";
}
else if(`gmatch $ctrl "*_lUpper*"`){
$ctrlUse=$leftLeg;
$region="upper";
}
select $ctrl;
string $newGroup=`group -name ($ctrl+"_sinGrp")`;
string $offsetVal="float $offset="+$ctrlOffset+";\n";
string $ctrlAmpStr="float $amp="+$ctrlAmp+";\n";
//translate
//string $sinTYVal=$newGroup+".translateY=sin("+$ctrlUse+"."+$region+"_sinPhase+$offset+" +$ctrlUse+ "." +$region+ "_y_sinOffset)*$amp * "+$ctrlUse+"."+$region+"_transY;\n";
string $sinTYVal=$newGroup+".translateY=sin("+$ctrlUse+"."+$region+"_sinPhase+$offset+" +$ctrlUse+ "." +$region+ "_y_sinOffset)*$amp * "+$ctrlUse+"."+$region+"_transY * "+$ctrlUse+"."+$region+"_amp;\n";
string $sinTZVal=$newGroup+".translateZ=sin("+$ctrlUse+"."+$region+"_sinPhase+$offset+"+$ctrlUse+"."+$region+"_z_sinOffset)*$amp * "+$ctrlUse+"."+$region+"_transZ * "+$ctrlUse+"."+$region+"_amp;\n";
string $sinRXVal=$newGroup+".rotateX=sin("+$ctrlUse+"."+$region+"_sinPhase+$offset+"+$ctrlUse+"."+$region+"_xRot_sinOffset)*$amp * "+$ctrlUse+"."+$region+"_rotoX * "+$ctrlUse+"."+$region+"_amp;\n";
string $sinRYVal=$newGroup+".rotateY=sin("+$ctrlUse+"."+$region+"_sinPhase+$offset+"+$ctrlUse+"."+$region+"_yRot_sinOffset)*$amp * "+$ctrlUse+"."+$region+"_rotoY * "+$ctrlUse+"."+$region+"_amp;\n";
string $sinRZVal=$newGroup+".rotateZ=sin("+$ctrlUse+"."+$region+"_sinPhase+$offset+"+$ctrlUse+"."+$region+"_zRot_sinOffset)*$amp * "+$ctrlUse+"."+$region+"_rotoZ * "+$ctrlUse+"."+$region+"_amp;\n";
string $expressionVal=$offsetVal + $ctrlAmpStr +$sinTYVal + $sinTZVal + $sinRXVal +$sinRYVal + $sinRZVal;
// lower_xRot_sinOffset
expression -s $expressionVal;
select -cl;
}
//CONTROLLER SETUP
//select controller for attributes to be added to, one by one. eg. left foot ctrl. then right.
string $footCtrl[]=`ls -sl`;
print $footCtrl[0];
//upper controls
addAttr -ln "o" -at "enum" -en "--------" -keyable 1 $footCtrl[0];
setAttr -lock true ($footCtrl[0]+".o");
addAttr -ln "upper_amp" -keyable 1 -at double -dv 1 $footCtrl[0];
addAttr -ln "upper_sinPhase" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "upper_transY" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "upper_transZ" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "upper_rotoX" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "upper_rotoY" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "upper_rotoZ" -keyable 1 -at double -dv 0 $footCtrl[0];
//lower controls
addAttr -ln "oo" -at "enum" -en "--------" -keyable 1 $footCtrl[0];
setAttr -lock true ($footCtrl[0]+".oo");
addAttr -ln "lower_amp" -keyable 1 -at double -dv 1 $footCtrl[0];
addAttr -ln "lower_sinPhase" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "lower_transY" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "lower_transZ" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "lower_rotoX" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "lower_rotoY" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "lower_rotoZ" -keyable 1 -at double -dv 0 $footCtrl[0];
//upper offsets
addAttr -ln "ooo" -at "enum" -en "--------" -keyable 1 $footCtrl[0];
setAttr -lock true ($footCtrl[0]+".ooo");
addAttr -ln "upper_y_sinOffset" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "upper_z_sinOffset" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "upper_xRot_sinOffset" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "upper_yRot_sinOffset" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "upper_zRot_sinOffset" -keyable 1 -at double -dv 0 $footCtrl[0];
//lower offsets
addAttr -ln "oooo" -at "enum" -en "--------" -keyable 1 $footCtrl[0];
setAttr -lock true ($footCtrl[0]+".oooo");
addAttr -ln "lower_y_sinOffset" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "lower_z_sinOffset" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "lower_xRot_sinOffset" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "lower_yRot_sinOffset" -keyable 1 -at double -dv 0 $footCtrl[0];
addAttr -ln "lower_zRot_sinOffset" -keyable 1 -at double -dv 0 $footCtrl[0];
___________________________________________________________________________
//CONNECT CONTROLLER TO THE MICRO CURVES
//select the micro curves, can select them all, set the leftLeg and rightLeg strings!
string $ctrlNameSel[]=`ls -sl`;
print $ctrlNameSel[0];
float $ctrlOffset=0;
float $ctrlAmp=1;
string $leftLeg="abc_lLegSwitchC";
string $rightLeg="abc_rLegSwitchC";
string $ctrlUse="none";
string $region="none";
//looping
for ($ctrl in $ctrlNameSel){
if(`gmatch $ctrl "*1C*"`){
//top Node, set offsetVal
$ctrlOffset=0;
$ctrlAmp=0.55;
}
else if(`gmatch $ctrl "*2C*"`){
//middle Node, set offsetVal
$ctrlOffset=1.65;
$ctrlAmp=1;
}
else if (`gmatch $ctrl "*3C*"`){
//bottom Node, set offsetVal
$ctrlOffset=2.2;
$ctrlAmp=0.4;
}
//WHICH PART
if(`gmatch $ctrl "*_rLower*"`){
$ctrlUse=$rightLeg;
$region="lower";
}
else if(`gmatch $ctrl "*_rUpper*"`){
$ctrlUse=$rightLeg;
$region="upper";
}
if(`gmatch $ctrl "*_lLower*"`){
$ctrlUse=$leftLeg;
$region="lower";
}
else if(`gmatch $ctrl "*_lUpper*"`){
$ctrlUse=$leftLeg;
$region="upper";
}
select $ctrl;
string $newGroup=`group -name ($ctrl+"_sinGrp")`;
string $offsetVal="float $offset="+$ctrlOffset+";\n";
string $ctrlAmpStr="float $amp="+$ctrlAmp+";\n";
//translate
//string $sinTYVal=$newGroup+".translateY=sin("+$ctrlUse+"."+$region+"_sinPhase+$offset+" +$ctrlUse+ "." +$region+ "_y_sinOffset)*$amp * "+$ctrlUse+"."+$region+"_transY;\n";
string $sinTYVal=$newGroup+".translateY=sin("+$ctrlUse+"."+$region+"_sinPhase+$offset+" +$ctrlUse+ "." +$region+ "_y_sinOffset)*$amp * "+$ctrlUse+"."+$region+"_transY * "+$ctrlUse+"."+$region+"_amp;\n";
string $sinTZVal=$newGroup+".translateZ=sin("+$ctrlUse+"."+$region+"_sinPhase+$offset+"+$ctrlUse+"."+$region+"_z_sinOffset)*$amp * "+$ctrlUse+"."+$region+"_transZ * "+$ctrlUse+"."+$region+"_amp;\n";
string $sinRXVal=$newGroup+".rotateX=sin("+$ctrlUse+"."+$region+"_sinPhase+$offset+"+$ctrlUse+"."+$region+"_xRot_sinOffset)*$amp * "+$ctrlUse+"."+$region+"_rotoX * "+$ctrlUse+"."+$region+"_amp;\n";
string $sinRYVal=$newGroup+".rotateY=sin("+$ctrlUse+"."+$region+"_sinPhase+$offset+"+$ctrlUse+"."+$region+"_yRot_sinOffset)*$amp * "+$ctrlUse+"."+$region+"_rotoY * "+$ctrlUse+"."+$region+"_amp;\n";
string $sinRZVal=$newGroup+".rotateZ=sin("+$ctrlUse+"."+$region+"_sinPhase+$offset+"+$ctrlUse+"."+$region+"_zRot_sinOffset)*$amp * "+$ctrlUse+"."+$region+"_rotoZ * "+$ctrlUse+"."+$region+"_amp;\n";
string $expressionVal=$offsetVal + $ctrlAmpStr +$sinTYVal + $sinTZVal + $sinRXVal +$sinRYVal + $sinRZVal;
// lower_xRot_sinOffset
expression -s $expressionVal;
select -cl;
}
______________________________________________________________________________
//REMOVE ATTRIBUTES FROM CONTROLLER
//select the controller (one by one)
//sets things to zero first, then deletes them
string $footCtrl[]=`ls -sl`;
print $footCtrl[0];
//remove upper controls, set to 0
setAttr -lock false ($footCtrl[0]+".o");
deleteAttr -at "o";
setAttr ($footCtrl[0]+".upper_amp") 0;
deleteAttr -at "upper_amp";
deleteAttr -at "upper_sinPhase";
deleteAttr -at "upper_transY";
deleteAttr -at "upper_transZ";
deleteAttr -at "upper_rotoX";
deleteAttr -at "upper_rotoY";
deleteAttr -at "upper_rotoZ";
//lower controls
setAttr -lock false ($footCtrl[0]+".oo");
deleteAttr -at "oo";
setAttr ($footCtrl[0]+".lower_amp") 0;
deleteAttr -at "lower_amp";
deleteAttr -at "lower_sinPhase";
deleteAttr -at "lower_transY";
deleteAttr -at "lower_transZ";
deleteAttr -at "lower_rotoX";
deleteAttr -at "lower_rotoY";
deleteAttr -at "lower_rotoZ";
//upper offsets
setAttr -lock false ($footCtrl[0]+".ooo");
deleteAttr -at "ooo";
deleteAttr -at "upper_y_sinOffset";
deleteAttr -at "upper_z_sinOffset";
deleteAttr -at "upper_xRot_sinOffset";
deleteAttr -at "upper_yRot_sinOffset";
deleteAttr -at "upper_zRot_sinOffset";
//lower offsets
setAttr -lock false ($footCtrl[0]+".oooo");
deleteAttr -at "oooo";
deleteAttr -at "lower_y_sinOffset";
deleteAttr -at "lower_z_sinOffset";
deleteAttr -at "lower_xRot_sinOffset";
deleteAttr -at "lower_yRot_sinOffset";
deleteAttr -at "lower_zRot_sinOffset";
__________________________________________________________________________
//DELETE SIN GROUPS FROM THE RIG
//just run it, no need to select (deletes all sin groups though)
string $ctrlSelected[]=`ls "*_sinGrp*"`;
for($group in $ctrlSelected){
select $group;
print ($group+"\n");
ungroup;
}
Subscribe to:
Posts (Atom)