I am trying to rotate a 3D model on several axes at the same time using accelerometers. When I do this, I use setToRotation(), but it is only one axis at a time.
For instance:
ModelInstance modelInstance = instances.first();
modelInstance.transform.setToRotation(Vector3.Z, phoneAccel.y*9);
modelInstance.transform.setToRotation(Vector3.X, phoneAccel.z*9);
The phone is in forced mode. I get an instance of the model I want to rotate.
I installed Vector3 phoneAccelbased on Gdx.input.getAccelerometerX/Y/Z().
In the above example, both lines of code work correctly, but only independently. When I try to use both (one after the other), the first turn (ROLL) is deleted. I would think that two rotation matrices would accumulate, i.e. The Z axis is superimposed on the rotation, and then the rotation is superimposed on the X axis.
Do I need to create my own aggregate rotation matrix and then apply it at the end?
?