Thread: Joints and mel
View Single Post
# 2 22-03-2006 , 06:02 PM
skywola's Avatar
Registered User
Join Date: Jan 2004
Location: Tempe, Arizona, USA
Posts: 224
It is possible, I have been planning on a tutorial somewhat like what you are asking, the coding is more advanced, in that it takes several steps. I do have examples of it in my Walkerman program :

https://www.simplymaya.com/download_p...tid=6&typeid=4

or

Download > Mel Download > Animation Download


If you want to see working examples. All of it works thru following the joint heirarchy and querying attributes.

Listed below is a snippet of code I used in the module that turns the hand control on by editing expressions that control the joints in the hand. You can use the same process to get joint information.

Because of the limited width of this window, your better off downloading the Walkerman program and looking at the code in the handControlOn procedure in notepad . . .


// get main parent of all character parts
string $selectedObjects[] = `ls -sl -type joint`;
string $relBuffer[];
string $ultimate;
int $characterType;
int $characterNumber;

if (size($selectedObjects) == 0) {
string $window;
$window = `window -title "Walkerman" -iconName "Name" -widthHeight 200 55`;
columnLayout -adjustableColumn true;
text -label "\r\n\r\n Select a character to use its control window. \r\n\r\n" -fn "boldLabelFont" -align "center";
button -label "Close" -align "center" -command ("deleteUI -window " + $window);
setParent ..;
showWindow $window;
// Resize the main window
window -edit -widthHeight 300 114 $window;
}
else{
string $relBuffer[] = `listRelatives -f $selectedObjects[0]`;
$numTokens = `tokenize $relBuffer[0] "|" $relBuffer`;
if (size($selectedObjects) == 0)
print("You must select a character to turn hand control off.");
if (size($selectedObjects) > 1)
print("Select only one character part to get its control window.");
// Get characterNumber and characterType 1 = Human 2 = Bird 3 = Spider 4 = Quadraped (four legged) //
if (size($selectedObjects) == 1)
$ultimate = $relBuffer[0] + ".characterType";
$characterType = `getAttr $ultimate`;
$ultimate = $relBuffer[0] + ".characterNumber";
$characterNumber = `getAttr $ultimate`;

// HAND JOINTS
string $LBone = "LBone" + $characterNumber; string $FL2J1 = "FL2J1" + $characterNumber;
string $FL3J1 = "FL3J1" + $characterNumber; string $FL4J1 = "FL4J1" + $characterNumber;
string $FL5J2 = "FL5J2" + $characterNumber;
string $lw = "lw" + $characterNumber;

string $RBone = "RBone" + $characterNumber; string $FR2J1 = "FR2J1" + $characterNumber;
string $FR3J1 = "FR3J1" + $characterNumber; string $FR4J1 = "FR4J1" + $characterNumber;
string $FR5J2 = "FR5J2" + $characterNumber;
string $rw = "rw" + $characterNumber;
string $exp;



// get expressions from FL2J0
string $FL2J0 = "FL2J0" + $characterNumber;
// Get expressions connected to above joint
string $buffer[] = `listConnections -type expression $FL2J0`;
string $element;
string $compString;
string $expressionToEdit;

// edit expressions to de-activate hand control
for( $element in $buffer ){
$compString = `expression -q -s $element`; // query for present expression //
$expressionToEdit = $FL2J0 + ".rotateZ";
if(startsWith($compString, $expressionToEdit)){ // boolean - look for rotateZ //
$exp = $FL2J1 + ".rotateZ = " + $lw + ".leftGrab;"; // Left RZ Index Finger
expression -e -s $exp -o FL2J1 -ae 1 -uc all $element; // edit it
}
$expressionToEdit = $FL2J0 + ".rotateY";
if(startsWith($compString, $expressionToEdit)){ // boolean - look for rotateY //
$exp = $FL2J1 + ".rotateY = " + $lw + ".leftSpread * -.5;"; // Left RY Index Finger
expression -e -s $exp -o FL2J1 -ae 1 -uc all $element; // edit it
}
}


"The Sage as an Astronomer: If you still see the stars as something above you, you lack the eye of knowledge." Friedrich Nietzsche