Creative COW SIGN IN :: SPONSORS :: ADVERTISING :: ABOUT US :: CONTACT US :: FAQ
Creative COW's LinkedIn GroupCreative COW's Facebook PageCreative COW on TwitterCreative COW's Google+ PageCreative COW on YouTube
ADOBE AFTER EFFECTS:HomeForumBasicsExpressionsTutorialsPodcastsAE TechniquesCreative Cloud DebateFAQ

3D Camera facing expressions

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Share on Facebook
high1memo3D Camera facing expressions
by on Sep 4, 2007 at 6:35:42 pm

Hi All, I initially posted this in the standard AE forums without realizing there was a seperate container for expressions, so I'm closing that and carrying on here.
The original thread is at
http://forums.creativecow.net/readpost/2/915589

To summarize I would like my 3D layers to
1. Always remain fully parallel to my camera
2. OR Always remain parallel to my camera while staying perpendicular to the floor (only rotate around Y axis).

The Auto-orient mode/expressions don't work because they POINT the layer to the camera, so if the camera is close to the layer the layer rotates a lot, and thus distorts (more details in the original thread) - I need the layer normal to be parallel to the camera normal, NOT pointing to the camera.

Searching these forums and the web, I've seen lots of people ask the same question but with no answer, so I'm posting my results so far which works good enough for what i need, but not fool proof so if anyone wants to improve they are more than welcome.

I'll start with Q2 first (the easier one, only rotate around Y).

paste this to the ORIENTATION:
camZ = normalize( thisComp.activeCamera.transform.position - thisComp.activeCamera.transform.pointOfInterest );
camX = normalize( cross(camZ, [0,1,0]) );
[0, radiansToDegrees(Math.atan2(-camX[2],camX[0])), 0];

In the original thread I mentioned putting this on the Y-Rotation which also works, but then doesnt work with the full camera facing mode (must be a rotation order thing).

Q1. (full camera facing) paste this to X-Rotation (in addition to above)
camZ = normalize( thisComp.activeCamera.transform.position - thisComp.activeCamera.transform.pointOfInterest );
-radiansToDegrees(Math.atan2(camZ[1], camZ[2]));


Like I said this isnt fool proof. If something has parents it may not work I dunno, this is my first AFX expression, so any experts who see potential pitfalls feel free to fix it. Also probably wont work if the camera is looking completely straight down. And finally, this doesnt take into consideration any camera orientation. I usually never use camera rotations but only use camera position and anchor-point. Moreover I usually import camera animation from 3dsmax or cinema4d which also just imports keyframes for position and anchor. So if you are using nulls to control camera or anchor, or animating actual camera rotation then the expressions would need to be modified for that.

This is such a fundamental thing for anyone doing any form of navigating 3D sets that I can't believe its not built into AE like the auto-orient thing is!



Return to posts index
Reply   Like  

cow
pxlguyRe: 3D Camera facing expressions
by on Sep 11, 2007 at 2:28:28 pm

http://www.motionscript.com/design-guide/auto-orient-y-only.html

Sorry you haven't gotten your answer yet! Here is a great link for a great page on a great site with even more information than you were asking for.

Good Luck!
Trent


Return to posts index
Reply   Like  

high1memoRe: 3D Camera facing expressions
by on Sep 11, 2007 at 3:18:21 pm

Hi Trent, that is indeed a great site and I have learnt a lot from it. In this case however, I could not find an answer to my question there. The page you've linked to seems very similar to what I'm asking, but actually it is exactly what I am trying to avoid. The expression on that page is for orienting the layer towards the camera - i.e. points the layer to the camera. So when the camera is close to the layer there is a lot of perspective deformation. What I am looking for is to keep the layer parallel to the screen (either on all 3 axis, or staying perpendicular to the floor - i.e. only rotating around Y).

I've seen a lot of people ask about this (and I even found an old post of mine from years ago when I'm asking how to do the same thing in combustion!).

To show the problem I've taken a capture from aftereffects of my project (if it doenst come up for some reason, its at http://public.memo.tv/camera-facing.gif): .

The expression I've come up with for rotating around Y only (shown in my post above) works perfectly for me now (thats the blue layer). Like I say, it probably wont work if linked to other layers and stuff, but I dont have time to figure that out right now.

The expression I came up with for full camera facing works not perfectly (with some camera angles it goes bonkers) - but for my current project its fine so I"m not working on it anymore. Probably in the future I will need a foolproof version as well. I'm just working with two axis rotation angles. the correct solution I guess would involve setting up a rotation matrix from the camera x,y,z axes; and then extracting the 3 orientation values. Like I said, I've seen a lot of posts with people asking how to do that, so if anyone would like to tackle it, it would be great!!


Return to posts index
Reply   Like  


Dan EbbertsRe: 3D Camera facing expressions
by on Sep 12, 2007 at 3:49:36 pm

I'm not sure if this is what you're after, but it should give a layer the same orientation as the camera:

C = thisComp.activeCamera;

V = C.toWorldVec([0,0,1]);
P = toWorld(anchorPoint);
lookAt(P, P + V);


Dan


Return to posts index
Reply   Like  

high1memoRe: 3D Camera facing expressions
by on Sep 12, 2007 at 5:44:54 pm

Yup thats perfect thanks! I cant believe how simple it is! I guess I need to look more into built-in functions like toWorldVec and lookAt to simplify things!

For the camera-facing around Y, would you advise that I keep my solution above, or use something like:
YRotation =
C = thisComp.activeCamera;
V = C.toWorldVec([0,0,1]);
P = toWorld(anchorPoint);
O = lookAt(P, P + V);
O[1];
i.e. It probably is more foolproof?

P.S. slightly off-topic, how can I save these expressions to my presets?

*EDIT* Ignore the last part about saving presets. found that, its dead easy...



Return to posts index
Reply   Like  

Dan EbbertsRe: 3D Camera facing expressions
by on Sep 12, 2007 at 7:02:01 pm

I'd give this a try:

C = thisComp.activeCamera;

V = C.toWorldVec([1,0,0]);
-radiansToDegrees(Math.atan2(V[2], V[0]))



Dan


Return to posts index
Reply   Like  


high1memoRe: 3D Camera facing expressions
by on Sep 14, 2007 at 10:49:05 am

yup works perfectly thanks!


Return to posts index
Reply   Like  

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
Share on Facebook


FORUMSTUTORIALSFEATURESVIDEOSPODCASTSEVENTSSERVICESNEWSLETTERNEWSBLOGS

Creative COW LinkedIn Group Creative COW Facebook Page Creative COW on Twitter
© 2014 CreativeCOW.net All rights are reserved. - Privacy Policy

[Top]