View Full Version : Offsetting a value in an expression by time
SirCharles 02-09-2005, 02:43 AM Can anyone tell me how to write an expression that will take object A and make its rotateX = to object B's rotateX but minus n frames?
So I want objectA.rotateX to = what objectB.rotateX was on the previous frame or on whatever frame I specify.
|
|
john_homer
02-09-2005, 04:45 AM
A.rx = `getAttr -t (frame - 1) B.rx`;
.j
SirCharles
02-09-2005, 07:19 AM
OK, that works but is there any way to make it work so that when I move B.rx it will update A.rx in realtime rather than having to scrub the time slider to do it?
seven6ty
02-09-2005, 07:49 AM
Utility nodes possibly? I'm not sure about querying the time with those though.
tsdorsey
02-10-2005, 02:56 AM
Hey SirCharles,
If you wanted to do this with a utility node (which will update much faster and be more reliable) you can use the frameCache node.
To create a frameCache node, type "createNode frameCache" without the quotes, into the command line or script editor. You then need to use the connection editor to plug it into your node setup.
when you create the node it will be selected, don't deselect it. Bring up the connection editor and hit the "Reload right" button. This will load the inputs of the frameCache node into the connection editor.
Now you need to bring up the hypergraph, select your object you want to be the driver object, and hit the "graph input and output connections" button.
find the animation curve going into the attribute you want to sample and select it. Hit reload left on the connection editor.
Now connect the "output" from the animation curve to the "stream" on the frameCache node.
What you have done so far:
The frameCache node takes in one animated channel into the stream attribute and allows you to connect as many channels as you want to its outputs, which are either future or past values of the animated channel, but with a frame number offset.
Back to making it work
OK. Now you have to decide how much of a frame offset you want to have. Lets say you want a frame offset of 5 and you want it to be in the past so the child follows the parent. You have to use the connectAttr command to do this. (I know it's kind of a hassle, but there is no real way arround it yet. I think I'll write a small interface for it though, but not now)
By default, the first frameCache node is named frameCache1 when you create it. (look at the top of the connection editor if your not sure)
Select the object you connected to the frameCache node (the parent)
Open the hypergraph (if you closed it)
graph input and output connections
you will see the frameCache node connected to the selected node.
the command to connect the key to the output of the frameCache node is
connectAttr frameCache1.past[5] child.translateX;
5 is the frame offset
"past" could also be "future" if you wanted it to lead the parent instead of following
here is an image to show you what it will look like in the hypergraph when you have the nodes connected.
http://www.tddev.com/images/framecache.jpg
If you have any question about this procedure, please post them. OR you can IM me with either YIM or AIM. the names are in my signiture.
Later,
Trevor
CGTalk Moderation
02-10-2006, 03:00 AM
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.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.