Jump to content
  • Advertisement
Sign in to follow this  

Billboard Position Problem

This topic is 4283 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

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:
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...

m_lpDevice->SetTransform(D3DTS_WORLD, &m_mtxBillboard);

My camera performs rotation calculations using Up, Right, and Look vectors, which are transformed and placed in the view matrix:
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);


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);

Any help is much appreciated! [Edited by - Shadowflare on March 25, 2007 1:36:40 AM]

Share this post

Link to post
Share on other sites
I figured out that the camera has nothing to do with it. Apparently the code I'm using to rotate the billboards to face the camera is distorting the position of the billboards. My code for figuring out the position and rotation of the billboard so it faces the camera is now:

lpDevice->GetTransform(D3DTS_VIEW, &mtxView);

D3DXMatrixInverse(&mtxBillboard, NULL, &mtxView);
// I also tried this with D3DXMatrixTranspose(&mtxBillboard, &mtxView) with similar but unsuccessful results.

mtxBillboard._41 = m_fPosX;
mtxBillboard._42 = m_fPosY;
mtxBillboard._43 = m_fPosZ;

lpDevice->SetTransform(D3DTS_WORLD, &mtxBillboard);

This is the method I've seen used in countless tutorials and programs I've found throughout the web (including threads on this forum). What is it that I'm doing wrong?


Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!