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

Mister Stewart

Billboarding prob...

Recommended Posts

Mister Stewart    122
hi all. I''m working on my own billboarding demo, and I''ve come across a little problem. the actual billboarding part works fine, but when the bitmaps are drawn, you can see the whole quad(including the part that should be transparent/non visible) All I did was add the matrix transpose code, and it was fine beforehand. Any ideas as to what may have caused this? Thanks "Dear MacGuyver, here is a paper clip, a rubber band and a straw - please save my dog."

Share this post

Link to post
Share on other sites
invective    118
You did not enable alpha testing or the texture has no alpha channel. It has nothing to do with the billboard matrix. OpenGL or Direct X? Post your texture op setup code.

Share this post

Link to post
Share on other sites
Mister Stewart    122
???how do you post texture files on here? It's the "Star.bmp" from the DrunkenHyena tutorials. The following code segments are posted in the order in which they are run...

anyway, this in in the actual particle constructor

global_device->SetTextureStageState(0,D3DTSS_COLOROP, D3DTOP_SELECTARG1);
global_device->SetTextureStageState(0,D3DTSS_COLORARG1, D3DTA_TEXTURE); //color comes from the texture
global_device->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);//this should turn on the transparency
global_device->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);

this is in the main D3D setup

//set up the render states
g_pDevice->SetRenderState(D3DRS_LIGHTING, TRUE);
g_pDevice->SetRenderState(D3DRS_AMBIENT, 0x33333333);
g_pDevice->SetRenderState(D3DRS_DITHERENABLE, TRUE);
g_pDevice->SetRenderState(D3DRS_ZENABLE, TRUE);
g_pDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);

g_pDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE); g_pDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_ONE);
g_pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);

g_pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
g_pDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
g_pDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
g_pDevice->SetTextureStageState(0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR);
g_pDevice->SetTextureStageState(0, D3DTSS_MINFILTER, D3DTEXF_LINEAR);

//set up the glowing stuff (textureStageState)
g_pDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
g_pDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
g_pDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TFACTOR); //controls the colour of the particle

g_pDevice->SetRenderState(D3DRS_TEXTUREFACTOR, D3DCOLOR_ARGB(0xFF, r,g,b));

and this is located in the main render loop

if(billBoardOnOff == true)
g_pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);

//shold check the d3dcaps before doing this part
g_pDevice->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE);
g_pDevice->SetRenderState(D3DRS_ALPHAREF, 0x00000000);

Dir.x = g_xLookAt - g_xEye;
Dir.y = g_yLookAt - g_yEye;
Dir.z = g_zLookAt - g_zEye;

if(Dir.x > 0.0f)
D3DXMatrixRotationY(&g_bbMatrix, -atanf(Dir.z/Dir.x) + 3.14/2);
D3DXMatrixRotationY(&g_bbMatrix, -atanf(Dir.z/Dir.x) - 3.14/2);

D3DXMatrixMultiply(&world_mat, &g_bbMatrix, &world_mat);

g_pDevice->SetTransform(D3DTS_WORLD, &world_mat);

particles[ i ]->draw(g_pDevice);

"Dear MacGuyver, here is a paper clip, a rubber band and a straw - please save my dog."

[edited by - Mister Stewart on January 23, 2004 10:43:28 AM]

[edited by - Mister Stewart on January 23, 2004 10:45:14 AM]

Share this post

Link to post
Share on other sites