Skip to main content
November 23, 2009
Answered

Depth of Field expression

  • November 23, 2009
  • 2 replies
  • 3125 views

Hi

i've got a comp with 70 3d layers.They are all arranged in a grid in the x+z axes .Distance between each layer is 3600Px.

The camera is parented to a null called"Cam_control".Basically,the camera flyies now to each 3d layer(which is contolled by the"Cam control" null)

and animates around each layer(Camera's position,rotation keyframed).

ok,i'd like now that the focus point of the cam is always on the "Cam_control"Null.How can i do this?Focus distance would then be the distance between Cam_control null and the cam's pos.

Problem is that the Null's position refers to the center of the comp so that the expression length(null's position,cam's position) doesn't work.

it would be nice now to have an expression that calculates the distance between the cam and this "cam-Contol"null.So that wherever "cam-control"is,this point will be in focus.

any help appreciated.

This topic has been closed for replies.
Correct answer Dan Ebberts

Try this:

L = thisComp.layer("Cam_control");
length( L.toWorld(L.anchorPoint), toWorld([0,0,0]))

Dan

2 replies

Participant
March 26, 2011

Little confused on where to apply the expression.

Could you clarify?

Thanks

C

Dan Ebberts
Community Expert
Community Expert
March 26, 2011

That expression would be applied to the camera's Focus Distance property.

Dan

Participant
March 26, 2011

Thanks Dan I thought that was it.

I did that but it didn't work.

Before I had my coffee, I'll try again.

Thanks

Clay Asbury

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
November 25, 2009

Try this:

L = thisComp.layer("Cam_control");
length( L.toWorld(L.anchorPoint), toWorld([0,0,0]))

Dan

November 25, 2009

Hi Dan

thx very much,it works of course

i guess your expression creates a vector from [0,0,0,] to the null'sAnchor Point.

Dan Ebberts
Community Expert
Community Expert
November 25, 2009

It just converts the null and camera postions to world space coordinates and then calculates the distance between them with length().

Dan