   Scaling Matrix Scales position of sprite also?
  Hi, in this situation I'm trying to apply a scaling matrix to sprite in the following order.Compute Scale MatrixSprite->BeginSprite->SetTransfor(Matrix)Sprote->DrawSprite->EndBut the problem is that when I set the position of the sprite in the Draw call and apply the matrix, the position vector gets scaled also. For example:I have a matrix that does X axis * 4, Y axis * 0.5, Z axis * 1.And lets say I pass in a position as x = 100, y = 200. The sprite wouldend up at position 400, 50. How can I prevent that from happening? Thanks   
  Hi,Are you using D3DXMatrixTransformation2D () for that? If not, I recommend you to build your sprite's transformation matrix with this.   ;Quote:Original post by programci_84Hi,Are you using D3DXMatrixTransformation2D () for that? If not, I recommend you to build your sprite's transformation matrix with this.Ok, I tried it, but similar results. Any other ideas?P.S Well technically I solved it by changing the position so that when it's scaled would give me the actual position I want. So lets say I want X to be 100 and my scaling factor is 1.5, I would make X 50, which would make it appear as thought its 100 after scaling. But are there any other less crude methods?   ;  Can you post how you're building your sprite transformation matrix with code?   ;  D3DXMatrixScaling(&ScaleMtrx, XScaleFactor, YScaleFactor, 1.0f);   ;  Hi,If you multiply your original matrix with a scale matrix that's been built up with D3DXMatrixScaling(), position data of the result matrix will be shifted as well.So, I recommend you to use D3DXMatrixTransformation2D(). Change your code like this:D3DXMATRIX spriteTransformation;//assume XScaleFactor, YScaleFactor, XPos and YPos are defined for scaling and translatingD3DXVECTOR2 myScaleFactor (XScaleFactor, YScaleFactor);D3DXVECTOR2 myTranslation (XPos, YPos);D3DXMatrixTransformation2D (&spriteTransformation, NULL, 0, &myScaleFactor, NULL, 0, &myTranslation);//...Sprite->Begin(...);Sprite->SetTransform (&spriteTransformation);Sprite->Draw (...);Sprite->End (); Hope this helps.   ;  Just to expand on programci_84. The order of operations is commutative (the result differs for different orderings) so a translation followed by a scaling will not provide the correct results where a scaling followed by a translation will.If you had an object with a matrix (so it already contains position, orientation, etc..) that you wanted to apply scaling to you would first need to translate it to the origin, apply the scaling matrix and translate back to its original position to make sure you don't move it when scaling.To learn more you might want to read about linear transformations.   ;  Thanks guys it actually worked :) So what's the point of the Draw call having a Position varibale if it gets thrown off by any previous transformation?   