Friday, August 15, 2008

Demo reel - Mundos & DAf



A simple cut showing most of the works where I worked during 2007 and fisrt half 2008.
Most works are from DAf and Mundos Project.

Sunday, August 10, 2008

Maya MEL Script - Random modifier


It helps to transform each of the selected object in a random position, rotation or scale. It can be use in an absolute or a relative transformation.



//Ventana
window -w 500 -h 700 -title "Objetos al azar" Azar1;
columnLayout -cal "left" -columnAttach "left" 5 -rowSpacing 5 -columnWidth 500;
text -l "1: Seleccionar los objetos que se quieren modificar al azar...";
text -l "2: Seleccionar le tipo de azar a aplicar.";
optionMenu -l "Aplicar azar " tipo;
menuItem -label "Relativo";
menuItem -label "Absoluto";
text -l "3: Agregar los valores MIN y MAX a modificar,\nValores 0 en los MAX no los modifica.";
text -l "Translate XYZ";
rowLayout -nc 3;
floatField -w 80 -value 0.0 mintx;
floatField -w 80 -value 0.0 minty;
floatField -w 80 -value 0.0 mintz;
setParent ..;
rowLayout -nc 3;
floatField -w 80 -value 0.0 maxtx;
floatField -w 80 -value 0.0 maxty;
floatField -w 80 -value 0.0 maxtz;
setParent ..;
text -l "Rotate XYZ";
rowLayout -nc 3;
floatField -w 80 -value 0.0 minrx;
floatField -w 80 -value 0.0 minry;
floatField -w 80 -value 0.0 minrz;
setParent ..;
rowLayout -nc 3;
floatField -w 80 -value 0.0 maxrx;
floatField -w 80 -value 0.0 maxry;
floatField -w 80 -value 0.0 maxrz;
setParent ..;
text -l "Scale XYZ";
checkBox -label "Mantener Proporciones (Valores de X)" -align "left" prop;
rowLayout -nc 3;
floatField -w 80 -value 0.0 minsx;
floatField -w 80 -value 0.0 minsy;
floatField -w 80 -value 0.0 minsz;
setParent ..;
rowLayout -nc 3;
floatField -w 80 -value 0.0 maxsx;
floatField -w 80 -value 0.0 maxsy;
floatField -w 80 -value 0.0 maxsz;
setParent ..;
setParent ..;
columnLayout -columnAttach "both" 5 -columnWidth 500;
button -label "Aplicar" -command ("aplica()");
button -label "Close" -command ("deleteUI -window Azar1");
setParent ..;
showWindow;


// Secuencia
global proc aplica() {

float $mintx = `floatField -q -value "mintx"`;
float $minty = `floatField -q -value "minty"`;
float $mintz = `floatField -q -value "mintz"`;
float $maxtx = `floatField -q -value "maxtx"`;
float $maxty = `floatField -q -value "maxty"`;
float $maxtz = `floatField -q -value "maxtz"`;

float $minrx = `floatField -q -value "minrx"`;
float $minry = `floatField -q -value "minry"`;
float $minrz = `floatField -q -value "minrz"`;
float $maxrx = `floatField -q -value "maxrx"`;
float $maxry = `floatField -q -value "maxry"`;
float $maxrz = `floatField -q -value "maxrz"`;

float $minsx = `floatField -q -value "minsx"`;
float $minsy = `floatField -q -value "minsy"`;
float $minsz = `floatField -q -value "minsz"`;
float $maxsx = `floatField -q -value "maxsx"`;
float $maxsy = `floatField -q -value "maxsy"`;
float $maxsz = `floatField -q -value "maxsz"`;

int $tipo = `optionMenu -q -select tipo`; // 1 Rel 2 Abs
int $prop = `checkBox -q -value prop`; // SI 0 NO
string $selection[] = `ls -selection`;
int $a = size($selection);

if ($tipo == 1){
for( $i = 0; $i < $a; $i++ ){
if ($maxtx == 0 && $maxty == 0 && $maxtz == 0){} else { move -r (rand($mintx, $maxtx)) (rand($minty, $maxty)) (rand($mintz, $maxtz)) $selection[$i]; }
if ($maxrx == 0 && $maxry == 0 && $maxrz == 0){} else { rotate -r (rand($minrx, $maxrx)) (rand($minry, $maxry)) (rand($minrz, $maxrz)) $selection[$i]; }
if ($maxsx == 0 && $maxsy == 0 && $maxsz == 0){} else {
if ($prop == 0){ scale -r (rand($minsx, $maxsx)) (rand($minsy, $maxsy)) (rand($minsz, $maxsz)) $selection[$i]; } else { float $rand = rand($minsx, $maxsx); scale -r $rand $rand $rand $selection[$i]; }
}
};
}

if ($tipo == 2){
for( $i = 0; $i < $a; $i++ ){
if ($maxtx == 0 && $maxty == 0 && $maxtz == 0){} else { move (rand($mintx, $maxtx)) (rand($minty, $maxty)) (rand($mintz, $maxtz)) $selection[$i]; }
if ($maxrx == 0 && $maxry == 0 && $maxrz == 0){} else { rotate (rand($minrx, $maxrx)) (rand($minry, $maxry)) (rand($minrz, $maxrz)) $selection[$i]; }
if ($maxsx == 0 && $maxsy == 0 && $maxsz == 0){} else {
if ($prop == 0){ scale (rand($minsx, $maxsx)) (rand($minsy, $maxsy)) (rand($minsz, $maxsz)) $selection[$i]; } else { float $rand = rand($minsx, $maxsx); scale $rand $rand $rand $selection[$i]; }
}
};
}

};