Skip to main content
Richard Rosenman
Inspiring
November 25, 2021
Question

3D Camera Matrix SDK Help

  • November 25, 2021
  • 1 reply
  • 491 views

Hi gang;

 

I am coding a relatively simple plugin with basic particle effects. At the moment, I have sliders that can rotate my around my particles but I would like to use the After Effects 3D camera since that's what it's for.

 

I have gone through the Resizer project and I have successfully pulled the camera and light info. I also carefully read through this thread as well: https://community.adobe.com/t5/after-effects-discussions/glator-for-dummies-and-from-dummy/m-p/6930311

 

I see that using the camera matrix, I can pull the camera X, Y and Z coordinates using:

 

matrix.mat[3][0];
matrix.mat[3][1];
matrix.mat[3][2];

 

I can't find anywhere in the documentation how to pull the remaninig info, like orientation. If I follow the GLater example, it suggests orientation would be:

 

matrix.mat[0][1];
matrix.mat[1][1];
matrix.mat[2][1];

 

But that returns floating point data.

 

Additionally, taking a look at the camera target, the GLater examples show:

 

matrix.mat[2][0];
matrix.mat[2][1];
matrix.mat[2][2];

 

But that too returns floating point data.

 

So my issue is two-fold: how to I get the remaining camera info, and more importantly, once I have it, how do I use it such as to adapt it to work with a 3D point in space?

 

It is a shame Adobe erased so many valuable forum threads that probably showed some great examples on how to use the camera. I searched the documentation and I can't even find a description anywhere on what camera matrix corresponds to what.

 

Can anyone help here? I realize it is a loaded question but seeing as how there is no relevant help anywhere else, a good reply (ideally with some example source code) would no doubt help a lot of other developers also trying to understand how to use the 3D camera in the SDK.

 

Thanks!

-Richard

1 reply

Community Expert
November 25, 2021

start with AEGP_GetEffectCameraMatrix, and then create the perspective matrix from the camera's FOV and concat with the camera transformation matrix.

https://ae-plugins.docsforadobe.dev/artisans/artisan-data-types.html?highlight=film%20size#film-size

Inspiring
August 21, 2025

Once I have that matrix, what's the overall process for recreating a Solid Layer in my 3D renderer? As in, how would I match a solid's position 1:1?

Community Expert
August 21, 2025

you need the layer's transformation matrix as well. you can get it using AEGP_GetLayerToWorldXform.
now, if i recall correctly, you multiply the layer and camera transformation matrices to get the relative offset of the layer to the caemra, and then you multiply the resulting matrix with the perspective matrix. (yeah, you need to constric the perspective matrix to include the focal length and possibly the camp pixel apsect ratio)

 

you should now have the final matrix which if you multiply a point in the layer coordinates with it, you get the correspoinging point on the screen as seen through the camera.