Commit 90c4757b authored by David Adam's avatar David Adam Committed by Alexandre Julliard

d3dx8: Implement D3DX*TransformCoord.

parent fa58dcee
......@@ -3,14 +3,14 @@
@ stdcall D3DXVec2CatmullRom(ptr ptr ptr ptr long)
@ stdcall D3DXVec2BaryCentric(ptr ptr ptr ptr long long)
@ stdcall D3DXVec2Transform(ptr ptr ptr)
@ stub D3DXVec2TransformCoord
@ stdcall D3DXVec2TransformCoord(ptr ptr ptr)
@ stub D3DXVec2TransformNormal
@ stdcall D3DXVec3Normalize(ptr ptr)
@ stdcall D3DXVec3Hermite(ptr ptr ptr ptr ptr long)
@ stdcall D3DXVec3CatmullRom(ptr ptr ptr ptr long)
@ stdcall D3DXVec3BaryCentric(ptr ptr ptr ptr long long)
@ stdcall D3DXVec3Transform(ptr ptr ptr)
@ stub D3DXVec3TransformCoord
@ stdcall D3DXVec3TransformCoord(ptr ptr ptr)
@ stub D3DXVec3TransformNormal
@ stub D3DXVec3Project
@ stub D3DXVec3Unproject
......
......@@ -109,6 +109,24 @@ D3DXVECTOR4* WINAPI D3DXVec2Transform(D3DXVECTOR4 *pout, CONST D3DXVECTOR2 *pv,
return pout;
}
D3DXVECTOR2* WINAPI D3DXVec2TransformCoord(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv, CONST D3DXMATRIX *pm)
{
FLOAT norm;
norm = pm->m[0][3] * pv->x + pm->m[1][3] * pv->y + pm->m[3][3];
if ( norm )
{
pout->x = (pm->m[0][0] * pv->x + pm->m[1][0] * pv->y + pm->m[3][0]) / norm;
pout->y = (pm->m[0][1] * pv->x + pm->m[1][1] * pv->y + pm->m[3][1]) / norm;
}
else
{
pout->x = 0.0f;
pout->y = 0.0f;
}
return pout;
}
/*_________________D3DXVec3_____________________*/
D3DXVECTOR3* WINAPI D3DXVec3BaryCentric(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv1, CONST D3DXVECTOR3 *pv2, CONST D3DXVECTOR3 *pv3, FLOAT f, FLOAT g)
......@@ -171,6 +189,27 @@ D3DXVECTOR4* WINAPI D3DXVec3Transform(D3DXVECTOR4 *pout, CONST D3DXVECTOR3 *pv,
return pout;
}
D3DXVECTOR3* WINAPI D3DXVec3TransformCoord(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv, CONST D3DXMATRIX *pm)
{
FLOAT norm;
norm = pm->m[0][3] * pv->x + pm->m[1][3] * pv->y + pm->m[2][3] *pv->z + pm->m[3][3];
if ( norm )
{
pout->x = (pm->m[0][0] * pv->x + pm->m[1][0] * pv->y + pm->m[2][0] * pv->z + pm->m[3][0]) / norm;
pout->y = (pm->m[0][1] * pv->x + pm->m[1][1] * pv->y + pm->m[2][1] * pv->z + pm->m[3][1]) / norm;
pout->z = (pm->m[0][2] * pv->x + pm->m[1][2] * pv->y + pm->m[2][2] * pv->z + pm->m[3][2]) / norm;
}
else
{
pout->x = 0.0f;
pout->y = 0.0f;
pout->z = 0.0f;
}
return pout;
}
/*_________________D3DXVec4_____________________*/
D3DXVECTOR4* WINAPI D3DXVec4BaryCentric(D3DXVECTOR4 *pout, CONST D3DXVECTOR4 *pv1, CONST D3DXVECTOR4 *pv2, CONST D3DXVECTOR4 *pv3, FLOAT f, FLOAT g)
......
......@@ -273,7 +273,7 @@ static void D3X8QuaternionTest(void)
static void D3X8Vector2Test(void)
{
D3DXVECTOR2 expectedvec, gotvec, nul, u, v, w, x;
D3DXVECTOR2 expectedvec, gotvec, nul, nulproj, u, v, w, x;
LPD3DXVECTOR2 funcpointer;
D3DXVECTOR4 expectedtrans, gottrans;
D3DXMATRIX mat;
......@@ -423,11 +423,21 @@ static void D3X8Vector2Test(void)
expectedtrans.x = 36.0f; expectedtrans.y = 44.0f; expectedtrans.z = 52.0f; expectedtrans.w = 60.0f;
D3DXVec2Transform(&gottrans,&u,&mat);
expect_vec4(expectedtrans,gottrans);
/*_______________D3DXVec2TransformCoord_______________________*/
expectedvec.x = 0.6f; expectedvec.y = 11.0f/15.0f;
D3DXVec2TransformCoord(&gotvec,&u,&mat);
expect_vec(expectedvec,gotvec);
/* Test the nul projected vector */
nulproj.x = -2.0f; nulproj.y = -1.0f;
expectedvec.x = 0.0f; expectedvec.y = 0.0f;
D3DXVec2TransformCoord(&gotvec,&nulproj,&mat);
expect_vec(expectedvec,gotvec);
}
static void D3X8Vector3Test(void)
{
D3DXVECTOR3 expectedvec, gotvec, nul, u, v, w, x;
D3DXVECTOR3 expectedvec, gotvec, nul, nulproj, u, v, w, x;
LPD3DXVECTOR3 funcpointer;
D3DXVECTOR4 expectedtrans, gottrans;
D3DXMATRIX mat;
......@@ -576,6 +586,16 @@ static void D3X8Vector3Test(void)
expectedtrans.x = 70.0f; expectedtrans.y = 88.0f; expectedtrans.z = 106.0f; expectedtrans.w = 124.0f;
D3DXVec3Transform(&gottrans,&u,&mat);
expect_vec4(expectedtrans,gottrans);
/*_______________D3DXVec3TransformCoord_______________________*/
expectedvec.x = 70.0f/124.0f; expectedvec.y = 88.0f/124.0f; expectedvec.z = 106.0f/124.0f;
D3DXVec3TransformCoord(&gotvec,&u,&mat);
expect_vec3(expectedvec,gotvec);
/* Test the nul projected vector */
nulproj.x = 1.0f; nulproj.y = -1.0f, nulproj.z = -1.0f;
expectedvec.x = 0.0f; expectedvec.y = 0.0f; expectedvec.z = 0.0f;
D3DXVec3TransformCoord(&gotvec,&nulproj,&mat);
expect_vec3(expectedvec,gotvec);
}
static void D3X8Vector4Test(void)
......
......@@ -65,12 +65,14 @@ D3DXVECTOR2* WINAPI D3DXVec2CatmullRom(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv0
D3DXVECTOR2* WINAPI D3DXVec2Hermite(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pt1, CONST D3DXVECTOR2 *pv2, CONST D3DXVECTOR2 *pt2, FLOAT s);
D3DXVECTOR2* WINAPI D3DXVec2Normalize(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv);
D3DXVECTOR4* WINAPI D3DXVec2Transform(D3DXVECTOR4 *pout, CONST D3DXVECTOR2 *pv, CONST D3DXMATRIX *pm);
D3DXVECTOR2* WINAPI D3DXVec2TransformCoord(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv, CONST D3DXMATRIX *pm);
D3DXVECTOR3* WINAPI D3DXVec3BaryCentric(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv1, CONST D3DXVECTOR3 *pv2, CONST D3DXVECTOR3 *pv3, FLOAT f, FLOAT g);
D3DXVECTOR3* WINAPI D3DXVec3CatmullRom( D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv0, CONST D3DXVECTOR3 *pv1, CONST D3DXVECTOR3 *pv2, CONST D3DXVECTOR3 *pv3, FLOAT s);
D3DXVECTOR3* WINAPI D3DXVec3Hermite(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv1, CONST D3DXVECTOR3 *pt1, CONST D3DXVECTOR3 *pv2, CONST D3DXVECTOR3 *pt2, FLOAT s);
D3DXVECTOR3* WINAPI D3DXVec3Normalize(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv);
D3DXVECTOR4* WINAPI D3DXVec3Transform(D3DXVECTOR4 *pout, CONST D3DXVECTOR3 *pv, CONST D3DXMATRIX *pm);
D3DXVECTOR3* WINAPI D3DXVec3TransformCoord(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv, CONST D3DXMATRIX *pm);
D3DXVECTOR4* WINAPI D3DXVec4BaryCentric(D3DXVECTOR4 *pout, CONST D3DXVECTOR4 *pv1, CONST D3DXVECTOR4 *pv2, CONST D3DXVECTOR4 *pv3, FLOAT f, FLOAT g);
D3DXVECTOR4* WINAPI D3DXVec4CatmullRom(D3DXVECTOR4 *pout, CONST D3DXVECTOR4 *pv0, CONST D3DXVECTOR4 *pv1, CONST D3DXVECTOR4 *pv2, CONST D3DXVECTOR4 *pv3, FLOAT s);
......
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