Im trying to set a new zero for the accelerometer and found this what seems to be the solution: https://stackoverflow.com/questions/9705446/calibrating-3d-accelerometer-for-2d-game
But I couldn't translate it to B4a, methods like "Quaternion().setFromCross" are missing in the LibGDX library, it is possible to take this code and move it into B4A?
Capture a vector representing the neutral direction:
Whenever you need inputs from the accelerometer, first run them through the rotation matrix:
B4X:
publicvoid handleAccelerometerInputs(float x,float y,float z ){
Vector3.tmp.set( x, y, z );Vector3.tmp.mul(this.calibrationMatrix );
x =Vector3.tmp.x;
y =Vector3.tmp.y;
z =Vector3.tmp.z;
[use x, y and z here]...}
For what I know, to work with Quaternion in LibGDX (B4A) first you need to declare a 4x4 matrix, you don't work directly with a variable of type Quaternion.
Something like: