billboarding

Started by
5 comments, last by Chaucer 21 years, 2 months ago
I''m trying to make this billboarding as simple as possible, taking out transparency, translations, scaling, etc first just so I can get it to work. Can anyone see a problem with what I''m doing?
  
D3DXMATRIX transposedMatrix, viewMatrix;			 
m_pd3dDevice->GetTransform(D3DTS_VIEW, &viewMatrix);
D3DXMatrixTranspose(&transposedMatrix, &viewMatrix);  	
m_pd3dDevice->SetTransform(D3DTS_WORLD, &transposedMatrix);
m_pd3dDevice->SetStreamSource(0, m_pVertexBuffer, sizeof(BILLBOARD_VERTEX));
m_pd3dDevice->SetVertexShader(D3DFVF_BILLBOARD_VERTEX);
m_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP,0,2);	
  
Whats happening is that the billboard is fanning in and out as I rotate the camera. My vertices are set up like this: m_pVertices[0].position = D3DXVECTOR3(0.0f, 0.0f, 0.0f); m_pVertices[1].position = D3DXVECTOR3(0.0f, 1.0f, 0.0f); m_pVertices[2].position = D3DXVECTOR3(1.0f, 0.0f, 0.0f); m_pVertices[3].position = D3DXVECTOR3(1.0f, 1.0f, 0.0f); m_pVertices[0].tu = 0; m_pVertices[0].tv = 0; m_pVertices[1].tu = 0; m_pVertices[1].tv = 1; m_pVertices[2].tu = 1; m_pVertices[2].tv = 0; m_pVertices[3].tu = 1; m_pVertices[3].tv = 1; The texture isn''t showing up correctly either.
Thanks!
Advertisement

You''re not setting the translation, so it''s going to be whatever happens to be in the Transpose. If you want no translation at all, just set the to zero, otherwise set them to something:

world_matrix._41 = x;
world_matrix._42 = y;
world_matrix._43 = z;



Stay Casual,

Ken
Drunken Hyena
Stay Casual,KenDrunken Hyena
So I actually HAVE to do a translation? I tried this and can''t see the billboard at all:

  D3DXMATRIX transposedMatrix, worldMatrix, viewMatrix;m_pd3dDevice->GetTransform(D3DTS_VIEW, &viewMatrix);D3DXMatrixTranspose(&transposedMatrix, &viewMatrix);  	worldMatrix._41 = 0;worldMatrix._42 = 0;worldMatrix._43 = 0;D3DXMatrixMultiply(&worldMatrix, &worldMatrix, &transposedMatrix);m_pd3dDevice->SetTransform(D3DTS_WORLD, &worldMatrix);m_pd3dDevice->SetStreamSource(0, m_pVertexBuffer, sizeof(BILLBOARD_VERTEX));m_pd3dDevice->SetVertexShader(D3DFVF_BILLBOARD_VERTEX);m_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP,0,2);  
Thanks!

  D3DXMATRIX transposedMatrix, viewMatrix;m_pd3dDevice->GetTransform(D3DTS_VIEW, &viewMatrix);D3DXMatrixTranspose(&transposedMatrix, &viewMatrix);  transposedMatrix._41 = 0;transposedMatrix._42 = 0;transposedMatrix._43 = 0;m_pd3dDevice->SetTransform(D3DTS_WORLD, &transposedMatrix);m_pd3dDevice->SetStreamSource(0, m_pVertexBuffer, sizeof(BILLBOARD_VERTEX));m_pd3dDevice->SetVertexShader(D3DFVF_BILLBOARD_VERTEX);m_pd3dDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP,0,2);   


[edited by - nlo on February 3, 2003 2:21:54 AM]
quote:Original post by Chaucer
So I actually HAVE to do a translation? I tried this and can''t see the billboard at all:


You don''t HAVE to do translation, but you were without realizing it. Those 3 members of the matrix are the translation component and they were non-zero. The code nlo posted was what I meant.


Stay Casual,

Ken
Drunken Hyena
Stay Casual,KenDrunken Hyena
Ah, thanks. The billboard is still starting out looking like a triangle at 0,0,0 and then fanning out into a long rectangle and moves as I move the camera. I guess there must be something else going on that doesn''t have to do with this code.
Thanks!
Does the projection need to be set to orthographic before I get the view matrix?
Thanks!

This topic is closed to new replies.

Advertisement