Quote:Original post by Sync ViewsAgain, googling for matrices should give loads of results.
I suppose I'll cover them in the next two years then....not sure I really want to wait that long though so can you explain what I basicly need to do? eg looking at that matrix function I'm realy not seeing what I'm meant to change to do rotation as well :( (I'm asuming it's not as simple as how many degress/radians as it would need to take into acount where the "centre" of my object is?)
If you have a matrix that translates an object by (10, 20), and a matrix that rotates an object by 45 degrees (Rotations are always about the origin), you can combine them into a matrix that will either rotate by 45 degrees, then translate by (10, 20), or you can combine them into a matrix that translates first, then rotates, depending on the order you multiply them in.
It's a bit difficult to go over it in detail, but you can think of it as m1 * m2 means "First do m1, then do m2", so:
D3DXMATRIX matRotate, matTranslate, matFinal;// Create a matrix that rotates by 45 degrees about the Z axis:D3DXMatrixRotationZ(&matRotate, D3DXToRadian(45.0f));// Create a matrix that translates by (10, 20, 0):D3DXMatrixTranslation(&matTranslate, 10.0f, 20.0f, 0.0f);// Multiply the two matrices to give one that rotates, then translates:D3DXMatrixMultiply(&matFinal, &matRotate, &matTranslate);// matFinal is now a matrix that rotates things by 45 degrees, then translates// them by (10, 20, 0).
EDIT:
If you have a tile or set of tiles which are from (0, 0) to (4000, 4000), and you want to rotate about the middle of them (2000, 2000), you need to:
Translate by (-2000, -2000)
Rotate
Translate by (2000, 2000)