Billboard woes
I''m just about at the end of my wits from reading my code over and over again trying to solve this problem. I''ve copied code off this forum, from the sdk examples.... it just won''t work.
My billboards are rotating to face the camera, but they do not retain their world positions!!! I''ve put in the little translation bit, and it doesn''t seem to make a lot of difference. They just slide around whenever the view is rotated. Please, can anyone help a man in dispair. My code looks something like this:
D3DXMATRIX matTransposed,matView;
D3DXMatrixIdentity(&matTransposed);
D3DXMatrixIdentity(&matView);
//get the current view matrix
matView = g_pCamera->GetViewMatrix();
//get the transposed matrix
D3DXMatrixTranspose(&matTransposed, &matView);
matTransposed._14 = matTransposed._24 = matTransposed._34 = 0.0f;
// do rendering
for (int t=0; tm_vPosition.x;
matTransposed._42 = m_pTrees[t]->m_vPosition.y;
matTransposed._43 = m_pTrees[t]->m_vPosition.z;
g_pd3dDevice->SetTransform( D3DTS_WORLD, &matTransposed );
if (FAILED(m_pTrees[t]->Render())) return E_FAIL;
}
The billboard matrix in the inverse of the camera matrix, not the transposed matrix.
HTH
Laurent -- http://www.jeux-directx.com/
HTH
Laurent -- http://www.jeux-directx.com/
Instead of placing the x,y,z of your trees into your transposed matrix, I think this may work:
D3DXMATRIX matWorld;
D3DXMatrixTranslation(&matWorld, m_pTrees[t]->m_vPosition.x, m_pTrees[t]->m_vPosition.y, m_pTrees[t]->m_vPosition.z);
D3DXMatrixMultiply(&matWorld,&matTransposed,&matWorld);
g_pd3dDevice->SetTransform(D3DTS_WORLD, &matWorld);
D3DXMATRIX matWorld;
D3DXMatrixTranslation(&matWorld, m_pTrees[t]->m_vPosition.x, m_pTrees[t]->m_vPosition.y, m_pTrees[t]->m_vPosition.z);
D3DXMatrixMultiply(&matWorld,&matTransposed,&matWorld);
g_pd3dDevice->SetTransform(D3DTS_WORLD, &matWorld);
is directdraw totaly dead? cause im using dx7 still but i heard about those billboard used with direct3d and i was wondering if it was a better way to do 2d?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement