Archived

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

Jirka

Inaccurate picking

Recommended Posts

Jirka    122
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
rotos    122
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