D3DXVECTOR3 vPos = D3DXVECTOR3(200.0f, 200.0f, 0.0f) ;
D3DXVECTOR3 vCenter = D3DXVECTOR3(100.0f, 100.0f, 0.0f) ;
FLOAT angle = 0.0f ;
void DrawRotatedSprite (void)
{
angle += 0.01f ;
//Rotating sprite
D3DXMATRIX matSprite ;
D3DXMatrixRotationZ (&matSprite, angle) ;
//Drawing sprite
g_pSprite->Begin (D3DXSPRITE_ALPHABLEND) ;
g_pSprite->SetTransform (&matSprite) ;
g_pSprite->Draw (g_pTexture, NULL, &vCenter, &vPos,
D3DCOLOR_RGBA(255,255,255,255)) ;
g_pSprite->End () ;
}
i get weird results by doing this, for example:
1. if vPos == vCenter : then the sprite is drawn in upper left corner =S,
wich is the point (0,0,0)
2. if vPos != vCenter : then the sprite is located relative to vPos (that's ok), but rotates around some weird axis located elsenwere (it should be located at vCenter but you see the rotating sprite and you'll clearly see that it isn't rotating relative to vCenter)
my question is:
1. what are the relationships between center, position and rotation of ID3DXSprite ??
2. what can i do for solving my problem ??
thx, and peace ...
btw: i have been reading the documentation and it says not so much about it ...
ID3DXSprite rotation misconception
hello, i have a big doubt about the relationship between ID3DXSprite::Draw()
and the rotation angle it draws when for example you do something like this ...
This may not help but I had a similar function and it really didn't work well using the position argument for the ID3DXSprite class. I had a lot of problems with it until I did something like :
sorry if the information was useless to you, but just remember this in case you get too many bugs with the translation!
D3DXVECTOR3 vCenter = D3DXVECTOR3(100.0f, 100.0f, 0.0f) ;FLOAT angle = 0.0f ;void DrawRotatedSprite (void){ angle += 0.01f ; //Rotating sprite D3DXMATRIX matRotate, matTranslate; D3DXMatrixRotationZ(&matRotate, angle) ; D3DXMatrixTranslation(&matTranslate, 200.0f, 200.0f, 0.0f) ; //Drawing sprite g_pSprite->Begin (D3DXSPRITE_ALPHABLEND) ; g_pSprite->SetTransform (&(matRotate * matTranslate)) ; g_pSprite->Draw (g_pTexture, NULL, &vCenter, NULL, D3DCOLOR_RGBA(255,255,255,255)) ; g_pSprite->End () ;}
sorry if the information was useless to you, but just remember this in case you get too many bugs with the translation!
i've been seeing too that using the position on ID3DXSPrite only makes things worse i think, things were pretty straightforward using NULL position (i could scale and translate my sprite without problems) until i had to reconsiderate puting a position value for rotation because it was getting buggy, it is posible that those relationships are bugged ... dxsdk doesn't say much about that fact
thx for the code, i'll try it when i can ... :):)
thx for the code, i'll try it when i can ... :):)
Lol i didnt expect that to be my thread.
The solution int the above link works great for me so i suggest you look at it. Oh and thanks for helping me out there MTClip.
My biggest problem was doing things in the worng order. I was rotating then translating then scaling and i forgot that the order matters.
Good Luck
The solution int the above link works great for me so i suggest you look at it. Oh and thanks for helping me out there MTClip.
My biggest problem was doing things in the worng order. I was rotating then translating then scaling and i forgot that the order matters.
Good Luck
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement