FWIW, the following unproject code seems to line up properly for me. Notice that I had to map view coordinates to (-1.25,1.25) instead of from (-2,2). I got these numbers empirically and have no idea why this would be so or how close to the correct values I am.
static void fixW(float[] v) { for(int i = 0; i < 4; i++) v[i] = v[i] / v[3]; } public static float[] unProject(float[] win, float[] mod, float[] proj, int[] view) { // XXX check for invertability and w=0.0 float[] m = multMM(proj, mod); float[] im = new float[16]; Matrix.invertM(im, 0, m, 0); // This should scale by 2f, but 1.25f seems to give // accurate results.. I dont know why! XXX! float[] w = new float[] { 1.25f * ((win[0] - view[0]) / view[2] - 0.5f), 1.25f * ((win[1] - view[1]) / view[3] - 0.5f), 2f * win[2] - 1f, 1f }; float[] r = multMV(im, w); fixW(r); return r; } -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en