Maya 2013 Rigging simple script Help

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Display Modes
  11 November 2012
Maya 2013 Rigging simple script Help

Alright, here's the issue. I actually have a script on some bones of the legs/arms of my character to make the leg/arm stretch. It works with a measure tool, so as far as the distance tool is higher than the base value (when the character is at his initial pose), the arms/legs will stretch.

The problem is that when I scale the Master Icon of my character, it scale the distances tools too, so make the character arms and legs stretch, but I don't want it. I want that the arms and legs don't stretch when I scale the whole character with the Master Icon.

So yeah, all I want is to be able to scale the whole character with the Master Icon without the legs and arms stretch. (Don't know if it's clear here?)

Here's the initial script for one bone of the left leg:

1-

if ( RG_L_legStretchDistanceDimension_Shape1.distance > 7 ) { BD_L_leg_1.scaleZ = (RG_L_legStretchDistanceDimension_Shape1.distance/7);

} else {

BD_L_leg_1.scaleZ = 1;

}





7 is the Distance value of the distance tool.



And here's the script attempt (that don't works actually) to add (multiply) the Master Icon stretch value to the distance tool value. This way it's supposed to cancel the extra stretch when I scale the Master Icon.

I used to try with only the Scale X of the Master Icon and it "worked", only, when I scaled the Master Icon in Y or Z, it didn't worked. So I attempted to connect all the 3 axis separately, but it don't works. I guess it's just the way to write the script, telling I want it to multiply the Distance Tool value (7) with the X, Y or Z of the Master Icon (or only X and Z or only Y and X etc etc).

Here's the script attempt:

2-


if ( RG_L_legStretchDistanceDimension_Shape1.distance > 7*(RG_C_masterIcon_1.scaleX || RG_C_masterIcon_1.scaleY || RG_C_masterIcon_1.scaleZ))
{ BD_L_leg_1.scaleZ = (RG_L_legStretchDistanceDimension_Shape1.distance/7*(RG_C_masterIcon_1.scaleX || RG_C_masterIcon_1.scaleY || RG_C_masterIcon_1.scaleZ) );

} else {

BD_L_leg_1.scaleZ = 1;

}



Here's some picture to show what happen (Maybe it'll help to understand the problem)

1. Initial pose:



2. Normal leg stretch (without scaling the Master Icon):




