# Axis Billboarding - how?

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

## Recommended Posts

I am trying to fire a long laser beam from a space creaft within my game. Now, I need to use billboarding, but not the regular billboarding which rotates the board so that it is always facing the camera, but the method which only allows the board to rotate around a single axis. I can do the regular billboard system, with this:
Quote:
 g3D->mDevice->GetTransform(D3DTS_VIEW, &matView); // Elements 41, 42 and 43 (row 4, columns 1, 2 and 3) in the matrix represent the translation, so by // setting them to 0 we ensure no translation will occur. matView._41 = 0.0f; matView._42 = 0.0f; matView._43 = 0.0f; // Transpose the matrix (basically, switch the rows & columns of the matrix) D3DXMatrixTranspose(&matBillboardView, &matView);
I have tried other ways, and nothing is quite right. And my Direct sdk does not come with a billboard sample, which is annoying as I see some versions of the sdk do come with a billboard sample which does a single axis billboard. Could anyone help me out with this, and show me a little code? I would really appreciate that, or a link. My googling has driven me mad, and not helped me find what I need.

##### Share on other sites
You may just not be googling for the right terms - try 'axial billboarding'. This topic came up here recently, and as I recall that search turned up a good reference on different billboarding techniques.

##### Share on other sites
Hi,

I assume that your beam will be a quad which you'd like to be always Y aligned, right ?
Is so, instead of using a matrix, you could lock your beam buffer and move the 4 points of the quad. It would be a looot simpler ^^ (I hate math ^^)

// first step, get the "up" vector of the viewerg3D->mDevice->GetTransform(D3DTS_VIEW, &matView);D3DXVECTOR3 up(matView._21, matView._22, matView._23);// second, create your beamD3DXVECTOR3 * vb;vertexBuffer->Lock(0, 0, (void **)&vb, 0);vb[0] = D3DXVECTOR3(beamStartPosition.x, beamStartPosition.y - up.y, beamStartPosition.z);vb[1] = D3DXVECTOR3(beamStartPosition.x, beamStartPosition.y + up.y, beamStartPosition.z);vb[2] = D3DXVECTOR3(beamEndPosition.x, beamEndPosition.y - up.y, beamEndPosition.z);vb[3] = D3DXVECTOR3(beamEndPosition.x, beamEndPosition.y + up.y, beamEndPosition.z);vertexBuffer->UnLock(0);

I would do that only because I don't like math, and I would spend a lot more time finding how to do it with matrices. Doing it with matrices would still be faster I think ^^

##### Share on other sites
Thanks for the input, I'll give that a try, though I think using matrices would be faster, anything which works for now would be good.

As for the google option, seriously, try googling for "axial billboarding", the majority of results are people asking for help with it, and people responding "go google for it." There is very little direction/tutorial, if any at all.

##### Share on other sites

Link 3 (OpenGL, watch for Righthanded/Lefthanded matrix issues).

Hope this helps :).

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

• 9
• 27
• 20
• 14
• 14
• ### Forum Statistics

• Total Topics
633389
• Total Posts
3011629
• ### Who's Online (See full list)

There are no registered users currently online

×