Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

AE coordinates to OpenGL coordinates

Explorer ,
Sep 25, 2023 Sep 25, 2023

Hello there !

I am developping an OpenGL plugin that allows 3D transformations of a selected layer in the comp (a sort of a 3D version of the "transform" effect)

I am able to checkout the selected layer, apply to it the transform data of the original layer, and display it on screen.

 

... BUT!

 

1. AE and OpenGL have a different coordinates system: in AE, {0,0} is not the center of the screen but rather the upper left corner. So OpenGL's objects are positioned in the 3D world according to their center, whereas AE's layers are placed on the comp according to their upper-left corner. 

 

2. Also, in OpenGL, Y points upwards and Z points away from the camera. In AE, it's the opposite.

So rotations are inverted, and moving through the Y and Z axis are inverted.

 

I tried many things, :

- For the first problem, to shift the camera by (comp_width/2, comp_height/2) and the layer by (-layer_width/2, -layer_height/2). Seems to work but I am not sure if there is a better way...

- For the second problem, to put a minus "-" before the Y and Z coordinate of the translation data of the layer's transform matrix. But that results in an empty screen as the layer is now far away from the camera.

Moving the camera to compensate also does not resolve the issue.

 

Does someone have a better solution for this ?

Thanks

TOPICS
SDK
206
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 25, 2023 Sep 25, 2023

Can you move the layer to the centre of the comp instead of the camera? 

for the coordinates, I'm not sure if you're writing shorthand, but something like this looks like it should work:

X = xVar + thisComp.width/2;
Y = yVar + thisComp.height/2*-1;
Z = zVar*-1;

[X,Y,Z]

 with xVar, yVar and zVar being the initial states of the layer position with the comp's dimensions for adjustment.

If you take a look at the C4D cineware plugin, that might shed some light on, as i notice that has comp camera and centred comp camera options.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 25, 2023 Sep 25, 2023
LATEST

Wouldn't you just use the GL functions for this? Set origin and set world matrix in particular?

 

Mylenium

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines