Simply Maya User Community

Simply Maya User Community (https://simplymaya.com/forum/index.php)
-   Programming (https://simplymaya.com/forum/forumdisplay.php?f=32)
-   -   Walkerman's addBodyCode Procedure (https://simplymaya.com/forum/showthread.php?t=20596)

skywola 10-03-2006 12:12 PM

Walkerman's addBodyCode Procedure
 
This is the third procedure called, in the Walkerman program.

If you are stepping thru Walkerman with the script editor, you would be doing this:

int $n = 1;
addSkeleton($n);
addAttributes($n);

Then we come to this procedure:

global proc addBodyCode (int $n){


Here we are just building strings so we can use them later in the code. . . .
// BODY JOINTS
string $bb = "bb" + $n; // gives "bb1"
string $hc = "hc" + $n; // gives "hc1"
string $hl = "hl" + $n; // gives "hl1"
string $hr = "hr" + $n; // etc . . .
string $ls = "ls" + $n;
string $rs = "rs" + $n;



Now the FUN part . . .

Here we build the string we need to add the mathematical coding for the expression we want.

string $exp1 = $hl + ".rotateZ = " + $hl + ".legSpread + tan(" +
$bb + ".clock * " + $hc + ".hipSwing/" + $bb
+ ".initYposition - .5)-5.74;";

Not a wide enough window to show the expression properly here, but it builds to a string:

hl1.rotateZ = hl1.legSpread +
tan(bb1.clock * hc1.hipSwing/bb1.initYposition -.5)-
5.74;


Now we actually create the expression:

expression -s $exp1 -o hl -ae 1 -uc all;



Jumping to a easier expression:

string $exp3 = $ls + ".tx = -"+ $rs + ".tx;";

builds the string:

ls1.tx = -rs1.tx;

Then we create the expression:
expression -s $exp3 -o rs -ae 1 -uc all ;


Everything that follows is basically the same functions being repeated to create coding for all the joints in the body. . . . and lots of fun stuff like MATH - a fun can of worms to open up if you have the time and patience. . . . :eek:


Keep in mind that the code

ls1.tx = -rs1.tx;

could also be:

ls2.tx = -rs2.tx; or ls4.tx = -rs4.tx;

Depending on which character number you are building.

Then we want the parent of all the joints selected as we exit the procedure . . .

select -r $bb;

}

The only complicated part of this procedure is the math . . . .
Building the sttings for the code can be a pain too, but you can print the expressions out in the script editor to see what they look like and then edit them as needed.


All times are GMT. The time now is 03:44 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Simply Maya 2018