Activity › Forums › Adobe After Effects Expressions › Horizontally Rotating car done with expressions
-
Horizontally Rotating car done with expressions
Posted by Floyd Paul on August 13, 2008 at 7:49 amOk guys heres a challenge for you coding gurus!
Ive shot stills of a car rotating 360 degrees. About 50 frames.
I want to put the stills in a 3d comp layer and move the layer around in 3d space. Depending on the angle the layer is to my camera i want to see the corresponding still.
This is to create the sense of a car riding across a landscape.
but in “2d”Any help would be greatfully apprecitated.
Floyd
Darby Edelen replied 17 years, 9 months ago 2 Members · 3 Replies -
3 Replies
-
Darby Edelen
August 15, 2008 at 2:41 amYour solution will require a pre-comp with your car sequence in it, and time remapping enabled on the pre-comp in your parent comp. From there you’ll need to determine the angle from which the camera is viewing your layer with some vector math, perhaps using a derivative of Dan Ebberts’ Auto-Orient to Camera expression. Try applying his expression to the Y-Rotation property:
delta = toWorld(anchorPoint) - thisComp.activeCamera.toWorld([0,0,0]);
radiansToDegrees(Math.atan2(delta[0],delta[2]));
Then you need to go to the proper frame in your pre-comp for that angle of view, so try applying this to the Time Remap property:
offset = 0;
reverse = 1;
numFrames = 50; //if your pre-comp is exactly the same length as the number of frames in your rotation sequence then you could try using numFrames = timeToFrames(duration);
deg = transform.rotationY; //this requires the previous expression be already applied to the Y rotation
(offset + reverse * deg * numFrames / 360) % numFrames;
The offset variable above would be used to offset the initial orientation of the car, it might be worthwhile to link this to a Slider expression control. The reverse variable should be switched to -1 if the car appears to be rotating in the wrong direction.
I haven’t had an opportunity to test any of the above in AE, so let me know if there are any problems. Also, I think you were asking for a 2D solution… if you leave everything 2D in your comp except for the car, then it should interact with a camera in the way that you desired. At least that’s the way it works in my head 🙂
I may test this out tomorrow at work and post some refinements if necessary.
Darby Edelen
NVIDIA
Santa Clara, CA -
Darby Edelen
August 15, 2008 at 5:28 am[Darby Edelen] “offset = 0;
reverse = 1;
numFrames = 50; //if your pre-comp is exactly the same length as the number of frames in your rotation sequence then you could try using numFrames = timeToFrames(duration);
deg = transform.rotationY; //this requires the previous expression be already applied to the Y rotation
(offset + reverse * deg * numFrames / 360) % numFrames;”Well, I still haven’t had a chance to test it, but the above expression is wrong. It needs a call to
framesToTime()on the final value:offset = 0;
reverse = 1;
numFrames = 50; //if your pre-comp is exactly the same length as the number of frames in your rotation sequence then you could try using numFrames = timeToFrames(duration);
deg = transform.rotationY; //this requires the previous expression be already applied to the Y rotation
framesToTime((offset + reverse * deg * numFrames / 360) % numFrames);Sorry for the mix up 🙂
Darby Edelen
NVIDIA
Santa Clara, CA -
Darby Edelen
August 15, 2008 at 10:00 pmUnfortunately the above expressions definitely don’t get the job done. I guess I can try and play around with it some more, but it looks like I need to rethink the way I’m approaching the problem.
Darby Edelen
NVIDIA
Santa Clara, CA
Reply to this Discussion! Login or Sign Up