Archived

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

johan_swe

ID3DXSprite problem

Recommended Posts

johan_swe    122
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)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
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?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
Try changing your Z value to soemthinmg greater than 0;

Share this post


Link to post
Share on other sites
johan_swe    122
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]

Share this post


Link to post
Share on other sites
Sean Doherty    144
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...

Share this post


Link to post
Share on other sites