Sign in to follow this  
fazekaim

problem around picking. isn't precise... (solved)

Recommended Posts

fazekaim    118
public static void computeViewRay( int[] mousePos){
        double[] eyeModelview = new double[16], eyeProjectionView = new double[16];
        gl.glGetDoublev( GL.GL_MODELVIEW_MATRIX, eyeModelview );
        gl.glGetDoublev( GL.GL_PROJECTION_MATRIX, eyeProjectionView );
        gl.glGetIntegerv( GL.GL_VIEWPORT, rayViewport );

        glu.gluUnProject( mousePos[0], rayViewport[3]-mousePos[1],0,eyeModelview,eyeProjectionView,rayViewport,nx,ny,nz); //mouse world position at near poly
        glu.gluUnProject( mousePos[0], rayViewport[3]-mousePos[1],1,eyeModelview,eyeProjectionView,rayViewport,fx,fy,fz); //mouse world position at far poly

        ray[0] = eye;
        ray[1] = new Vector34f( (float)(fx[0]-nx[0]),(float)(fy[0]-ny[0]),(float)(fz[0]-nz[0]) );
    }


in close distance, it works well, but far away the ray computation "moves away", it will be approx 32 pixel distance between my mouse pos and computed position. How can i correct this? Thanks... [Edited by - fazekaim on November 24, 2005 10:57:49 AM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this