Creative COW ACCOUNT & SETTINGS :: SPONSORS :: ABOUT US :: CONTACT US
ADOBE AFTER EFFECTS: ForumAE BasicsAE ExpressionsTutorialsArticlesPodcastsPodcast ForumTrainingCinema 4D
ATTO
Noise Industries
Roland
Maxx Digital
GMax Storage

Layer Space Transform question

Cow Forums : Adobe After Effects Expressions
Layer Space Transform question
by Lloyd Alvarez on May 7, 2008 at 3:08:32 pm

I have a cube that is in a pre-comp. This precomp has collapse transformations turned on and is a 3D layer in the parent comp where the camera is. What I need to do is match a 3D null in the parent comp to the anchor point of one of the sides of my cube in the pre-comp.


I have a small test project that has the setup in case my description doesnt make any sense.

http://aescripts.com/temp/transforms_help.aep.zip

Thanks in advance!

-Lloyd

Respond to this post     Return to posts index

Re: Layer Space Transform question
by Darby Edelen on May 7, 2008 at 3:32:35 pm

I think you may need two instances of toWorld(), one to convert the anchor point of the layer to its world position inside the composition and another to convert that position to a world position in the current comp... I can't test these until I get to work but I think something like this may work:

l = comp("myComp").layer("myLayer"); //myComp is the composition with the layer (myLayer) that we want to retrieve the anchor point of

toWorld(l.toWorld(anchorPoint));


This is assuming that the first call to l.toWorld(anchorPoint) will return the position of the anchor point in the nested composition, and I'm not entirely confident of that. I don't usually use layer space transforms between comps =O

Darby Edelen
Lead Designer
Left Coast Digital
Santa Cruz, CA

Respond to this post     Return to posts index

Re: Layer Space Transform question
by Dan Ebberts on May 7, 2008 at 3:45:21 pm

Lloyd,

I think this is what you're looking for:

L = comp("Pre-Comp").layer("FOLDING SIDE");
CL = thisComp.layer("Pre-Comp");
CL.toWorld(L.toWorld(L.anchorPoint));


Dan



Respond to this post     Return to posts index


Re: Layer Space Transform question
by Lloyd Alvarez on May 7, 2008 at 3:55:46 pm

Thanks! That did the trick, but I forgot to mention that I also need the rotations (and orientation) of the null. Seems toWorld only works with vectors or length 2 or 3 (at least that's what the error message says ;-)

-Lloyd

http://aescripts.com

Respond to this post     Return to posts index

Re: Layer Space Transform question
by Dan Ebberts on May 7, 2008 at 4:22:44 pm

That's a lot tougher. I think the best you can do is to match the world orientation. Give this a try:

L = comp("Pre-Comp").layer("FOLDING SIDE");
CL = thisComp.layer("Pre-Comp");
u = CL.toWorldVec(L.toWorldVec([1,0,0]));
v = CL.toWorldVec(L.toWorldVec([0,1,0]));
w = CL.toWorldVec(L.toWorldVec([0,0,1]));

sinb = clamp(w[0],-1,1);
b = Math.asin(sinb);
cosb = Math.cos(b);
if (Math.abs(cosb) > .0005){
c = -Math.atan2(v[0],u[0]);
a = -Math.atan2(w[1],w[2]);
}else{
a = Math.atan2(u[1],v[1]);
c = 0;
}
[radiansToDegrees(a),radiansToDegrees(b),radiansToDegrees(c)]


Dan



Respond to this post     Return to posts index

Re: Layer Space Transform question
by Lloyd Alvarez on May 7, 2008 at 4:42:51 pm

Wow Dan! That's some serious math going on there!
Well, I am happy to report that it works!!
Thank again!

-Lloyd

http://aescripts.com

Respond to this post     Return to posts index


Re: Layer Space Transform question
by Darby Edelen on May 7, 2008 at 7:36:40 pm

[Dan Ebberts] "L = comp("Pre-Comp").layer("FOLDING SIDE");
CL = thisComp.layer("Pre-Comp");
CL.toWorld(L.toWorld(L.anchorPoint)); "


Woops, heh... I had assumed when I started writing my code that the expression would be applied to the pre-comp, but when I realized that probably wouldn't be the case I went back and revised it slightly... of course I forgot to get a reference to the pre-comp layer =O

Darby Edelen
Lead Designer
Left Coast Digital
Santa Cruz, CA

Respond to this post     Return to posts index

<< PREVIOUS THREAD   •   VIEW ALL THREADS   •   NEXT THREAD >>
G-Tech
Apple Final Cut


FORUMSLIBRARYPODCASTSBLOGSMAGAZINESERVICESNEWSLETTERSNEWSSTOREEVENTSRSS

© CreativeCOW.net All rights are reserved.

[Top]