Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Does sprite set transform transform the location too?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 noatom   Members   -  Reputation: 785

Like
0Likes
Like

Posted 06 March 2014 - 05:39 AM

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!



Sponsor:

#2 Buckeye   Crossbones+   -  Reputation: 6386

Like
0Likes
Like

Posted 06 March 2014 - 08:58 AM

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.


Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.


#3 Norman Barrows   Crossbones+   -  Reputation: 2357

Like
0Likes
Like

Posted 06 March 2014 - 09:58 PM

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);
}
 
 

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

 

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

 

 





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS