Beer glass scene creation
This course contains a little bit of everything with modeling, UVing, texturing and dynamics in Maya, as well as compositing multilayered EXR's in Photoshop.
# 1 10-03-2006 , 11:19 AM
skywola's Avatar
Registered User
Join Date: Jan 2004
Location: Tempe, Arizona, USA
Posts: 224

Walkerman's addAttributes Procedure

On this procedure, I will only list PART of it, it is very straigh-forward and relatively redundant, as far as the commands go.

If you want to view the WHOLE procedure, just open up the file you have downloaded . . .

If you want to step thru the action, you can call the addSkeleton procedure:

addSkeleton 1;


You may need to create the $n variable to make it work right when you step through manually

int $n = 1;

OK, so now we call the addAttributes procedure:


global proc addAttributes (int $n){

Again, we are passing the $n parameter so we know which skeleton we are adding the attributes to. . .

Now we build a string so we can plug it in to the addAttr command, so it will know where to add in the attribute.
If you were to do this command manually, you would select the joint you wanted to add the attribute to and under MODELING, you would go to modify>add attribute. After doing this on a joint, look in the script editor, and lo and behold, there is the code!

string $bb = "|bb" + $n;
addAttr -ln slope -k on -at double -min -50 -max 50 -dv 0 $bb;

"slope" is the name of the attribute we are adding.
-k on . . . allow keyframing
-at double . . . type of attribute, could be int, string, etc.
-min -50 . . . allow values only => -50
-max 50 . . . allow values only =< 50
-dv . . . default value of zero
-string $bb is obtained from previous line of code; it looks like
this: |bb1
bb1 is the parent of all the joints in the skeleton.



Same as explained above on the code that follows, just adding
more new attributes to joint bb1 . . .

addAttr -ln bodybounce -k on -dv .3 -at double $bb;
addAttr -ln fwdspeed -k on -dv 1 -at double $bb;
addAttr -ln clock -k on -at double $bb;
addAttr -ln initXposition -k on -at double $bb;




This attribute added below allows me to be able to control characters based on what type of character it is. . . I haven't coded the bird or spider yet, those will be future projects, unless someone here decides to beat me to it . . :attn:

//Character Type 1=Human 2=Bird 3=Spider 4=Quadraped
addAttr -ln characterType -r true -dv 1 $bb;




//Keep record of what character number for future reference.
This stores the character number right on the skeleton of the
character itself . . . so if I need to find out what the character
number is that is selected, I can just query this attribute.

addAttr -ln characterNumber -r true -dv $n $bb;



Here we build a second string, so we can add attributes to a new joint location . . .

string $mb = "|bb" + $n + "|mb" + $n;

-string $mb is obtained from previous line of code; it looks like
this: |bb1|mb1
bb1 is the parent of all the joints in the skeleton.
mb1 is the joint we are adding the attributes below to.

addAttr -ln basebacklean -k on -at double -dv 0 $mb;
addAttr -ln shoulderPivot -k on -at double $mb;



The rest of the code in the procedure is the same with of course some of the paths to joints much longer, so it would be dreadfully boring if I listed it all, and if you want to see it in action you can step through it in the script editor . . .



Then at the end I have:

This is just legacy stuff that I was using to position the perspective camera via MEL . . . commented out.
// Position Perspective view camera
//setAttr "persp.translateX" 30;
//setAttr "persp.translateY" 22;
//setAttr "persp.translateZ" 45;


// pause for one second . . . without this in here, I was having trouble with the attributributes all adding if I remember correctly,
If you ever run into a problem where you code seems perfect when you step through it, but you are not getting proper results when it actually runs, you might want to give this a shot.

pause -sec 1;

}

And that is all on the addAttributes procedure. . . .


"The Sage as an Astronomer: If you still see the stars as something above you, you lack the eye of knowledge." Friedrich Nietzsche
Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off

Similar Threads