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.

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

D3DXMatrixIdentity(&m_mtxBillboard);
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);

D3DXMatrixIdentity(&m_mtxView);

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 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);D3DXMatrixIdentity(&mtxBillboard);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?

Thanks!

Share on other sites
I figured it out. Very, very stupid mistake on my part.

1. 1
2. 2
Rutin
17
3. 3
4. 4
5. 5

• 9
• 26
• 10
• 11
• 9
• Forum Statistics

• Total Topics
633717
• Total Posts
3013511
×