348 posts
  • Has referred 10+ members
  • Has sold $40,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 100+ items on Envato Market
+6 more
andrenavarre says

Hey guys… You have any tips for auto-orienting a layer in a pre-composition to a parent composition camera?

TX

201 posts
  • Has referred 200+ members
  • Has sold $125,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+9 more
Darkpulse says

What are you meaning by saying auto orientation ?

348 posts
  • Has referred 10+ members
  • Has sold $40,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 100+ items on Envato Market
+6 more
andrenavarre says

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 :)

201 posts
  • Has referred 200+ members
  • Has sold $125,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+9 more
Darkpulse says

You layer is not 3D ?

348 posts
  • Has referred 10+ members
  • Has sold $40,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 100+ items on Envato Market
+6 more
andrenavarre says

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.

201 posts
  • Has referred 200+ members
  • Has sold $125,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+9 more
Darkpulse says

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 ?

5083 posts
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $125,000+ on Envato Market
  • Has been part of the Envato Community for over 5 years
  • Helps us moderate the forums
+11 more
felt_tips Volunteer moderator says

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.

On position:
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]));
348 posts
  • Has referred 10+ members
  • Has sold $40,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 100+ items on Envato Market
+6 more
andrenavarre says

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”?

5083 posts
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $125,000+ on Envato Market
  • Has been part of the Envato Community for over 5 years
  • Helps us moderate the forums
+11 more
felt_tips Volunteer moderator says

double post

5083 posts
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $125,000+ on Envato Market
  • Has been part of the Envato Community for over 5 years
  • Helps us moderate the forums
+11 more
felt_tips Volunteer moderator says

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”?

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
by
by
by
by
by
by