Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Layer Transforms?

  • Posted by Mihai Wilson on January 22, 2012 at 4:37 pm

    Hi, I’m really struggling with understanding layer transforms. I’ve found plenty of great looking posts from people like Dan, but I’m still too green to actually understand how to put them into practice.

    So. I am hoping someone can help me do this:

    translate the position and rotation of a 2D layer that sits within a 2D subcomp of a 3D comp to that of the comp. I would like a null within the comp to be able to basically “lock” onto the position and rotation of a null (layer) within the subcomp.

    structure:
    layer (scaled, positioned, rotated)
    subcomp (2d – no camera, no 3d layers) (scaled, positioned, possibly rotated)
    comp (3d – has camera. 3d layers)

    An example comp would be ridiculously fantastic, but I’m sure I can figure it out with plain old text too.

    Once I get a handle on this I think I will post a tutorial — such a useful thing to understand, but from what I have gathered, it is not well understood (barring geniuses of Dan’s sort)

    Dan Ebberts replied 14 years, 3 months ago 2 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    January 22, 2012 at 11:08 pm

    The problem is that there aren’t any built-in transforms to give you world rotation of a 3D layer. You can do it, but the math for rotation transforms is pretty ugly.

    Dan

  • Mihai Wilson

    January 22, 2012 at 11:45 pm

    How ugly are we talking? No cheap hacks?

    I’m still curious to figure this out — I saw a post on here where I think you laid it out for someone else, but I couldnt figure out how to put the code into practice. (Was confused as to which names of which entities needed to go where)

    Is this it:

    L = comp("Pre-Comp").layer("FOLDING SIDE");
    CL = thisComp.layer("Pre-Comp");
    u = CL.toWorldVec(L.toWorldVec([1,0,0]));
    v = CL.toWorldVec(L.toWorldVec([0,1,0]));
    w = CL.toWorldVec(L.toWorldVec([0,0,1]));

    sinb = clamp(w[0],-1,1);
    b = Math.asin(sinb);
    cosb = Math.cos(b);
    if (Math.abs(cosb) > .0005){
    c = -Math.atan2(v[0],u[0]);
    a = -Math.atan2(w[1],w[2]);
    }else{
    a = Math.atan2(u[1],v[1]);
    c = 0;
    }
    [radiansToDegrees(a),radiansToDegrees(b),radiansToDegrees(c)]

    Got that from here : https://forums.creativecow.net/thread/227/10169

  • Dan Ebberts

    January 23, 2012 at 12:20 am

    Yes, that’s the one, although with a 2D layer I think you’d need to change this:

    w = CL.toWorldVec(L.toWorldVec([0,0,1]));

    to this:

    w = CL.toWorldVec([0,0,1]);

    “L” would be the 2D layer.
    “CL” would be the 2D comp as a 3D layer in the 3D comp.
    You would apply it to the orientation property of your 3D null.

    Dan

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