1

I am a new to android development and libgdx...,

supposedly i loaded a 3d .obj file oval (earth) in libgdx and i wanted to control it using accelerometer downward and sideways..,

how could i do that any suggestion,.

zerocool
  • 192
  • 2
  • 10

1 Answers1

1

If you want to read accelerometer values for axises x, y, z use this

float accelX = Gdx.input.getAccelerometerX();
float accelY = Gdx.input.getAccelerometerY();
float accelZ = Gdx.input.getAccelerometerZ();

If you want to get rotation matrix for rendering from these values, its better to use getRotationMatrix() from SensorManager or its abstraction in Input class

public void getRotationMatrix (float[] matrix) {
    SensorManager.getRotationMatrix(matrix, null, accelerometerValues, magneticFieldValues);
}

Take a look at this tutorial

jellyfication
  • 1,595
  • 1
  • 16
  • 37