[PATCH] Implement D3DXMatrixShadow with a test
David Adam
David.Adam at math.cnrs.fr
Thu Nov 15 05:53:10 CST 2007
---
dlls/d3dx8/d3dx8.spec | 2 +-
dlls/d3dx8/math.c | 26 ++++++++++++++++++++++++++
dlls/d3dx8/tests/math.c | 14 ++++++++++++++
include/d3dx8math.h | 2 ++
4 files changed, 43 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;
}
=20
+D3DXMATRIX* WINAPI D3DXMatrixShadow(D3DXMATRIX *pout, CONST D3DXVECTOR4 *pl=
ight, CONST D3DXPLANE *pplane)
+{
+ D3DXPLANE Nplane;
+ FLOAT dot;
+
+ D3DXPlaneNormalize(&Nplane, pplane);
+ dot =3D D3DXPlaneDot(&Nplane, plight);
+ pout->u.m[0][0] =3D dot - Nplane.a * plight->x;
+ pout->u.m[0][1] =3D -Nplane.a * plight->y;
+ pout->u.m[0][2] =3D -Nplane.a * plight->z;
+ pout->u.m[0][3] =3D -Nplane.a * plight->w;
+ pout->u.m[1][0] =3D -Nplane.b * plight->x;
+ pout->u.m[1][1] =3D dot - Nplane.b * plight->y;
+ pout->u.m[1][2] =3D -Nplane.b * plight->z;
+ pout->u.m[1][3] =3D -Nplane.b * plight->w;
+ pout->u.m[2][0] =3D -Nplane.c * plight->x;
+ pout->u.m[2][1] =3D -Nplane.c * plight->y;
+ pout->u.m[2][2] =3D dot - Nplane.c * plight->z;
+ pout->u.m[2][3] =3D -Nplane.c * plight->w;
+ pout->u.m[3][0] =3D -Nplane.d * plight->x;
+ pout->u.m[3][1] =3D -Nplane.d * plight->y;
+ pout->u.m[3][2] =3D -Nplane.d * plight->z;
+ pout->u.m[3][3] =3D 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;
=20
@@ -171,12 +173,16 @@ static void D3DXMatrixTest(void)
U(mat2).m[0][3] =3D -4.0f; U(mat2).m[1][3] =3D -3.0f; U(mat2).m[2][3] =
=3D -2.0f;
U(mat2).m[3][3] =3D -1.0f;
=20
+ plane.a =3D -3.0f; plane.b =3D -1.0f; plane.c =3D 4.0f; plane.d =3D 7.0=
f;
+
q.x =3D 1.0f; q.y =3D -4.0f; q.z =3D7.0f; q.w =3D -11.0f;
=20
at.x =3D -2.0f; at.y =3D 13.0f; at.z =3D -9.0f;
axis.x =3D 1.0f; axis.y =3D -3.0f; axis.z =3D 7.0f;
eye.x =3D 8.0f; eye.y =3D -5.0f; eye.z =3D 5.75f;
=20
+ light.x =3D 9.6f; light.y =3D 8.5f; light.z =3D 7.4; light.w =3D 6.3;
+
angle =3D D3DX_PI/3.0f;
=20
/*____________D3DXMatrixAffineTransformation______*/
@@ -396,6 +402,14 @@ static void D3DXMatrixTest(void)
D3DXMatrixScaling(&gotmat,0.69f,0.53f,4.11f);
expect_mat(expectedmat,gotmat);
=20
+/*____________D3DXMatrixShadow______________*/
+ U(expectedmat).m[0][0] =3D 12.786773f; U(expectedmat).m[0][1] =3D 5.000=
961f; U(expectedmat).m[0][2] =3D 4.353778f; U(expectedmat).m[0][3] =3D 3.706=
595f;
+ U(expectedmat).m[1][0] =3D 1.882715; U(expectedmat).m[1][1] =3D 8.80561=
5f; U(expectedmat).m[1][2] =3D 1.451259f; U(expectedmat).m[1][3] =3D 1.23553=
2f;
+ U(expectedmat).m[2][0] =3D -7.530860f; U(expectedmat).m[2][1] =3D -6.66=
7949f; U(expectedmat).m[2][2] =3D 1.333590f; U(expectedmat).m[2][3] =3D -4.9=
42127f;
+ U(expectedmat).m[3][0] =3D -13.179006f; U(expectedmat).m[3][1] =3D -11.=
668910f; U(expectedmat).m[3][2] =3D -10.158816f; U(expectedmat).m[3][3] =3D =
-1.510094f;
+ D3DXMatrixShadow(&gotmat,&light,&plane);
+ expect_mat(expectedmat,gotmat);
+
/*____________D3DXMatrixTranslation______________*/
U(expectedmat).m[0][0] =3D 1.0f; U(expectedmat).m[0][1] =3D 0.0f; U(exp=
ectedmat).m[0][2] =3D 0.0f; U(expectedmat).m[0][3] =3D 0.0f;
U(expectedmat).m[1][0] =3D 0.0; U(expectedmat).m[1][1] =3D 1.0f; U(expe=
ctedmat).m[1][2] =3D 0.0f; U(expectedmat).m[1][3] =3D 0.0f;
diff --git a/include/d3dx8math.h b/include/d3dx8math.h
index 7660b21..9abbb6c 100644
--- a/include/d3dx8math.h
+++ b/include/d3dx8math.h
@@ -288,6 +288,8 @@ D3DXMATRIX* WINAPI D3DXMatrixRotationY(D3DXMATRIX *pout,=
FLOAT angle);
D3DXMATRIX* WINAPI D3DXMatrixRotationYawPitchRoll(D3DXMATRIX *pout, FLOAT y=
aw, 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 *pl=
ight,
+CONST D3DXPLANE *pPlane);
D3DXMATRIX* WINAPI D3DXMatrixTranslation(D3DXMATRIX *pout, FLOAT x, FLOAT y=
, FLOAT z);
D3DXMATRIX* WINAPI D3DXMatrixTranspose(D3DXMATRIX *pout, CONST D3DXMATRIX *=
pm);
=20
--=20
1.5.3.2
--=_1sq9bn1lluzo--
More information about the wine-patches
mailing list