This method matches a pixel on the screen to the terrain coordinates that represent that pixel.
It is advised to use IRender4::ScreenToWorld() instead of the this method.
HRESULT ScreenToTerrain(
[in] int X,
[in] int Y,
[out] VARIANT* doubleTerrainX,
[out] VARIANT* doubleTerrainY,
[out] VARIANT* doubleTerrainElevation)
Parameters:
X – The x-coordinate, in pixels, of the point whose corresponding terrain coordinate you are seeking
Note: This pixel is relative to the top-left corner of the 3D window whose coordinates are (0, 0).
Y – The y-coordinate, in pixels (given in render coordinates), of the top-left corner of the 3D Window.
Note: This pixel is relative to the top-left corner of the 3D window whose coordinates are (0, 0).
doubleTerrainX – The terrain x-coordinate that corresponds to the given pixel.
doubleTerrainY – The terrain y-coordinate that corresponds to the given pixel.
doubleTerrainElevation – The terrain height that corresponds to the given pixel.
Note: The height coordinate is returned here in MPT coordinates and not relative to the ground since, in that case, it would always be zero.
Return Values:
The return value obtained from the returned HRESULT can be one of the following:
Return value |
Meaning |
S_OK |
Success. |
E_FAIL |
Catastrophic failure. |
Remarks:
If a pixel that is chosen does not fall in the 3D Window, the terrain coordinates that are returned have are all zero.