I have a nice little fireworks demo running, and I thought for the heck of it I'd spin the "ball of particles" that comprises the fireworks. To do this, I assumed that the steps were:
- Translate back to origin from where it lives in space
- Apply rotation matrices for X, Y, Z
- Translate back to where object lived in space
- Set that as the World matrix before drawing the object (leaving projection and view completely alone)
It does not work as I would expect (or at all, really). It just jumps around a bunch but largely stays put (no rotation). I'm placing that new world matrix into the shader before drawing the instance. I know all that works, as it draws them without rotation exactly as I'd hoped. It's just my application of rotation that has broken everything...
Either I've got a really ugly bug or a very poor grasp of how to compose such a matrix. A prod in either direction would be very much appreciated!
D3DXMATRIX matrixTranslateBefore; D3DXMATRIX matrixRotationX; D3DXMATRIX matrixRotationY; D3DXMATRIX matrixRotationZ; D3DXMATRIX matrixTranslateAfter; float rads = fElapsedTime * 50.0f; D3DXMatrixTranslation(&matrixTranslateBefore, -pExplosion->_centerPosition.x, -pExplosion->_centerPosition.y, -pExplosion->_centerPosition.z); D3DXMatrixRotationX(&matrixRotationX, rads); D3DXMatrixRotationY(&matrixRotationY, rads); D3DXMatrixRotationZ(&matrixRotationZ, rads); D3DXMatrixTranslation(&matrixTranslateAfter, pExplosion->_centerPosition.x, pExplosion->_centerPosition.y, pExplosion->_centerPosition.z); pCameraManager->_worldMatrix = matrixTranslateBefore * matrixRotationX * matrixRotationY * matrixRotationZ * matrixTranslateAfter;