Mailing List AE-List@media-motion.tv ? Message #41256
From: Sascha Gritz <s.gritz@vucx.de>
Subject: [AE] smooth keyframes expression
Date: Wed, 14 Dec 2011 13:14:37 +0100
To: After Effects Mail List <ae-list@media-motion.tv>
Dear list,
sorry for the wrong subject I used for the last email.
We  got the following problem:
we track a point and give the tracked position data (x,y) to a null object. What we want to do now is write an adjustable expression that compares the values of the tracked data from frame to frame that determines changes in position that are above a specific threshold. Only if a change in position is beyond this threshold, movement should take place.

We put the expression on the keyframed transform.position of our null-object.
but it seems it isn't working.

The error we get at this point is that valueAtTime(0) is undefined. Although there is a Keyframe at frame 0;
since we step from error to error, there must be another problem.

By the way, the smooth function on the other hand is not an option, because it produces, in regard to our footage, not a fitting movement.

here is what we tried:

------------------------------
CODE
------------------------------

p = transform.position;

//we go through the frames and determine if major changes has taken place

for (f = 0; f <= timeToFrames(); f++){

savepos = p.valueAtTime(0);  //error at this line!

if (timeToFrames(0) == 0){
lastpos = savepos;
}


// define two points in time to compare values of these two

now = framesToTime(f);
nextnow = framesToTime(f+1);

tempLoc1 = p.valueAtTime(now);
tempLoc2 = p.valueAtTime(nextnow);

tempX1 = tempLoc1[0];
tempX2 = tempLoc2[0];
tempY2 = tempLoc2[1];

threshold = 0.5;


// if there is a change that is big enough we set the new position, else it stays as before

if (tempX1 < tempX2+threshold){
lastpos = [tempX2,tempY2];
p = lastpos;

}else{

p = lastpos;

}

}


------------
END CODE
------------

Many thanks in advance,
Sascha


--
__________________________________
VISION UNLTD. CREATIVE WORX GmbH

Bruesselerstr. 85
50672 Koeln

Fon +49 (0)221 56978 42
Fax +49 (0)221 56978 11
Mob +49 (0)178 7992039
s.gritz@vucx.de

check out our web page: www.vucx.de
die medienprofis: www.profigilde.de


 
Subscribe (FEED) Subscribe (DIGEST) Subscribe (INDEX) Unsubscribe Mail to ListMaster