FORUMS TUTORIALS MAGAZINE STOCKYARD VIDEOS PODCASTS EVENTS SERVICES NEWSLETTER NEWS BLOGS
 ADOBE AFTER EFFECTS: Home Forum Basics Expressions Tutorials Podcasts AE Techniques Training Creative Cloud Debate FAQ

# Re: Joining 2 nulls with a line in 3d space

COW Forums : Adobe After Effects Expressions

 Re: Joining 2 nulls with a line in 3d spaceby Darby Edelen on Aug 12, 2008 at 5:31:17 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