public static void jLookAt(GL2 gl, JVector3d eye, JVector3d at, JVector3d up) { // Define our look vector (z axis) JVector3d look = at.operatorSub(eye); look.normalize(); // Define our new x axis JVector3d xaxis = JMaths.jCross(look, up); xaxis.normalize(); // Define our new y axis as the cross of the x and z axes JVector3d upv = JMaths.jCross(xaxis, look); // Turn around the z axis look.mul(-1.0); // Put it all into a GL-friendly matrix double[] dm = new double[16]; dm[0] = xaxis.getX(); dm[1] = xaxis.getY(); dm[2] = xaxis.getZ(); dm[3] = 0.f; dm[4] = upv.getX(); dm[5] = upv.getY(); dm[6] = upv.getZ(); dm[7] = 0.f; dm[8] = look.getX(); dm[9] = look.getY(); dm[10] = look.getZ(); dm[11] = 0.f; dm[12] = eye.getX(); dm[13] = eye.getY(); dm[14] = eye.getZ(); dm[15] = 1.f; // Push it onto the matrix stack gl.glMultMatrixd(dm, 0); }