mirror of
git://source.winehq.org/git/wine.git
synced 2024-11-05 18:01:34 +00:00
d3dx8: Implement D3XMatrixVec3Project.
This commit is contained in:
parent
3231c01c42
commit
6c902b42d5
4 changed files with 39 additions and 2 deletions
|
@ -12,7 +12,7 @@
|
|||
@ stdcall D3DXVec3Transform(ptr ptr ptr)
|
||||
@ stdcall D3DXVec3TransformCoord(ptr ptr ptr)
|
||||
@ stdcall D3DXVec3TransformNormal(ptr ptr ptr)
|
||||
@ stub D3DXVec3Project
|
||||
@ stdcall D3DXVec3Project(ptr ptr ptr ptr ptr ptr)
|
||||
@ stub D3DXVec3Unproject
|
||||
@ stdcall D3DXVec4Cross(ptr ptr ptr ptr)
|
||||
@ stdcall D3DXVec4Normalize(ptr ptr)
|
||||
|
|
|
@ -553,6 +553,20 @@ D3DXVECTOR3* WINAPI D3DXVec3Normalize(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv)
|
|||
return pout;
|
||||
}
|
||||
|
||||
D3DXVECTOR3* WINAPI D3DXVec3Project(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv, CONST D3DVIEWPORT8 *pviewport, CONST D3DXMATRIX *pprojection, CONST D3DXMATRIX *pview, CONST D3DXMATRIX *pworld)
|
||||
{
|
||||
D3DXMATRIX m1, m2;
|
||||
D3DXVECTOR3 vec;
|
||||
|
||||
D3DXMatrixMultiply(&m1, pworld, pview);
|
||||
D3DXMatrixMultiply(&m2, &m1, pprojection);
|
||||
D3DXVec3TransformCoord(&vec, pv, &m2);
|
||||
pout->x = pviewport->X + ( 1.0f + vec.x ) * pviewport->Width / 2.0f;
|
||||
pout->y = pviewport->Y + ( 1.0f - vec.y ) * pviewport->Height / 2.0f;
|
||||
pout->z = pviewport->MinZ + vec.z * ( pviewport->MaxZ - pviewport->MinZ );
|
||||
return pout;
|
||||
}
|
||||
|
||||
D3DXVECTOR4* WINAPI D3DXVec3Transform(D3DXVECTOR4 *pout, CONST D3DXVECTOR3 *pv, CONST D3DXMATRIX *pm)
|
||||
{
|
||||
pout->x = pm->u.m[0][0] * pv->x + pm->u.m[1][0] * pv->y + pm->u.m[2][0] * pv->z + pm->u.m[3][0];
|
||||
|
|
|
@ -692,10 +692,11 @@ static void D3X8Vector2Test(void)
|
|||
|
||||
static void D3X8Vector3Test(void)
|
||||
{
|
||||
D3DVIEWPORT8 viewport;
|
||||
D3DXVECTOR3 expectedvec, gotvec, nul, nulproj, u, v, w, x;
|
||||
LPD3DXVECTOR3 funcpointer;
|
||||
D3DXVECTOR4 expectedtrans, gottrans;
|
||||
D3DXMATRIX mat;
|
||||
D3DXMATRIX mat, projection, view, world;
|
||||
FLOAT coeff1, coeff2, expected, got, scale;
|
||||
|
||||
nul.x = 0.0f; nul.y = 0.0f; nul.z = 0.0f;
|
||||
|
@ -704,11 +705,26 @@ static void D3X8Vector3Test(void)
|
|||
w.x = 3.0f; w.y = -5.0f; w.z = 7.0f;
|
||||
x.x = 4.0f; x.y = 1.0f; x.z = 11.0f;
|
||||
|
||||
viewport.Width = 800; viewport.MinZ = 0.2f; viewport.X = 10;
|
||||
viewport.Height = 680; viewport.MaxZ = 0.9f; viewport.Y = 5;
|
||||
|
||||
U(mat).m[0][0] = 1.0f; U(mat).m[0][1] = 2.0f; U(mat).m[0][2] = 3.0f; U(mat).m[0][3] = 4.0f;
|
||||
U(mat).m[1][0] = 5.0f; U(mat).m[1][1] = 6.0f; U(mat).m[1][2] = 7.0f; U(mat).m[1][3] = 8.0f;
|
||||
U(mat).m[2][0] = 9.0f; U(mat).m[2][1] = 10.0f; U(mat).m[2][2] = 11.0f; U(mat).m[2][3] = 12.0f;
|
||||
U(mat).m[3][0] = 13.0f; U(mat).m[3][1] = 14.0f; U(mat).m[3][2] = 15.0f; U(mat).m[3][3] = 16.0f;
|
||||
|
||||
view.m[0][1] = 5.0f; view.m[0][2] = 7.0f; view.m[0][3] = 8.0f;
|
||||
view.m[1][0] = 11.0f; view.m[1][2] = 16.0f; view.m[1][3] = 33.0f;
|
||||
view.m[2][0] = 19.0f; view.m[2][1] = -21.0f; view.m[2][3] = 43.0f;
|
||||
view.m[3][0] = 2.0f; view.m[3][1] = 3.0f; view.m[3][2] = -4.0f;
|
||||
view.m[0][0] = 10.0f; view.m[1][1] = 20.0f; view.m[2][2] = 30.0f;
|
||||
view.m[3][3] = -40.0f;
|
||||
|
||||
world.m[0][0] = 21.0f; world.m[0][1] = 2.0f; world.m[0][2] = 3.0f; world.m[0][3] = 4.0;
|
||||
world.m[1][0] = 5.0f; world.m[1][1] = 23.0f; world.m[1][2] = 7.0f; world.m[1][3] = 8.0f;
|
||||
world.m[2][0] = -8.0f; world.m[2][1] = -7.0f; world.m[2][2] = 25.0f; world.m[2][3] = -5.0f;
|
||||
world.m[3][0] = -4.0f; world.m[3][1] = -3.0f; world.m[3][2] = -2.0f; world.m[3][3] = 27.0f;
|
||||
|
||||
coeff1 = 2.0f; coeff2 = 5.0f;
|
||||
scale = -6.5f;
|
||||
|
||||
|
@ -817,6 +833,12 @@ static void D3X8Vector3Test(void)
|
|||
D3DXVec3Normalize(&gotvec,&nul);
|
||||
expect_vec3(expectedvec,gotvec);
|
||||
|
||||
/*_______________D3DXVec3Project_________________________*/
|
||||
expectedvec.x = 1135.721924f; expectedvec.y = 147.086914f; expectedvec.z = 0.153412f;
|
||||
D3DXMatrixPerspectiveFovLH(&projection,D3DX_PI/4.0f,20.0f/17.0f,1.0f,1000.0f);
|
||||
D3DXVec3Project(&gotvec,&u,&viewport,&projection,&view,&world);
|
||||
expect_vec3(expectedvec,gotvec);
|
||||
|
||||
/*_______________D3DXVec3Scale____________________________*/
|
||||
expectedvec.x = -58.5f; expectedvec.y = -39.0f; expectedvec.z = -13.0f;
|
||||
D3DXVec3Scale(&gotvec,&u,scale);
|
||||
|
|
|
@ -300,6 +300,7 @@ D3DXVECTOR3* WINAPI D3DXVec3BaryCentric(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv
|
|||
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);
|
||||
D3DXVECTOR3* WINAPI D3DXVec3Project(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv, CONST D3DVIEWPORT8 *pviewport, CONST D3DXMATRIX *pprojection, CONST D3DXMATRIX *pview, CONST D3DXMATRIX *pworld);
|
||||
D3DXVECTOR4* WINAPI D3DXVec3Transform(D3DXVECTOR4 *pout, CONST D3DXVECTOR3 *pv, CONST D3DXMATRIX *pm);
|
||||
D3DXVECTOR3* WINAPI D3DXVec3TransformCoord(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv, CONST D3DXMATRIX *pm);
|
||||
D3DXVECTOR3* WINAPI D3DXVec3TransformNormal(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv, CONST D3DXMATRIX *pm);
|
||||
|
|
Loading…
Reference in a new issue