• Advertisement


This topic is now archived and is closed to further replies.

Using D3DXmatrix, how to have billboarded object face me on certain angle?

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

Hi, im doing the billboarding stuff, ive got one function that does the position,rotation,scale for the world matrix, then another function that gets that matrix and multiplies it by the billboard matrix which is the transpose of the view matrix. this is fine, it makes objects face me wherever i go. what im trying to do is make the object face me at an angle. eg say ive set the x-axis rotation in the world matrix to 2, i want the object on the x-axis to face me at the angle 2, not 0. But when i try this using what ive got so far, the object goes nuts, and gets large on the screen. So does anyone know how to make it face me on the angle i set? heres my source so far.
void setWorldBillboard()
	D3DXMATRIXA16 matOriginal, matBillboard, matView,matRot;
	D3DXMatrixTranspose(&matBillboard, &matView);

	lp_Device->SetTransform( D3DTS_WORLD, &matBillboard);

void setWorld(D3DXVECTOR3 position, D3DXVECTOR3 rotation, D3DXVECTOR3 scale)
	D3DXMATRIXA16 matRot, matWorld,matScale;
	D3DXMatrixTranslation(&matWorld , position.x ,position.y,position.z);
	D3DXMatrixScaling(&matScale, scale.x, scale.y, scale.z);
	D3DXMatrixRotationYawPitchRoll(&matRot,rotation.y, rotation.x, rotation.z);
	lp_Device->SetTransform( D3DTS_WORLD, &matWorld);

//and i call them like so

//setting the xAxis rotation at 2

thanks, [edited by - johnnyBravo on February 26, 2004 12:49:17 AM]

Share this post

Link to post
Share on other sites

  • Advertisement