Skip to main content
Inspiring
October 21, 2021
Answered

Get z position of camera and current layer

  • October 21, 2021
  • 1 reply
  • 1270 views

For a project, I would like to get the z position of camera and current layer. Is there a simple way to :- 

a. Check if The 3d layer is enabled for current layer

b. If enabled, get x,y,z position of camera and current layer.

 

Artie is a bit involved as a simple example to just get this info.

 

This topic has been closed for replies.
Correct answer James Whiffin

I got the position of the camera as 

matrix.mat[3][0], matrix.mat[3][1], matrix.mat[3][2] - I use this as x,y,z 


You can also use the math suite to decompose the matrix into it's components 

ERR(suites.MathSuite1()->AEGP_MatrixDecompose4(&layer2WorldMat, &posVP, &scaleVP, &shearVP, &rotVP));

 

1 reply

AnmolMAuthor
Inspiring
October 21, 2021

This is what I am trying to do in c++ sdk

 

d = length(toWorld(anchorPoint),thisComp.activeCamera.position);

James Whiffin
Legend
October 23, 2021

To check if a layer is 3D, you can query it's flags (same as to check if it's an adjustment layer, cont raster, has moblur, etc). 

 

The resizer example in the SDK gets a 3D camera and transforms. AEGP_GetLayerToWorldXform is very handy as it accounts for all parented transforms. 

AnmolMAuthor
Inspiring
October 23, 2021

Is there an example where AEGP_GetLayerToWorldXform will take the matrix and spit out the camera position in world co-ordinates ?