Original Post
Greetings, I have created a particle system that uses billboards. I also have a camera class I wrote that I am using to move around the world to test the billboard effect. It appears that something I'm doing when I rotate the billboards to face the user is really screwing up my camera. If I try to rotate my camera, it instead faces in the same direction it was facing and orbits in a circle around the origin. Here is the code I'm using to rotate the billboards, which basically inverts the view matrix and sets it as the world matrix: My camera performs rotation calculations using Up, Right, and Look vectors, which are transformed and placed in the view matrix: Any help is much appreciated! [Edited by - Shadowflare on March 25, 2007 1:36:40 AM]
m_lpDevice->GetTransform(D3DTS_VIEW, &m_mtxView);
D3DXMatrixInverse(&m_mtxBillboard, NULL, &m_mtxView);
// Don't want to translate to the camera
m_mtxBillboard._41 = 0.0f;
m_mtxBillboard._42 = 0.0f;
m_mtxBillboard._43 = 0.0f;
m_lpDevice->SetTransform(D3DTS_WORLD, &m_mtxBillboard);
// ...draw the particles...
D3DXMatrixIdentity(&m_mtxBillboard);
m_lpDevice->SetTransform(D3DTS_WORLD, &m_mtxBillboard);
m_vecUp = D3DXVECTOR3(0.0f, 1.0f, 0.0f);
m_vecRight = D3DXVECTOR3(1.0f, 0.0f, 0.0f);
m_vecView = D3DXVECTOR3(0.0f, 0.0f, 1.0f);
D3DXMatrixRotationAxis(&mtxYaw, &m_vecUp, m_fYaw);
D3DXVec3TransformCoord(&m_vecView, &m_vecView, &mtxYaw);
D3DXVec3TransformCoord(&m_vecRight, &m_vecRight, &mtxYaw);
D3DXMatrixIdentity(&m_mtxView);
m_mtxView._11 = m_vecRight.x; m_mtxView._12 = m_vecUp.x; m_mtxView._13 = m_vecView.x;
m_mtxView._21 = m_vecRight.y; m_mtxView._22 = m_vecUp.y; m_mtxView._23 = m_vecView.y;
m_mtxView._31 = m_vecRight.z; m_mtxView._32 = m_vecUp.z; m_mtxView._33 = m_vecView.z;
m_mtxView._41 = -D3DXVec3Dot(&m_vecEye, &m_vecRight);
m_mtxView._42 = -D3DXVec3Dot(&m_vecEye, &m_vecUp);
m_mtxView._43 = -D3DXVec3Dot(&m_vecEye, &m_vecView);
m_lpDevice->SetTransform(D3DTS_VIEW, &m_mtxView);