d3dx9: Improve D3DXMatrixRotationYawPitchRoll().

This commit is contained in:
Rico Schüller 2012-12-04 22:10:46 +01:00 committed by Alexandre Julliard
parent 6ac3c48384
commit 2cb1372350
1 changed files with 28 additions and 11 deletions

View File

@ -631,20 +631,37 @@ D3DXMATRIX* WINAPI D3DXMatrixRotationY(D3DXMATRIX *pout, FLOAT angle)
return pout; return pout;
} }
D3DXMATRIX* WINAPI D3DXMatrixRotationYawPitchRoll(D3DXMATRIX *pout, FLOAT yaw, FLOAT pitch, FLOAT roll) D3DXMATRIX * WINAPI D3DXMatrixRotationYawPitchRoll(D3DXMATRIX *out, FLOAT yaw, FLOAT pitch, FLOAT roll)
{ {
D3DXMATRIX m; FLOAT sroll, croll, spitch, cpitch, syaw, cyaw;
TRACE("(%p, %f, %f, %f)\n", pout, yaw, pitch, roll); TRACE("out %p, yaw %f, pitch %f, roll %f\n", out, yaw, pitch, roll);
D3DXMatrixIdentity(pout); sroll = sinf(roll);
D3DXMatrixRotationZ(&m, roll); croll = cosf(roll);
D3DXMatrixMultiply(pout, pout, &m); spitch = sinf(pitch);
D3DXMatrixRotationX(&m, pitch); cpitch = cosf(pitch);
D3DXMatrixMultiply(pout, pout, &m); syaw = sinf(yaw);
D3DXMatrixRotationY(&m, yaw); cyaw = cosf(yaw);
D3DXMatrixMultiply(pout, pout, &m);
return pout; out->u.m[0][0] = sroll * spitch * syaw + croll * cyaw;
out->u.m[0][1] = sroll * cpitch;
out->u.m[0][2] = sroll * spitch * cyaw - croll * syaw;
out->u.m[0][3] = 0.0f;
out->u.m[1][0] = croll * spitch * syaw - sroll * cyaw;
out->u.m[1][1] = croll * cpitch;
out->u.m[1][2] = croll * spitch * cyaw + sroll * syaw;
out->u.m[1][3] = 0.0f;
out->u.m[2][0] = cpitch * syaw;
out->u.m[2][1] = -spitch;
out->u.m[2][2] = cpitch * cyaw;
out->u.m[2][3] = 0.0f;
out->u.m[3][0] = 0.0f;
out->u.m[3][1] = 0.0f;
out->u.m[3][2] = 0.0f;
out->u.m[3][3] = 1.0f;
return out;
} }
D3DXMATRIX* WINAPI D3DXMatrixRotationZ(D3DXMATRIX *pout, FLOAT angle) D3DXMATRIX* WINAPI D3DXMatrixRotationZ(D3DXMATRIX *pout, FLOAT angle)