FORUMS: list search recent posts

How can I make a null object's anchor point dependant of any point in a shape?

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Anthony Graham
How can I make a null object's anchor point dependant of any point in a shape?
on Jun 20, 2017 at 10:37:07 am

Hi,

I've created a call out title for which I plan to be tracking points in footage.
The following link is a screenshot of my composition, it will help illustrate the issue:
https://postimg.org/image/w2yemzhmd/

I would like the 'Target Null' to be able to travel anywhere around the target's external line (circle) (so that the 'Target Null's' anchor point would be dependant of any point of the target's circle/revolution) so that I can move this target comfortably around the image without having to re-ajuste the 'Connecting Line's' end point on this circle.

How can I do this?


Return to posts index

Philip Neves
Re: How can I make a null object's anchor point dependant of any point in a shape?
on Jun 20, 2017 at 12:35:11 pm

There are probably really sophisticated ways to nail a null to an outline, but I don't know what they are and you said you only need a circle. So here's how I would try it.

1. Create a circle shape layer with the dimensions 200,200 and centered.
2. Move your null to the edge of the circle (so if it was centered at 960,540, it will be at 1060,540)
3. Parent the null to the circle.
4. Put this expression on the null's rotation to maintain rotation while the parent rotates:

-parent.transform.rotation

5. Put this expression on the null's scale to maintain scale while the parent scales:

s = 100*transform.scale[0]/parent.transform.scale[0];
[s,s]


6. Rotate and scale the circle. The null should rotate in a circle without rotating itself, and the scale should make the circle larger without scaling the null. You can now match the circle to your target's position and size.
7. You can now hide the circle (or replace it with a null... it's just a circle as a visual aid. Or with the target if that's intended to move.) Tracking data can get sent to the circle, or you can put another null parent in the chain above the circle if shifting anchor points becomes a problem.

Does this help you or did I misunderstand what you were asking?


Return to posts index

Anthony Graham
Re: How can I make a null object's anchor point dependant of any point in a shape?
on Jun 20, 2017 at 2:46:20 pm

Thanks Philip.

You got the concept of what I want to do. Unfortunately with your indications, I can't get it to work.

From bullet point 1 to 7: everything fine.
Side note 1: I had adjusted the Null's anchor point to be positioned onto the circle (on the middle of it's right edge)
Side note 2: The circle is actually not intended for visual only, it's part of the design.

Now, I've added a connecting line (solide white background + beam effect). When I parent the Beam's 'Staring Point' to the null's position (or even tried anchor point), the 'Starting Point' ends up off frame. And even if I try rotating the circle, the Beam's 'Starting Point' does not change its position.

Where have I gone wrong?


Return to posts index


Anthony Graham
Re: How can I make a null object's anchor point dependant of any point in a shape?
on Jun 20, 2017 at 2:48:47 pm

Apologies, I forgot to post a screenshot:
https://postimg.org/image/69oqtkfcz/


Return to posts index

Philip Neves
Re: How can I make a null object's anchor point dependant of any point in a shape?
on Jun 20, 2017 at 3:35:09 pm

Beams are tricky because they work with the position in their own layer instead of in the comp. So we're in the wonderful world of layer space transforms.

If you don't need the beam to be adaptive to different positions, precomp that effect & layer together.

If you do need it to adapt, you could try mapping the beam to the positions of your objects. Unparent the beam layer, center and unrotate it again, and write an expression for the start point on the beam that looks like this:


L = thisComp.layer("Null");
L.toComp([0,0,0])


