Sign in to follow this  
neeker

D3DXMatrixLookAtLH internally

Recommended Posts

Hi,

 

I have a project that to remove all dependency on d3dx9, so I have to manually implement the functionality of D3DXMatrixLookAtLH.  I found some great resources for implementing D3DXMatrixPerspectiveFovLH, but I can seem to find anything D3DXMatrixLookAtLH.  I've tried looking at the return values and it's not making much sense right now.  Does anyone have an idea how the final matrix is built?

Edited by neeker

Share this post


Link to post
Share on other sites

What nonoptimalrobot said, but if you want to see an implementation example:

		Matrix MatLookAt(const Vector3& vEye, const Vector3& vAt, const Vector3& vUp)
		{
			Vector3 vZ = (vAt - vEye).normal();
			Vector3 vX = (vUp.Cross(vZ)).normal();
			Vector3 vY = vZ.Cross(vX);

			return Matrix(	vX.x,			vY.x,			vZ.x,			0.0f,
							vX.y,			vY.y,			vZ.y,			0.0f,
							vX.z,			vY.z,			vZ.z,			0.0f,
							-vX.Dot(vEye), -vY.Dot(vEye),	-vZ.Dot(vEye),	1.0f);
		}

Share this post


Link to post
Share on other sites

I hate to downvote, Kubera, but with XNA dead in the water, that is about as useful a suggestion as using d3dx math. I would recommend DirectXMath as a current, and more future proof library.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this