If you're doing this to set up and draw your scene: gl.glMatrixMode(GL10.GL_PROJECTION); gl.glLoadIdentity(); GLU.gluPerspective(gl, FOV, viewAspectRatio, zNear, zFar); // **get or recreate this matrix for the unproject projection gl.glMatrixMode(GL10.GL_MODELVIEW); gl.glLoadIdentity(); GLU.gluLookAt(gl, pos.x, pos.y, pos.z, lookAt.x, lookAt.y, lookAt.z, upVec.x, upVec.y, upVec.z); // **get or recreate this matrix for the unproject modelview
// for each object gl.glPushMatrix(); // transform/rotate/scale to match collision data - do not use this matrix for unproject. // draw gl.glPopMatrix(); then using GLU.gluUnProject with those same matrices that I pointed out (projection and modelview) will return the correct point in world space which should be the same coordinate system as your collision data. After that you just need to use ((normalize(lookAt - pos) * farZ) + the unproject point) and you have your ray. On May 10, 1:24 pm, Alfonso <alfonsocris...@gmail.com> wrote: > I've got that collision detection system implemented, yet. And I'm > agree to use glUnproject as the best achoice. My problem is that I > remap the modelview matrix with the sensors and when I rotate the > phone, change the coords of the screen returned by glUnproject. Even > if I keep the object in the same place of the screen. Furthermore, I > don't understand why it doesn't return values according to the given > viewport. Because of all this I was looking for alternatives, but if > you explain me what's the matter with glUnproject, I'll be really > pleasent. > > Thanks you very much for this answer and (I hope) for the next one. > > On 10 mayo, 19:11, Robert Green <rbgrn....@gmail.com> wrote: > > > > > > > What are you trying to do? > > > glReadPixels is a pipeline stall - it will slow everything down. If > > you want to check to see if an object has been touched, use a > > collision detection system, unproject the touch point into a ray and > > get the closest item that intersects with that ray. It's actually > > easier, more reliable and faster. > > > On May 10, 10:16 am, Alfonso <alfonsocris...@gmail.com> wrote: > > > > glReadPixels is too slow, so I need another way. Without testing > > > object by object, Is there any other way? > > > > Thanks you very much > > > > -- > > > 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 > > > athttp://groups.google.com/group/android-developers?hl=en > > > -- > > 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 > > athttp://groups.google.com/group/android-developers?hl=en > > -- > 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 > athttp://groups.google.com/group/android-developers?hl=en -- 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