The following subroutines map screen coordinates to world coordinates. If you want to know what the world coordinate values are for the screen coordinates of an object, these subroutines provide a 2-D and a 3-D method to perform the mapping.
The mapw subroutine takes a 2-D screen point and maps it onto a line in 3-D world space. Its viewobj parameter contains the viewing, projection, and viewport transformations that map the current displayed objects to the screen.
The mapw subroutine reverses these transformations and maps the screen coordinates back to world coordinates. It returns two points in the (modelx1, modely1, modelz1) and the (modelx2, modely2, modelz2) parameters, which specify the endpoints of the line. The screenx and screeny parameters specify the screen point to be mapped. The syntax is as follows:
void mapw(Int32 viewobj, Screencoord screenx, Screencoord screeny, Coord *modelx1, Coord *modely1, Coord *modelz1, Coord *modelx2, Coord *modely2, Coord *modelz2)
The mapw2 subroutine is the 2-D version of the mapw subroutine. In 2-D, the system maps screen coordinates to world coordinates rather than to a line. The viewobj parameter contains the projection and viewing transformations that map the displayed objects to world coordinates; the screenx and screeny parameters define screen coordinates. The modelx and modely parameters return the corresponding world coordinates. If the transformations in the viewobj parameter are not two-dimensional (orthogonal) projections, the result is undefined. The syntax is as follows:
void mapw2(Int32 viewobj, Screencoord screenx, Screencoord screeny, Coord *modelx, Coord *modely)