ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Expression Meaning

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Ole PetersExpression Meaning
by on Aug 6, 2015 at 8:37:50 pm

Hello,
I'm kind of new to writing expressions, and I want to know what this expression "means";
cnt = thisComp.layer("Controls").effect("Count")(1);
indexOffset = thisComp.layer("Controls").effect("Start Index")(1) - 1;
idx = index - indexOffset;
if (idx > cnt || idx <= 0) [0,0,0] else {
tunLength = thisComp.layer("Controls").effect("Tunnel Length")(1);
spd = thisComp.layer("Controls").effect("Tunnel Flythrough (s)")(1);
tunFrames = timeToFrames(spd);
fps = 1.0 / thisComp.frameDuration;
zOffset = tunLength / tunFrames;
if (idx > tunFrames) [0,0,0] else {
z = - zOffset * ((timeToFrames(time) % tunFrames + spd * (fps / cnt) * (idx - 1)) % tunFrames);
transform.position + [0, 0, z];
}
}

It's applied to the position on a layer and moves it back when it reaches a certain point - but how? I do know the really basic stuff like thisComp.layer("Controls").effect("Start Index" )(1)
but not more, I appreciate the help.

Ole


Return to posts index


Kalle KannistoRe: Expression Meaning
by on Aug 7, 2015 at 8:41:31 am
Last Edited By Kalle Kannisto on Aug 7, 2015 at 8:43:06 am

This is how I read it:

cnt = number of layers used for the tunnel, as set by a control (likely a slider)
indexoffset = the first layer used (assuming there are layers that you don't want to include as tunnel layers), as set by a control
idx = layer index (which AE generates internally) minus indexoffset
tunLenght = tunnel lenght; how many layers make up the tunnel (set by control)
spd = speed at which the layers are moved along z axis, one length of tunnel in seconds (set by a control)
tunFrames = how many frames that one length of tunnel takes to travel
fps = frames per second
zOffset = how much to offset along z-axis for one frame

The main calculation is then done in this part:
z = - zOffset * ((timeToFrames(time) % tunFrames + spd * (fps / cnt) * (idx - 1)) % tunFrames);
Which calculates the modulus of full tunnel lengths traveled, i.e. subtracts the number of complete tunnel lengths traveled.
This is then returned as final position value transformation (change to current value):
transform.position + [0, 0, z];


Return to posts index

Ole PetersRe: Expression Meaning
by on Aug 8, 2015 at 3:16:53 pm

Thank you for the explanation :)


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]