AE coordinates to OpenGL coordinates
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
