Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Trouble With Auto-Orient and Z-Rotation

  • Trouble With Auto-Orient and Z-Rotation

    Posted by Sebastian Martinez on March 18, 2008 at 3:15 pm

    Hi everyone!

    I can’t warp my head around it:

    I’m moving a camera parented to a null in various directions through a 3D space. I want a 3D text layer face constantly towards the camera and also keeping the angle to the borders of the camera’s frame.

    Auto-orientaion makes no use, the text spins around its z-axis depending on the position of the camera. I made various attempts tweeking around with different expressions both in orientation and rotation with auto-orientation switched ON and OFF. Only poor results.

    Might there be a solution with auto-orient ON and an expression on z-rotation? Or is there something I am missing compleatly? Any help in this case will be appreciated!

    (Before had I parented the camera to a null all expressions worked very fine:

    Orientaion:
    L = thisComp.layer(“Null 45°”);
    s = L.scale/100;
    u = L.toWorldVec([s[0],0,0]);
    v = L.toWorldVec([0,s[1],0]);
    w = L.toWorldVec([0,0,s[2]]);
    sinb = clamp(w[0],-1,1);
    b = Math.asin(sinb/thisComp.pixelAspect);
    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)]

    Scaling:
    dist = length(thisComp.layer(“45°”).position, position);
    S=dist/14;
    [S,S,S]

    Both expressions by Dan Ebberts, thanks to him, very usefull fine stuff!)

    Chears
    Sebastian

    Sebastian Martinez

    Sebastian Martinez replied 18 years, 4 months ago 2 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    March 18, 2008 at 5:45 pm

    That’s a tough one. If you turn on auto orient, it’s probably going to be a vector operation similar to this:

    C = thisComp.activeCamera;
    v1 = fromWorldVec(C.toWorldVec([1,0,0]));
    v2 = [1,0,0];
    radiansToDegrees(Math.acos(dot(v1,v2)))

    Maybe somebody has time to fiddle with it.

    Dan

  • Sebastian Martinez

    March 18, 2008 at 6:33 pm

    Thanks Dan! I put the layer onto auto-orient and put the expression into z-rotation aswell as into orientation. There just came up the Warning:

    Invalid numerical result (this is a translation from German AE) (division by zero?)
    Expression deactivated.
    Error in Line 4.

    I began a different workaround by deactivating the orentation of the camera and get rid of the parented null. did work but wasn’t reproducable, for what reason ever …

    I know, cameras wich aren’t parented ain’t that good! But what about an expression that could level the z-rotation of the camera when moving aroundeverywhere in space?

    But many thanks anyway, I admire you stuff and dedication to this site!

    Sebastian

    Sebastian Martinez

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