Activity › Forums › Adobe After Effects › expressions / camera distance
-
expressions / camera distance
Posted by Alex Harding on November 3, 2006 at 5:23 pmi wonder could anyone please help me
i want to make a text number that descreases in value as the camera approaches in 3d space. I have found the “number” effect which displays digits in the comp, the value of which can be defined by expressions.i need to know how to calculate the distance from the camera to the layer on which the effect resides with an expression.
can anyone help?
thanks in advance
alexAlex Harding replied 19 years, 6 months ago 5 Members · 6 Replies -
6 Replies
-
Julian Sixx
November 3, 2006 at 5:52 pmHi
i’m not sure if that is what you’re looking for.Let’s assume when the camera moves from -600 to -400 in z-space the Number effects counts from 40 to 20
driver=thisComp.layer(“Kamera 1”).transform.position[2];
minCam=-400
maxCam=-600
minNr=20
maxNr=40
linear(driver, minCam, maxCam, maxNr,minNr) -
Alex Harding
November 3, 2006 at 6:27 pmthanks for your help,
that helped, but it isn’t quite what im afterperhaps if i explain what i’m doing..
i want to have a series of graphical “reticals” in the HUD of a spaceship that act as guides as it lands; the camera passes through them one after the other in 3d space. i want each one to display a number that represents the distance from the space ship (the camera) to that point in space, hitting 0 at the moment that the camera ocupies the same coordinates. (nerdy i know)
so ideally i need to calculate a value representing the distance between the points irrespective of what axes that distance lies in.
is this rediculously complicated?
any help will be appreciated, thanks
alex -
Mike Clasby
November 3, 2006 at 7:49 pmThis should do what you want, you need a little vector math to calculate the distance from the rocket (camera) to your HUD. For any HUD layer add this expression to the Value/Offset (alt click the Stopwatch) of the Numbers Effect:
point1=this_layer.position;
point2=thisComp.layer(“Camera 1”).position;
delta=sub(point1, point2);// Find the vector between them
distance=length(delta);// Now find the length
linear(distance, 0,10000, 0, 10000);This limits out at 10,000 pixels so if you want you camera father away, change the 10,000’s to whatever figure you want. If you want the numbers to change slower you could skew the linear interpolation to something like this:
linear(distance, 0,10000, 0, 1000);
Now the 10 pixels equals 1 until of camera travel (meters in Outer Space Distance?)
This is a modification from here:
https://jjgifford.com/expressions/geometry/length.html
Example: Interactive Blur -
Dan Ebberts
November 3, 2006 at 7:49 pmI’d use a text layer with an expression like this for Source Text:
length(thisComp.layer(“Camera 1”).position,position)
Dan
-
Colin Braley
November 3, 2006 at 8:01 pmDoes this one do the trick?
//begin
p1 = thisComp.layer(“Camera”).position;
p2 = thisComp.layer(“HUD”).position;
distance = Math.round( length( p1 , p2 ) ) ;
distance
//end~Colin
Reply to this Discussion! Login or Sign Up