View Full Version : Time Expressions

06-23-2007, 01:17 AM
With expressions, I want to move a NULL up the Y axis from 0m to 1m. Beginning at the 30th frame, and stopping at the 60th frame.

How would I write this?

I admit I'm not the sharpest tool in the shed, so any help would be greatly appreciated. I've combed the Expression Builder, searched the .pdf, tried a zillion different things but I still can't figure out how to get Lightwave 9.2 to do this simple thing...

06-23-2007, 05:13 AM
What about:

clamp( Frame, 30, 60 ) / 30 - 1

When Frame is anything below 30 it is 30 / 30 - 1 = 0.
When Frame is anything above 60 it is 60 / 30 - 1 = 1.
When Frame is anything inbetween it will be a linear curve going from 0 to 1.

Just out of curiousity, why do you need this as an expression? Why can't you key it?

06-26-2007, 12:38 AM
Thanks Evenflow!!!
The reason I am not just keyframing this is because I want to learn the basic methodology so I can apply it to other animations. "Teach a man to fish he eats for a lifetime" as the saying goes.

Despite reading the manual, pdf and builder, "Clamp" would have been the last thing I would have used!

But I don't understand how ( Frame, 30, 60 ) works.
I would think it would be something like (Frame 30 - 60)
Why commas?

06-26-2007, 12:54 AM
Oh wait, reading the builder I see how the "Clamp" is set up within the parenthesis but I think I don't understand the "/ 30 -1" part.

Is it knocking the motion back down a meter since otherwise it would be going from 1m to 2 m at that point?

06-26-2007, 01:14 AM
hmmm... okay, playing with it somemore I think I get it.
Was that really tricky on your part, or is this just how one normally writes expressions?

06-26-2007, 03:27 AM
Yes, the expression IS odd and hard to read. I did try to create a nested conditional statement first (if-then-else) but it didn't seem possible so instead I looked for functions that could turn a value of 30 to 0 and 60 to 1 (ie remap frame value into the values I wanted). I knew some such functions was available from prior experience. So if you want to become efficient with expressions continue what your doing, inform yourself of what's available and put it to use.

No, one typically wouldn't use expressions for something like this. Having a channel value depend on frame value only is uncommon, usually things depend on other channels values (at the same point in time, or slightly offset). I think most would've keyframed this, because it's easier to edit and if you'd like to have something depend on these channels keyframed values are always reliable. What I mean is that an expression, motion modifier, ik etc might have trouble reading the value created by another expression, motion modifier, ik etc. Ie a value can't depend on another value that in turn depends on something else. This is one of the biggest fault of the motion architecture. It might work at times because you got lucky with the evaluation order but is not reliable.