Jump to content
  • Advertisement
Sign in to follow this  

Billboarding on all 3 axis

This topic is 3604 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 );
		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
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!