• Advertisement
Sign in to follow this  

Billboarding on all 3 axis

This topic is 3387 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
Here are two links which discuss (amongst other things) keeping the billboards facing the camera:

Link1
Link2

Share this post


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

  • Advertisement