关于D3DXMatrixTransformation2D函数的问题,请大家帮忙看一下,谢谢
void Sprite_Transform_Draw(LPDIRECT3DTEXTURE9 image, int x, int y, int width, int height,
int frame, int columns, float rotation, float scaling, D3DCOLOR color)
{
//create a scale vector
D3DXVECTOR2 scale( scaling, scaling );
//create a translate vector
D3DXVECTOR2 trans( x, y );
//set center by dividing width and height by two
D3DXVECTOR2 center( (float)( width * scaling )/2, (float)( height * scaling )/2);
//create 2D transformation matrix
D3DXMATRIX mat;
D3DXMatrixTransformation2D( &mat, NULL, 0, &scale, ¢er, rotation, &trans );
//tell sprite object to use the transform
spriteobj->SetTransform( &mat );
//calculate frame location in source image
int fx = (frame % columns) * width;
int fy = (frame / columns) * height;
RECT srcRect = {fx, fy, fx + width, fy + height};
//draw the sprite frame
spriteobj->Draw( image, &srcRect, NULL, NULL, color );
}
这段代码使一个物体旋转伸缩,但是物体缩放时是以物体左上角的左边为中心缩放的,请问一下能不能是它按照物体的中心为中心点进行缩放。