Commit a1010e6c authored by David Adam's avatar David Adam Committed by Alexandre Julliard

d3dx8: Implement D3DXMatrixShadow.

parent c432b48a
......@@ -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
......
......@@ -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);
......
......@@ -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;
......
......@@ -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);
......
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