D3DXMATRIX* WINAPI D3DXMatrixTransformation2D(
D3DXMATRIX *pOut, //연산 결과 행렬
CONST D3DXVECTOR2* pScalingCenter, //스케일 중심점 지정, NULL(=0,0), 0,0 이미지 왼쪽 상단인듯
FLOAT ScalingRotation, //확대 회전 요소를 지정, pScaling 의 x,y의 확대비율이 다른 경우에
//영향을 준다.
CONST D3DXVECTOR2* pScaling, //확대율을 지정 , NULL 은 스케일 하지 않음
CONST D3DXVECTOR2* pRotationCenter, //회전 중심점 NULL(=0,0)
FLOAT Rotation, //회전 각도(Radian 단위), 우회전 기준
CONST D3DXVECTOR2* pTranslation //평행이동 NULL(=0,0)
);
David Adam : d3dx8: Implement D3DXMatrixTransformation2D.
Alexandre Julliard julliard at winehq.orgThu Nov 13 08:51:46 CST 2008
- Previous message: David Adam : d3dx8: Implement D3DXMatrixAffineTransformation2D.
- Next message: Paul Vriens : gdi32/tests: Fix a few failures on Win9x and WinMe.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Module: wine Branch: master Commit: 09c6caea062c4aeaaea874bf6805ba31afdce39d URL: http://source.winehq.org/git/wine.git/?a=commit;h=09c6caea062c4aeaaea874bf6805ba31afdce39d Author: David Adam <david.adam.cnrs at gmail.com> Date: Wed Nov 12 19:16:30 2008 +0100 d3dx8: Implement D3DXMatrixTransformation2D. --- dlls/d3dx9_36/d3dx9_36.spec | 2 +- dlls/d3dx9_36/math.c | 80 +++++++++++++++++++++++++++++++++++++++++++ dlls/d3dx9_36/tests/math.c | 79 ++++++++++++++++++++++++++++++++++++++++++ include/d3dx9math.h | 1 + 4 files changed, 161 insertions(+), 1 deletions(-) diff --git a/dlls/d3dx9_36/d3dx9_36.spec b/dlls/d3dx9_36/d3dx9_36.spec index 9058dd7..d7fba36 100644 --- a/dlls/d3dx9_36/d3dx9_36.spec +++ b/dlls/d3dx9_36/d3dx9_36.spec @@ -225,7 +225,7 @@ @ stdcall D3DXMatrixScaling(ptr long long long) d3dx8.D3DXMatrixScaling @ stdcall D3DXMatrixShadow(ptr ptr ptr) d3dx8.D3DXMatrixShadow @ 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 D3DXMatrixTranspose(ptr ptr) d3dx8.D3DXMatrixTranspose @ stub D3DXOptimizeFaces diff --git a/dlls/d3dx9_36/math.c b/dlls/d3dx9_36/math.c index b5cdde2..a00ffc5 100644 --- a/dlls/d3dx9_36/math.c +++ b/dlls/d3dx9_36/math.c @@ -1,6 +1,7 @@ /* * Mathematical operations specific to D3DX9. * + * Copyright (C) 2008 David Adam * Copyright (C) 2008 Philip Nilsson * * This library is free software; you can redistribute it and/or @@ -130,6 +131,85 @@ HRESULT WINAPI D3DXMatrixDecompose(D3DXVECTOR3 *poutscale, D3DXQUATERNION *poutr } /************************************************************************* + * 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 */ D3DXPLANE* WINAPI D3DXPlaneTransformArray( diff --git a/dlls/d3dx9_36/tests/math.c b/dlls/d3dx9_36/tests/math.c index 2930d34..cc71b33 100644 --- a/dlls/d3dx9_36/tests/math.c +++ b/dlls/d3dx9_36/tests/math.c @@ -1,4 +1,5 @@ /* + * Copyright 2008 David Adam * Copyright 2008 Philip Nilsson * * 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); } +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) { unsigned int i; @@ -725,5 +803,6 @@ START_TEST(math) { test_Matrix_AffineTransformation2D(); test_Matrix_Decompose(); + test_Matrix_Transformation2D(); test_D3DXVec_Array(); } diff --git a/include/d3dx9math.h b/include/d3dx9math.h index 9992919..83b8749 100644 --- a/include/d3dx9math.h +++ b/include/d3dx9math.h @@ -296,6 +296,7 @@ D3DXMATRIX* WINAPI D3DXMatrixRotationZ(D3DXMATRIX *pout, FLOAT angle); D3DXMATRIX* WINAPI D3DXMatrixScaling(D3DXMATRIX *pout, FLOAT sx, FLOAT sy, FLOAT sz); 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 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 D3DXMatrixTranspose(D3DXMATRIX *pout, CONST D3DXMATRIX *pm);
반응형
'수학 (Mathematics) > 3D수학' 카테고리의 다른 글
GPU 에서 노멀맵 굽기 (0) | 2012.11.02 |
---|---|
표면 스케터링으로 실시간 근사 (0) | 2012.11.02 |
로컬좌표와 월드 좌표 (0) | 2012.11.02 |
라디오시티 (0) | 2012.11.02 |
에르미트 (0) | 2012.11.02 |