Jump to content
  • Advertisement
Sign in to follow this  
Orwall

help : problem with D3DXMatrixLookAtRH

This topic is 2770 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.Identity();

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
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!