Hello,
I just want to have a ray from the mouse …
I use this:
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
CVector_4D Ray;
GLint viewportCoords[4] = {0};
GLdouble modelMatrix[16] = {0};
GLdouble projMatrix[16] = {0};
//gluLookAt …
glGetIntegerv(GL_VIEWPORT, viewportCoords);
glGetDoublev(GL_PROJECTION_MATRIX, projMatrix);
glGetDoublev(GL_MODELVIEW_MATRIX, modelMatrix);
double vecx, vecy, vecz;
gluUnProject(xmouse, viewportCoords[3] - ymouse, 0.0, modelMatrix, projMatrix, viewportCoords, &vecx, &vecy, &vecz);
double vecx2, vecy2, vecz2;
gluUnProject(xmouse, viewportCoords[3] - ymouse, 1.0, modelMatrix, projMatrix, viewportCoords, &vecx2, &vecy2, &vecz2);
Ray.x = vecx2 - vecx;
Ray.y = vecy2 - vecy;
Ray.z = vecz2 - vecz;
But it doesn’t seams to work
Can you help me ?
Elrick