• Advertisement
Sign in to follow this  

help : problem with D3DXMatrixLookAtRH

This topic is 2508 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

when i use D3DXMatrixLookRH( viewMat, eye, at, up );
i set the y component of eye vector to " non-zero" , i get wrong result

but this function could get right result ,

Matrix4x4 MatrixLookAtRH(Vector4 &eye, Vector4 &lookat, Vector4 &up)
Vector4 up_normalized = VectorNormalize(up);
Vector4 zaxis = (eye - lookat); zaxis.Normalize();
Vector4 xaxis = Vector3CrossProduct(up_normalized, zaxis);
Vector4 yaxis = Vector3CrossProduct(zaxis, xaxis);

Matrix4x4 matrix;

matrix.SetColumn(0, xaxis);
matrix.SetColumn(1, yaxis);
matrix.SetColumn(2, zaxis);
matrix[3][0] = -Vector3Dot(xaxis, eye)[0];
matrix[3][1] = -Vector3Dot(yaxis, eye)[0];
matrix[3][2] = -Vector3Dot(zaxis, eye)[0];

return matrix;

i use same parameters to call these two functions, they get different result,
why ? thanks !!!

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement