Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Absolute Postion and X,Y,Z Rotation of Camera

  • Absolute Postion and X,Y,Z Rotation of Camera

    Posted by Ari Valen levinson on October 16, 2015 at 11:13 pm

    Hey folks, I’m banging my head against the wall trying to figure out what I think should be a pretty simple expression.

    I’m trying to hand off my camera move from an animatic to an animator, and it doesn’t import properly on his system unless the camera isn’t parented to anything in after effects.

    So, my relatively simple (I thought) solution was to use the toWorld expression on a new camera to look at the old one and generate absolute position and X,Y,Z rotations. However, nothing I’m doing seems to put the new camera in the proper place, and I can’t figure out how to make the rotation keyframes work at all.

    Just a little info on the project: the camera has separate X, Y, and Z position keyframes and keyframes for X and Y rotation as well as Orientation (though I want the final camera to just have X, Y Z rotation keyframes). The camera is parented to a null which has keyframed Y rotation.

    If anyone can help me put these expressions together I would be so grateful! Thanks!

    Ari Valen levinson replied 10 years, 9 months ago 2 Members · 2 Replies
  • 2 Replies
  • Kalleheikki Kannisto

    October 17, 2015 at 4:06 pm

    The expression-to-keyframes method comes to mind. It creates keyframes for every frame for a given property.

    Put the expression “value” to any property you want to do this for, the select Animation>Keyframe Assistant>Convert Expressions to Keyframes.

    Not sure how it treats parented properties, but you’ll find out soon enough.

  • Ari Valen levinson

    October 17, 2015 at 8:44 pm

    I posted this question over at the Adobe forum, and the inimitable Dan Ebberts came through with flying colors. For anyone else trying to solve this problem, here’s the answer:

    If, like me, you have your cameras set to auto-orient: off, you can ignore the POI expression. I can vouch for that setup. Worked like a charm for me.

    After applying the expressions, convert all to keyframes, and you’ll have a perfect objective data set to hand off to your 3D program.

    // position

    C = thisComp.layer("Camera 1");
    C.toWorld([0,0,0])

    // point of interest

    C = thisComp.layer("Camera 1");
    C.toWorld(C.pointOfInterest)

    // orientation

    C = thisComp.layer("Camera 1");
    u = C.toWorldVec([1,0,0]);
    v = C.toWorldVec([0,1,0]);
    w = C.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)]

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