View Full Version : frameCache node

10 October 2003, 05:28 AM
Hi There,

Can anyone think of a way to be able to use a variable with the frame cache node, which can be used in an expression.

Basically, instead of :

connectAttr frameCacheNodeName.past[integer] objectConnected.attribute,

I'd like

connectAttr frameCacheNodeName.past[$variable] objectConnected.attribute



10 October 2003, 07:50 AM
Maybe with the "eval" command.

string $cmd = "connectAttr frameCacheNodeName.past[" + $variable + "] objectConnected.attribute";


10 October 2003, 03:20 PM
works okay, and thankyou ajk48n ;) (, but can anyone think of how to make this an animateable parameter?
Seems like the frameCache node can only receive one value in an array. Am I right?


10 October 2003, 03:45 PM
Maybe you could use the current time to get your variable:
$varible = time - 1;

string $cmd = "connectAttr frameCacheNodeName.past[" + $variable + "] objectConnected.attribute";

Don't know if this will work, but it might be worth trying.

10 October 2003, 03:22 AM

yep, that would work, but it still won't give me imput.
Anhow, I've given up on the frameCache node, optimized as it is :p , and gone with good ol' clunky getAttr.

I'm just trying to get a heirachial offset like on the attachment.

I'm wondering if some guru could show me how to optimize this clunky code. It works as I would like it too, but I know it's cumbersome.


float $delay = frame - parent.lag;
float $dampIO = parent.useDamping;
float $damp = parent.damping;

if ($dampIO==off){

child.translateX = eval("getAttr -t " + $delay + " parent.translateX");
child1.translateX = eval("getAttr -t " + ($delay - parent.lag) +" parent.translateX");
child2.translateX = eval("getAttr -t " + ($delay - 2*parent.lag) +" parent.translateX");
child3.translateX = eval("getAttr -t " + ($delay - 3*parent.lag) +" parent.translateX");
child.translateX = eval("getAttr -t " + $delay + " parent.translateX")*$damp;
child1.translateX = eval("getAttr -t " + ($delay - parent.lag) +" parent.translateX")*($damp/2);
child2.translateX = eval("getAttr -t " + ($delay - 2*parent.lag) +" parent.translateX")*($damp/3);
child3.translateX = eval("getAttr -t " + ($delay - 3*parent.lag) +" parent.translateX")*($damp/4);



10 October 2003, 04:53 PM
frameCache, as you've discovered, simply isn't flexible enough to do what you're trying to do. Using getAttr in an expression is usually worth avoiding, but in a case like this it's effective. Just be careful (as I just pointed out in a different thread) not to accidentally force recalculation of your entire scene twice on every frame by getting values for attributes that require such recalcuation.

-- Mark

CGTalk Moderation
01 January 2006, 12:00 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.