OpenGL ES 2.0 gluUnProject
Posted
by
secheung
on Game Development
See other posts from Game Development
or by secheung
Published on 2012-03-28T02:10:03Z
Indexed on
2012/03/28
23:46 UTC
Read the original article
Hit count: 267
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.
© Game Development or respective owner