Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Auto orient to camera plane (not camera!)

  • Auto orient to camera plane (not camera!)

    Posted by Jim Darski on September 8, 2012 at 2:08 am

    I have been searching for an answer to that for hours but in vain so far… But I know it can be done…
    Here is the problem: I have a bunch of screens in 3d space that are slowly rotated by a null (in y axis so they are orbiting around).
    While they circulate around I want them to always stay facing the camera plane, but not the camera itself. Auto-orient to Camara or Auto-orient on Y axis script doesn’t work for me. The reason is you can start to see them twist in perspective the more they go off center. In other words they do not face the same direction but each one has it’s own orientation towards the camera. I want all of them to keep facing the same direction which is the camera plane (not camera’s anchor point). I’m sure there must be a script that does it…
    Is you know it, let me know, please!

    Appreciate your help.

    Nick Ll replied 8 years, 3 months ago 6 Members · 11 Replies
  • 11 Replies
  • Dan Ebberts

    September 8, 2012 at 2:54 am

    Try this orientation expression:


    L = thisComp.layer("Camera 1");
    u = fromWorldVec(L.toWorldVec([1,0,0]));
    v = fromWorldVec(L.toWorldVec([0,1,0]));
    w = normalize(fromWorldVec(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 = (sinb < 0 ? -1 : 1)*Math.atan2(u[1],v[1]);
    c = 0;
    }
    [radiansToDegrees(a),radiansToDegrees(b),radiansToDegrees(c)]

    Dan

  • Tim Drage

    September 11, 2012 at 9:21 am

    Useful, thanks!

  • Jim Darski

    October 1, 2012 at 7:13 pm

    Thanks so much Dan!
    This expression work really well. Got sidetracked by several other projects, thus the delay in reply. Anyway, this is a really nice expression. AE should incorporate in the auto orient settings!
    J.

  • Johannes Eichberger

    December 20, 2012 at 11:55 am

    Thanks, Dan – really a great expression.

  • Nate Mulliken

    January 23, 2013 at 8:09 pm

    Awesome! Dan you are the best.
    For those that may have made it this far and need that extra helping hand, it may be good to mention to make sure you zero out all orientation and rotation parameters first. Then lay this expression into the orientation parameter making sure that the name of your comp camera matches the camera name in pasted expression.

    Obvious stuff for some but my first question was “where do I put it?”
    once I got it in it works great.

    Hopefully this is all correct information.

  • Jim Darski

    August 12, 2013 at 9:00 pm

    I have no idea why but I getting an error on your expression:

    Please help!

  • Dan Ebberts

    August 12, 2013 at 10:10 pm

    Hard to say without seeing a project file with the broken expression.

    Dan

  • Nick Ll

    February 6, 2018 at 5:49 am

    Thanks for the additional tips Nate! Im new to expressions so that a helped me out. An additional question I have is there any way to use the “Active Camera” rather than the specific camera. Im switching between multiple cameras in my animation but get the sides of objects when i switch, and my futile attempt to put “Active Camera” as the camera name gives me an error. Is there any simple solution if not I could work around it.

  • Nate Mulliken

    February 6, 2018 at 4:51 pm

    Nick,
    It has been a long time since I have looked into this. I like the idea of using the active camera.
    Not sure how Dan’s expression would respond to that.

    Is there perhaps a way to use your muli-cam set up as a reference then manually mimic the cuts with new cameras and/or subcomps once you have a lock on your shots?

    Then you’d be able to enter the expression on each one?

    I realize this is obvious and very clunky not to mention a nightmare to edit if your cuts were to change.

  • Nate Mulliken

    February 6, 2018 at 4:55 pm

    Also not sure how you tried to enter active camera in the expression. for example typed out like “activeCamera”

    Perhaps look up how to create global variables in After Effects using a controller layer. You may be able to use the expression in some form of controller layer that looks for activeCamera.

    -Nate

Page 1 of 2

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