Advertisement Jump to content
Sign in to follow this  

[C++, DX9] Trouble rotating billboard sprite

This topic is 4502 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 there, I used ID3DXSPRITE to create my billboard sprites but I'm having some trouble spinning them around the Z-axis. The rotation works fine if I'm not using the billboard flags though (D3DXSPRITE_OBJECTSPACE | D3DXSPRITE_BILLBOARD). Can anyone tell me what I'm doing wrong? Thanks! Here're some code snippet if it helps:
m_graphics->GetSpriteCOM()->SetWorldViewLH(m_worldPos.GetMatrix(m_graphics), m_camera.GetMatrix());


D3DXMATRIX matScale;
D3DXMatrixScaling(&matScale, m_scale.x, -m_scale.y, 1.0f);
D3DXMATRIX matRotate;
D3DXMatrixRotationZ(&matRotate, D3DXToRadian(m_rotation));
m_group->GetID3DXSprite()->SetTransform(&(matScale * matRotate));
spritePos = D3DXVECTOR3(m_pos.x, -m_pos.y, m_pos.z);

if (FAILED(m_group->GetID3DXSprite()->Draw((m_group->GetTexture()->GetTexture()),	// The texture we want to draw from
				&srcRect,   // Clipping area to get image from
				&D3DXVECTOR3(m_center.x, m_center.y, 0.0f),   // Center of sprite rotation
				&spritePos,   // X, Y, Z position of image
				m_argb)))   // Color tint
		return FALSE;

Share this post

Link to post
Share on other sites
No one tried rotating ID3DXSPRITE billboards before? [sad]

After some further testing, the billboard sprite seems to be moving in circles instead of rotating... and it does a quick 180 degrees flip while moving through the lower half of the movement circle (hope that makes sense).

Could it be due to problem with the matrices that I passed into SetWorldViewLH?

Share this post

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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!