ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

How to get the global position of parented objects.

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Peter stenhouse
How to get the global position of parented objects.
on Aug 19, 2008 at 8:35:38 am

What I want to do is use a the puppet tool in combination with some nulls so that it will act more like joints using rotation, rather than position. So if I have a puppet point in the foot, it would follow the position of a null, that is parented to a null at the knee (so that I can rotate the knee). surely all I need to do is have both use positions in relation to world or composition space. But I am not sure how to querie that value.

My second problem is writing an expression that would point an object at another. I can think of the math to work at an angle given the difference in position, but again, would want this to work with universal coordinates rather than layer, parent, whatever.

Thanks very much in advance for your help.

I had a look at toWorld in the help, but it didn't cooperate as I expected.

Sincerely

Peter


Return to posts index

Peter stenhouse
Re: How to get the global position of parented objects.
on Aug 19, 2008 at 12:02:53 pm

So "lookat" will point an object at another, but it won't return values outside of -90 to 90 degrees. how do I get it to Look at with a range of 360 degrees?



small flowers crack concrete


Return to posts index

Dan Ebberts
Re: How to get the global position of parented objects.
on Aug 19, 2008 at 1:17:27 pm

To get the world position of a parented layer, you need to use the layer's anchor point, like this:

L = thisComp.layer("Null 1");
L.toWorld(L.anchorPoint)

Dan



Return to posts index


Dan Ebberts
Re: How to get the global position of parented objects.
on Aug 19, 2008 at 1:25:27 pm

To get the world position of a parented layer, you need to use the layer's anchorPoint, like this:

L = thisComp.layer("Null 1");
L.toWorld(L.anchorPoint)


Dan



(edit) - oops - duplicate post, sorry


Return to posts index

Andy Engelkemier
Re: How to get the global position of parented objects.
on Nov 25, 2013 at 9:16:32 pm

How does this work with rotation?

I've got a glow on an object in 2D. Well, that doesn't work if it rotates. So I would like to do the 3D rotation in a nested composition, and apply a glow to the result. This worked great for the position, but I nee to match the orientation. The layer I'm using for position is liked to another, so it appears to have no rotation.

I tried:
L = comp("Ignite 4 animation").layer("u Outlines");
L.toWorld(L.transform.orientation);

But at the start time, it should be orientation 0,0,0, but it's actually 49.5, 347.5,0 so I'm a bit lost.

I did get it to do what I want, but not in the way I was hoping. I'm just linking the rotation to the Null I'm using to control rotation. And I'm hooking the position to a copy of the same layer that I'm simply turning off.

Is there an easier way to precomp a layer and have it's attributes automatically assigned to the appropriate places via expressions? That would be killer. It's pretty annoying to have to change everything to comp. I'm not sure if there is better way of doing this.

What I'm trying to learn here is if you can match the world orientation. It's not seeming to work for me how I expected. Something is happening, it just doesn't make sense to me yet.


Return to posts index

Dan Ebberts
Re: How to get the global position of parented objects.
on Nov 25, 2013 at 11:06:19 pm

Generally, something like this works to get the world orientation of another 3D layer:


L = thisComp.layer("Source");
u = (L.toWorldVec([1,0,0]));
v = (L.toWorldVec([0,1,0]));
w = normalize(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 = (sinb < 0 ? -1 : 1)*Math.atan2(u[1],v[1]);
c = 0;
}
[radiansToDegrees(a),radiansToDegrees(b),radiansToDegrees(c)]


It gets more complicated though if you're transforming coordinates between an object in a parent comp and another in a nested precomp.


Dan



Return to posts index


Steve Edwards
Re: How to get the global position of parented objects.
on Sep 18, 2017 at 11:21:30 am

I used Dan's suggested

L = thisComp.layer("Null 1");
L.toWorld(L.anchorPoint)

with no joy. (Well, it shifted the camera way off axis and nowhere near the parented null) Then I found on another site that copying and pasting direct from a website can have peculiar results and it suggested I use something like TextEdit or SimpleText first.

Viola! Worked just as Dan said it would.

Now you know.


Return to posts index

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