Jump to content
  • Advertisement
Sign in to follow this  
leggyguy

Axis Billboarding - how?

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

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 viewer
g3D->mDevice->GetTransform(D3DTS_VIEW, &matView);
D3DXVECTOR3 up(matView._21, matView._22, matView._23);

// second, create your beam
D3DXVECTOR3 * 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 this post


Link to post
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 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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!