...where the first line targets the null (you'll need to correct it to the right name), and the second line adapts the null's position to the corresponding position on your layer. If I did it right.

You'd then need to repeat this for the beam's end point, which will need a target -- maybe just add another null, parented to the first null.

http://www.motionscript.com/mastering-expressions/lst-lens-flare.html


Return to posts index

Philip Neves
Re: How can I make a null object's anchor point dependant of any point in a shape?
on Jun 20, 2017 at 3:42:05 pm

Oh, and I'm not sure I understand what you're doing with anchor points... so these expressions might not work perfectly for you since they're position-based.


Return to posts index


Anthony Graham
Re: How can I make a null object's anchor point dependant of any point in a shape?
on Jun 20, 2017 at 7:52:38 pm

This is superb, I followed your instructions for the Beam option and it works! In regards to the anchor point, I thought it had some influence on how the Beam's starting point would locate itself on the null.

Thanks a bunch for your quick help.

Please would you be able to explain what the expressions in this thread meant, in very basic words?

  • -parent.transform.rotation

  • s = 100*transform.scale[0]/parent.transform.scale[0];
    [s,s]

  • L = thisComp.layer("Null");
    L.toComp([0,0,0])


    Return to posts index

    Philip Neves
    Re: How can I make a null object's anchor point dependant of any point in a shape?
    on Jun 20, 2017 at 9:55:37 pm

    Glad it worked.

    I can try, but I'm not great at either coding or explaining.


    -parent.transform.rotation


    For this one we want to cancel the rotation of the parent. If the parent rotates 60 degrees, we rotate 60 the other way. So this just says "get the rotation of the parent" and puts a minus sign in front of it to invert it. 60-60 = 0 = no rotation.

    It's a little flawed, because it will always equal 0, and some time you may want to add some rotation on purpose. So it could be rewritten this way:


    value-parent.transform.rotation

    or

    -parent.transform.rotation+value


    "value" is null's original rotation value. This will add any rotation you've already applied to the null back, while canceling parent rotation.

    ----


    s = 100*transform.scale[0]/parent.transform.scale[0];
    [s,s]


    To reverse parent scale, we can't just flip the sign, we have to invert the number. If your parent null scales up 4x...

    4*100 = 400

    then you would want to scale down 1/4x to cancel.

    1/4*400 = 100

    In that expression, we grab the x scale of your null (transform.scale[0]) and divide it by the parent's x scale (parent.transform.scale[0]) and multiply by 100 to convert it from a percent (.25) to the whole number (25) that AE is expecting.

    Sidebar: When you pull a scale property, you don't get one number, you get two, like [100,100]. When you write scale[0] you're just grabbing the first one (computers start counting at 0. I made an assumption your scale would be the same in both dimensions.


    "s =" assigns the value to a variable we just made up named "s".

    This is so that on the next line we can give it to After Effects in the two-number format it expects: [s,s]. If you give it just one number it will yell at you.

    This expression also has a flaw -- if your parent scale is 0, it'll divide by zero and stop working. So don't do that.

    ----


    L = thisComp.layer("Null");
    L.toComp([0,0,0])


    I grabbed this from someone else. I don't fully understand toComp, but I'll try my best:

    toComp is a method that transforms points from layer space to composition space. We feed it a point and it gives us back a point that's corrected.

    If you have a solid that's rotated, scaled, and repositioned, or is in 3D, 960x540 on the layer won't be in the same place as 960x540 in the comp. toComp([0,0,0]) will correct for that and return a value that compensates for those things.

    It could also be written:

    thisComp.layer("Null").toComp([0,0,0])


    ...but assigning the layer to a variable and using the method on the variable (L.toComp()) is a good habit because if you're writing longer expressions, you don't have to replace the target "thisComp.layer("Null")" in five different places if it ever needs to be changed.

    Here's some resources that may help explain things:





    -- Reversing parent rotation




    -- Beam and toComp
    http://www.motionscript.com/mastering-expressions/lst-lens-flare.html -- Layer Space Transforms


    Return to posts index

    Anthony Graham
    Re: How can I make a null object's anchor point dependant of any point in a shape?
    on Jun 20, 2017 at 10:27:46 pm

    Brilliant, that's more than I expected, thanks a lot Philip!


    Return to posts index

    << PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
    © 2017 CreativeCOW.net All Rights Reserved
    [TOP]