Page 1 of 1

Parent lens flare centre

Posted: May 20th, 2009, 12:06 am
by amitzinman
Hi,
I have a null with some tracking information. I would like to move the lens flare center according to it.
What expression could I use to to parent a property rather than the entire layer?

Amit

Re: Parent lens flare centre

Posted: May 20th, 2009, 12:48 am
by Paul Tuersley
You should be able to just add an expression to the Lens Flare Center property and drag the expression pickwhip to the null's Position property. Which will give you an expression like:

Code: Select all

thisComp.layer("Null 1").transform.position

Re: Parent lens flare centre

Posted: May 20th, 2009, 5:30 am
by amitzinman
yes, I did that but it doesn't parent it. Its just follows the null's position which is way far off.

Re: Parent lens flare centre

Posted: May 20th, 2009, 5:57 am
by Paul Tuersley
There's no built in way to do something exactly like parenting with expressions, but you can put in an offset. Something like:

Code: Select all

thisComp.layer("Null 1").transform.position + [-100, 50];

Re: Parent lens flare centre

Posted: May 20th, 2009, 6:23 am
by amitzinman
also, not helping if the tracking data has rotation values.

Re: Parent lens flare centre

Posted: May 20th, 2009, 10:29 am
by Paul Tuersley
I don't really see how rotation comes into it. There's almost certainly a way to do it but maybe you could describe better exactly what's going on, or even better, post a reduced project.

Re: Parent lens flare centre

Posted: May 20th, 2009, 10:43 am
by amitzinman
Dan Eberts posted this expression as a reply to this query, but in another forum...

L = thisComp.layer("Null 1");
p = L.transform.position;
r = L.transform.rotation;
d = valueAtTime(0) - p.valueAtTime(0);
angle = degreesToRadians(r - r.valueAtTime(0));
s = Math.sin(angle);
c = Math.cos(angle);
x = d[0]*c - d[1]*s;
y = d[0]*s + d[1]*c;

p + [x,y]