I am developing an AR application on Android and would like to to, regardless of device roll orientation get horizontal and vertical values, much like a spirit level. An example would be a user holds their device in portrait mode and spins their phone, I would like the horizon on the phone to match the natural horizon. I have played with the roll value returned from the sensor manager but it seems to take pitch into account (ie. the device is now in landscape mode, what should be pitch affects roll.)
Also, when reading pitch, I would like the horizon to move up and down, regardless of roll. At the moment, when the device has rolled to 90 degrees, any pitch changes move in the horizontal direction rather than the vertical direction.
Any pointers?
Thanks in advance.
Paul
Yeah, I think your best bet, which I understand has it's flaws is using the accelerometers to determine the direction of the ground.
Use something like this....
in your onCreate method, then put this
in your onResume and this to handle the updates
Then, just use those Acceleration values to determine the direction of the ground. :-) I find that way is a lot more fluid, I hope that helps. :-)
For more info, check out the following for more info: http://developer.android.com/reference/android/hardware/SensorEvent.html#values