Archived

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

billboarding

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

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->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 on other sites

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 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 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 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 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 on other sites
Does the projection need to be set to orthographic before I get the view matrix?

1. 1
Rutin
42
2. 2
3. 3
4. 4
5. 5

• 9
• 27
• 20
• 9
• 15
• Forum Statistics

• Total Topics
633392
• Total Posts
3011636
• Who's Online (See full list)

There are no registered users currently online

×