ID3DXSprite problem
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)
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?
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?
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]
[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
view Matrix
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...
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...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement