•      Sign In
• Create Account

### #ActualZerocyde

Posted 17 May 2012 - 10:28 PM

I found a solution. This is what ended up working for me:

D3DXMATRIX yawMatrix, pitchMatrix, rollMatrix, combined;

// rotate around your 3 maintained axis
D3DXMatrixRotationAxis(&yawMatrix, &up, yaw);
D3DXMatrixRotationAxis(&pitchMatrix, &right, pitch);
D3DXMatrixRotationAxis(&rollMatrix, &look, roll);

// combined them into one rotation matrix
D3DXMatrixMultiply(&combined, &yawMatrix, &pitchMatrix);
D3DXMatrixMultiply(&combined, &rollMatrix, &combined);

// rotate 2 of the axis by the combined rotation matrix and build the third using cross product
D3DXVec3TransformCoord(&right, &right, &combined);
D3DXVec3TransformCoord(&up, &up, &combined);
D3DXVec3Cross(&look, &right, &up);

// normalize all 3 axis
D3DXVec3Normalize(&right, &right);
D3DXVec3Normalize(&up, &up);
D3DXVec3Normalize(&look, &look);

// build the final matrix like this
rotMatrix = D3DXMATRIX
(
right.x, right.y, right.z, 0.0f,
up.x, up.y, up.z, 0.0f,
look.x, look.y, look.z, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f
);


### #2Zerocyde

Posted 17 May 2012 - 10:28 PM

I found a solution. This is what ended up working for me:

D3DXMATRIX yawMatrix, pitchMatrix, rollMatrix, combined;

// rotate around your 3 maintained axis
D3DXMatrixRotationAxis(&yawMatrix, &up, yaw);
D3DXMatrixRotationAxis(&pitchMatrix, &right, pitch);
D3DXMatrixRotationAxis(&rollMatrix, &look, roll);

// combined them into one rotation matrix
D3DXMatrixMultiply(&combined, &yawMatrix, &pitchMatrix);
D3DXMatrixMultiply(&combined, &rollMatrix, &combined);

// build rotate 2 of the axis by the combined rotation matrix and build the third using cross product
D3DXVec3TransformCoord(&right, &right, &combined);
D3DXVec3TransformCoord(&up, &up, &combined);
D3DXVec3Cross(&look, &right, &up);

// normalize all 3 axis
D3DXVec3Normalize(&right, &right);
D3DXVec3Normalize(&up, &up);
D3DXVec3Normalize(&look, &look);

// build the final matrix like this
rotMatrix = D3DXMATRIX
(
right.x, right.y, right.z, 0.0f,
up.x, up.y, up.z, 0.0f,
look.x, look.y, look.z, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f
);


### #1Zerocyde

Posted 17 May 2012 - 10:25 PM

I found a solution. This is what ended up working for me:

D3DXMATRIX yawMatrix, pitchMatrix, rollMatrix, combined;

D3DXMatrixRotationAxis(&yawMatrix, &up, yaw);
D3DXMatrixRotationAxis(&pitchMatrix, &right, pitch);
D3DXMatrixRotationAxis(&rollMatrix, &look, roll);
D3DXMatrixMultiply(&combined, &yawMatrix, &pitchMatrix);
D3DXMatrixMultiply(&combined, &rollMatrix, &combined);
D3DXVec3TransformCoord(&right, &right, &combined);
D3DXVec3TransformCoord(&up, &up, &combined);
D3DXVec3Cross(&look, &right, &up);
D3DXVec3Normalize(&right, &right);
D3DXVec3Normalize(&up, &up);
D3DXVec3Normalize(&look, &look);
rotMatrix = D3DXMATRIX
(
right.x, right.y, right.z, 0.0f,
up.x, up.y, up.z, 0.0f,
look.x, look.y, look.z, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f
);


PARTNERS