AE ENHANCERS

Expressions/Scripts/Presets
It is currently Thu May 23, 2013 3:12 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Camera After Motion Between Frames
PostPosted: Wed Oct 31, 2007 1:41 pm 
Offline
User avatar

Joined: Mon Apr 30, 2007 5:55 am
Posts: 157
Location: United States, Ohio
Hi All,

I have been trying to do camera after motion.
I have this expression:
Code:
t = time- key(2).time;
if (t < 0) {
value;
}
else
{
veloc =28;
amplitude = 60;
decay =2.05;
x = amplitude*Math.cos(veloc*t)/Math.exp(decay*t);
y = amplitude*Math.sin(veloc*t)/Math.exp(decay*t);
value + [x,y];
}


Which does work if place it in the position field of the camera.

However, it only works for two keyframes.
In my comp I have a camera which starts off far away, then moves into view and stops. This takes up two keyframes. After the second keyframe the expression code kicks in and does a slight wobble on the camera.

What I would like to do, is to allow multiple camera moves and stops with the wobble only kicking in between the stops.

I'm wondering how I could modify the expression to achieve this functionality?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 31, 2007 2:15 pm 
Offline

Joined: Sat Jun 26, 2004 10:01 am
Posts: 298
Location: Folsom, CA
This might do what you want. It should cause the wobble at each even numbered keyframe - the assumption being that the even numbered keyframes are hold keyframes and the camera travels between odd and even keyframes.

Code:
n = 0;
if (numKeys > 0){
  n = nearestKey(time).index;
  if (key(n).time > time) n--;
  if (n%2)n--;
}
if (n == 0){
  value;
}else{
  t = time - key(n).time;
  veloc =28;
  amplitude = 60;
  decay =2.05;
  x = amplitude*Math.cos(veloc*t)/Math.exp(decay*t);
  y = amplitude*Math.sin(veloc*t)/Math.exp(decay*t);
  value + [x,y];
}


Dan

_________________
http://www.motionscript.com


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 01, 2007 6:56 am 
Offline
User avatar

Joined: Mon Apr 30, 2007 5:55 am
Posts: 157
Location: United States, Ohio
Thanks Dan,

That looks like it works!

Hmmm...
An interesting side effect of this expression is that is crashes After Effects 7 if you change the length of your comp.
Here is the work flow for creating the crash.

1.)Make a new comp that is 10 seconds long.
2.)Add some text and turn on the 3D switch.
3.)Add a camera.
4.)Paste the expression code into the position property of the camera.
5.)Set four keyframes for the camera with some space inbetween to observe the after motion effect.
6.)Press the insert key and preview the animation.
7.)Now use CTRL-K and change the time from 10 seconds to 5 seconds.

I'm not eactly sure what causes the crash, but if you preview a couple of times after you have reduced the length of the comp, then click to interupt the preview you get a (0::42) crash.

Seems to work fine if you do not change the comp length.
Just thought I'd mention the caveat.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group