FORUMS: list search recent posts

Problem with nested compositions and space reference

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Lorenzo Fernandez
Problem with nested compositions and space reference
on Jul 7, 2011 at 3:05:33 pm

Hello, I have two compositions one nested in the second one.
Let's call them

nestedComp
Main

In nestedComp there is a layer that use the position of a Pointer layer in Main to change it's positioning in zSpace.

I imagine that I need to use toWorld or something similar, but I'm really unclear how that works.

Thanks for any help

I'll post here the code:

beginScale = 90;//Scale begins at this
endScale = 100;//Scale ends at this
beginDistance = thisLayer.width/3;//Distance to begin magnifying in pixels
endDistance = 0;//Distance to end magnifying in pixels

//--Don't modify below here
dis= Math.sqrt(Math.pow((thisLayer.position[0]-comp("Main").layer("Pointer").position[0]),2)+Math.pow((thisLayer.position[1]-comp("Main").layer("Pointer").position[1]),2));

val = ease(dis, beginDistance, endDistance, endScale, beginScale);
[val]


Return to posts index

Dan Ebberts
Re: Problem with nested compositions and space reference
on Jul 7, 2011 at 3:36:30 pm

It's going to be something like this:

beginVal = 90;
endVal = 100;
beginDistance = thisLayer.width/3;
endDistance = 0;
p1 = comp("Main").layer("Pointer").position;
L = comp("Main").layer(thisComp.name);
p2 = L.toWorld(toWorld(anchorPoint));
dis= length(p1,p2);
ease(dis, beginDistance, endDistance, endVal, beginVal);


Dan



Return to posts index

Lorenzo Fernandez
Re: Problem with nested compositions and space reference
on Jul 7, 2011 at 3:52:23 pm

First of all, thanks!

It's all quite clear the problem is that I was only using the 2D distance (x,y). Can I use toWorld to refer only to either x or y (position[0],position[1])?

Thanks!


Return to posts index


Dan Ebberts
Re: Problem with nested compositions and space reference
on Jul 7, 2011 at 4:07:54 pm

Yes, you can just use the bracket notation as you would with any array:

p = toWorld(anchorPoint);
x = p[0];
y = p[1];




Dan



Return to posts index

Lorenzo Fernandez
Re: Problem with nested compositions and space reference
on Jul 8, 2011 at 1:32:19 pm

Hello Dan, I tried tons of different combinations, but no success. This is the last code I've used, the nested layer moves on the zSpace, but I honestly can't understand with which rationale.

Thanks for any further help.

Lorenzo

startFade = 700; // Start fade 1500 pixels from camera.
endFade = 100; // End fade 1000 pixels from camera.
P = toWorld(anchorPoint);
d =Math.sqrt(Math.pow((thisLayer.position[0]-comp("Main").layer("Pointer").position[0]),2)+Math.pow((thisLayer.position[1]-comp("Main").layer("Pointer").position[1]),2));
ease(d,startFade,endFade,-300,0);


Return to posts index

Lorenzo Fernandez
Re: Problem with nested compositions and space reference
on Jul 8, 2011 at 2:04:04 pm

I'm almost there, I tried again and again and now it almost works. I need to figure out how to decrease the perspective distorsion (It looks like as if it was moving also on the X and Y). But apart that is ok!


Thanks Dan

I post the code I used:

beginVal = 90;
endVal = -200;
beginDistance = 1000;
endDistance = 0;
p1 = comp("Main").layer("Pointer").position;
L = comp("Main").layer(thisComp.name);
p2 = L.toWorld(toWorld(anchorPoint));
dis =Math.sqrt(Math.pow((p1[0]-p2[0]),2)+Math.pow((p1[1]-p2[1]),2));
ease(dis, beginDistance, endDistance, endVal, beginVal);


Return to posts index


Lorenzo Fernandez
Re: Problem with nested compositions and space reference
on Jul 12, 2011 at 9:26:35 am

I'm really having a hard time understanding how toWorld works. Now I have a composition with this path.

Main/Movies_Section/Animation

from Animation I'm trying to refer to the position of the layer "Pointer" in Main. But obviously is not working.
I'll paste the code under.

Thanks for any help.

Lorenzo

beginDistance = this_comp.layer("Controls&Settings").effect("scaleRange").param("Slider");
endDistance = 0;

beginVal = this_comp.layer("Controls&Settings").effect("scaleMin").param("Slider");
endVal =this_comp.layer("Controls&Settings").effect("scaleMax").param("Slider");

p1 = comp("Main").layer("Pointer").position;
L = comp("Main").layer("Movies_Section");
p2 = L.toWorld(toWorld(anchorPoint));

dis =Math.sqrt(Math.pow((p1[0]-p2[0]),2)+Math.pow((p1[1]-p2[1]),2));
s=ease(dis, beginDistance, endDistance, endVal, beginVal);
[s,s,s];


Return to posts index

Dan Ebberts
Re: Problem with nested compositions and space reference
on Jul 12, 2011 at 3:11:28 pm

Is "Animation" a comp or a layer?

In general, you have to go up the comp hierarchy one comp at at time, doing a space conversion at each level. That is, convert a layer's position into its comp's world space. Convert that value from the comp's layer space in the next higher comp to that comp's world space, and so on, until you get to the level you need. It looks like you're missing at least one of those intermediate steps.

Dan



Return to posts index

Lorenzo Fernandez
Re: Problem with nested compositions and space reference
on Jul 12, 2011 at 3:15:24 pm

Thanks Dan,

Animation is a composition and it's inside this composition that I have the layer at the last level of hierarchy.

Let me read carefully what you wrote and see if I can get it.
In any case, any further help is appreciated!

Thanks
L


Return to posts index


Lorenzo Fernandez
Re: Problem with nested compositions and space reference
on Jul 12, 2011 at 4:18:07 pm

Dan, I have tried and tried, but I don't understand how do you go back in the hierarchy.
If you could give me a hint it would be great!

Thanks
L

beginDistance = this_comp.layer("Controls&Settings").effect("scaleRange").param("Slider");
endDistance = 0;

beginVal = this_comp.layer("Controls&Settings").effect("scaleMin").param("Slider");
endVal =this_comp.layer("Controls&Settings").effect("scaleMax").param("Slider");

L = comp("Movies_Section").layer("Animation");
p2 = L.toWorld(toWorld(toWorld(anchorPoint)));
p1 = comp("Main").layer("Pointer").position;

dis=Math.sqrt(Math.pow((p1[0]-p2[0]),2)+Math.pow((p1[1]-p2[1]),2));
s=ease(dis, beginDistance, endDistance, endVal, beginVal);
[s,s,s];


Return to posts index

Dan Ebberts
Re: Problem with nested compositions and space reference
on Jul 12, 2011 at 4:49:53 pm

I haven't tested this, but it's going to looks something like this:

p1 = comp("Main").layer("Pointer").position;
pTemp1 = toWorld(anchorPoint);
L = comp("Movies_Section").layer("Animation");
pTemp2 = L.toWorld(pTemp1);
L = comp("Main").layer("Movies_Section");
p2 = L.toWorld(pTemp2);


Dan



Return to posts index


Lorenzo Fernandez
Re: Problem with nested compositions and space reference
on Jul 12, 2011 at 5:04:26 pm

No need to test!
It works perfectly.

Now let's see if I understand it.


Thanks again
L


Return to posts index

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