Commit 6840049f authored by David Adam's avatar David Adam Committed by Alexandre Julliard

d3dx8: Implement D3DXMatrixAffine Transformation.

parent a51486c6
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
@ stdcall D3DXMatrixRotationQuaternion(ptr ptr) @ stdcall D3DXMatrixRotationQuaternion(ptr ptr)
@ stdcall D3DXMatrixRotationYawPitchRoll(ptr long long long) @ stdcall D3DXMatrixRotationYawPitchRoll(ptr long long long)
@ stub D3DXMatrixTransformation @ stub D3DXMatrixTransformation
@ stub D3DXMatrixAffineTransformation @ stdcall D3DXMatrixAffineTransformation(ptr long ptr ptr ptr)
@ stdcall D3DXMatrixLookAtRH(ptr ptr ptr ptr) @ stdcall D3DXMatrixLookAtRH(ptr ptr ptr ptr)
@ stdcall D3DXMatrixLookAtLH(ptr ptr ptr ptr) @ stdcall D3DXMatrixLookAtLH(ptr ptr ptr ptr)
@ stdcall D3DXMatrixPerspectiveRH(ptr long long long long) @ stdcall D3DXMatrixPerspectiveRH(ptr long long long long)
......
...@@ -34,6 +34,44 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3dx8); ...@@ -34,6 +34,44 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3dx8);
/*_________________D3DXMatrix____________________*/ /*_________________D3DXMatrix____________________*/
D3DXMATRIX* WINAPI D3DXMatrixAffineTransformation(D3DXMATRIX *pout, float scaling, D3DXVECTOR3 *rotationcenter, D3DXQUATERNION *rotation, D3DXVECTOR3 *translation)
{
D3DXMATRIX m1, m2, m3, m4, m5, p1, p2, p3;
D3DXMatrixScaling(&m1, scaling, scaling, scaling);
if ( !rotationcenter )
{
D3DXMatrixIdentity(&m2);
D3DXMatrixIdentity(&m4);
}
else
{
D3DXMatrixTranslation(&m2, -rotationcenter->x, -rotationcenter->y, -rotationcenter->z);
D3DXMatrixTranslation(&m4, rotationcenter->x, rotationcenter->y, rotationcenter->z);
}
if ( !rotation )
{
D3DXMatrixIdentity(&m3);
}
else
{
D3DXMatrixRotationQuaternion(&m3, rotation);
}
if ( !translation )
{
D3DXMatrixIdentity(&m5);
}
else
{
D3DXMatrixTranslation(&m5, translation->x, translation->y, translation->z);
}
D3DXMatrixMultiply(&p1, &m1, &m2);
D3DXMatrixMultiply(&p2, &p1, &m3);
D3DXMatrixMultiply(&p3, &p2, &m4);
D3DXMatrixMultiply(pout, &p3, &m5);
return pout;
}
FLOAT WINAPI D3DXMatrixfDeterminant(CONST D3DXMATRIX *pm) FLOAT WINAPI D3DXMatrixfDeterminant(CONST D3DXMATRIX *pm)
{ {
D3DXVECTOR4 minor, v1, v2, v3; D3DXVECTOR4 minor, v1, v2, v3;
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#include "wine/test.h" #include "wine/test.h"
#define admitted_error 0.00001f #define admitted_error 0.0001f
#define expect_color(expectedcolor,gotcolor) ok((fabs(expectedcolor.r-gotcolor.r)<admitted_error)&&(fabs(expectedcolor.g-gotcolor.g)<admitted_error)&&(fabs(expectedcolor.b-gotcolor.b)<admitted_error)&&(fabs(expectedcolor.a-gotcolor.a)<admitted_error),"Expected Color= (%f, %f, %f, %f)\n , Got Color= (%f, %f, %f, %f)\n", expectedcolor.r, expectedcolor.g, expectedcolor.b, expectedcolor.a, gotcolor.r, gotcolor.g, gotcolor.b, gotcolor.a); #define expect_color(expectedcolor,gotcolor) ok((fabs(expectedcolor.r-gotcolor.r)<admitted_error)&&(fabs(expectedcolor.g-gotcolor.g)<admitted_error)&&(fabs(expectedcolor.b-gotcolor.b)<admitted_error)&&(fabs(expectedcolor.a-gotcolor.a)<admitted_error),"Expected Color= (%f, %f, %f, %f)\n , Got Color= (%f, %f, %f, %f)\n", expectedcolor.r, expectedcolor.g, expectedcolor.b, expectedcolor.a, gotcolor.r, gotcolor.g, gotcolor.b, gotcolor.a);
...@@ -177,6 +177,21 @@ static void D3DXMatrixTest(void) ...@@ -177,6 +177,21 @@ static void D3DXMatrixTest(void)
angle = D3DX_PI/3.0f; angle = D3DX_PI/3.0f;
/*____________D3DXMatrixAffineTransformation______*/
expectedmat.m[0][0] = -459.239990f; expectedmat.m[0][1] = -576.719971f; expectedmat.m[0][2] = -263.440002f; expectedmat.m[0][3] = 0.0f;
expectedmat.m[1][0] = 519.760010f; expectedmat.m[1][1] = -352.440002f; expectedmat.m[1][2] = -277.679993f; expectedmat.m[1][3] = 0.0f;
expectedmat.m[2][0] = 363.119995f; expectedmat.m[2][1] = -121.040001f; expectedmat.m[2][2] = -117.479996f; expectedmat.m[2][3] = 0.0f;
expectedmat.m[3][0] = -1239.0f; expectedmat.m[3][1] = 667.0f; expectedmat.m[3][2] = 567.0f; expectedmat.m[3][3] = 1.0f;
D3DXMatrixAffineTransformation(&gotmat,3.56f,&at,&q,&axis);
expect_mat(expectedmat,gotmat);
/* Test the NULL case */
expectedmat.m[0][0] = -459.239990f; expectedmat.m[0][1] = -576.719971f; expectedmat.m[0][2] = -263.440002f; expectedmat.m[0][3] = 0.0f;
expectedmat.m[1][0] = 519.760010f; expectedmat.m[1][1] = -352.440002f; expectedmat.m[1][2] = -277.679993f; expectedmat.m[1][3] = 0.0f;
expectedmat.m[2][0] = 363.119995f; expectedmat.m[2][1] = -121.040001f; expectedmat.m[2][2] = -117.479996f; expectedmat.m[2][3] = 0.0f;
expectedmat.m[3][0] = 1.0f; expectedmat.m[3][1] = -3.0f; expectedmat.m[3][2] = 7.0f; expectedmat.m[3][3] = 1.0f;
D3DXMatrixAffineTransformation(&gotmat,3.56f,NULL,&q,&axis);
expect_mat(expectedmat,gotmat);
/*____________D3DXMatrixfDeterminant_____________*/ /*____________D3DXMatrixfDeterminant_____________*/
expectedfloat = -147888.0f; expectedfloat = -147888.0f;
gotfloat = D3DXMatrixfDeterminant(&mat); gotfloat = D3DXMatrixfDeterminant(&mat);
......
...@@ -259,6 +259,7 @@ typedef struct D3DXCOLOR ...@@ -259,6 +259,7 @@ typedef struct D3DXCOLOR
FLOAT r, g, b, a; FLOAT r, g, b, a;
} D3DXCOLOR, *LPD3DXCOLOR; } D3DXCOLOR, *LPD3DXCOLOR;
D3DXMATRIX* WINAPI D3DXMatrixAffineTransformation(D3DXMATRIX *pout, float scaling, D3DXVECTOR3 *rotationcenter, D3DXQUATERNION *rotation, D3DXVECTOR3 *translation);
FLOAT WINAPI D3DXMatrixfDeterminant(CONST D3DXMATRIX *pm); FLOAT WINAPI D3DXMatrixfDeterminant(CONST D3DXMATRIX *pm);
D3DXMATRIX* WINAPI D3DXMatrixInverse(D3DXMATRIX *pout, FLOAT *pdeterminant, CONST D3DXMATRIX *pm); D3DXMATRIX* WINAPI D3DXMatrixInverse(D3DXMATRIX *pout, FLOAT *pdeterminant, CONST D3DXMATRIX *pm);
D3DXMATRIX* WINAPI D3DXMatrixLookAtLH(D3DXMATRIX *pout, CONST D3DXVECTOR3 *peye, CONST D3DXVECTOR3 *pat, CONST D3DXVECTOR3 *pup); D3DXMATRIX* WINAPI D3DXMatrixLookAtLH(D3DXMATRIX *pout, CONST D3DXVECTOR3 *peye, CONST D3DXVECTOR3 *pat, CONST D3DXVECTOR3 *pup);
......
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