Jump to content
  • Advertisement
Sign in to follow this  

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

This topic is 4868 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!