Increment Rotation At Markers

Moderators: Disciple, zlovatt

Post Reply
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:

This expression will increase (and animate) the rotation by the user defined number or degrees at every marker on the layer. If you set the duration to anything more than 0 the rotation will animate into the marker. In other words it will start the rotation f frames before the marker and it will finish the rotation at the marker.

Code: Select all


f=5; //duration in frames of rotation, set to zero if you want it to click
d=20; //degrees to rotate


f=framesToTime(f, fps = 1.0 / thisComp.frameDuration);
n = 0;
if (marker.numKeys > 0){
  n = marker.nearestKey(time).index;
  if (time > marker.key(n).time && n < marker.numKeys){
	n++;
  }
r=(d*(n-1)) + value;
linear (time,marker.key(n).time-f,marker.key(n).time,r,r+d);
}
-Lloyd
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:

This expression will oscillate rotation back and forth at markers:

Code: Select all

f=5; //duration in frames of rotation, set to zero if you want it to click
d=20; //degrees to rotate

r=value;
f=framesToTime(f, fps = 1.0 / thisComp.frameDuration);
n = 0;
if (marker.numKeys > 0){
  n = marker.nearestKey(time).index;
if (n%2) {d=d*-1; r=r-d;} 
linear (time,marker.key(n).time-f,marker.key(n).time,r,r+d);
}
User avatar
Disciple
Posts: 137
Joined: June 5th, 2004, 8:05 am
Location: Los Angeles, CA
Contact:

Hey Lloyd

This might come in handy for me on a current project. How would you combine this with a wiggle? ie if I wanted the wiggle to increase based on your script?

Thanks
Alex
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:

you want the amount of wiggle to increase at each marker?
User avatar
Disciple
Posts: 137
Joined: June 5th, 2004, 8:05 am
Location: Los Angeles, CA
Contact:

Yes, sorry if I wasn't clear. I'm basically trying to find ways to control the evolution of a wiggle parametrically, ie without keyframes from a slider. Markers are one good way I hadn't thought of...

Thanks!
Alex
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:

Code: Select all

freq=24; //wiggle frequency in frames per second
s=0; //wiggle start amount
d=20; //amount to increase wiggle at each marker
f=15;  //duration in frames of transition to next amount, set to zero if you want it to click

f=framesToTime(f, fps = 1.0 / thisComp.frameDuration);
n = value;
if (marker.numKeys > 0){
  n = marker.nearestKey(time).index;
  if (time > marker.key(n).time && n < marker.numKeys){
   n++;
  }
r=(d*(n-1))+s;
a=linear (time,marker.key(n).time-f,marker.key(n).time,r,r+d);
wiggle(freq,a);

}
User avatar
Atomic
Posts: 157
Joined: April 30th, 2007, 5:55 am
Location: United States, Ohio

Can this be used with audio somehow?

Ideally to rotate on the beat. I often have the raw tracks for music, such as only the kick or only the snare fairly well isolated.
"Up And Atom

No...No

Up And At Them!"
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:

totally, that's what I wrote it for in the first place.. simply place markers on your layer at every beat..

if you want a more automated way to do that, you can reference this tutorial by Dan: http://www.motionscript.com/design-guid ... igger.html

and feed my expression the threshold time instead of the marker time. But in my experience i get better results when I mark the beats myself.. at least use Trapcode's soundkeys which can let you isolate frequencies better.

-lloyd
Post Reply