I'm moving my sphere on the screen using this method:
Matrix4 m = myBall.body.getCenterOfMassTransform(); Vector3 translation = new Vector3(); m.getTranslation(translation); float multiplier = delta * 4 * game.platform.accelerometerFactor(); movement = new Vector3(Gdx.input.getAccelerometerY() * multiplier, 0, Gdx.input.getAccelerometerX() * multiplier); translation.add(movement); m.setTranslation(translation); myBall.body.setCenterOfMassTransform(m);
Then I would like to rotate my sphere during movement. So I counted angle which sphere should be rotated and then applied it before I call myBall.body.setCenterOfMassTransform(m) using:
float x = movement.x; float z = movement.z; Vector3 axis = new Vector3(z, 0, -x); m.rotate(axis, angle);
But the sphere is rotating strangely. Where is the problem in my process of rotation?