   advice for gluunproject
  hi,i need some advice for using gluUnproject, i do not have any problem getting the results from gluUnproject, but needs some theoretical assistance, so i am going to draw my scenario......first....i have a scene drawn within a viewport that takes up the size of the window,the viewport's lens is a gluperspective lens with near clipping at 1.0 and far clipping at 200.0.inside the viewport have a drawn a grid that spans 10 units in both positive and negative direction of the x and z axis, the y(up-down) axis is represented with a simple vertical red line. the most important thing is that the grid's center origin lies at 0,0,0.now when i use unprojecting to get world coords for near z-clip and far z-clip i get the desired results(the far-clip is out by + - .00060).so i draw a glpoint on the screen to test where it falls in the 3d world, i give the point an initial 5,5,-5 position (as the z-axis runs toward the negative into the screen??), then i use a mouse click to translate this point to a new position, i am not using an equation yet to work out a point between the the near and far-clip, instead i am testing the results for setting the z-ray-value of gluUnproject from 0.0(nearest) to 1.0(furtherest).........set at 0.0 in gluUnproject the point will move to the nearest clip position on the z-axis (the near clip is 1.0 so it moves to -1.0) on the z-axis, at 1.0 in gluUnproject the point will move to -200.0 on the z-axis,if i use any value between 0.0 and 1.0 in gluUnproject i cannot predict where it wall fall on the z-axis,but if i change the near clip in gluPerspective i can predict where it will fallwith setting 0.0 in gluUnprojecte.g.gluPerspective(45,ratio,1.0,200.0)gluUnproject(?,?,0.0,?,?,?,?,?,&wz)a point with z-value of wz will fall at near clipping which is 1.0 or -1.0(?) on the z-axis.gluPerspective(45,ratio,5.0,200.0)gluUnproject(?,?,0.0,?,?,?,?,?,&wz)a point with z-value of wz will fall at near clipping which is now 5.0 or -5.0(?) on the z-axis.i apologise if this is a little confusing, my question mainly is how would i be able to get the point to fall on any positive or negative z-value of the grid which has an origin at 0,0,0so far i can get the point to move up and down the z-axis on one side of the origin, but only by a hacked and stupid way.i can not get the point to fall on the the origin or the other side of it.would i have to draw the grid deep inside the viewport, or what? i explain this so terribly so if this is just too confusing i can post a minimal code.any help??   
  here is sample code i usei declare these globally....from redbook example-glut srcGLint viewport[4];GLdouble mvmatrix[16], projmatrix[16];GLint realy;  /*  OpenGL y coordinate position  */GLdouble wx=4;GLdouble wy=4;GLdouble wz=4;then in my render func.......glClearColor(0.3,0.3,0.3,1.0);glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );   glViewport(0,0,wide,high);   glMatrixMode (GL_PROJECTION);   glLoadIdentity ();   gluPerspective(45.0,(float)(wide/high),1.0,200.0);glMatrixMode(GL_MODELVIEW);   glLoadIdentity ();   glGetDoublev (GL_PROJECTION_MATRIX, projmatrix);   glGetDoublev (GL_MODELVIEW_MATRIX, mvmatrix);   glGetIntegerv (GL_VIEWPORT, viewport);   glEnable (GL_DEPTH_TEST);   i use these in mouse func to move about   glTranslatef(transx,transy,-otherzoom);   glRotatef(rotx,1,0,0);   glRotatef(roty,0,1,0);contents of rendergrid().................center at 0,0,0    glBegin(GL_LINES);   for(i = -10; i <= 10; i++)    {   glVertex3f(i,0,-10);glVertex3f(i,0,10);glVertex3f(10,0,i);glVertex3f(-10,0,i);}    glEnd();the point with init value coords of wx wy wz;   glBegin(GL_POINTS);   glColor3f(1.0,1.0,1.0);   glVertex3f(wx,wy,wz);   glEnd();in my mouse func for right button....... case SDL_BUTTON_RIGHT: realy = viewport[3] - (GLint) event.button.y - 1; now here is where i test values of z-ray------> from 0.0 to 1.0----usually there would be two one at near clip other at far clip,----for 0.0 this yield result for wz = about 1.0 which is near clip---which will move point to wx,wy,1.0 gluUnProject ((GLdouble) event.button.x, (GLdouble) realy, 0.0, mvmatrix, projmatrix, viewport, &wx, &wy, &wz;fprintf (stdout,"World coords at z=0.0 are (%f,  %f, %f)\n", wx, wy, wz);---therefore if i adjust nearclip to 5.0 i will get wz = 5.0;---which will move point to wx,wy,5.0---but i shouldn't be adjusting my nearclip all the timeam i not comprehending this properly?will do x,y positions later but fornow i want to be able to move point anywhere along z-axis, this restricts me to move point to minimum val of -1.0 on z-axis....should i draw the grid deeper inside viewport, beyond the bounds of the near clip plane??and adjust from there or am i totally missing the point?i reckon the latter.....any advice,pointers, or places i can read about this? 