Sign in to follow this  

Billboarding on all 3 axis

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this