Need help find 3D pos. from mouse click.

Hello,

How do I find a point in 3D space given a mouse click in perspective mode, given z of the world and the camera is looking down z axis?

I know that when moving the camera such that point(0,0,0) is at an edge matrixV x <0,0,0> will give you (+/-) 1.0 of that edge such that having that point to the far right will give you (1.0,0.0, some value based on camera distance)

To be more detailed…

Given:
mouseX
mouseY
zDepth
matrixV <- projection x modelView matrix
matrixVi <- inverse of matrixV

Find:
worldX
worldY

Can someone explain to me what the z term is when you go from world to screen?

Turn out there’s a gluUnProject to gluProject… how did I not see that -_-.

Anyway that still leaves one more issue… what do I put for WinZ if I want to know the x and y for a given Z?