The pitch and the heading work perfectly :
fun onDrawFrame(pitch: Float, roll: Float, heading: Float) {
val lookAtX = cos(pitch) * cos(heading)
val lookAtY = -sin(pitch)
val lookAtZ = cos(pitch) * sin(heading)
val upX = 0.0F
val upY = 1.0F
val upZ = 0.0F
Matrix.setLookAtM(cameraPositionMatrix, 0, 0.0F, 0.0F, 0.0F, lookAtX.toFloat(), lookAtY.toFloat(), lookAtZ.toFloat(), upX.toFloat(), upY.toFloat(), upZ.toFloat())
...
}
But how can I rotate (roll) the camera? I guess I need to rotate the UP vector based on the roll angle around the "line of sight", but it's more complex than I thought.
Does anyone know the formula to calculate the cartesian coordinates of a point A(Xa, Ya, Za) after a rotation of an angle δ (in radians) around an axis B(Xb, Yb, Zb)C(Xc, Yc, Zc)?
This question concerns both setLookAtM (OpenGL ES) and gluLookAt (OpenGL)