d3dx8: Implement D3DXMatrixTransformation2D.
This commit is contained in:
parent
4f1d5c26d1
commit
09c6caea06
|
@ -225,7 +225,7 @@
|
||||||
@ stdcall D3DXMatrixScaling(ptr long long long) d3dx8.D3DXMatrixScaling
|
@ stdcall D3DXMatrixScaling(ptr long long long) d3dx8.D3DXMatrixScaling
|
||||||
@ stdcall D3DXMatrixShadow(ptr ptr ptr) d3dx8.D3DXMatrixShadow
|
@ stdcall D3DXMatrixShadow(ptr ptr ptr) d3dx8.D3DXMatrixShadow
|
||||||
@ stdcall D3DXMatrixTransformation(ptr ptr ptr ptr ptr ptr ptr) d3dx8.D3DXMatrixTransformation
|
@ stdcall D3DXMatrixTransformation(ptr ptr ptr ptr ptr ptr ptr) d3dx8.D3DXMatrixTransformation
|
||||||
@ stub D3DXMatrixTransformation2D
|
@ stdcall D3DXMatrixTransformation2D(ptr ptr long ptr ptr long ptr)
|
||||||
@ stdcall D3DXMatrixTranslation(ptr long long long) d3dx8.D3DXMatrixTranslation
|
@ stdcall D3DXMatrixTranslation(ptr long long long) d3dx8.D3DXMatrixTranslation
|
||||||
@ stdcall D3DXMatrixTranspose(ptr ptr) d3dx8.D3DXMatrixTranspose
|
@ stdcall D3DXMatrixTranspose(ptr ptr) d3dx8.D3DXMatrixTranspose
|
||||||
@ stub D3DXOptimizeFaces
|
@ stub D3DXOptimizeFaces
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* Mathematical operations specific to D3DX9.
|
* Mathematical operations specific to D3DX9.
|
||||||
*
|
*
|
||||||
|
* Copyright (C) 2008 David Adam
|
||||||
* Copyright (C) 2008 Philip Nilsson
|
* Copyright (C) 2008 Philip Nilsson
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
|
@ -129,6 +130,85 @@ HRESULT WINAPI D3DXMatrixDecompose(D3DXVECTOR3 *poutscale, D3DXQUATERNION *poutr
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*************************************************************************
|
||||||
|
* D3DXMatrixTransformation2D
|
||||||
|
*/
|
||||||
|
D3DXMATRIX* WINAPI D3DXMatrixTransformation2D(
|
||||||
|
D3DXMATRIX *pout, CONST D3DXVECTOR2 *pscalingcenter,
|
||||||
|
FLOAT scalingrotation, CONST D3DXVECTOR2 *pscaling,
|
||||||
|
CONST D3DXVECTOR2 *protationcenter, FLOAT rotation,
|
||||||
|
CONST D3DXVECTOR2 *ptranslation)
|
||||||
|
{
|
||||||
|
D3DXQUATERNION rot, sca_rot;
|
||||||
|
D3DXVECTOR3 rot_center, sca, sca_center, trans;
|
||||||
|
|
||||||
|
if ( pscalingcenter )
|
||||||
|
{
|
||||||
|
sca_center.x=pscalingcenter->x;
|
||||||
|
sca_center.y=pscalingcenter->y;
|
||||||
|
sca_center.z=0.0f;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sca_center.x=0.0f;
|
||||||
|
sca_center.y=0.0f;
|
||||||
|
sca_center.z=0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( pscaling )
|
||||||
|
{
|
||||||
|
sca.x=pscaling->x;
|
||||||
|
sca.y=pscaling->y;
|
||||||
|
sca.z=0.0f;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sca.x=0.0f;
|
||||||
|
sca.y=0.0f;
|
||||||
|
sca.z=0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( protationcenter )
|
||||||
|
{
|
||||||
|
rot_center.x=protationcenter->x;
|
||||||
|
rot_center.y=protationcenter->y;
|
||||||
|
rot_center.z=0.0f;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rot_center.x=0.0f;
|
||||||
|
rot_center.y=0.0f;
|
||||||
|
rot_center.z=0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ptranslation )
|
||||||
|
{
|
||||||
|
trans.x=ptranslation->x;
|
||||||
|
trans.y=ptranslation->y;
|
||||||
|
trans.z=0.0f;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
trans.x=0.0f;
|
||||||
|
trans.y=0.0f;
|
||||||
|
trans.z=0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
rot.w=cos(rotation/2.0f);
|
||||||
|
rot.x=0.0f;
|
||||||
|
rot.y=0.0f;
|
||||||
|
rot.z=sin(rotation/2.0f);
|
||||||
|
|
||||||
|
sca_rot.w=cos(scalingrotation/2.0f);
|
||||||
|
sca_rot.x=0.0f;
|
||||||
|
sca_rot.y=0.0f;
|
||||||
|
sca_rot.z=sin(scalingrotation/2.0f);
|
||||||
|
|
||||||
|
D3DXMatrixTransformation(pout, &sca_center, &sca_rot, &sca, &rot_center, &rot, &trans);
|
||||||
|
|
||||||
|
return pout;
|
||||||
|
}
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* D3DXPlaneTransformArray
|
* D3DXPlaneTransformArray
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
/*
|
/*
|
||||||
|
* Copyright 2008 David Adam
|
||||||
* Copyright 2008 Philip Nilsson
|
* Copyright 2008 Philip Nilsson
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
|
@ -584,6 +585,83 @@ static void test_Matrix_Decompose(void)
|
||||||
ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %x\n", hr);
|
ok(hr == D3DERR_INVALIDCALL, "Expected D3DERR_INVALIDCALL, got %x\n", hr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_Matrix_Transformation2D(void)
|
||||||
|
{
|
||||||
|
D3DXMATRIX exp_mat, got_mat;
|
||||||
|
D3DXVECTOR2 rot_center, sca, sca_center, trans;
|
||||||
|
FLOAT rot, sca_rot;
|
||||||
|
|
||||||
|
rot_center.x = 3.0f;
|
||||||
|
rot_center.y = 4.0f;
|
||||||
|
|
||||||
|
sca.x = 12.0f;
|
||||||
|
sca.y = -3.0f;
|
||||||
|
|
||||||
|
sca_center.x = 9.0f;
|
||||||
|
sca_center.y = -5.0f;
|
||||||
|
|
||||||
|
trans.x = -6.0f;
|
||||||
|
trans.y = 7.0f;
|
||||||
|
|
||||||
|
rot = D3DX_PI/3.0f;
|
||||||
|
|
||||||
|
sca_rot = 5.0f*D3DX_PI/4.0f;
|
||||||
|
|
||||||
|
exp_mat.m[0][0] = -4.245192f;
|
||||||
|
exp_mat.m[1][0] = -0.147116f;
|
||||||
|
exp_mat.m[2][0] = 0.0f;
|
||||||
|
exp_mat.m[3][0] = 45.265373f;
|
||||||
|
exp_mat.m[0][1] = 7.647113f;
|
||||||
|
exp_mat.m[1][1] = 8.745192f;
|
||||||
|
exp_mat.m[2][1] = 0.0f;
|
||||||
|
exp_mat.m[3][1] = -13.401899f;
|
||||||
|
exp_mat.m[0][2] = 0.0f;
|
||||||
|
exp_mat.m[1][2] = 0.0f;
|
||||||
|
exp_mat.m[2][2] = 0.0f;
|
||||||
|
exp_mat.m[3][2] = 0.0f;
|
||||||
|
exp_mat.m[0][3] = 0.0f;
|
||||||
|
exp_mat.m[1][3] = 0.0f;
|
||||||
|
exp_mat.m[2][3] = 0.0f;
|
||||||
|
exp_mat.m[3][3] = 1.0f;
|
||||||
|
|
||||||
|
D3DXMatrixTransformation2D(&got_mat, &sca_center, sca_rot, &sca, &rot_center, rot, &trans);
|
||||||
|
|
||||||
|
expect_mat(&exp_mat, &got_mat);
|
||||||
|
|
||||||
|
/*_________*/
|
||||||
|
|
||||||
|
sca_center.x = 9.0f;
|
||||||
|
sca_center.y = -5.0f;
|
||||||
|
|
||||||
|
trans.x = -6.0f;
|
||||||
|
trans.y = 7.0f;
|
||||||
|
|
||||||
|
rot = D3DX_PI/3.0f;
|
||||||
|
|
||||||
|
sca_rot = 5.0f*D3DX_PI/4.0f;
|
||||||
|
|
||||||
|
exp_mat.m[0][0] = 0.0f;
|
||||||
|
exp_mat.m[1][0] = 0.0f;
|
||||||
|
exp_mat.m[2][0] = 0.0f;
|
||||||
|
exp_mat.m[3][0] = 2.830127f;
|
||||||
|
exp_mat.m[0][1] = 0.0f;
|
||||||
|
exp_mat.m[1][1] = 0.0f;
|
||||||
|
exp_mat.m[2][1] = 0.0f;
|
||||||
|
exp_mat.m[3][1] = 12.294229f;
|
||||||
|
exp_mat.m[0][2] = 0.0f;
|
||||||
|
exp_mat.m[1][2] = 0.0f;
|
||||||
|
exp_mat.m[2][2] = 0.0f;
|
||||||
|
exp_mat.m[3][2] = 0.0f;
|
||||||
|
exp_mat.m[0][3] = 0.0f;
|
||||||
|
exp_mat.m[1][3] = 0.0f;
|
||||||
|
exp_mat.m[2][3] = 0.0f;
|
||||||
|
exp_mat.m[3][3] = 1.0f;
|
||||||
|
|
||||||
|
D3DXMatrixTransformation2D(&got_mat, &sca_center, sca_rot, NULL, NULL, rot, &trans);
|
||||||
|
|
||||||
|
expect_mat(&exp_mat, &got_mat);
|
||||||
|
}
|
||||||
|
|
||||||
static void test_D3DXVec_Array(void)
|
static void test_D3DXVec_Array(void)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
@ -725,5 +803,6 @@ START_TEST(math)
|
||||||
{
|
{
|
||||||
test_Matrix_AffineTransformation2D();
|
test_Matrix_AffineTransformation2D();
|
||||||
test_Matrix_Decompose();
|
test_Matrix_Decompose();
|
||||||
|
test_Matrix_Transformation2D();
|
||||||
test_D3DXVec_Array();
|
test_D3DXVec_Array();
|
||||||
}
|
}
|
||||||
|
|
|
@ -296,6 +296,7 @@ D3DXMATRIX* WINAPI D3DXMatrixRotationZ(D3DXMATRIX *pout, FLOAT angle);
|
||||||
D3DXMATRIX* WINAPI D3DXMatrixScaling(D3DXMATRIX *pout, FLOAT sx, FLOAT sy, FLOAT sz);
|
D3DXMATRIX* WINAPI D3DXMatrixScaling(D3DXMATRIX *pout, FLOAT sx, FLOAT sy, FLOAT sz);
|
||||||
D3DXMATRIX* WINAPI D3DXMatrixShadow(D3DXMATRIX *pout, CONST D3DXVECTOR4 *plight, CONST D3DXPLANE *pPlane);
|
D3DXMATRIX* WINAPI D3DXMatrixShadow(D3DXMATRIX *pout, CONST D3DXVECTOR4 *plight, CONST D3DXPLANE *pPlane);
|
||||||
D3DXMATRIX* WINAPI D3DXMatrixTransformation(D3DXMATRIX *pout, CONST D3DXVECTOR3 *pscalingcenter, CONST D3DXQUATERNION *pscalingrotation, CONST D3DXVECTOR3 *pscaling, CONST D3DXVECTOR3 *protationcenter, CONST D3DXQUATERNION *protation, CONST D3DXVECTOR3 *ptranslation);
|
D3DXMATRIX* WINAPI D3DXMatrixTransformation(D3DXMATRIX *pout, CONST D3DXVECTOR3 *pscalingcenter, CONST D3DXQUATERNION *pscalingrotation, CONST D3DXVECTOR3 *pscaling, CONST D3DXVECTOR3 *protationcenter, CONST D3DXQUATERNION *protation, CONST D3DXVECTOR3 *ptranslation);
|
||||||
|
D3DXMATRIX* WINAPI D3DXMatrixTransformation2D(D3DXMATRIX *pout, CONST D3DXVECTOR2 *pscalingcenter, FLOAT scalingrotation, CONST D3DXVECTOR2 *pscaling, CONST D3DXVECTOR2 *protationcenter, FLOAT rotation, CONST D3DXVECTOR2 *ptranslation);
|
||||||
D3DXMATRIX* WINAPI D3DXMatrixTranslation(D3DXMATRIX *pout, FLOAT x, FLOAT y, FLOAT z);
|
D3DXMATRIX* WINAPI D3DXMatrixTranslation(D3DXMATRIX *pout, FLOAT x, FLOAT y, FLOAT z);
|
||||||
D3DXMATRIX* WINAPI D3DXMatrixTranspose(D3DXMATRIX *pout, CONST D3DXMATRIX *pm);
|
D3DXMATRIX* WINAPI D3DXMatrixTranspose(D3DXMATRIX *pout, CONST D3DXMATRIX *pm);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue