Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Joining 2 nulls with a line in 3d space

  • Joining 2 nulls with a line in 3d space

    Posted by Mark Warner on August 12, 2008 at 10:32 am

    Hello everyone

    I’m trying to join 2 null points, randomly floating around in 3d space, with a simple straight line. The line should move, rotate and scale to line up exactly with the 2 points.

    I’ve tried pointing a solid with a stroked mask at the null but it’s a real pain animating the “End” point of the mask to marry up with the target null.

    Any help would be greatly appreciated.

    Regards

    Mark Warner replied 17 years, 9 months ago 3 Members · 4 Replies
  • 4 Replies
  • Lloyd Alvarez

    August 12, 2008 at 3:44 pm
  • Mark Warner

    August 12, 2008 at 4:14 pm

    Thank you. Really nice solution for 2d! How do I get that z depth in there?

  • Darby Edelen

    August 12, 2008 at 5:31 pm

    [Mark Warner] “Thank you. Really nice solution for 2d! How do I get that z depth in there?”

    You can adjust the size of the line based on how near/far it is from the camera.

    Here’s an updated expression for the start point, end point, start size and end size:

    Start:

    l = thisComp.layer("StartNull");
    fromComp(l.toComp(l.anchorPoint));

    End:

    l = thisComp.layer("EndNull");
    fromComp(l.toComp(l.anchorPoint));

    Start Size:

    s = value;
    l = thisComp.layer("StartNull");
    c = thisComp.activeCamera;
    p = l.toWorld(l.anchorPoint);
    f = c.cameraOption.zoom;
    dist = p - c.toWorld([0,0,0]);
    vec = c.toWorldVec([0,0,1]);
    dist = dot(dist, vec);

    s * f / dist;

    End Size:

    s = value;
    l = thisComp.layer("EndNull");
    c = thisComp.activeCamera;
    p = l.toWorld(l.anchorPoint);
    f = c.cameraOption.zoom;
    dist = p - c.toWorld([0,0,0]);
    vec = c.toWorldVec([0,0,1]);
    dist = dot(dist, vec);

    s * f / dist;

    This should give you dynamic resizing of the beam based on its “3D” position. Note, though, that the position expression only works until you pass the camera beyond the Nulls… you’ll definitely notice it when this happens. It might require that you rethink your animation if you had been planning to do a truck in past the nulls.

    Darby Edelen

    NVIDIA
    Santa Clara, CA

  • Mark Warner

    August 12, 2008 at 9:09 pm

    Lovely stuff! I’ll give it a pop but I think your right with the re-think suggestion.

    Many thanks for your time.

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