d3dx8: Implement D3DXVec3Unproject.

This commit is contained in:
David Adam 2007-11-11 17:38:20 +01:00 committed by Alexandre Julliard
parent 6c902b42d5
commit 147600b671
4 changed files with 23 additions and 1 deletions

View File

@ -13,7 +13,7 @@
@ stdcall D3DXVec3TransformCoord(ptr ptr ptr)
@ stdcall D3DXVec3TransformNormal(ptr ptr ptr)
@ stdcall D3DXVec3Project(ptr ptr ptr ptr ptr ptr)
@ stub D3DXVec3Unproject
@ stdcall D3DXVec3Unproject(ptr ptr ptr ptr ptr ptr)
@ stdcall D3DXVec4Cross(ptr ptr ptr ptr)
@ stdcall D3DXVec4Normalize(ptr ptr)
@ stdcall D3DXVec4Hermite(ptr ptr ptr ptr ptr long)

View File

@ -606,6 +606,21 @@ D3DXVECTOR3* WINAPI D3DXVec3TransformNormal(D3DXVECTOR3 *pout, CONST D3DXVECTOR3
}
D3DXVECTOR3* WINAPI D3DXVec3Unproject(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv, CONST D3DVIEWPORT8 *pviewport, CONST D3DXMATRIX *pprojection, CONST D3DXMATRIX *pview, CONST D3DXMATRIX *pworld)
{
D3DXMATRIX m1, m2, m3;
D3DXVECTOR3 vec;
D3DXMatrixMultiply(&m1, pworld, pview);
D3DXMatrixMultiply(&m2, &m1, pprojection);
D3DXMatrixInverse(&m3, NULL, &m2);
vec.x = 2.0f * ( pv->x - pviewport->X ) / pviewport->Width - 1.0f;
vec.y = 1.0f - 2.0f * ( pv->y - pviewport->Y ) / pviewport->Height;
vec.z = ( pv->z - pviewport->MinZ) / ( pviewport->MaxZ - pviewport->MinZ );
D3DXVec3TransformCoord(pout, &vec, &m3);
return pout;
}
/*_________________D3DXVec4_____________________*/
D3DXVECTOR4* WINAPI D3DXVec4BaryCentric(D3DXVECTOR4 *pout, CONST D3DXVECTOR4 *pv1, CONST D3DXVECTOR4 *pv2, CONST D3DXVECTOR4 *pv3, FLOAT f, FLOAT g)

View File

@ -878,6 +878,12 @@ static void D3X8Vector3Test(void)
expectedvec.x = 57.0f; expectedvec.y = 74.0f; expectedvec.z = 91.0f;
D3DXVec3TransformNormal(&gotvec,&u,&mat);
expect_vec3(expectedvec,gotvec);
/*_______________D3DXVec3Unproject_________________________*/
expectedvec.x = -2.913411f; expectedvec.y = 1.593215f; expectedvec.z = 0.380724f;
D3DXMatrixPerspectiveFovLH(&projection,D3DX_PI/4.0f,20.0f/17.0f,1.0f,1000.0f);
D3DXVec3Unproject(&gotvec,&u,&viewport,&projection,&view,&world);
expect_vec3(expectedvec,gotvec);
}
static void D3X8Vector4Test(void)

View File

@ -304,6 +304,7 @@ D3DXVECTOR3* WINAPI D3DXVec3Project(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv, CO
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);
D3DXVECTOR3* WINAPI D3DXVec3Unproject(D3DXVECTOR3 *pout, CONST D3DXVECTOR3 *pv, CONST D3DVIEWPORT8 *pviewport, CONST D3DXMATRIX *pprojection, CONST D3DXMATRIX *pview, CONST D3DXMATRIX *pworld);
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);