-
3D Camera facing expressions
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
https://forums.creativecow.net/readpost/2/915589To 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!
.