/******************************************************
walkingFella.mel
Makes a guy who walks via animation expressions.
User may choose clothing accessories.
USAGE: walkingFella <int hat> <int bowtie>
******************************************************/
global proc walkingFella(int $hatSel, int $btieSel)
{
// Create all the Man's geo
string $head[] = `polySphere -r 1 -sx 8 -sy 8 -ax 0 1 0 -cuv 2 -ch 1`;
xform -t 0 8 0 $head[0];
string $body[] = `polyCube -w 3 -h 3 -d 1 -sx 1 -sy 1 -sz 1 -ax 0 1 0 -cuv 4 -ch 1`;
xform -t 0 5.3 0 $body[0];
select -r ($body[0]+".vtx[0:1]") ($body[0]+".vtx[6:7]") ;
scale -r -p 0cm 3.8cm 0cm 0.744391 1 1 ;
string $leg1[] = `polyCylinder -r 0.4 -h 3.5 -sx 8 -sy 1 -sz 1 -ax 0 1 0 -rcp 0 -cuv 3 -ch 1`;
xform -t -0.5 1.8 0 $leg1[0];
xform -ws -piv -0.5 3.55 0 $leg1[0];
string $leg2[] = `polyCylinder -r 0.4 -h 3.5 -sx 8 -sy 1 -sz 1 -ax 0 1 0 -rcp 0 -cuv 3 -ch 1`;
xform -t 0.5 1.8 0 $leg2[0];
xform -ws -piv 0.5 3.55 0 $leg2[0];
string $arm1[] = `polyCylinder -r 0.3 -h 3 -sx 8 -sy 1 -sz 1 -ax 0 1 0 -rcp 0 -cuv 3 -ch 1`;
xform -t -1.6 5.1 0 $arm1[0];
xform -ws -piv -1.6 6.6 0 $arm1[0];
string $arm2[] = `polyCylinder -r 0.3 -h 3 -sx 8 -sy 1 -sz 1 -ax 0 1 0 -rcp 0 -cuv 3 -ch 1`;
xform -t 1.6 5.1 0 $arm2[0];
xform -ws -piv 1.6 6.6 0 $arm2[0];
// Add expressions
expression -s ($leg1[0]+".rotateX = sin(time*4)*45;") -ae 1 -uc all ;
expression -s ($leg2[0]+".rotateX = -sin(time*4)*45;") -ae 1 -uc all ;
expression -s ($arm1[0]+".rotateX = -sin(time*4)*20;") -ae 1 -uc all ;
expression -s ($arm2[0]+".rotateX = sin(time*4)*20;") -ae 1 -uc all ;
// Create a group for the head. If Hat is selected, the hat will be parented.
select -r $head[0];
string $headGroup = `group`;
xform -ws -piv 0 7 0 $headGroup;
// Create a group for the body, in case bowtie is selected.
select -r $body[0];
string $bodyGroup = `group`;
// Optional Hat creation
if ($hatSel == 1)
{
string $hat[] = `polyCylinder -r 0.75 -h 1.5 -sx 12 -sy 2 -sz 1 -ax 0 1 0 -rcp 0 -cuv 3 -ch 1`;
xform -t 0 9.5 0 $hat[0];
select -r ($hat[0]+".e[12:23]");
xform -r -t 0 -0.398477 0;
string $extrude1[] = `polyExtrudeFacet -constructionHistory 1 -keepFacesTogether 1 -pvx 0 -pvy 8.925761506 -pvz 0 -divisions 1 -twist 0 -taper 1 -off 0 -thickness 0 -smoothingAngle 30 ($hat[0]+".f[0:11]")`;
setAttr ($extrude1[0]+".localTranslate") -type double3 0 0 0.422521 ;
parent $hat[0] $headGroup;
string $hatShad = `shadingNode -asShader blinn`;
sets -renderable true -noSurfaceShader true -empty -name ($hatShad+"SG");
connectAttr -f ($hatShad+".outColor") ($hatShad+"SG.surfaceShader");
// Create a ramp to make a red ribbon around the hat.
string $rampTex = `shadingNode -asTexture ramp`;
string $p2dt = `shadingNode -asUtility place2dTexture`;
connectAttr ($p2dt+".outUV") ($rampTex+".uv");
connectAttr ($p2dt+".outUvFilterSize") ($rampTex+".uvFilterSize");
connectAttr -f ($rampTex+".outColor") ($hatShad+".color");
// Adjust the ramp settings
setAttr ($rampTex+".interpolation") 0;
setAttr ($rampTex+".colorEntryList[0].position") 0.510836;
setAttr ($rampTex+".colorEntryList[1].position") 0.569659;
setAttr ($rampTex+".colorEntryList[2].position") 0;
setAttr ($rampTex+".colorEntryList[0].color") -type double3 0.551 0 0;
setAttr ($rampTex+".colorEntryList[1].color") -type double3 0 0 0;
setAttr ($rampTex+".colorEntryList[2].color") -type double3 0 0 0;
select -r $hat[0];
sets -e -forceElement ($hatShad+"SG");
}
// Optional Bowtie
if ($btieSel == 1)
{
string $bowtie[] = `polyCube -w 1 -h 0.5 -d 0.2 -sx 2 -sy 1 -sz 1 -ax 0 1 0 -cuv 4 -ch 1`;
select -r ($bowtie[0]+".e[12]") ($bowtie[0]+".e[18]") ;
scale -r -p 0cm 0cm 0cm 1 0.251157 1 ;
xform -t 0 6.5 0.7 $bowtie[0];
parent $bowtie[0] $bodyGroup;
// Add red bowtie shader
string $btShad = `shadingNode -asShader blinn`;
sets -renderable true -noSurfaceShader true -empty -name ($btShad+"SG");
connectAttr -f ($btShad+".outColor") ($btShad+"SG.surfaceShader");
setAttr ($btShad+".color") -type double3 0.551 0 0 ;
select -r $bowtie[0];
sets -e -forceElement ($btShad+"SG");
}
// Add expression to the Head / Hat.
expression -s ($headGroup+".translateY = abs(sin(time*4))*0.2;\n"
+$headGroup+".rotateZ = sin(time*4)*10;") -ae 1 -uc all ;
// Group body, head and arms. Add expression.
select -r $headGroup $bodyGroup $arm1[0] $arm2[0];
string $bodyGroupAnim = `group`;
expression -s ($bodyGroupAnim+".translateY = abs(sin(time*4)*0.1);\n"
+$bodyGroupAnim+".rotateY = sin(time*4)*10;") -ae 1 -uc all ;
select -r $leg1[0] $leg2[0] $bodyGroupAnim;
group -n "walkingFella";
select -cl;
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter