Hi everybody,
I'm trying to recoginize if there is something painted on the OpenGL
layer. Of course I've attemp to use glReadPixels, but I've given it up
because of it's cpu wasting. The only alternative soltution I've found
it's using glu.glProject or, for a faster execution, simulating by
myself the projection.
I've got the modelview matrix, that it is not a problem, and I build
the projection Matrix so:
float orthoProjectionMatrix[] = new float[] {1/(near_height * ratio),
0, 0, 0, 0, 1/(near_height), 0, 0, 0, 0, -2 / (zFar-zNear), - (zFar
+zNear)/(zFar-zNear), 0, 0, 0, 1};
The projection is settings are defined with the line:
gl.glOrthof(-near_height * ratio, near_height * ratio, -near_height,
near_height, zNear, zFar);
And with the next lines:
float pos3DdelPuntoInteres [] = new float [] {0.0f,0.0f,4.0f};
float posVistadelPI [] = new float[4];
float posPantalladelPI [] = new float[4];
android.opengl.Matrix.multiplyMV(posVistadelPI, 0, modelViewMatrix, 0,
pos3DdelPuntoInteres, 0);
float orthoProjectionMatrix[] = new float[] {1/(near_height * ratio),
0, 0, 0, 0, 1/(near_height), 0, 0, 0, 0, -2 / (zFar-zNear), - (zFar
+zNear)/(zFar-zNear), 0, 0, 0, 1};
android.opengl.Matrix.multiplyMV(posPantalladelPI, 0,
orthoProjectionMatrix, 0, posVistadelPI, 0);
Log.e("IconoRenderer", "Posición del icono en la vista: (" +
posPantalladelPI[0]/posPantalladelPI[3] + ", " + posPantalladelPI[1]/
posPantalladelPI[3] + ", " + posPantalladelPI[2]/posPantalladelPI[3] +
")");
I try to detect if the point defined in pos3DdelPuntoInteres appears
on the screen. As far as I know, the log would show values X and Y
between -1 and +1 if pos3DdelPuntoInteres is painted. But that is not
the case. Any help would be appreciated.
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 [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