#### Archived

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 5405 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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;
lp_Device->GetTransform(D3DTS_WORLD,&matOriginal);
lp_Device->GetTransform(D3DTS_VIEW,&matView);

D3DXMatrixTranspose(&matBillboard, &matView);
D3DXMatrixMultiply(&matBillboard,&matBillboard,&matOriginal);

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);
D3DXMatrixMultiply(&matWorld,&matScale,&matWorld);
D3DXMatrixRotationYawPitchRoll(&matRot,rotation.y, rotation.x, rotation.z);
D3DXMatrixMultiply(&matWorld,&matRot,&matWorld);
lp_Device->SetTransform( D3DTS_WORLD, &matWorld);
}

//and i call them like so

//setting the xAxis rotation at 2

setWorld(D3DXVECTOR3(0,0,0),D3DXVECTOR3(2,0,0),D3DXVECTOR3(1,1,1));
setWorldBillboard();

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

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5

• 11
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633722
• Total Posts
3013540
×