3. And now the problem it goes when I scale the Master Icon (the legs aren't stretched voluntarily they are at their initial pose (like on the 1st pic, only the Master Icon got scaled)) - What I want is that the pose stay like on the 1st pic when I scale the Master Icon.

__________________
Portfolio | Videos
 
  11 November 2012
The || operator will always return 1 or 0. So the result of 7*(RG_C_masterIcon_1.scaleX || RG_C_masterIcon_1.scaleY || RG_C_masterIcon_1.scaleZ) will either be 7 or 0, and that is not what you want. Your approach is correct though. So you just need to add a few lines to get the multiplier calculated correctly. Do you really need to allow for non-proportional scale?

David
__________________
http://www.djx.com.au
 
  11 November 2012
Originally Posted by djx: The || operator will always return 1 or 0. So the result of 7*(RG_C_masterIcon_1.scaleX || RG_C_masterIcon_1.scaleY || RG_C_masterIcon_1.scaleZ) will either be 7 or 0, and that is not what you want. Your approach is correct though. So you just need to add a few lines to get the multiplier calculated correctly. Do you really need to allow for non-proportional scale?

David


Alright thanks for telling here, actually what kind of lines should I add? And yeah I need to be able to do a non-proportional scale, it'll be pretty much cartoon.
__________________
Portfolio | Videos
 
  11 November 2012
Yeah, I guess I was hinting that you should rethink how you are doing it. My knee-jerk response was that mapping the non-proportional scale of 3 axes to a single measurement will need more than a simple conditional statement like you were writing. However if you were to add a 2nd distance node to measure the base size, then you would only need to compare the two distances.

David
__________________
http://www.djx.com.au
 
  11 November 2012
Originally Posted by djx: Yeah, I guess I was hinting that you should rethink how you are doing it. My knee-jerk response was that mapping the non-proportional scale of 3 axes to a single measurement will need more than a simple conditional statement like you were writing. However if you were to add a 2nd distance node to measure the base size, then you would only need to compare the two distances.

David


Alright, yeah, might think, put a Measure tool for each axes and then multiply them to the leg dinstance?

not sure to understand clearly what you mean here, what would it looks like in code:

However if you were to add a 2nd distance node to measure the base size, then you would only need to compare the two distances.

The distance tool you would had would be at the Master Icon when you say "Base size"?

And not sure to clearly understand how would I compare the 2 distances (which distance exactly and what kind of code to compare this? And what value would it bring? The value to multiply to the leg stretch distance?)

Sorry I really don't know that much in code, I don't know that much how to write more complexe stuff. Like how put in code what I want.
__________________
Portfolio | Videos

Last edited by BrioBriss : 11 November 2012 at 06:54 AM.
 
  11 November 2012
Originally Posted by BrioBriss: ...put a Measure tool for each axes and then multiply them to the leg dinstance?

No, thats not what I meant.
I'm assuming you have the measure tool set up to give you the distance that the ik handle on the leg moves and you are using that distance to calculate how much to stretch the leg bones. At the moment you have a hard coded base value (7) so that when your rig is scaled up, the fixed base value gives you the wrong result. In your code you seem to be trying to work out a way to scale the base value to match the rig scale, which needs to allow for non-proportional scale.

What I'm suggesting is that where you have that measure tool, make another one, but this time rather than connecting one end to the ik handle, connect to the same place in the heirarchy as the other end, but position it where the ik handle is in its neutral state. This 2nd measure tooll gives you the base value, and it will be scaled with the rig, just like the first one. Now you just need to compare the two.

if ( RG_L_legStretchDistanceDimension_Shape1.distance > RG_L_legBaseDistanceDimension_Shape1.distance ) { BD_L_leg_1.scaleZ = (RG_L_legStretchDistanceDimension_Shape1.distance/RG_L_legBaseDistanceDimension_Shape1.distance);

} else {

BD_L_leg_1.scaleZ = 1;

}


David
__________________
http://www.djx.com.au
 
  11 November 2012
Originally Posted by djx: No, thats not what I meant.
I'm assuming you have the measure tool set up to give you the distance that the ik handle on the leg moves and you are using that distance to calculate how much to stretch the leg bones. At the moment you have a hard coded base value (7) so that when your rig is scaled up, the fixed base value gives you the wrong result. In your code you seem to be trying to work out a way to scale the base value to match the rig scale, which needs to allow for non-proportional scale.

What I'm suggesting is that where you have that measure tool, make another one, but this time rather than connecting one end to the ik handle, connect to the same place in the heirarchy as the other end, but position it where the ik handle is in its neutral state. This 2nd measure tooll gives you the base value, and it will be scaled with the rig, just like the first one. Now you just need to compare the two.
David


Actually just to be clear this way to do it would be for a non-proportional scale, right?

Alright thanks a lot for the code, it's easier for me to understand. Actually the thing I'm not sure to fully understand is where you want me to put the 2nd Distance tool exactly. You mean to not put it exactly where the one I use is but you seems to mean to put it at the neutral position (which the one I already use is actually). Not sure to understand that part.

Also to clear that, the distance tool isn't with the IK handle, it is at the start of the leg to the foot. It measure the lenght of the leg actually, so when the distance tool value is higher than 7 (in this case) (7 is the neutral pose), the leg start to stretch.

Hop it's clearer here.
Your help is highly appreciate btw.
__________________
Portfolio | Videos
 
  11 November 2012
Well I had to make some guesses about your rig Anyway, where I said "ik handle", read "foot" then. In my rigs the foot_CTL would normally drive the ik handle that controls the leg.
Having 2 measure tools working together means you no longer need to worry about the non-proportional scale. Both measure tools receive the same scale so no extra math is required. One measure tool is dynamic, meaning is changes length when the "foot" moves. The other is static, meaning it is fixed in length (except for the fact that it is below your master control which you have said can scale non-proportionally). The fixed length of the 2nd measure tool is the base length for your stretch calculation, meaning it is the same length as the dynamic measure tool when the "foot" is in the neutral pose.

David
__________________
http://www.djx.com.au
 
  11 November 2012
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright ©2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 04:06 AM.


Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.