You need to cast a ray from that 2D point in the viewport through the center of the frustum and do a collision check on the bounds of your "clickable" objects. The highest Z object in camera-space would be the closest.
On Sep 16, 9:52 am, Great <[email protected]> wrote: > I use perspective projection, and parallel projection looks well. > > So my question exactly is how to scale unproject result to real word > coordinate (1, 1, 1) when using perspective projection? > > 2009/9/16 Gameboy <[email protected]> > > > I try to select 3D vertex (1, 1, 1) from 2D screen, basic thought is > > get near and far points with gluUnproject, then use line through these > > two points to intersect selection point, but seems has problem with > > test code. > > > float[] win= new float[3] ; > > float[] world = new float[3] ; > > 1) GLU.gluProject(1, 1, 1, modelview, 0, project, 0, viewport, 0, win, > > 0); > > 2) GLU.gluUnProject(win[0], win[1], win[2], modelview, 0, project, 0, > > viewport, 0, world, 0); > > 3) GLU.gluProject(world[0], world[1], world[2], modelview, 0, project, > > 0, viewport, 0, win, 0); > > > 1) returns correct values as screen selection, but 2) return world > > coordinate is not (1, 1, 1), smaller than it. Maybe because > > gltranslate and glrotate results on it. So 3) returns different > > windows screen coordinate as 1)'s. > > > It looks gluUnproject is not invertible with gluProject. > > > Does anybody has experience and idea to tell me how to scale 2)'s > > result to match real world coordinate (1, 1, 1)? > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

