Hello, I am doing a 3d scene on an android. I need to realize the tilt of the camera. It turns out that if the rotation angle is Y = 0. Then for the top-down tilt, the rotation on the X axis corresponds.
So I tried to write something, but it turns out nonsense.
public void onDrawFrame(GL10 gl) { //Clear Screen And Depth Buffer gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT); gl.glLoadIdentity(); //Reset The Current Modelview Matrix gl.glRotatef(azimut, 0.0f, 1.0f, 0.0f); // вращение по оси Y // float angle = roll; // угол наклона телефона // double angleRadianse = Math.toRadians(angle); // float angleCos = (float) Math.cos(angleRadianse); // float angleSin = (float) Math.sin(angleRadianse); // gl.glRotatef(angleSin * angle, 1.0f, 0.0f, 0.0f); //X // gl.glRotatef(angleCos * angle , 0.0f, 0.0f, 1.0f); //Z iterPos = 0; while (iterPos < cubes.size()) { cubes.get(iterPos++).draw(gl); } gl.glDisableClientState(GL10.GL_VERTEX_ARRAY); gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY); } How can I realize camera tilt?