Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Member Since 28 Apr 2012
Offline Last Active Oct 20 2012 12:44 AM

Posts I've Made

In Topic: Rotation around maintained arbitrary axis.

17 May 2012 - 10:25 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

In Topic: Simple question about transparent textures and what can be seen though them.

28 April 2012 - 06:25 PM

Thanks a million, I'll start work on that right away.