public static void setLookAtM(float[] rm, int rmOffset,
            float eyeX, float eyeY, float eyeZ,
            float centerX, float centerY, float centerZ, float upX, float upY,
            float upZ) {

        // See the OpenGL GLUT documentation for gluLookAt for a description
        // of the algorithm. We implement it in a straightforward way:

        float fx = centerX - eyeX;
        float fy = centerY - eyeY;
        float fz = centerZ - eyeZ;

        // Normalize f
        float rlf = 1.0f / Matrix.length(fx, fy, fz);
        fx *= rlf;
        fy *= rlf;
        fz *= rlf;

        // compute s = f x up (x means "cross product")
        float sx = fy * upZ - fz * upY;
        float sy = fz * upX - fx * upZ;
        float sz = fx * upY - fy * upX;

        // and normalize s
        float rls = 1.0f / Matrix.length(sx, sy, sz);
        sx *= rls;
        sy *= rls;
        sz *= rls;

        // compute u = s x f
        float ux = sy * fz - sz * fy;
        float uy = sz * fx - sx * fz;
        float uz = sx * fy - sy * fx;

        rm[rmOffset + 0] = sx;
        rm[rmOffset + 1] = ux;
        rm[rmOffset + 2] = -fx;
        rm[rmOffset + 3] = 0.0f;

        rm[rmOffset + 4] = sy;
        rm[rmOffset + 5] = uy;
        rm[rmOffset + 6] = -fy;
        rm[rmOffset + 7] = 0.0f;

        rm[rmOffset + 8] = sz;
        rm[rmOffset + 9] = uz;
        rm[rmOffset + 10] = -fz;
        rm[rmOffset + 11] = 0.0f;

        rm[rmOffset + 12] = 0.0f;
        rm[rmOffset + 13] = 0.0f;
        rm[rmOffset + 14] = 0.0f;
        rm[rmOffset + 15] = 1.0f;

        translateM(rm, rmOffset, -eyeX, -eyeY, -eyeZ);
    }
public static void setLookAtM ( float [ ] rm , int rmOffset , float eyeX , float eyeY , float eyeZ , float centerX , float centerY , float centerZ , float upX , float upY , float upZ ) { float fx = centerX - eyeX ; float fy = centerY - eyeY ; float fz = centerZ - eyeZ ; float rlf = 1.0f / Matrix . length ( fx , fy , fz ) ; fx *= rlf ; fy *= rlf ; fz *= rlf ; float sx = fy * upZ - fz * upY ; float sy = fz * upX - fx * upZ ; float sz = fx * upY - fy * upX ; float rls = 1.0f / Matrix . length ( sx , sy , sz ) ; sx *= rls ; sy *= rls ; sz *= rls ; float ux = sy * fz - sz * fy ; float uy = sz * fx - sx * fz ; float uz = sx * fy - sy * fx ; rm [ rmOffset + 0 ] = sx ; rm [ rmOffset + 1 ] = ux ; rm [ rmOffset + 2 ] = - fx ; rm [ rmOffset + 3 ] = 0.0f ; rm [ rmOffset + 4 ] = sy ; rm [ rmOffset + 5 ] = uy ; rm [ rmOffset + 6 ] = - fy ; rm [ rmOffset + 7 ] = 0.0f ; rm [ rmOffset + 8 ] = sz ; rm [ rmOffset + 9 ] = uz ; rm [ rmOffset + 10 ] = - fz ; rm [ rmOffset + 11 ] = 0.0f ; rm [ rmOffset + 12 ] = 0.0f ; rm [ rmOffset + 13 ] = 0.0f ; rm [ rmOffset + 14 ] = 0.0f ; rm [ rmOffset + 15 ] = 1.0f ; translateM ( rm , rmOffset , - eyeX , - eyeY , - eyeZ ) ; }
Define a viewing transformation in terms of an eye point, a center of
view, and an up vector.

@param rm returns the result
@param rmOffset index into rm where the result matrix starts
@param eyeX eye point X
@param eyeY eye point Y
@param eyeZ eye point Z
@param centerX center of view X
@param centerY center of view Y
@param centerZ center of view Z
@param upX up vector X
@param upY up vector Y
@param upZ up vector Z