我想拾取三维物体的坐标,用的是网上流行的方法,我用的代码如下:
       GLdouble modelview[16];
    GLdouble projection[16];
    GLint viewport[4]; glPushMatrix();
glMatrixMode(GL_MODELVIEW);
         //以下都是在绘制三维物体前的模型视图矩阵变换
glLoadIdentity();
gluLookAt(0.0,0.0,2*eyeZ,0.0,0.0,0.0,0.0,1.0,0.0);
glTranslatef(translateX,translateY,0.0);
glRotatef(yRange,0,1,0);
glRotatef(xRange,1,0,0);
glTranslatef(-centerX,-centerY,0.0);  
glGetDoublev (GL_MODELVIEW_MATRIX, modelview);
glMatrixMode(GL_PROJECTION);
         //以下都是在Onsize()函数中的投影矩阵的变化
glLoadIdentity();
gluPerspective(15.0,1.0*(GLfloat)m_fWidth/(GLfloat)m_fHeight,0.0,10);
glGetDoublev (GL_PROJECTION_MATRIX, projection); glGetIntegerv (GL_VIEWPORT, viewport);
    
glPopMatrix();
      GLdouble winx,winy; winx=(double)point.x;
winy=viewport[3]-(double)point.y; GLdouble near_x, near_y, near_z;
GLdouble far_x,far_y,far_z;
    // 获取近裁剪面上的交点
                gluUnProject( winx, winy, 0.0, 
    modelview, projection, viewport, &near_x, &near_y, &near_z);
//获取远裁剪面上的交点
gluUnProject( winx, winy, 1.0, 
    modelview, projection, viewport, &far_x, &far_y, &far_z);
可是调试运行near_x, near_y, near_z和far_x,far_y,far_z都是-9.2559631349317831e+061,但视口,视图模型矩阵和投影矩阵都是有值的,哪位大神能告诉小弟一些解决方法呢?