Esempio n. 1
0
        public PO Map_to_Space(int x, int y)
        {
            util u1 = new util();

            unsafe
            {
                double *modelview  = stackalloc double[16];
                double *projection = stackalloc double[16];
                int *   viewport   = stackalloc int[4];
                PO      pf;
                double  z;
                pf = new PO();
                GLU.glGetDoublev(GLU.GL_MODELVIEW_MATRIX, modelview);
                GLU.glGetDoublev(GLU.GL_PROJECTION_MATRIX, projection);
                GLU.glGetIntegerv(GLU.GL_VIEWPORT, viewport);
                GLU.glReadPixels(x, y, 1, 1, GLU.GL_DEPTH_COMPONENT, GLU.GL_FLOAT, &z);
                double world_x, world_y, world_z;
                GLU.gluUnProject((double)x, (double)(viewport[3] - y - 1), 1,
                                 modelview, projection, viewport,
                                 &world_x, &world_y, &world_z);
                pf.x = (float)world_x;
                pf.y = (float)world_y;
                pf.z = 0;
                return(pf);
            }
        }