#### Archived

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

# Billboarding

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

## Recommended Posts

I''m having a problem with Billboarding my particle system. Everything was perfect until I had to multiply my local matrix of my parent object with my BillboardRot matrix. Here is the original code without multiplying the local Matrix: D3DXMATRIX matTranspose, matBillboardRot, matWorld, Translate; D3DXMatrixTranspose(&matTranspose, &dx->mat_view); D3DXMatrixIdentity(&matBillboardRot); matBillboardRot._11 = matTranspose._11; matBillboardRot._12 = matTranspose._12; matBillboardRot._13 = matTranspose._13; matBillboardRot._21 = matTranspose._21; matBillboardRot._22 = matTranspose._22; matBillboardRot._23 = matTranspose._23; matBillboardRot._31 = matTranspose._31; matBillboardRot._32 = matTranspose._32; matBillboardRot._33 = matTranspose._33; CDXParticle *p= &m_rParticles[loop]; D3DXMatrixTranslation( &Translate,p->m_vLocation.x, p->m_vLocation.y, p->m_vLocation.z ); matWorld = matBillboardRot * Translate; dx->d3d_device->SetTransform( D3DTS_WORLD, &matWorld); Here is the code when I multipy the local Matrix: (I only show the code I changed) matWorld = matBillboardRot * Translate * mLocal; dx->d3d_device->SetTransform( D3DTS_WORLD, &matWorld); When I try to multiply the Local Matrix of my parent object the particle positions are perfect except they don''t face the camera anymore, which defeats the purpse. I tried to multyply the matBillboardRot, Translate, and mLocal in every possible order - yet the particles still will not face the camera anymore. Am I missing something? I was pretty sure it would be the order in which you multiplied the matrix''s. Can anyone help?

##### Share on other sites
For testing purposes only:

Does it work if you move the camera to the opposite side after you call the function below and then move it back prior to the call to the fucntion below?

##### Share on other sites
I solved the problem. What I really needed was the x,y,z location of the Parent object Matrix. I found the code I needed in Microsoft''s Direct3D sample code on Billboarding.

p->m_vLocation.x = mLocal._41;
p->m_vLocation.y = mLocal._42;
p->m_vLocation.z = mLocal._43;

D3DXMatrixTranslation( &Translate,p->m_vLocation.x,
p->m_vLocation.y,
p->m_vLocation.z );

matWorld = matBillboardRot * Translate;
dx->d3d_device->SetTransform( D3DTS_WORLD, &matWorld);

It works perfect now Apparently, unless I''m wrong, the location of the matrix (in world space) is stored in the variables, _41,_42,_43

1. 1
2. 2
Rutin
23
3. 3
4. 4
frob
16
5. 5

• 9
• 33
• 13
• 12
• 10
• ### Forum Statistics

• Total Topics
632579
• Total Posts
3007174

×