NNS_G3dScrPosToWorldLine

C Specification

#include <nnsys/g3d/util.h>

int
NNS_G3dScrPosToWorldLine(
int px,
int py,
VecFx32* pNear,
VecFx32* pFar
);

Arguments

px Pointer to the x coordinate on the screen
py Pointer to the y coordinate on the screen
pNear Point of the world coordinate position on the near clip plane corresponding to the coordinate position on the screen
pFar Point of the world coordinate position on the far clip plane corresponding to the coordinate position on the screen

Return Values

Returns 0 if *px and *py are inside the viewport. Returns -1 if they are outside of the viewport.

Description

Returns the point on the near clip plane and the far clip plane corresponding to the position on the screen as a world coordinate. When pFar is NULL, the calculation of the point on the far clip plane is abbreviated.The camera matrix and the projection matrix must be configured in the NNS_G3dGlb structure. Even if the return value is -1, the value is stored in *pNear and *pFar can be used as a directional guide. For perspective projections, the margin of error for the *pFar value will be larger when compared with *pNear. This is because the far clip plane is bigger than the near clip plane, so when looking for the original point from the normalized screen coordinate point, the far plane is enlarged. When applying a horizontal offset to the 3D screen by using the Nitro-SDK G3X_SetHOffset function, only the offset portion of the x coordinate argument needs to be moved in advance.

See Also

NNS_G3dLocalOriginToScrPos, NNS_G3dWorldPosToScrPos

Revision History

11/01/2004 Initial version.


CONFIDENTIAL