Module: wine Branch: master Commit: a1010e6c9437878138e2a3280351496eb0a16989 URL: http://source.winehq.org/git/wine.git/?a=commit;h=a1010e6c9437878138e2a32803...
Author: David Adam David.Adam@math.cnrs.fr Date: Thu Nov 15 12:53:10 2007 +0100
d3dx8: Implement D3DXMatrixShadow.
---
dlls/d3dx8/d3dx8.spec | 2 +- dlls/d3dx8/math.c | 26 ++++++++++++++++++++++++++ dlls/d3dx8/tests/math.c | 14 ++++++++++++++ include/d3dx8math.h | 1 + 4 files changed, 42 insertions(+), 1 deletions(-)
diff --git a/dlls/d3dx8/d3dx8.spec b/dlls/d3dx8/d3dx8.spec index 71c55ac..dae4570 100644 --- a/dlls/d3dx8/d3dx8.spec +++ b/dlls/d3dx8/d3dx8.spec @@ -47,7 +47,7 @@ @ stdcall D3DXMatrixOrthoLH(ptr long long long long) @ stdcall D3DXMatrixOrthoOffCenterRH(ptr long long long long long long) @ stdcall D3DXMatrixOrthoOffCenterLH(ptr long long long long long long) -@ stub D3DXMatrixShadow +@ stdcall D3DXMatrixShadow(ptr ptr ptr) @ stub D3DXMatrixReflect @ stub D3DXQuaternionToAxisAngle @ stub D3DXQuaternionRotationMatrix diff --git a/dlls/d3dx8/math.c b/dlls/d3dx8/math.c index 032d2db..990aa55 100644 --- a/dlls/d3dx8/math.c +++ b/dlls/d3dx8/math.c @@ -410,6 +410,32 @@ D3DXMATRIX* WINAPI D3DXMatrixScaling(D3DXMATRIX *pout, FLOAT sx, FLOAT sy, FLOAT return pout; }
+D3DXMATRIX* WINAPI D3DXMatrixShadow(D3DXMATRIX *pout, CONST D3DXVECTOR4 *plight, CONST D3DXPLANE *pplane) +{ + D3DXPLANE Nplane; + FLOAT dot; + + D3DXPlaneNormalize(&Nplane, pplane); + dot = D3DXPlaneDot(&Nplane, plight); + pout->u.m[0][0] = dot - Nplane.a * plight->x; + pout->u.m[0][1] = -Nplane.a * plight->y; + pout->u.m[0][2] = -Nplane.a * plight->z; + pout->u.m[0][3] = -Nplane.a * plight->w; + pout->u.m[1][0] = -Nplane.b * plight->x; + pout->u.m[1][1] = dot - Nplane.b * plight->y; + pout->u.m[1][2] = -Nplane.b * plight->z; + pout->u.m[1][3] = -Nplane.b * plight->w; + pout->u.m[2][0] = -Nplane.c * plight->x; + pout->u.m[2][1] = -Nplane.c * plight->y; + pout->u.m[2][2] = dot - Nplane.c * plight->z; + pout->u.m[2][3] = -Nplane.c * plight->w; + pout->u.m[3][0] = -Nplane.d * plight->x; + pout->u.m[3][1] = -Nplane.d * plight->y; + pout->u.m[3][2] = -Nplane.d * plight->z; + pout->u.m[3][3] = dot - Nplane.d * plight->w; + return pout; +} + D3DXMATRIX* WINAPI D3DXMatrixTranslation(D3DXMATRIX *pout, FLOAT x, FLOAT y, FLOAT z) { D3DXMatrixIdentity(pout); diff --git a/dlls/d3dx8/tests/math.c b/dlls/d3dx8/tests/math.c index 526fc00..abc3a98 100644 --- a/dlls/d3dx8/tests/math.c +++ b/dlls/d3dx8/tests/math.c @@ -152,8 +152,10 @@ static void D3DXMatrixTest(void) { D3DXMATRIX expectedmat, gotmat, mat, mat2, mat3; LPD3DXMATRIX funcpointer; + D3DXPLANE plane; D3DXQUATERNION q; D3DXVECTOR3 at, axis, eye; + D3DXVECTOR4 light; BOOL expected, got; FLOAT angle, determinant, expectedfloat, gotfloat;
@@ -171,12 +173,16 @@ static void D3DXMatrixTest(void) U(mat2).m[0][3] = -4.0f; U(mat2).m[1][3] = -3.0f; U(mat2).m[2][3] = -2.0f; U(mat2).m[3][3] = -1.0f;
+ plane.a = -3.0f; plane.b = -1.0f; plane.c = 4.0f; plane.d = 7.0f; + q.x = 1.0f; q.y = -4.0f; q.z =7.0f; q.w = -11.0f;
at.x = -2.0f; at.y = 13.0f; at.z = -9.0f; axis.x = 1.0f; axis.y = -3.0f; axis.z = 7.0f; eye.x = 8.0f; eye.y = -5.0f; eye.z = 5.75f;
+ light.x = 9.6f; light.y = 8.5f; light.z = 7.4; light.w = 6.3; + angle = D3DX_PI/3.0f;
/*____________D3DXMatrixAffineTransformation______*/ @@ -396,6 +402,14 @@ static void D3DXMatrixTest(void) D3DXMatrixScaling(&gotmat,0.69f,0.53f,4.11f); expect_mat(expectedmat,gotmat);
+/*____________D3DXMatrixShadow______________*/ + U(expectedmat).m[0][0] = 12.786773f; U(expectedmat).m[0][1] = 5.000961f; U(expectedmat).m[0][2] = 4.353778f; U(expectedmat).m[0][3] = 3.706595f; + U(expectedmat).m[1][0] = 1.882715; U(expectedmat).m[1][1] = 8.805615f; U(expectedmat).m[1][2] = 1.451259f; U(expectedmat).m[1][3] = 1.235532f; + U(expectedmat).m[2][0] = -7.530860f; U(expectedmat).m[2][1] = -6.667949f; U(expectedmat).m[2][2] = 1.333590f; U(expectedmat).m[2][3] = -4.942127f; + U(expectedmat).m[3][0] = -13.179006f; U(expectedmat).m[3][1] = -11.668910f; U(expectedmat).m[3][2] = -10.158816f; U(expectedmat).m[3][3] = -1.510094f; + D3DXMatrixShadow(&gotmat,&light,&plane); + expect_mat(expectedmat,gotmat); + /*____________D3DXMatrixTranslation______________*/ U(expectedmat).m[0][0] = 1.0f; U(expectedmat).m[0][1] = 0.0f; U(expectedmat).m[0][2] = 0.0f; U(expectedmat).m[0][3] = 0.0f; U(expectedmat).m[1][0] = 0.0; U(expectedmat).m[1][1] = 1.0f; U(expectedmat).m[1][2] = 0.0f; U(expectedmat).m[1][3] = 0.0f; diff --git a/include/d3dx8math.h b/include/d3dx8math.h index 7660b21..195badd 100644 --- a/include/d3dx8math.h +++ b/include/d3dx8math.h @@ -288,6 +288,7 @@ D3DXMATRIX* WINAPI D3DXMatrixRotationY(D3DXMATRIX *pout, FLOAT angle); D3DXMATRIX* WINAPI D3DXMatrixRotationYawPitchRoll(D3DXMATRIX *pout, FLOAT yaw, FLOAT pitch, FLOAT roll); D3DXMATRIX* WINAPI D3DXMatrixRotationZ(D3DXMATRIX *pout, FLOAT angle); D3DXMATRIX* WINAPI D3DXMatrixScaling(D3DXMATRIX *pout, FLOAT sx, FLOAT sy, FLOAT sz); +D3DXMATRIX* WINAPI D3DXMatrixShadow(D3DXMATRIX *pout, CONST D3DXVECTOR4 *plight, CONST D3DXPLANE *pPlane); D3DXMATRIX* WINAPI D3DXMatrixTranslation(D3DXMATRIX *pout, FLOAT x, FLOAT y, FLOAT z); D3DXMATRIX* WINAPI D3DXMatrixTranspose(D3DXMATRIX *pout, CONST D3DXMATRIX *pm);