David Adam : d3dx8: Implement D3DXMatrixReflect.

Alexandre Julliard julliard at winehq.org
Fri Nov 16 08:31:15 CST 2007


Module: wine
Branch: master
Commit: 5cc527d30d83f317b7937ec02ec868004d98a0b8
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=5cc527d30d83f317b7937ec02ec868004d98a0b8

Author: David Adam <David.Adam at math.cnrs.fr>
Date:   Thu Nov 15 13:09:38 2007 +0100

d3dx8: Implement D3DXMatrixReflect.

---

 dlls/d3dx8/d3dx8.spec   |    2 +-
 dlls/d3dx8/math.c       |   21 +++++++++++++++++++++
 dlls/d3dx8/tests/math.c |    7 +++++++
 include/d3dx8math.h     |    1 +
 4 files changed, 30 insertions(+), 1 deletions(-)

diff --git a/dlls/d3dx8/d3dx8.spec b/dlls/d3dx8/d3dx8.spec
index dae4570..9dca39b 100644
--- a/dlls/d3dx8/d3dx8.spec
+++ b/dlls/d3dx8/d3dx8.spec
@@ -48,7 +48,7 @@
 @ stdcall D3DXMatrixOrthoOffCenterRH(ptr long long long long long long)
 @ stdcall D3DXMatrixOrthoOffCenterLH(ptr long long long long long long)
 @ stdcall D3DXMatrixShadow(ptr ptr ptr)
-@ stub D3DXMatrixReflect
+@ stdcall D3DXMatrixReflect(ptr ptr)
 @ stub D3DXQuaternionToAxisAngle
 @ stub D3DXQuaternionRotationMatrix
 @ stub D3DXQuaternionRotationAxis
diff --git a/dlls/d3dx8/math.c b/dlls/d3dx8/math.c
index 990aa55..cb6789a 100644
--- a/dlls/d3dx8/math.c
+++ b/dlls/d3dx8/math.c
@@ -325,6 +325,27 @@ D3DXMATRIX* WINAPI D3DXMatrixPerspectiveRH(D3DXMATRIX *pout, FLOAT w, FLOAT h, F
     return pout;
 }
 
+D3DXMATRIX* WINAPI D3DXMatrixReflect(D3DXMATRIX *pout, CONST D3DXPLANE *pplane)
+{
+    D3DXPLANE Nplane;
+
+    D3DXPlaneNormalize(&Nplane, pplane);
+    D3DXMatrixIdentity(pout);
+    pout->u.m[0][0] = 1.0f - 2.0f * Nplane.a * Nplane.a;
+    pout->u.m[0][1] = -2.0f * Nplane.a * Nplane.b;
+    pout->u.m[0][2] = -2.0f * Nplane.a * Nplane.c;
+    pout->u.m[1][0] = -2.0f * Nplane.a * Nplane.b;
+    pout->u.m[1][1] = 1.0f - 2.0f * Nplane.b * Nplane.b;
+    pout->u.m[1][2] = -2.0f * Nplane.b * Nplane.c;
+    pout->u.m[2][0] = -2.0f * Nplane.c * Nplane.a;
+    pout->u.m[2][1] = -2.0f * Nplane.c * Nplane.b;
+    pout->u.m[2][2] = 1.0f - 2.0f * Nplane.c * Nplane.c;
+    pout->u.m[3][0] = -2.0f * Nplane.d * Nplane.a;
+    pout->u.m[3][1] = -2.0f * Nplane.d * Nplane.b;
+    pout->u.m[3][2] = -2.0f * Nplane.d * Nplane.c;
+    return pout;
+}
+
 D3DXMATRIX* WINAPI D3DXMatrixRotationAxis(D3DXMATRIX *pout, CONST D3DXVECTOR3 *pv, FLOAT angle)
 {
     D3DXVECTOR3 v;
diff --git a/dlls/d3dx8/tests/math.c b/dlls/d3dx8/tests/math.c
index abc3a98..05a72e9 100644
--- a/dlls/d3dx8/tests/math.c
+++ b/dlls/d3dx8/tests/math.c
@@ -346,6 +346,13 @@ static void D3DXMatrixTest(void)
     D3DXMatrixPerspectiveRH(&gotmat, 0.2f, 0.75f, -2.4f, 8.7f);
     expect_mat(expectedmat,gotmat);
 
+/*____________D3DXMatrixReflect______________*/
+    U(expectedmat).m[0][0] = 0.307692f; U(expectedmat).m[0][1] = -0.230769f; U(expectedmat).m[0][2] = 0.923077f; U(expectedmat).m[0][3] = 0.0f;
+    U(expectedmat).m[1][0] = -0.230769; U(expectedmat).m[1][1] = 0.923077f; U(expectedmat).m[1][2] = 0.307693f; U(expectedmat).m[1][3] = 0.0f;
+    U(expectedmat).m[2][0] = 0.923077f; U(expectedmat).m[2][1] = 0.307693f; U(expectedmat).m[2][2] = -0.230769f; U(expectedmat).m[2][3] = 0.0f;
+    U(expectedmat).m[3][0] = 1.615385f; U(expectedmat).m[3][1] = 0.538462f; U(expectedmat).m[3][2] = -2.153846f; U(expectedmat).m[3][3] = 1.0f;
+    D3DXMatrixReflect(&gotmat,&plane);
+    expect_mat(expectedmat,gotmat);
 /*____________D3DXMatrixRotationAxis_____*/
     U(expectedmat).m[0][0] = 0.508475f; U(expectedmat).m[0][1] = 0.763805f; U(expectedmat).m[0][2] = 0.397563f; U(expectedmat).m[0][3] = 0.0f;
     U(expectedmat).m[1][0] = -0.814652f; U(expectedmat).m[1][1] = 0.576271f; U(expectedmat).m[1][2] = -0.065219f; U(expectedmat).m[1][3] = 0.0f;
diff --git a/include/d3dx8math.h b/include/d3dx8math.h
index 195badd..930c417 100644
--- a/include/d3dx8math.h
+++ b/include/d3dx8math.h
@@ -281,6 +281,7 @@ D3DXMATRIX* WINAPI D3DXMatrixPerspectiveLH(D3DXMATRIX *pout, FLOAT w, FLOAT h, F
 D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenterLH(D3DXMATRIX *pout, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, FLOAT zf);
 D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenterRH(D3DXMATRIX *pout, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, FLOAT zf);
 D3DXMATRIX* WINAPI D3DXMatrixPerspectiveRH(D3DXMATRIX *pout, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf);
+D3DXMATRIX* WINAPI D3DXMatrixReflect(D3DXMATRIX *pout, CONST D3DXPLANE *pplane);
 D3DXMATRIX* WINAPI D3DXMatrixRotationAxis(D3DXMATRIX *pout, CONST D3DXVECTOR3 *pv, FLOAT angle);
 D3DXMATRIX* WINAPI D3DXMatrixRotationQuaternion(D3DXMATRIX *pout, CONST D3DXQUATERNION *pq);
 D3DXMATRIX* WINAPI D3DXMatrixRotationX(D3DXMATRIX *pout, FLOAT angle);




More information about the wine-cvs mailing list