OpenGLES 2.0 gluunProject
- by secheung
I've spent more time than i should trying to get my ray picking program working. I'm pretty convinced my math is solid with respect to line plane intersection, but I believe the problem lies with the changing of the mouse screen touch into 3D world space.
Heres my code
public void passTouchEvents(MotionEvent e){
int[] viewport = {0,0,viewportWidth,viewportHeight};
float x = e.getX(), y = viewportHeight - e.getY();
float[] pos1 = new float[4];
float[] pos2 = new float[4];
GLU.gluUnProject( x, y, 0.0f,
mViewMatrix, 0,
mProjectionMatrix, 0,
viewport, 0,
pos1, 0);
GLU.gluUnProject( x, y, 1.0f,
mViewMatrix, 0,
mProjectionMatrix, 0,
viewport, 0,
pos2, 0);
}
Just as a reference I've tried transforming the coordinates 0,0,0 and got an offset. It would be appreciated if you would answer using opengl es 2.0 code.
Thanks