PDA

View Full Version : Maya 2013 Rigging simple script Help


BrioBriss
11-24-2012, 01:06 AM
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:

http://i206.photobucket.com/albums/bb52/oli_briss/InitialPose.jpg

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

http://i206.photobucket.com/albums/bb52/oli_briss/LegStretch.jpg


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.

http://i206.photobucket.com/albums/bb52/oli_briss/ScaleMasterIcon.jpg

djx
11-25-2012, 02:40 AM
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

BrioBriss
11-25-2012, 02:43 AM
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.

djx
11-25-2012, 05:14 AM
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

BrioBriss
11-25-2012, 05:50 AM
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.

djx
11-25-2012, 08:16 AM
...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

BrioBriss
11-25-2012, 06:23 PM
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.

djx
11-25-2012, 07:39 PM
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

CGTalk Moderation
11-25-2012, 07:39 PM
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.