抱歉 我手上已經不再使用 AR Toolkit 了所以沒有辦法直接測試是否只有一個問題
你 mouseEvent 這段有點問題
void mouseEvent(int button, int state, int x, int y)
{
GLuint selectBuf[SIZE];
GLint hits;
GLint viewport[4];
if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN)
{
glGetIntegerv (GL_VIEWPORT, viewport);
glSelectBuffer (SIZE, selectBuf);
glRenderMode(GL_SELECT);
glInitNames();
glPushName(-1);
glMatrixMode (GL_PROJECTION);
glPushMatrix ();
glLoadIdentity ();
/* create 5x5 pixel picking region near cursor location */
gluPickMatrix ((GLdouble) x, (GLdouble) (viewport[3] - y),
5.0, 5.0, viewport);
--> 這裡應該要載入投射矩陣的參數 你沒有載入所以就變成預設狀態的 單位矩陣
因該要載入這兩個函數
> argDrawMode3D();
> argDraw3dCamera( 0, 0 );
// gluOrtho2D (-2.0, 2.0, -2.0, 2.0);
// drawObjects(GL_SELECT);
draw( object, objectnum,GL_SELECT);
glMatrixMode (GL_PROJECTION);
glPopMatrix ();
glFlush ();
hits = glRenderMode (GL_RENDER);
processHits (hits, selectBuf);
glutPostRedisplay();
}
} |