Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Chaucer

billboarding

This topic is 5677 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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);

Share this post


Link to post
Share on other sites

  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]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!