ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

calculate angle

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
alex harding
calculate angle
on Feb 8, 2009 at 10:16:07 pm

Hi,

was wondering if there's a way to calculate the angle of a 3d layer relative to the world / a camera.

i want to mimic the effect from old sprite based pseudo 3d games like doom. i want to take, say, 8 photos of an object from 8 different angles, and make the layer switch to the correct image depending on the position of the camera.

i was planning to use the auto orient feature so that the layer always faces the camera. however this doesn't report any angle information that can be picked up by an expression, as far as i can see...

any ideas?

once i get the values of the angle, i was simply planning to have a precomp with 8 images on different frames and use time remapping to have the layer refference the correct image.

help much appreciated!

thanks,

alex



Return to posts index

Dan Ebberts
Re: calculate angle
on Feb 8, 2009 at 11:32:03 pm

This should give you an angle you can do something with:

C = thisComp.activeCamera;
d = toWorld(anchorPoint) - C.toWorld([0,0,0]);
angle = radiansToDegrees(Math.atan2(d[0],d[2]));


Dan



Return to posts index

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