Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You're supplying <code>null</code> for the inclination matrix - that's not correct.</p> <pre><code>SensorManager.getRotationMatrix(rotationMatrix, null, gravity, geomag); </code></pre> <p>There are lots of examples on how to use the SensorManager's <code>getRotationMatrix(...)</code>. </p> <pre><code>float[] R = new float[16]; float[] I = new float[16]; if (SensorManager.getRotationMatrix(R, I, accelerometerValues, geomagneticValues)) { float[] anglesInRadians = new float[3]; SensorManager.getOrientation(R, anglesInRadians); ... } </code></pre> <p>Also "<em>rotate the opengl's camera to wherever the phone is pointing to</em>" is rather ambiguous. For instance, if you meant some sort of a augmented reality approach, then you should be mapping <code>AXIS_X</code> to <code>AXIS_Z</code>. Note that remapping might not even be necessary, e.g. when you already fix your activity to landscape mode. More details <a href="http://developer.android.com/reference/android/hardware/SensorManager.html#remapCoordinateSystem%28float[],%20int,%20int,%20float[]%29" rel="nofollow noreferrer">here</a>.</p> <p>Some example codes involving sensor data and OpenGL ES:</p> <ul> <li><a href="http://www.netmite.com/android/mydroid/cupcake/development/samples/Compass/src/com/example/android/compass/CompassActivity.java" rel="nofollow noreferrer"><code>CompassActivity</code></a></li> <li><a href="https://stackoverflow.com/questions/2881128/how-to-use-onsensorchanged-sensor-data-in-combination-with-opengl">How to use onSensorChanged sensor data in combination with OpenGL</a></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload