I made my own matrix lookat method that functions just like D3DXMatrixLookAtLH. Yet when I use it in place of that directx method I end up seeing nothing but black in the game viewport. Is there an obvious flaw in this code?
I am doing this for a left handed, row major matrix. In the method, the matrix dest is intended to be initialized as a lookat transform matrix. Thanks for any help!
- You might try swapping the arguments to one or more of the calls to Cross(). Generally speaking, the relationship between the basis vectors is x = yXz, y = zXx, and z = xXy. The cross product is non-commutative, so if you get things backwards the overall results may be incorrect.
- Make sure you understand the difference between row/column major and row/column vectors, and make sure that the conventions you're using are compatible with Direct3D (in other words, that the matrix is laid out in memory in the order that Direct3D expects).
- This probably isn't the problem, but the cross product should be a binary function that doesn't modify its arguments rather than a member function that writes the result to the object on which it's called. (Arguably, at least.) Implementing the cross product in this way will make your code cleaner and easier to follow.