Activity › Forums › Adobe After Effects Expressions › 3d line between to nulls – REVISITED
-
3d line between to nulls – REVISITED
Posted by Tom Gomez on January 1, 2011 at 3:56 pmHowdy Folks,
I’ve been looking for the ultimate way to draw a simple line between 2 nulls moving around in 3d space. Dan E. and Roland K. created some great expressions to help out with this using the Beam plugin. Awesome and genius and thank you!
But might there be a way to calculate the distance between the nulls, and then create a line at that length using a simple shape, then 3D that layer, and use a fancy expression to position and rotate/orient the layer so that it was the correct angle between the nulls in 3D space? It seems like that would take care of most of the stacking and perspective problems, and technically you could even use shapes and layers and stuff that weren’t even lines.
I remember a great expression I used to calculate the angle between to objects in 2D that worked like a charm because I wanted a funky animated line to stay connected to two objects moving around. Maybe that’s possible in 3d?
Any thoughts?
thanks and happy new year!
Tom
Arne Münch replied 7 years, 11 months ago 6 Members · 13 Replies -
13 Replies
-
Todd Kopriva
January 1, 2011 at 6:17 pmThis thread has what I think that you’re looking for:
https://forums.creativecow.net/thread/2/986902———————————————————————————————————
Todd Kopriva, Adobe Systems Incorporated
Technical Support for professional video software
After Effects Help & Support
Premiere Pro Help & Support
——————————————————————————————————— -
Tom Gomez
January 1, 2011 at 6:31 pmThat’s a super solution. But I’m hoping there’s a way to make something magic like that work in 3D…
YOU can help save TimeSpace. Join the Chronos Protectorate!
https://www.95ers.com
https://www.SpaceAceMedia.com -
Tom Gomez
January 1, 2011 at 8:29 pmHere’s my solution…
Not elegant maybe, but works great. I’d love any feedback or enhancements.
This set of expressions will allow you to make a 3D line between any two 3d layers you stick it between. It will respond to depth of field, moving layers, etc. with no stacking issues and no need to use beam filter. The nice thing is that you can modify it so your line could have all kinds of effects or change shape, etc.
1) Stick a rectangular shape layer (with 3D checked and position dimensions separated) between any two 3D layers (that have position dimensions separated). The anchor of your shape layer should be (0,0,0).
2) Make the width of your rectangle exactly match the distance between those layers with this expression. (You need to apply this expression to JUST the width parameter of the rectangle.) I did it this way:
In a SLIDER:
point1=this_comp.layer(thisLayer, -1).position;
point2=this_comp.layer(thisLayer, 1).position;
length(point1, point2)In my rectangle in the size parameter:
temp = effect(“Slider Control”)(“Slider”);
[temp[0], value[1]]3) Put the shape exactly between the two layers in 3D space.
In X:
(thisComp.layer(thisLayer,-1).transform.xPosition+thisComp.layer(thisLayer, 1).transform.xPosition)/2In Y:
(thisComp.layer(thisLayer,-1).transform.yPosition+thisComp.layer(thisLayer,1).transform.yPosition)/2In Z:
(thisComp.layer(thisLayer,-1).transform.zPosition+thisComp.layer(thisLayer,1).transform.zPosition)/24) Orient the layer so it exactly connects the two other layers:
In ORIENTATION:
lookAt (thisComp.layer(thisLayer,-1).transform.position, thisComp.layer(thisLayer,1).transform.position)
Again, I’d love any suggestions. Thanks!
================================================
YOU can help save TimeSpace. Join the Chronos Protectorate!https://www.95ers.com
https://www.SpaceAceMedia.com -
Tom Gomez
January 1, 2011 at 8:41 pmPS. And change the line’s y rotation to 90.
================================================
YOU can help save TimeSpace. Join the Chronos Protectorate!https://www.95ers.com
https://www.SpaceAceMedia.com -
Joao Peachtree
November 22, 2011 at 7:50 pmHi Tom!
I’m a newbie in expressions and I’m trying to do your 3D “rope”, but I get an error when i get to the XYZ positioning saying: “Class ‘Group’ has no property or method named ‘xPosition’”.
Any thoughts on how i could resolve this would be much appreciated!Thanks a lot
-
Tom Gomez
November 22, 2011 at 7:58 pmBe sure to right click on your position transformation and tell it to “separate dimensions”… Then your x,y,z will turn into three separate values that the expression wants.
================================================
YOU can help save TimeSpace. Join the Chronos Protectorate!https://www.95ers.com
https://www.SpaceAceMedia.com -
Joao Peachtree
November 22, 2011 at 8:16 pmThanks for the quick reply!
I did that before, sorry if I wasn’t clear. Do you have any other idea why it isn’t working?The Slider and the Orientation expressions are working.
I’m running CS5Thanks
-
Tom Gomez
November 22, 2011 at 8:31 pmI won’t be able to check into it for a few days… But I’d be happy to.
================================================
YOU can help save TimeSpace. Join the Chronos Protectorate!https://www.95ers.com
https://www.SpaceAceMedia.com -
Tom Gomez
December 14, 2011 at 11:16 amGreetings Joao,
Sorry it took so long to get back to you. Hopefully this is still helpful. I’ve just revamped these expressions for a 3d line and maybe it will help.
First, create a shape rectangle layer, make it 3d, give it a fill, place it between any two 3d layers (so for example layer 1 is a 3d layer, layer would be this layer, and layer 3 would be another 3d layer).
Next, give it two expression sliders. Call the first one LINE LENGTH MODIFIER, the second LINE WIDTH. For now, give those the values 1 and 4 respectively.
Nexy, add these expressions:
To the rectangle’s size property:
x = (effect(“LINE LENGTH MODIFIER”)(“Slider”));
point1 = ((thisComp.layer(this_layer,-1).position)*x);
point2 = ((thisComp.layer(this_layer,1).position)*x);
y = (length(point1, point2))*(x);
w = effect(“LINE WIDTH”)(“Slider”);[y, w]
To the position property of the layer:
a = thisComp.layer(this_layer,-1).transform.position[0];
b = thisComp.layer(this_layer,1).transform.position[0];
c = (a+b)/2;
d = thisComp.layer(this_layer,-1).transform.position[1];
e = thisComp.layer(this_layer,1).transform.position[1];
f = (a+b)/2;
g = thisComp.layer(this_layer,-1).transform.position[2];
h = thisComp.layer(this_layer,1).transform.position[2];
i = (a+b)/2;[c, f, i]
On the layer’s orientation property:
lookAt (thisComp.layer(this_layer,-1).transform.position, thisComp.layer(this_layer,1).transform.position)
FINALLY, set the layer’s rotation to 90.
You can copy and paste the whole line layer between any two 3d layers and it will automatically adjust to the new layers.
Viola.
================================================
YOU can help save TimeSpace. Join the Chronos Protectorate!https://www.95ers.com
https://www.SpaceAceMedia.com -
Garrett Eaton
February 9, 2012 at 8:18 pmGreat expression Tom; thanks! There’s just a couple typos in there that I fixed so people can just copy/paste:
a = thisComp.layer(this_layer,-1).transform.position[0];
b = thisComp.layer(this_layer,1).transform.position[0];
c = (a+b)/2;
d = thisComp.layer(this_layer,-1).transform.position[1];
e = thisComp.layer(this_layer,1).transform.position[1];
f = (d+e)/2;
g = thisComp.layer(this_layer,-1).transform.position[2];
h = thisComp.layer(this_layer,1).transform.position[2];
i = (g+h)/2;’>i = (g+h)/2;[c, f, i]
Reply to this Discussion! Login or Sign Up