Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions How to feed an argument of lenght 1 when a lenght 2 is demanded?

  • How to feed an argument of lenght 1 when a lenght 2 is demanded?

  • Cesar Siena

    March 5, 2021 at 12:26 am

    Hello everybody!
    .
    — SITUATION —
    There is a 3D head layer (with its usual X, Y and Z rotation) inside Comp1, that has to be controlled by a 2D null in Comp2. The idea is having the 2D null floating over comp2, affected (moved) by the mouse. Its X position will control Y rotation of the 3D head; its Y position will control X rotation and its rotation will control the Z rotation of the head, as summarized below:
    .

    DIRECT PICKWHIPING

    3D head in Comp1 2D null in Comp2
    X rotation property —————————————————————- Y position
    comp(“comp2”).layer(“2D_null”).transform.yPosition

    Y rotation property —————————————————————- X position
    comp(“comp2”).layer(“2D_null”).transform.xPosition

    Z rotation property —————————————————————– rotation
    comp(“comp2”).layer(“2D_null”).transform.rotation

    .

    — PROBLEM —
    When I pickwhip from the 3D head properties to 2D null properties, I have the simple expressions above, turning the 3D head to a crooked image, in a strange position, difficult to be controlled by moving the 2D null with the mouse.
    When I try to send those properties toWorld (or toComp) and catch them back fromWorld (fromComp), Ae throws this ERROR:

    “First argument to toComp (or toWorld) must be a vector of length 2 or 3”

    .
    — QUESTION —
    How can those simple expressions be written, so that layer transforms are correct?

    I thank you all in advance for the answers!

  • Filip Vandueren

    March 5, 2021 at 8:07 am

    You should send a 2D or 3D value into toWorld(), usually that doesn’t need to be the position of the layer, but a point on the layer. Most often we want to find the position of a layer’s anchorPoint in space, and for a default null that would be [0,0,0].

    So the code for what you’re asking is this:

    nullLayer = comp("comp2").layer("2D_null");
    xyz=thisLayer.fromWorld(nullLayer.toWorld([0,0,0]));
    x=xyz[0];
    y=xyz[1];

    But I’m not entirely sure this is going to do what you expect it to do. When do you expect the rotations to be at 0 ?

  • Filip Vandueren

    March 5, 2021 at 8:11 am

    Maybe all you need is a lookAt() expression on the orientation of the layer?

  • Cesar Siena

    March 5, 2021 at 12:21 pm

    Thank you for replying.

    Feedback

    It worked(!) in 3D Head’s “X rotation” and “Y rotation” using the following command (last) lines below, but it didn’t work in “Z rotation”.

    Small issue

    The head gained a little twist when the expressions were applied, in a way that, to correct head’s position, the 2D null had to be dislocated far from the screen’center (in other words, I didn’t manage to center the 2D null after that – any ideas?)

    The 2 expressions that worked were:

    IN THE X ROTATION OF THE 3D HEAD
    nullLayer = comp(“Comp2”).layer(“2D_null”);
    xyz=thisLayer.fromWorld(nullLayer.toWorld([0,0,0]));
    x=xyz[0];
    y=xyz[1];
    y

    IN THE Y ROTATION OF THE 3D HEAD
    nullLayer = comp(“Comp2”).layer(“2D_null”);
    xyz=thisLayer.fromWorld(nullLayer.toWorld([0,0,0]));
    x=xyz[0];
    y=xyz[1];
    x

    IN THE Z ROTATION OF 3D HEAD
    — DIDN’T WORK —
    nullLayer = comp(“Comp2”).layer(“2D_null”);
    xyz=thisLayer.fromWorld(nullLayer.toWorld([0,0,0]));
    x=xyz[0];
    y=xyz[1];
    z=xyz[2]
    z

    IN THE Z ROTATION OF 3D HEAD

    — WORKED —

    simple pickwhip to 2D null’s rotation, without any layer transforms between different comps of different dimensions.

    I already read Adobe’s information about lookAt and watched tutorials, but I presume that Java Script knowledge is necessary to fully understand that. I have also tryed fromComptoSurface with no results.

    These are common doubts even of experienced animators. Maybe Adobe could improve it’s explanations and examples about it.

    Any ideas to correct 2D null’s position described above?

    Thank you very much, Filip! Best regards!

  • Filip Vandueren

    March 5, 2021 at 1:20 pm

    You are correct that for Z, you could still use the actual rotation as before.

    To correct the 2D position of the null I would have to see the entire project, because it depends on the positions of face and null layer and wether the heads position is animated etc.

  • Cesar Siena

    March 5, 2021 at 7:26 pm

    The project alone, without the assets, wouldn’t be enough for this, but I thank you very much for all the help! Kind regards

Viewing 1 - 6 of 6 posts

Log in to reply.

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