Moderators: Disciple, zlovatt

Topic Author
Posts: 1
Joined: Wed Aug 05, 2015 4:39 pm

Time remap and spatial interpolation in a single expression

Wed Aug 19, 2015 12:17 am

Hi all,

I'm having trouble getting two bits of code to talk within the one expression. A time remap, and a spatial interpolation. I need the latter to be determined by the former. I'm no expert, but I've tinkered around a bit and can manage a few things - but this has me stumped.

Originally, I had these two bits of code separate - the time remap code was operating on time remap keyframes applied to a precomp, and the spatial interpolation code operated on a null object inside that precomp. Things worked fine. For various client related reasons, I needed to pull the contents out of the precomp and place it all in the main comp, which has made the two bits of code clash somehow.

What I am trying to do is two things:

1) establish an elastic time zone in my comp, which is controlled by the time location of a marker on a duration controller layer. Move the marker and the elastic time zone contracts or stretches. I want this to apply to the position data of a null called the Movement Controller.

2) The position of the Movement Controller null over time is interpolated between the locations of three other null objects - Origin, Resting Point and Destination. It is also determined by four markers:

- In-Animation Start time
- In-Animation End time
- Out-Animation Start time
- Out-Animation End time.

In between the In-Animation End and Out-Animation Start time markers lies the elastic time zone, where the Movement controller will sit at the Resting Point position.

Currently I have two chunks of code in the one expression, which I can't get to interact properly. Everything seems to work fine until the out animation begins, and the Movement controller's position just jumps in one frame from Resting Point to Destination Point.

Help! (and thanks in advance for your help)



Here is the code:

//Time Remap Code

// This is the total duration of the animate in and animate out keyframes
totalDelay = 3.6;

// This takes the time value of the total duration marker minus totalDelay
holdTime = thisComp.layer("Duration Controller").marker.key(1).time - totalDelay;

// This is the layer containing the two markers which delineate the ‘elastic’ time region
ElasticZone = thisComp.layer("Elastic Time Zone Markers");

t1 = ElasticZone.marker.key(1).time;
t2 = t1 + holdTime;
t3 = ElasticZone.marker.key(2).time;

//This remaps the time in the elastic time zone according to the duration marker

if (time < t1) { t = time }
else if (time < t2) { t = linear(time,t1,t2,t1,t3) }
else { t = t3 + (time - t2)} ;


// Spatial Interpolation Code

OriginPos = thisComp.layer("Animation Origin Point").transform.position; // Position of the origin point null where the animation begins
RestingPos = thisComp.layer("Animation Resting Point").transform.position; // Position of the resting point null where the animation comes to rest
DestPos = thisComp.layer("Animation Destination Point").transform.position; // Position of the destination point null where the animation finishes

InStart = thisLayer.marker.key(2).time; // in-animation start point time
InEnd = thisLayer.marker.key(3).time // in-animation end point time
OutStart = thisLayer.marker.key(4).time; // out-animation start point time
OutEnd = thisLayer.marker.key(5).time; // out-animation end point time

easeVal1 = ease(time,InStart,InEnd,0,100); // This is so that I can ease the ease below a bit more

// This section eases the position of this null object between the OriginPos, RestingPos and DestPos over time

if (time < InStart) { OriginPos }
else if (time < In End) { easeOut(easeVal1,0,100,OriginPos,RestingPos) }
else If (time < OutStart) { RestingPos }
else if (time < OutEnd) { ease(time,OutStart,OutEnd,RestingPos,DestPos) }
else { DestPos };

Who is online

Users browsing this forum: No registered users and 2 guests