PDA

View Full Version : frameCache node


BigSky
10-24-2003, 06: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

Cheers.

;)

ajk48n
10-24-2003, 08:50 AM
Maybe with the "eval" command.

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

eval($cmd);

BigSky
10-24-2003, 04: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?

Cheers

mhovland
10-24-2003, 04:45 PM
Maybe you could use the current time to get your variable:
////
$varible = time - 1;

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

eval($cmd);
////
Don't know if this will work, but it might be worth trying.

BigSky
10-25-2003, 04:22 AM
Mike,

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.

EXPRESSION FOR AUTO OFFSET:

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");
}
else
{
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);
}


help!



:shrug:

mark_wilkins
10-25-2003, 05: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-16-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.