Graphics Programs Reference
In-Depth Information
case Sensor.TYPE_GRAVITY: {
_gravVals = event.values.clone();
In Listing 2-15 , the variables named _*Vals or _*Filtered are fields
( float[3] ) that store sensor data. They are multiplied with some (strange seem-
ing) values to smooth the sensor data.
Figure 2-18 . Rotating toward west through north (device facing up)
Finally, by calling the getRotationMatrix method (a public method of
SensorManager class), the rotation matrix is computed, which can be directly
used as a rotate matrix to rotate any 3D object rendered using OpenGL. Now, let's
talk about the SENSORROTATION application from the source code for this chapter.
Like the TOUCH ROTATION application, the SENSOR ROTATION application con-
tains a Renderer class for rendering a 3D object; and, once again, this class makes it
possible to access the fields for rotating the object. However, class Main now imple-
ments the interface SensorEventListener to process the raw sensor data.
If you run this application on your Android device, you should see some text dis-
played in the top-left corner of the screen, because we have added a TextView as
an additional content view. It is used to show:
Search WWH ::

Custom Search