FORUMS: list search recent posts

Translating distance from a camera in Mastercomp to Scale/Width of an object in Precomp

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Oskar Ziemba
Translating distance from a camera in Mastercomp to Scale/Width of an object in Precomp
on Aug 29, 2014 at 3:03:08 pm

Hello creative people,
i am apprentice, when it comes to expressions, so please bear with me.
I have been fiddling with the Vehicle Rig Tutorial by Carl Larsen (http://library.creativecow.net/articles/larsen_carl/vehicle_rig.php) and it works fine.

I've changed the setup like this: my vehicle is a precomp called "LKW" and i use it in a mastercomp called "Test Rotation". The setup of the master looks like this:



My camera is on zero coordinates. So instead of moving the camera i just rotate a solid circle 'BG', which represents the floor. LKW is linked to a null 'Rotationsgelenk', which is also at zero coordinates and is inversely linked to the solids rotation, so that LKW always stays in the middle of the camera. So i wanted to match the wheels of the precomp LKW with the rotation of the BG.

In the tutorial by Larsen, he links the Rotation of the wheels to the distance traveled by the body the wheels are parented to, but since i needed my truck to rotate around a center, i decided to tie the rotation of the wheels to the circumference of a circle described by the distance of the precomp LKW from the camera in the master comp.
That works quite okay, except for one thing: the width of the wheels is changed through the distance from the camera, which means that my translation of the distance to the rotation my wheelsis wrong.
So i need to find a way to translate the change in scale due to distance from camera into the expression.
You can find my altered expression for the wheels at the bottom.

I hope i could make my problem clear,
cheers!

d=width/4;
pi=Math.PI;
circ=d*pi;
rot=360/circ;
distance=(((comp("Test Rotation").layer("LKW").transform.position[2]*2)*Math.PI)/360)*comp("Test Rotation").layer("Rotationsgelenk LKW").transform.yRotation;

distance*rot


Return to posts index

Oskar Ziemba
Re: Translating distance from a camera in Mastercomp to Scale/Width of an object in Precomp
on Aug 29, 2014 at 3:13:49 pm

Oh, one more thing about "d=width/4;"
I#ve divided that by 4 because the precomp is scaled to 25%.

Plus: I thought i would be really smart because i could animate the distance of the precomp "LKW" to the camera and the wheels would become faster and slower as the car moved to or fro the camera. BUT: if the precomp gets closer to the camera the wheels actually stop, is there something like a median? So i can avoid that?

Thanks!


Return to posts index


Dan Ebberts
Re: Translating distance from a camera in Mastercomp to Scale/Width of an object in Precomp
on Aug 29, 2014 at 3:51:28 pm

I haven't tried it, but it seems like it's basically just a gear ratio problem where the wheel rotation is just the rotation in the master comp times the ratio of the distance from the camera divided by the wheel radius (taking any scaling into account).

Animating the distance from the camera really complicates things though, because if you do that, I think your expression will need to loop through all the previous frames and calculate the rotation contribution due to conditions existing at the time of each frame.


Dan



Return to posts index


Oskar Ziemba
Re: Translating distance from a camera in Mastercomp to Scale/Width of an object in Precomp
on Aug 29, 2014 at 4:10:14 pm
Last Edited By Oskar Ziemba on Aug 29, 2014 at 4:13:31 pm

Hello Dan,

Thanks for your quick reply.
Bearing in mind i am a newbie how would i write that first part as an expression?

i wrote it like this now, and i divided the width by 8, because half the width is the radius and that times 4, because the precomp is scaled to 25%. It looks pretty ok, but not quite right, what am i not seeing?

So there is nothing i can do about the distance from the camera?

Thanky very much,
Oskar

((comp("Test Rotation").layer("Rotationsgelenk LKW").transform.yRotation*comp("Test Rotation").layer("LKW").transform.position[2])/(width/8));


Return to posts index


Dan Ebberts
Re: Translating distance from a camera in Mastercomp to Scale/Width of an object in Precomp
on Aug 29, 2014 at 4:34:09 pm

I just roughed out a mockup and your numbers look right to me. How are you determining that it's not quite right?

>So there is nothing i can do about the distance from the camera?

No, you can do it--it just makes the expression much more complex.

Dan



Return to posts index

Oskar Ziemba
Re: Translating distance from a camera in Mastercomp to Scale/Width of an object in Precomp
on Aug 29, 2014 at 7:45:52 pm

Hey thanks again for your reply,
it looked off to me so i fiddled with the numbers again and i finally settled on dividing width by four because and then it looked ok. Sorry i didn't get back to you sooner.

About the other distance to camera thing your probably right as well, so i'll do other stuff. Just in case i would want to pursuit later, could you per chance point me to some tutorials that i could look at?

Many thanks,
Oskar


Return to posts index

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