Maya - Driving spine volume preservation with animCurve?

Hi, guys,

I’ve been trying to achieve something in Maya and I’m having a hard time getting the right setup for it. So what I have is the spine of a character: some joints constrained to a curve (using motion paths). So far, so good. Next step is adding volume preservation to the spine, which is not hard: take the original length of the spine curve, divide it by the current length after squashing/stretching and using that value to drive the scaleY and scaleZ attributes on each joint. Using a multiplication factor, independent on each joint, I can add some variation to the scale so I have, for example, a belly that scales a bit more than the chest.

What I’m trying to do is to read these multiplication factors from an animCurve that I have set up in another object. First step is trying to read the keyframe value information, which is possible by using these lines:

getAttr myCurve.keyTimeValue[0].keyValue; 

… which returns the value for the first keyframe (I have a animCurve with 3 keyframes that follows the shape of a Gauss bell curve (http://www.itl.nist.gov/div898/handbook/pmc/section5/gifs/normal.gif)). I tried to expose those attributes in the connection editor, but apparently the only way to access them is by scripting. So I went to the Expression Editor, and although everything seems to work in terms of syntax, by using this expression:

baseObject.scaleY = myCurve.keyTimeValue[0].keyValue;

… the value of scaleY is always 0, when the value returned in the first line I quoted is different than 0.

And then, eventually, I might need to get the animCurve value not only in the keyframes, but that will come later. So do you know if I’m missing something here? Is this the way it should be done? Do you happen to know another way?

Thanks!!!

Just to add more things to the mix, I can get the value of the curve at an specific frame (4, in this example) by using:

`getAttr -t -4 myCurve.scaleCurve` // this is the parameter where the curve is

… but as far as I know you cannot use getAttr inside an expression, and I don’t know any other way to get this value.

Are you just using the animCurve to approximate a falloff function, or do you actually want to animate it? If you’re just using it as an ease curve, you can do it with the hermite function: a hermite with tangents at 0 is half of an ease curve.

Hi,

Here’s an idea to get the animation curve’s data using Maya’s builtin frameCache node. Hope this is helpful.

so weve got the animated curve with keys at say frame 1, 5, and 6.

try making a frameCache node and connect attribute that is animated to the “stream” attribute of frameCache node (animated attribute --> cacheName.stream). Now frameCache has info on animation curve.

try changing “varyTime” attribute of frame cache to 5. this makes frameCache have data on the 5th frame of animation curve. To get the animated value query the cache’s “varying” attribute.

changing varyTime to 3 would give the animated value at 3rd frame eventhough a key wasn’t set there.

cheers,
-Nate

Inspired by Jason Schleifer’s Animator Friendly Rigging (jasonschleifer dot com).

Nate! That sounds like what I was looking for! I cannot wait to try it.

Both of you, thanks!