Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void createMouseRay(GL2 gl, int x, int y) {
- int viewport[] = new int[4];
- double modelview[] = new double[16];
- double projection[] = new double[16];
- double rayStartPos[] = new double[4];
- double rayEndPos[] = new double[4];
- gl.glGetDoublev(GL2.GL_MODELVIEW_MATRIX, modelview, 0);
- gl.glGetDoublev(GL2.GL_PROJECTION_MATRIX, projection, 0);
- gl.glGetIntegerv(GL2.GL_VIEWPORT, viewport, 0);
- int vpheight = viewport[3];
- int wx = x;
- int wy = vpheight - y;
- GLU.createGLU(gl).gluUnProject(wx, wy, 0.0,
- modelview, 0,
- projection, 0,
- viewport, 0,
- rayStartPos, 0);
- GLU.createGLU(gl).gluUnProject(wx, wy, 1.0,
- modelview, 0,
- projection, 0,
- viewport, 0,
- rayEndPos, 0);
- mouseRayStart = new Vector3(rayStartPos[0], rayStartPos[1], rayStartPos[2]);
- mouseRayEnd = new Vector3(rayEndPos[0], rayEndPos[1], rayEndPos[2]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement