Commit 4ff191a7 authored by David Adam's avatar David Adam Committed by Alexandre Julliard

d3dx8: Implement D3DX*Hermite.

parent ea8e7ce4
@ stdcall D3DXVec2Normalize(ptr ptr)
@ stub D3DXVec2Hermite
@ stdcall D3DXVec2Hermite(ptr ptr ptr ptr ptr long)
@ stub D3DXVec2CatmullRom
@ stdcall D3DXVec2BaryCentric(ptr ptr ptr ptr long long)
@ stub D3DXVec2Transform
@ stub D3DXVec2TransformCoord
@ stub D3DXVec2TransformNormal
@ stdcall D3DXVec3Normalize(ptr ptr)
@ stub D3DXVec3Hermite
@ stdcall D3DXVec3Hermite(ptr ptr ptr ptr ptr long)
@ stub D3DXVec3CatmullRom
@ stdcall D3DXVec3BaryCentric(ptr ptr ptr ptr long long)
@ stub D3DXVec3Transform
......@@ -16,7 +16,7 @@
@ stub D3DXVec3Unproject
@ stub D3DXVec4Cross
@ stdcall D3DXVec4Normalize(ptr ptr)
@ stub D3DXVec4Hermite
@ stdcall D3DXVec4Hermite(ptr ptr ptr ptr ptr long)
@ stub D3DXVec4CatmullRom
@ stdcall D3DXVec4BaryCentric(ptr ptr ptr ptr long long)
@ stub D3DXVec4Transform
......
......@@ -61,6 +61,20 @@ D3DXVECTOR2* WINAPI D3DXVec2BaryCentric(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv
return pout;
}
D3DXVECTOR2* WINAPI D3DXVec2Hermite(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pt1, CONST D3DXVECTOR2 *pv2, CONST D3DXVECTOR2 *pt2, FLOAT s)
{
FLOAT h1, h2, h3, h4;
h1 = 2.0f * s * s * s - 3.0f * s * s + 1.0f;
h2 = s * s * s - 2.0f * s * s + s;
h3 = -2.0f * s * s * s + 3.0f * s * s;
h4 = s * s * s - s * s;
pout->x = h1 * (pv1->x) + h2 * (pt1->x) + h3 * (pv2->x) + h4 * (pt2->x);
pout->y = h1 * (pv1->y) + h2 * (pt1->y) + h3 * (pv2->y) + h4 * (pt2->y);
return pout;
}
D3DXVECTOR2* WINAPI D3DXVec2Normalize(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv)
{
FLOAT norm;
......@@ -89,6 +103,21 @@ D3DXVECTOR3* WINAPI D3DXVec3BaryCentric(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv
return pout;
}
D3DXVECTOR3* WINAPI D3DXVec3Hermite(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv1, CONST D3DXVECTOR3 *pt1, CONST D3DXVECTOR3 *pv2, CONST D3DXVECTOR3 *pt2, FLOAT s)
{
FLOAT h1, h2, h3, h4;
h1 = 2.0f * s * s * s - 3.0f * s * s + 1.0f;
h2 = s * s * s - 2.0f * s * s + s;
h3 = -2.0f * s * s * s + 3.0f * s * s;
h4 = s * s * s - s * s;
pout->x = h1 * (pv1->x) + h2 * (pt1->x) + h3 * (pv2->x) + h4 * (pt2->x);
pout->y = h1 * (pv1->y) + h2 * (pt1->y) + h3 * (pv2->y) + h4 * (pt2->y);
pout->z = h1 * (pv1->z) + h2 * (pt1->z) + h3 * (pv2->z) + h4 * (pt2->z);
return pout;
}
D3DXVECTOR3* WINAPI D3DXVec3Normalize(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv)
{
FLOAT norm;
......@@ -119,6 +148,23 @@ D3DXVECTOR4* WINAPI D3DXVec4BaryCentric(D3DXVECTOR4 *pout, CONST D3DXVECTOR4 *pv
pout->w = (1.0f-f-g) * (pv1->w) + f * (pv2->w) + g * (pv3->w);
return pout;
}
D3DXVECTOR4* WINAPI D3DXVec4Hermite(D3DXVECTOR4 *pout, CONST D3DXVECTOR4 *pv1, CONST D3DXVECTOR4 *pt1, CONST D3DXVECTOR4 *pv2, CONST D3DXVECTOR4 *pt2, FLOAT s)
{
FLOAT h1, h2, h3, h4;
h1 = 2.0f * s * s * s - 3.0f * s * s + 1.0f;
h2 = s * s * s - 2.0f * s * s + s;
h3 = -2.0f * s * s * s + 3.0f * s * s;
h4 = s * s * s - s * s;
pout->x = h1 * (pv1->x) + h2 * (pt1->x) + h3 * (pv2->x) + h4 * (pt2->x);
pout->y = h1 * (pv1->y) + h2 * (pt1->y) + h3 * (pv2->y) + h4 * (pt2->y);
pout->z = h1 * (pv1->z) + h2 * (pt1->z) + h3 * (pv2->z) + h4 * (pt2->z);
pout->w = h1 * (pv1->w) + h2 * (pt1->w) + h3 * (pv2->w) + h4 * (pt2->w);
return pout;
}
D3DXVECTOR4* WINAPI D3DXVec4Normalize(D3DXVECTOR4 *pout, CONST D3DXVECTOR4 *pv)
{
FLOAT norm;
......
......@@ -27,7 +27,7 @@
#define expect_vec(expectedvec,gotvec) ok((fabs(expectedvec.x-gotvec.x)<admitted_error)&&(fabs(expectedvec.y-gotvec.y)<admitted_error),"Expected Vector= (%f, %f)\n , Got Vector= (%f, %f)\n", expectedvec.x, expectedvec.y, gotvec.x, gotvec.y);
#define expect_vec3(expectedvec,gotvec) ok((fabs(expectedvec.x-gotvec.x)<admitted_error)&&(fabs(expectedvec.y-gotvec.y)<admitted_error)&&(fabs(expectedvec.z-gotvec.z)<admitted_error),"Expected Vector= (%f, %f,%f)\n , Got Vector= (%f, %f, %f)\n", expectedvec.x, expectedvec.y, expectedvec.z, gotvec.x, gotvec.y, gotvec.z);
#define expect_vec3(expectedvec,gotvec) ok((fabs(expectedvec.x-gotvec.x)<admitted_error)&&(fabs(expectedvec.y-gotvec.y)<admitted_error)&&(fabs(expectedvec.z-gotvec.z)<admitted_error),"Expected Vector= (%f, %f, %f)\n , Got Vector= (%f, %f, %f)\n", expectedvec.x, expectedvec.y, expectedvec.z, gotvec.x, gotvec.y, gotvec.z);
#define expect_vec4(expectedvec,gotvec) ok((fabs(expectedvec.x-gotvec.x)<admitted_error)&&(fabs(expectedvec.y-gotvec.y)<admitted_error)&&(fabs(expectedvec.z-gotvec.z)<admitted_error)&&(fabs(expectedvec.w-gotvec.w)<admitted_error),"Expected Vector= (%f, %f, %f, %f)\n , Got Vector= (%f, %f, %f, %f)\n", expectedvec.x, expectedvec.y, expectedvec.z, expectedvec.w, gotvec.x, gotvec.y, gotvec.z, gotvec.w);
......@@ -273,7 +273,7 @@ static void D3X8QuaternionTest(void)
static void D3X8Vector2Test(void)
{
D3DXVECTOR2 expectedvec, gotvec, nul, u, v, w;
D3DXVECTOR2 expectedvec, gotvec, nul, u, v, w, x;
LPD3DXVECTOR2 funcpointer;
FLOAT coeff1, coeff2, expected, got, scale;
......@@ -281,6 +281,7 @@ static void D3X8Vector2Test(void)
u.x = 3.0f; u.y = 4.0f;
v.x = -7.0f; v.y = 9.0f;
w.x = 4.0f; w.y = -3.0f;
x.x = 2.0f; x.y = -11.0f;
coeff1 = 2.0f; coeff2 = 5.0f;
scale = -6.5f;
......@@ -313,10 +314,10 @@ static void D3X8Vector2Test(void)
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
/*_______________D3DXVec2Dot__________________________*/
expected = 15.0f;
got = D3DXVec2Dot(&u,&v);
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
/* Tests the case NULL */
expected = 15.0f;
got = D3DXVec2Dot(&u,&v);
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
/* Tests the case NULL */
expected=0.0f;
got = D3DXVec2Dot(NULL,&v);
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
......@@ -324,6 +325,11 @@ static void D3X8Vector2Test(void)
got = D3DXVec2Dot(NULL,NULL);
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
/*_______________D3DXVec2Hermite__________________________*/
expectedvec.x = 2604.625f; expectedvec.y = -4533.0f;
D3DXVec2Hermite(&gotvec,&u,&v,&w,&x,scale);
expect_vec(expectedvec,gotvec);
/*_______________D3DXVec2Length__________________________*/
expected = 5.0f;
got = D3DXVec2Length(&u);
......@@ -405,7 +411,7 @@ static void D3X8Vector2Test(void)
static void D3X8Vector3Test(void)
{
D3DXVECTOR3 expectedvec, gotvec, nul, u, v, w;
D3DXVECTOR3 expectedvec, gotvec, nul, u, v, w, x;
LPD3DXVECTOR3 funcpointer;
FLOAT coeff1, coeff2, expected, got, scale;
......@@ -413,6 +419,7 @@ static void D3X8Vector3Test(void)
u.x = 9.0f; u.y = 6.0f; u.z = 2.0f;
v.x = 2.0f; v.y = -3.0f; v.z = -4.0;
w.x = 3.0f; w.y = -5.0f; w.z = 7.0f;
x.x = 4.0f; x.y = 1.0f; x.z = 11.0f;
coeff1 = 2.0f; coeff2 = 5.0f;
scale = -6.5f;
......@@ -453,6 +460,11 @@ static void D3X8Vector3Test(void)
got = D3DXVec3Dot(NULL,NULL);
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
/*_______________D3DXVec3Hermite__________________________*/
expectedvec.x = -6045.75f; expectedvec.y = -6650.0f; expectedvec.z = 1358.875f;
D3DXVec3Hermite(&gotvec,&u,&v,&w,&x,scale);
expect_vec3(expectedvec,gotvec);
/*_______________D3DXVec3Length__________________________*/
expected = 11.0f;
got = D3DXVec3Length(&u);
......@@ -534,7 +546,7 @@ static void D3X8Vector3Test(void)
static void D3X8Vector4Test(void)
{
D3DXVECTOR4 expectedvec, gotvec, nul, u, v, w;
D3DXVECTOR4 expectedvec, gotvec, nul, u, v, w, x;
LPD3DXVECTOR4 funcpointer;
FLOAT coeff1, coeff2, expected, got, scale;
......@@ -542,7 +554,7 @@ static void D3X8Vector4Test(void)
u.x = 1.0f; u.y = 2.0f; u.z = 4.0f; u.w = 10.0;
v.x = -3.0f; v.y = 4.0f; v.z = -5.0f; v.w = 7.0;
w.x = 4.0f; w.y =6.0f; w.z = -2.0f; w.w = 1.0f;
x.x = 6.0f; x.y = -7.0f; x.z =8.0f; x.w = -9.0f;
coeff1 = 2.0f; coeff2 = 5.0;
scale = -6.5f;
......@@ -573,6 +585,11 @@ static void D3X8Vector4Test(void)
got = D3DXVec4Dot(NULL,NULL);
ok(fabs( got - expected ) < admitted_error, "Expected: %f, Got: %f\n", expected, got);
/*_______________D3DXVec4Hermite_________________________*/
expectedvec.x = 1224.625f; expectedvec.y = 3461.625f; expectedvec.z = -4758.875f; expectedvec.w = -5781.5f;
D3DXVec4Hermite(&gotvec,&u,&v,&w,&x,scale);
expect_vec4(expectedvec,gotvec);
/*_______________D3DXVec4Length__________________________*/
expected = 11.0f;
got = D3DXVec4Length(&u);
......
......@@ -61,12 +61,15 @@ typedef struct D3DXCOLOR
D3DXQUATERNION* WINAPI D3DXQuaternionNormalize(D3DXQUATERNION *pout, CONST D3DXQUATERNION *pq);
D3DXVECTOR2* WINAPI D3DXVec2BaryCentric(D3DXVECTOR2 *pout, CONST D3DXVECTOR2 *pv1, CONST D3DXVECTOR2 *pv2, CONST D3DXVECTOR2 *pv3, FLOAT f, FLOAT g);
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);
D3DXVECTOR3* WINAPI D3DXVec3BaryCentric(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv1, CONST D3DXVECTOR3 *pv2, CONST D3DXVECTOR3 *pv3, FLOAT f, FLOAT g);
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 D3DXVec4BaryCentric(D3DXVECTOR4 *pout, CONST D3DXVECTOR4 *pv1, CONST D3DXVECTOR4 *pv2, CONST D3DXVECTOR4 *pv3, FLOAT f, FLOAT g);
D3DXVECTOR4* WINAPI D3DXVec4Hermite(D3DXVECTOR4 *pout, CONST D3DXVECTOR4 *pv1, CONST D3DXVECTOR4 *pt1, CONST D3DXVECTOR4 *pv2, CONST D3DXVECTOR4 *pt2, FLOAT s);
D3DXVECTOR4* WINAPI D3DXVec4Normalize(D3DXVECTOR4 *pout, CONST D3DXVECTOR4 *pv);
#include <d3dx8math.inl>
......
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