Commit 324aad45 authored by David Adam's avatar David Adam Committed by Alexandre Julliard

d3dx8: Implement D3DXMatrixLookAtLH.

parent 8d996a22
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
@ stub D3DXMatrixTransformation @ stub D3DXMatrixTransformation
@ stub D3DXMatrixAffineTransformation @ stub D3DXMatrixAffineTransformation
@ stdcall D3DXMatrixLookAtRH(ptr ptr ptr ptr ptr) @ stdcall D3DXMatrixLookAtRH(ptr ptr ptr ptr ptr)
@ stub D3DXMatrixLookAtLH @ stdcall D3DXMatrixLookAtLH(ptr ptr ptr ptr)
@ stub D3DXMatrixPerspectiveRH @ stub D3DXMatrixPerspectiveRH
@ stub D3DXMatrixPerspectiveLH @ stub D3DXMatrixPerspectiveLH
@ stub D3DXMatrixPerspectiveFovRH @ stub D3DXMatrixPerspectiveFovRH
......
...@@ -44,6 +44,35 @@ FLOAT WINAPI D3DXMatrixfDeterminant(CONST D3DXMATRIX *pm) ...@@ -44,6 +44,35 @@ FLOAT WINAPI D3DXMatrixfDeterminant(CONST D3DXMATRIX *pm)
return det; return det;
} }
D3DXMATRIX* WINAPI D3DXMatrixLookAtLH(D3DXMATRIX *pout, CONST D3DXVECTOR3 *peye, CONST D3DXVECTOR3 *pat, CONST D3DXVECTOR3 *pup)
{
D3DXVECTOR3 right, rightn, up, upn, vec, vec2;
D3DXVec3Subtract(&vec2, pat, peye);
D3DXVec3Normalize(&vec, &vec2);
D3DXVec3Cross(&right, pup, &vec);
D3DXVec3Cross(&up, &vec, &right);
D3DXVec3Normalize(&rightn, &right);
D3DXVec3Normalize(&upn, &up);
pout->m[0][0] = rightn.x;
pout->m[1][0] = rightn.y;
pout->m[2][0] = rightn.z;
pout->m[3][0] = -D3DXVec3Dot(&rightn,peye);
pout->m[0][1] = upn.x;
pout->m[1][1] = upn.y;
pout->m[2][1] = upn.z;
pout->m[3][1] = -D3DXVec3Dot(&upn, peye);
pout->m[0][2] = vec.x;
pout->m[1][2] = vec.y;
pout->m[2][2] = vec.z;
pout->m[3][2] = -D3DXVec3Dot(&vec, peye);
pout->m[0][3] = 0.0f;
pout->m[1][3] = 0.0f;
pout->m[2][3] = 0.0f;
pout->m[3][3] = 1.0f;
return pout;
}
D3DXMATRIX* WINAPI D3DXMatrixLookAtRH(D3DXMATRIX *pout, CONST D3DXVECTOR3 *peye, CONST D3DXVECTOR3 *pat, CONST D3DXVECTOR3 *pup) D3DXMATRIX* WINAPI D3DXMatrixLookAtRH(D3DXMATRIX *pout, CONST D3DXVECTOR3 *peye, CONST D3DXVECTOR3 *pat, CONST D3DXVECTOR3 *pup)
{ {
D3DXVECTOR3 right, rightn, up, upn, vec, vec2; D3DXVECTOR3 right, rightn, up, upn, vec, vec2;
......
...@@ -198,6 +198,14 @@ static void D3DXMatrixTest(void) ...@@ -198,6 +198,14 @@ static void D3DXMatrixTest(void)
got = D3DXMatrixIsIdentity(NULL); got = D3DXMatrixIsIdentity(NULL);
ok(expected == got, "Expected : %d, Got : %d\n", expected, got); ok(expected == got, "Expected : %d, Got : %d\n", expected, got);
/*____________D3DXMatrixLookatLH_______________*/
expectedmat.m[0][0] = -0.822465f; expectedmat.m[0][1] = -0.409489f; expectedmat.m[0][2] = -0.394803f; expectedmat.m[0][3] = 0.0f;
expectedmat.m[1][0] = -0.555856f; expectedmat.m[1][1] = 0.431286f; expectedmat.m[1][2] = 0.710645f; expectedmat.m[1][3] = 0.0f;
expectedmat.m[2][0] = -0.120729f; expectedmat.m[2][1] = 0.803935f; expectedmat.m[2][2] = -0.582335f; expectedmat.m[2][3] = 0.0f;
expectedmat.m[3][0] = 4.494634f; expectedmat.m[3][1] = 0.809719f; expectedmat.m[3][2] = 10.060076f; expectedmat.m[3][3] = 1.0f;
D3DXMatrixLookAtLH(&gotmat,&eye,&at,&axis);
expect_mat(expectedmat,gotmat);
/*____________D3DXMatrixLookatRH_______________*/ /*____________D3DXMatrixLookatRH_______________*/
expectedmat.m[0][0] = 0.822465f; expectedmat.m[0][1] = -0.409489f; expectedmat.m[0][2] = 0.394803f; expectedmat.m[0][3] = 0.0f; expectedmat.m[0][0] = 0.822465f; expectedmat.m[0][1] = -0.409489f; expectedmat.m[0][2] = 0.394803f; expectedmat.m[0][3] = 0.0f;
expectedmat.m[1][0] = 0.555856f; expectedmat.m[1][1] = 0.431286f; expectedmat.m[1][2] = -0.710645f; expectedmat.m[1][3] = 0.0f; expectedmat.m[1][0] = 0.555856f; expectedmat.m[1][1] = 0.431286f; expectedmat.m[1][2] = -0.710645f; expectedmat.m[1][3] = 0.0f;
......
...@@ -59,6 +59,7 @@ typedef struct D3DXCOLOR ...@@ -59,6 +59,7 @@ typedef struct D3DXCOLOR
} D3DXCOLOR, *LPD3DXCOLOR; } D3DXCOLOR, *LPD3DXCOLOR;
FLOAT WINAPI D3DXMatrixfDeterminant(CONST D3DXMATRIX *pm); FLOAT WINAPI D3DXMatrixfDeterminant(CONST D3DXMATRIX *pm);
D3DXMATRIX* WINAPI D3DXMatrixLookAtLH(D3DXMATRIX *pout, CONST D3DXVECTOR3 *peye, CONST D3DXVECTOR3 *pat, CONST D3DXVECTOR3 *pup);
D3DXMATRIX* WINAPI D3DXMatrixLookAtRH(D3DXMATRIX *pout, CONST D3DXVECTOR3 *peye, CONST D3DXVECTOR3 *pat, CONST D3DXVECTOR3 *pup); D3DXMATRIX* WINAPI D3DXMatrixLookAtRH(D3DXMATRIX *pout, CONST D3DXVECTOR3 *peye, CONST D3DXVECTOR3 *pat, CONST D3DXVECTOR3 *pup);
D3DXMATRIX* WINAPI D3DXMatrixMultiply(D3DXMATRIX *pout, CONST D3DXMATRIX *pm1, CONST D3DXMATRIX *pm2); D3DXMATRIX* WINAPI D3DXMatrixMultiply(D3DXMATRIX *pout, CONST D3DXMATRIX *pm1, CONST D3DXMATRIX *pm2);
D3DXMATRIX* WINAPI D3DXMatrixRotationAxis(D3DXMATRIX *pout, CONST D3DXVECTOR3 *pv, FLOAT angle); D3DXMATRIX* WINAPI D3DXMatrixRotationAxis(D3DXMATRIX *pout, CONST D3DXVECTOR3 *pv, FLOAT angle);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment