Jump to content
  • Advertisement
Sign in to follow this  
blueshogun96

Billboarding on all 3 axis

This topic is 3510 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 recently learned how to do billboarding by reading an old Direct3D SDK sample. It only shows how to billboard objects on the Y axis, and I was wondering how does it work with the X and Z axis? I tried playing around and trying to learn myself and searching google, but google was not my friend. Here's my code
// Set up the billboard matrix
	vecDir = camera.vecLookAt - camera.vecPosition;

	if( vecDir.x > 0.0f )
		D3DXMatrixRotationY( &mtxBillboard, -atanf( vecDir.z/vecDir.x ) + D3DX_PI/2 );
	else
		D3DXMatrixRotationY( &mtxBillboard, -atanf( vecDir.z/vecDir.x ) - D3DX_PI/2 );

	D3DXMatrixMultiply( &mtxWorld, &mtxWorld, &mtxBillboard );
	pD3DDevice->SetTransform( D3DTS_WORLD, &mtxWorld );
Any ideas? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!