Hey guys… You have any tips for auto-orienting a layer in a pre-composition to a parent composition camera?
TX
- Author had a Free File of the Month
- Author was Featured
- Microlancer Beta Tester
- Repeatedly Helped protect Envato Marketplaces against copyright violations
- Exclusive Author
- Sold between 10 000 and 50 000 dollars
- Contributed a Blog Post
- France
- Has been a member for 1-2 years
What are you meaning by saying auto orientation ?
Hey there Darkpulse. Layer > Transform > Auto Orient… but I cannot see that it creates an expression that I could modify so that it auto orients to a specific camera. Felt? Where are you! I need to access your infinite knowledge base 
- Author had a Free File of the Month
- Author was Featured
- Microlancer Beta Tester
- Repeatedly Helped protect Envato Marketplaces against copyright violations
- Exclusive Author
- Sold between 10 000 and 50 000 dollars
- Contributed a Blog Post
- France
- Has been a member for 1-2 years
You layer is not 3D ?
Yes it is 3D, the option to auto-orient towards the camera wouldn’t be present otherwise. The layer is in a pre-composition. I am just trying to get the layer to auto-orient to a camera that is outside the composition in a parent composition containing the pre-composition.
Instead of using the auto-orient feature, maybe I should use an expression on the orientation of the layer to match a null object’s values in the parent composition which in turn is auto-oriented towards the camera! I’ll try this now.
- Author had a Free File of the Month
- Author was Featured
- Microlancer Beta Tester
- Repeatedly Helped protect Envato Marketplaces against copyright violations
- Exclusive Author
- Sold between 10 000 and 50 000 dollars
- Contributed a Blog Post
- France
- Has been a member for 1-2 years
Sorry, I Have difficulties to understand your problem (try in french Andre !
, and what about enable collapse on the pre-comp in the main comp ?
- Community Moderator
- Sold between 50 000 and 100 000 dollars
- Author was Featured
- Item was Featured
- Author had a File in an Envato Bundle
- Beta Tester
- Has been a member for 4-5 years
- United Kingdom
If you don’t have a camera in the precomp, then presumably your precomp is collapsed?
If not, you’d need to use expressions to make a duplicate camera in the precomp and then you can orientate towards that. That’s a bit complicated to do robustly. On position of one-node camera:
C = comp("Comp 1").activeCamera;
thisLayer.fromWorld(C.toWorld([0,0,0]));
On orientation of one-node camera:
C = comp("Comp 1").activeCamera;
glOr(C);
function glOr(aL,aT){aT=(aT?aT:time);var x=normalize(aL.toWorldVec([1,0,0],aT)),y=normalize(aL.toWorldVec([0,1,0],aT)),z=normalize(aL.toWorldVec([0,0,1],aT));return [Math.atan2(-z[1],z[2]),Math.asin(z[0]),Math.atan2(-y[0],x[0])]*180/Math.PI}
Otherwise, if the precomp is collapsed, you could use an expression on the layer.
L = comp("Comp 1").layer("Original layer");
L.toWorld(L.anchorPoint);
On orientation:
C = comp("Comp 1").activeCamera;
L = thisLayer;
lookAt(L.toWorld(L.anchorPoint), C.toWorld([0,0,0]));Hey felt thanks for a speedy response. Really appreciate it.
The precomp is indeed collapsed. The precomp is also a 3D layer itself. The layer I’m trying to auto orient also has CC sphere effect associated with it – but don’t worry, I’m not doing an earth project 
So with this in mind I have tried your second set of expressions. Although the first set is also very interesting!
But I can’t seem to get the right associations… Maybe you could help me out with this example?
- “Main Comp” contains a camera, lights, and 3D collapsed pre-comp “Pre-comp”.
- “Pre-comp” contains 3D layer “Layer” which has CC sphere
Did you mean to apply that expression on “Layer” and have Comp 1 be “Main Comp” and Original layer be “Layer”?
- Community Moderator
- Sold between 50 000 and 100 000 dollars
- Author was Featured
- Item was Featured
- Author had a File in an Envato Bundle
- Beta Tester
- Has been a member for 4-5 years
- United Kingdom
double post
- Community Moderator
- Sold between 50 000 and 100 000 dollars
- Author was Featured
- Item was Featured
- Author had a File in an Envato Bundle
- Beta Tester
- Has been a member for 4-5 years
- United Kingdom
andrenavarre said
Hey felt thanks for a speedy response. Really appreciate it.The precomp is indeed collapsed. The precomp is also a 3D layer itself. The layer I’m trying to auto orient also has CC sphere effect associated with it – but don’t worry, I’m not doing an earth project
So with this in mind I have tried your second set of expressions. Although the first set is also very interesting!
But I can’t seem to get the right associations… Maybe you could help me out with this example?
Did you mean to apply that expression on “Layer” and have Comp 1 be “Main Comp” and Original layer be “Layer”?
- “Main Comp” contains a camera, lights, and 3D collapsed pre-comp “Pre-comp”.
- “Pre-comp” contains 3D layer “Layer” which has CC sphere
Are you rotating the precomp layer itself? If so, your task just got massively conceptually harder, since you’d need to effectively unrotate the layer to orientate it correctly. You’re getting into inverse matrix math here…lots of lines of code and really not a cut and paste expression.
If you’re trying to orientate a point on a CC sphere towards camera, you’re going to need to understand vectors and how to convert them to Euler angles (orientations). The clue is in the first set of expressions above with the glOr function, which is the result of multiplying out matrices for unit rotations around each of the three axes in the correct order. You will break your brains over this for weeks or months, but if you manage to grasp it, you will be able to conjure with 3D space! The link at the bottom of this post is a useful introduction, if you’re interested.
Otherwise, just use the second set of expressions I wrote before. I’d suggest you try it with a simple example to get your head around it and then move up. I can point you in the right direction, but I’m afraid I can’t do it for you. Too busy.
http://www.euclideanspace.com/maths/algebra/matrix/orthogonal/rotation/index.htm