Hi!To learn OpenGL I'm trying to adapt the Graphics->OpenGL->Touch Rotate cube in the ApiDemo to respond to sensors.Has anyone done this or knows of a good tutorial on how to control a 3D object using Android's sensors?

What does requestRender() do? The Sensor Listener is in a different thread than the GL rendering loop. Be careful there. If requestRender is just setting a flag or some data for onDrawFrame() to use, then you should be ok. If it is actually trying to do some gl calls then look out. Generally, you just want to save off the data you get from the sensor and use it in onDrawFrame(). At least that is what I do.

Not sure if it makes much difference, but I have my Activity implementing the SensorListener rather than the GlSurfaceView doing it.

// Size it for my world Vector3.scale(acceleration,acceleration, 0.002f);

// Update the velocity with the acceleration Vector3.add(velocity,velocity,acceleration); }

The accelerometer values are just an x,y,z vector relative to your phone orientation. If you think of them as a vector representing gravity, then it is easy to visualize how they should affect stuff in your application.

My experience with the sensors has been underwhelming. The results aren't so good (heck, my HTC Magic says G is 10.1m/s^2, maybe I live in a high gravity zone!)Worse, using a phone from other manufacturer gives a different set of results.

The "smoothing" of the results you use makes a lot of sense, sometimes the sensors generate weird results and take a long time to settle.

Hi...iam trying to develop an augment reality app on Android phone.I have camera preview on a surface view.On that i have a 3d grid on GlSurfaceView which i would control using sensors.Now i would like to draw some png images as Markers on the 3d grid.How do i do that?For 3d grid i have defined vertices and connected using indices.I have used gl.glDrawElements(GL10.GL_LINES, indices.length, GL10.GL_UNSIGNED_SHORT, indexBuffer);for drawing.public void onDrawFrame(GL10 gl) {gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); gl.glLoadIdentity(); gl.glTranslatef(0,0,-4); gl.glScalef(2.0f, 1.0f, 1.0f); gl.glPushMatrix(); gl.glRotatef(-45 , 1, 0, 0); sq.draw(gl); gl.glPopMatrix();}