In my code I need to reduce the default forecast android.graphics.Camera . According to the official API, by default its position is set to (0,0, -8), but I can use the setLocation(float,float,float) method to divert the viewpoint to (0, 0, -24) and, therefore, reduce the distortion effect.
Unfortunately, this method is only available for API 12+ and Romain Guy, verified on twitter. I have to manually set the matrix values to get the same result without using this convenience method. Therefore (if I'm not mistaken), I have to generate my own matrix and combine it with the one that I get from the Camera object.
Camera class, unfortunately, is not pure Java, but a simple JNI-wrapper for its own SkCamera3D class, implemented in the Skia 2D framework ( SkCamera.h and SkCamera.cpp ).
Digging in the code, I found out that the matrix contained in this class can be represented as follows:
| scaleX skewX transX | | skewY scaleY transY | | persp0 persp1 persp2 |
but to be honest, I still can’t understand all this complicated math inside my own code, and I can’t figure out how to change the matrix values myself to get what I want. Can someone point me to some reference implementation, or (even better) to some detailed explanation of how this matrix works?
source share