Jump to content
  • Advertisement
Sign in to follow this  
noatom

Does sprite set transform transform the location too?

This topic is 2048 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

D3DXMATRIX mat;
D3DXMatrixTransformation2D(&mat, &D3DXVECTOR2(all_sprites.at(i)->width / 2, all_sprites.at(i)->height / 2), 0.0, &D3DXVECTOR2(1, 1), &D3DXVECTOR2(all_sprites.at(i)->width / 2, all_sprites.at(i)->height / 2), D3DXToRadian(270), 0);
ppSprite->SetTransform(&mat);

That's all I do, and my sprite gets all messed up( I literally can't see it). If I don't setup the rotation, the sprite get drawn correctly at the right position!

Share this post


Link to post
Share on other sites
Advertisement

Just a guess: since you're not scaling, set scaling center vector pointer and scaling vector pointer to NULL to default to an identity matrix.

Share this post


Link to post
Share on other sites

this may help:

 

 

 
 
 
 
 
 
// draw a sprite. x,y are screen coords of the UL corner.
void Zdrawsprite(int texID,int x,int y,float sx,float sy)
{
D3DXVECTOR3 position;
D3DXMATRIX m;
D3DXMatrixScaling(&m,sx,sy,1.0f);
Zsprite->SetTransform(&m);
position.x=(float)x/sx;
position.y=(float)y/sy;
position.z=0;
Zsprite->Draw(Ztex[texID].tex,NULL,NULL,&position,0xFFFFFFFF);
}
 
 
 
 
 
// draw a rotated sprite. x,y are screen coords of the center.
void Zdrawsprite2(int texID,int x,int y,float sx,float sy,float rz)
{
D3DXVECTOR3 center;
D3DXMATRIX m,m2;
D3DXMatrixScaling(&m,sx,sy,1.0f);
D3DXMatrixRotationZ(&m2,rz);
D3DXMatrixMultiply(&m,&m,&m2);
D3DXMatrixTranslation(&m2,(float)x,(float)y,0.0f);
D3DXMatrixMultiply(&m,&m,&m2);
Zsprite->SetTransform(&m);
center.x=128.0f;
center.y=128.0f;
center.z=0.0f;
Zsprite->Draw(Ztex[texID].tex,NULL,&center,NULL,0xFFFFFFFF);
}
 
 

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net 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!