Hi,
I have to draw a disk (gluDisk) at (x, y, z), which should always face directly to the user. To simplify the problem, my projection is always parallel to z-axis. I use the following working but ugly algorithm. Do you have a better algorithm for this purpose? Please help. Thanks.
GLint viewport[4];
GLdouble projM [16];
GLdouble modelViewMat[16];
glGetIntegerv (GL_VIEWPORT, viewport);
glGetDoublev(GL_PROJECTION_MATRIX, projM);
glGetDoublev(GL_MODELVIEW_MATRIX, modelViewMat);
double wx, wy, wz;
gluProject (x, y, z, modelViewMat, projM, viewport, &wx, &wy, &wz);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glGetIntegerv (GL_VIEWPORT, viewport);
glGetDoublev(GL_PROJECTION_MATRIX, projM);
glGetDoublev(GL_MODELVIEW_MATRIX, modelViewMat);
gluUnProject (wx, wy, wz, modelViewMat, projM, viewport, &x, &y, &z);
glTranslated(x, y, z);
gluDisk(m_pQuarObj, .radius, 2.*radius, 25, 1);
glPopMatrix();
I used the gluProject and gluUnProject because I didn’t sucessfully compute the new position of (x, y, z) by using GL_MODELVIEW_MATRIX. I glGetDoublev first and then multiplied it with (x, y, z), but the result was not what I wanted.