Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Jirka

Inaccurate picking

This topic is 5307 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

im trying to pock objects in my scene, but it doesnt work accurately. It seems like the object is moved a bit down for the picking - if i click a bit under the object a still pick it and when i click at the top of the object i dont pick it. This is mt selection code : GLuint buffer[512]={0}; GLint viewport[4]={0}; GLint choose; GLint hits; GLint depth; glGetIntegerv(GL_VIEWPORT,viewport); glSelectBuffer(512,buffer); (void) glRenderMode(GL_SELECT); glInitNames(); glPushName(-1); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); gluPickMatrix((GLdouble)MouseX,(GLdouble) (viewport[3]- MouseY),0.1f,0.1f,viewport ); gluPerspective(Config.scnViewAngle_i, (float)(viewport[2] - viewport[0]) / (float)(viewport[3] - viewport[1]),Config.scnNearClip_f ,Config.scnFarClip_f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); //////////////////////////////////////////////////////////////////// Loop(1);//Draws the scene //////////////////////////////////////////////////////////////////// glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); hits = glRenderMode(GL_RENDER); if (hits > 0) { choose = buffer[3]; depth = buffer[1]; for (int loop=1;loop

Share this post


Link to post
Share on other sites
Advertisement
Maybe you should try (viewport[3] - MouseY - 1) in gluPickMatrix. As it is, your mouse coordinate is off by one on the Y axis.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!