I have the orientation values from Android device RotationVector sensor expressed in degress as Yaw, Pitch and Roll angles. I want to continuously update the LibGDX Perspective camera rotation based on these orientation values. My goal is to build a 3D compass.
In the render() method I am trying:
@Override
public void render() {
ScreenUtils.clear(Color.BLACK, true);
// do some rendering
modelBatch.begin(cam);
modelBatch.render(instance, lights);
modelBatch.end();
// calculate/get the orientation angles
float Yaw = ...;
float Pitch = ...;
float Roll = ...;
// update camera orientation
cam.view.setFromEulerAngles(Yaw, Pitch, Roll);
cam.update();
}
I see the continuously changing Yaw/Pitch/Roll values in the logcat on the Android device orientation change, but unfortunately my model (the 3D compass) does not rotate. What is wrong with the above code? Why the camera rotation does not work?
Thanks to @bornander I ended up with the below perfectly working code: