Microsoft DirectX 8.1 (C++)

D3DXMatrixLookAtRH

Builds a right-handed look-at matrix.

D3DXMATRIX* D3DXMatrixLookAtRH(
  D3DXMATRIX* pOut,
  CONST D3DXVECTOR3* pEye,
  CONST D3DXVECTOR3* pAt,
  CONST D3DXVECTOR3* pUp
); 

Parameters

pOut
[in, out] Pointer to the D3DXMATRIX structure that is the result of the operation.
pEye
[in] Pointer to the D3DXVECTOR3 structure that defines the eye point. This value is used in translation.
pAt
[in] Pointer to the D3DXVECTOR3 structure that defines the camera look-at target.
pUp
[in] Pointer to the D3DXVECTOR3 structure that defines the current world's up, usually [0, 1, 0].

Return Values

Pointer to a D3DXMATRIX structure that is a right-handed look-at matrix.

Remarks

The return value for this function is the same value returned in the pOut parameter. In this way, the D3DXMatrixLookAtRH function can be used as a parameter for another function.

This function uses the following formula to compute the returned matrix.

zaxis = normal(Eye - At)
xaxis = normal(cross(Up, zaxis))
yaxis = cross(zaxis, xaxis)

 xaxis.x           yaxis.x           zaxis.x          0
 xaxis.y           yaxis.y           zaxis.y          0
 xaxis.z           yaxis.z           zaxis.z          0
-dot(xaxis, eye)  -dot(yaxis, eye)  -dot(zaxis, eye)  1

Requirements

  Header: Declared in D3dx8math.h.
  Import Library: Use D3dx8.lib.

See Also

D3DXMatrixLookAtLH