Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions 3D Camera To Psunami Camera (3D rotation matrix)

  • 3D Camera To Psunami Camera (3D rotation matrix)

    Posted by Jamie Bradshaw on April 7, 2011 at 4:15 pm

    Hi all.

    I am trying to write expressions for the Tilt Pan And Roll controllers within the Psunami plugin so that they correspond to a (non auto orientated) camera in the composition.

    Originally I was just using something like this:

    // Pan
    camL = thisComp.layer(“cam”);
    targL = thisComp.layer(“target”);

    pos1 = camL.toWorld(camL.anchorPoint);
    pos2 = targL.toWorld(targL.anchorPoint);

    orient1 = lookAt(pos1, pos2);

    orient1[1]
    //

    However, this code obviously breaks when the camera position goes through an axis.

    I had a little dig around and found this thread from here:

    https://forums.creativecow.net/thread/227/8478#8497

    … which is really helpful (I was unaware of the toWorldVec function and I’m still getting my head round it). From that thread I have used this code to determine the Psunami Pan property:

    // Pan
    C = thisComp.activeCamera;

    V = C.toWorldVec([1,0,0]);
    -radiansToDegrees(Math.atan2(V[2], V[0]))
    //

    This works a treat but I have to admit that I am completely stumped as to what I exactly need to change to get this working for the Tilt and Roll properties. Can anyone help?

    Many thanks,
    Jamie

    JimJam•Graphics
    https://www.jimjamgraphics.com/

    Eden Exposito replied 12 years, 9 months ago 3 Members · 5 Replies
  • 5 Replies
  • Jamie Bradshaw

    April 7, 2011 at 9:55 pm

    Okay so I have been trying to dig further into this problem. I found this previous thread:

    https://forums.creativecow.net/thread/227/8461#8465

    … and from which this code looks like it might be close to what I need:

    //
    L = thisComp.layer(“Layer 1”);
    u = L.toWorldVec([1,0,0]);
    v = L.toWorldVec([0,1,0]);
    w = 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)]
    //

    (obviously I can then use radiansToDegrees(a) for the Psunami Tilt and radiansToDegrees(b) for Pan etc)

    It certainly feels like I’m getting closer with it but still not there. I have a sneaky feeling it has something to do with a different rotation order from the AE camera and the Psunami camera.

    For example, it I rotate the AE camera just on the x-axis it works fine, but as soon as I add any rotation on the y-axis it starts to break (and vice-versa).

    Any help would be massively appreciated as I have been trying to solve this issue for a long time now. I’d even appreciate if someone with more knowledge on such things could suggest if they think I am on the right tracks or if they think it is even possible.

    Thanks,
    Jamie

    JimJam•Graphics
    https://www.jimjamgraphics.com/

  • Tudor “ted” jelescu

    April 7, 2011 at 10:00 pm

    I have successfully used the tutorial below to link the Psunami camera to AE.
    https://www.digitalanarchy.com/tutes/psunami_camera-link.pdf
    Hope it helps.

    Tudor “Ted” Jelescu
    Senior VFX Artist

  • Jamie Bradshaw

    April 7, 2011 at 10:11 pm

    Hi Ted.

    I actually found your tutorial as I started to google for help after first I ran into trouble. Unfortunately though it didn’t seem to work for me. Not sure if I was doing anything wrong, but I still encountered the same camera rotation problem.

    Many thanks,
    Jamie

    JimJam•Graphics
    https://www.jimjamgraphics.com/

  • Jamie Bradshaw

    April 8, 2011 at 11:28 am

    Problem half solved.

    After more investigation I have now found the problem and a work-around.

    As I suspected, the issue is that the AE camera uses a rotation order of X>Y>Z while the Psunami camera uses Y>X>Z.

    I started to try and work out what modifications I would need to make Dan Ebbert’s code work (that I previously posted) but I think it would take me too long to get my head around.

    So instead I have simply created a work-around by parented rig system that effectively makes the rotation order of my AE camera the same as Psunami’s (Y>X>Z)

    Here is a short test of that working:

    https://reels.creativecow.net/film/psunami-camera-test

    It has made my intended animation for the camera a lot more fiddly to do though so if someone out there does know a good way to convert X>Y>Z to Y>X>Z that would be fantastic. If anyone can help this then I would also be happy to contribute towards a definitive tutorial/script on this matter as I have seen quite a few people asking the same problem and I think a good solution really would make the Psunami plugin even more powerful.

    Thanks,
    Jamie

    JimJam•Graphics
    https://www.jimjamgraphics.com/

  • Eden Exposito

    July 20, 2013 at 6:31 am

    Hi Jamie!

    Can you post all expressions to mimic after effects camera and where we must place it or a screenshot with it?

    Thanks!!

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