Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions automating rotation across multiple layers

  • automating rotation across multiple layers

    Posted by Fadi Baqi on July 25, 2013 at 3:11 pm

    Imagine a bead curtain, except instead of beads there are windmills. Each windmill rotates at a different speed depending on height relative to the curtain. I want to be able to activate the rotation per thread in some easy and visually intuitive way. Check out the link for an example of what I mean.

    https://www.dropbox.com/s/b6uzs1z0y6a3ybg/NEW%20COMP_2.mp4

    I tried using Trapcode Form, windmills for particles, and then using the rotation layermap with a gradient layer. But the rotation parameter when sampling a layer does not provide constant rotation and will rotate the particle to a fixed angle.

    I tried using Dan Ebberts’ code to control constant rotation with a slider, and then got the slider to sample a layer, but it also provided erratic results.

    Does anyone have a better suggestion?

    DAN EBBERTS EXPRESSION TO CONTROL CONSTANT ROTATION WITH A SLIDER

    spd = effect("Slider Control")("Slider");
    n = spd.numKeys;
    if (n > 0 && spd.key(1).time < time){
    accum = spd.key(1).value*(spd.key(1).time - inPoint);
    for (i = 2; i <= n; i++){
    if (spd.key(i).time > time) break;
    k1 = spd.key(i-1);
    k2 = spd.key(i);
    accum += (k1.value + k2.value)*(k2.time - k1.time)/2;
    }
    accum += (spd.value + spd.key(i-1).value)*(time - spd.key(i-1).time)/2;
    }else{
    accum = spd.value*(time - inPoint);
    }
    value + accum

    Fadi Baqi replied 13 years ago 3 Members · 3 Replies
  • 3 Replies
  • Mitch Mann

    July 25, 2013 at 5:45 pm

    Hmm. Here’s how I might approach it…

    Lay out all of the windmills by hand. On any given line, have the lower windmill’s rotation equil the top (source) windmill’s rotation. Then you could multiply (or divide) that rotation value for each windmill by its layer’s layer number minus the source windmill’s layer number. That way, the lower down ones would be different speed from the higher up.

    Then to drive the rotation of the top (source) windmills’ rotations… If you want a visual way, you could make virtual sliders on the screen. Put a null above each string, then make an expression that uses Dan’s formula to have the y value of the null drive the source windmill’s speed. Move the null for a string up & down to control rotation speed. Or you could just do the same thing with sliders instead of null y-values, but it wouldn’t be visual right in the comp.

    I don’t know, that’s how I’d do it.

    Mitch

  • Dan Ebberts

    July 25, 2013 at 7:02 pm

    The problem with using that expression is that it’s driven by keyframes. You might try converting your sampleImage() expression to keyframes and see if it works.

    If that doesn’t work, do you really need to drive the speed with a gradient? It might be easier to solve if you could reduce everything to expression math and keyframes.

    Dan

  • Fadi Baqi

    July 25, 2013 at 8:42 pm

    Hey Dan, Hey Mitch,

    Here’s what I ended up with.

    https://www.dropbox.com/s/oizf3ewyoszdeoq/existing%2001%20folder.zip

    Strangely, the expression works until I try to sampleImage from a global position. In the file are two sets of windmills, the one on the left, reading a global position, gives the same value as the one on the right, sampleImaging from the layer’s position, but the first set doesn’t produce a rotation while the second (the one reading from the wrong position) does.

    Any ideas?

    Is there a far simpler way to do this that I am unaware of? I am setting up like this because I want to experiment with activating the windmills according to a variety of different patterns. That’s why I thought this would be the way to go.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy