   A moving fog volume depends on glLookAt( )
  Hi,  In real world inside a fog volume. The object will get more and more clear while we walking close it. But in my opengl world, the object remain the same visiblility all the time. no matter how close I walk to it, using glLookAt().  gluLookAt(EyeX, EyeY, EyeZ, TarX, TarY, TarZ, UpX, UpY, UpZ);   ......  glFogi(GL_FOG_MODE, GL_LINEAR);  glFogf(GL_FOG_DENSITY, 0.35f);  glFogf(GL_FOG_START, EyeZ);  glFogf(GL_FOG_END, EyeZ+50);  How can I get the fog volume moving along my Eye-Tar vector?Thanks a lot.Daniel   
  Don't put your viewpoint transform in the projection matrix unless you know what you're doing. OpenGL calculates fog after the moreview matrix but before the projection matrix, so if you put the viewpoint transform in the porjection matrix, OpenGL can't take the viewpoint transform into consideration when calculating the fog.   ;Still don't get it, fog volume's direction remained from -Z to +Z, not changed while I change Eye coordinate.My procedure is..... glMatrixMode(GL_PROJECTION);  glLoadIdentity();gluPerspective(FovDegree,(GLfloat)width/(GLfloat)height,1.0f,1000.0f); gluLookAt(EyeX, EyeY, EyeZ, TarX, TarY, TarZ, UpX, UpY, UpZ); glMatrixMode(GL_MODELVIEW);  glLoadIdentity();   glViewport(0, 0, width, height);   .....Draw many models.....   ;  gluLookAt needs to be applied to the modelview matrix, not the projection matrix. Read this for more info.   ;  Hi, Cocalus,Don't know why? I use glLookAt() without problem only when it must be in Projection stack. >>  glMatrixMode(GL_PROJECTION); >>  glLoadIdentity(); >>  gluPerspective(FovDegree,(GLfloat)width/(GLfloat)height,1.0f,1000.0f); >>  gluLookAt(EyeX, EyeY, EyeZ, TarX, TarY, TarZ, UpX, UpY, UpZ); >>  glMatrixMode(GL_MODELVIEW); >>  glLoadIdentity(); >>  glViewport(0, 0, width, height); >>  DrawModels.....I can move eyeXYZ to/away tarXYZ along vector(eyeXYZ->tarXYZ) to do Zoom In/Zoom Out very well, or move eyeXYZ and tarXYZ together to View Left/Right/Up/Down/Forward/Backward as well.  Only for the fog, I can't get it moving along my Eye->Tar vector.Hi, Bob,  I read the article, but still don't get it to make my fog volume moving. May you show me some clear codes to do it? Thanks.p.s. For now, I can move around anywhere, anyorientation without problem, except the fog volume.Daniel ;Here is my source for your reference. http://dan59314.myweb.hinet.net/OpenGL_Dan01.rarPress mouse left button, drag down/up to zoomout/zoomin.Press 'C' to show many objects.press 'B' to show fog volume.See? Fog volume is fixed all the time.Thanks.Daniel   ;  The code is way to complex for me to have time to give you a working solution, but I can tell you what is wrong and how to fix it.The reason it doesn't work have been said a few times in this tread already; you put your viewpoint transform in the projection matrix. DON'T DO THAT! Put the viewpoint transform in the modelview matrix where the fogging system expects it to be.The solution is basically this;glMatrixMode(GL_PROJECTION);glLoadIdentity();gluPerspective(FovDegree,(GLfloat)width/(GLfloat)height,1.0f,1000.0f);glMatrixMode(GL_MODELVIEW);glLoadIdentity();gluLookAt(EyeX, EyeY, EyeZ, TarX, TarY, TarZ, UpX, UpY, UpZ);glViewport(0, 0, width, height); There. The viewpoint transform is now in the modelview matrix instead of in the projection matrix. This is how the fogging system expect it to be.You perform the viewpoint transform in Camera3D::SetupProjection, and in CGfxOpenGL::Render you draw your scene. In CGfxOpenGL::Render you also clear the modelview matrix, but instead of doing that you should (sort of) call Camera3D::SetupProjection to properly setup the matrices and make sure the viewpoint transform goes to the correct matrix stack (i.e. NOT the projection matrix).   ;  Hi, Bob,I catch the problem, I called glLoadIdentity many times after glMatrixMode(GL_MODELVIEW). I wonder it can only be called once.I was guessing that I can always restore the prior added matrices back without difference by using glPushMatrix(), glPopMatrix(), even call glLoadIdentity().glMatrixMode(GL_MODELVIEW);glLoadIdentity();gluLookAt(EyeX, EyeY, EyeZ, TarX, TarY, TarZ, UpX, UpY, UpZ);glViewport(0, 0, width, height); glPuseMatrix();  glLoadIdentity();   // <---- this is the problem  DrawModels......glPopMatrix();DrawModels.......Thanks for all kind helps.Daniel