ID3DXSprite problem

Started by
5 comments, last by johan_swe 20 years, 6 months ago
m_pD3DXSprite->Begin(D3DXSPRITE_ALPHABLEND); D3DXMATRIX matScaling; D3DXMatrixScaling(&matScaling, m_Scaling.x, m_Scaling.y, 1.0f); m_pD3DXSprite->SetTransform(&matScaling); m_pD3DXSprite->Draw(m_pTexture, NULL, NULL, D3DXVECTOR3(m_Pos.x, m_Pos.y, 0.0f), 0xFFFFFFFF); m_pD3DXSprite->End(); The problem is that the sprite is not being drawn on position (m_Pos.x, m_Pos.y). What is wrong? (poor use of english language, sorry)
Advertisement
It did not work for me either. Since you are using a transform just put your position information in the matrix along with the scaling.

D3DXMATRIX matScaling, matTransform;
D3DXMatrixScaling( &matScaling, m_Scaling.x, m_scaling.y,1.0f);
D3DXMatrixTranslation( &matTransform, m_Pos.x, m_Pos.y, 0.0f );

D3DXMatrixMultiply( &transform, &transform, &matScaling );
m_pD3DXSprite->SetTransform( &transform );

m_pD3DXSprite->Draw(m_pTexture, NULL, NULL, NULL, 0xFFFFFFFF);

I''d like to know what others are doing?
It still doesn''t work...
Try changing your Z value to soemthinmg greater than 0;
Is it because the values are in the range 0 to 1?
I changed D3DXMatrixMultiply(&matTrans, &matTrans, &matScale) to D3DXMatrixMultiply(&matTrans, &matScale, &matTrans). It works =)

[edited by - johan_swe on October 11, 2003 7:18:33 AM]
Generally, the order of combinations for the world and view matricies, as defined in first Jims Book (book plug) on page 183, is as follows:

World Matrix
quote:
matWorld = matScale * matRotateX * matRotateY * matRotateZ * matTranslate


view Matrix
quote:
matView = matTranslate * matRotateX * matRotateY * matRotateZ



Please note that you don''t need all these matrices and the order to the rotation matrices can be changed to eliminate Gimbal lock depending on you situation.

Understanding is a three edged sword...
_______________________________________Understanding is a three edged sword...Freelance Games - Home of XBLIG Starchonwww.FreelanceGames.com

This topic is closed to new replies.

Advertisement