I know that this subject has alot of available resources already available, but none of them seem to be able to solve my problem.
I know that an excellent sprite class already exists, but for the purpose of my own education I prefer to work from scratch rather than using all of its wonderfull features. So that covers the "Use the Sprite class to do it" answer.
This is what I am attempting to do :
Rotate a texture about its Z axis using its center as the rotation center, and the textures dimensions must stay constant. I have no problem rotating the texture, its the constant dimensions that are the problem.
My device matrices are set up as follows :
device.Transform.Projection = Matrix.OrthoLH(1, 1, 0, 1);
device.Transform.World = Matrix.Identity;
My texture is of type CustomVertex.PositionedColoredTextured, and I am using primitive type TriangleList to render them. I have set up my vertex buffer correctly and can render 2 primitives that form a square ect ect, so my render method is not the problem as far as I know.
This is how I am rotating the world before I render the texture.
Matrix transform =
Matrix.Translation(sclX, sclY, 0f)
* Matrix.Translation(-sclX, -sclY, 0f) * Matrix.RotationZ(angle)
* Matrix.Scaling(1, 1, 1)
* Matrix.Translation(sclX, sclY, 0f);
device.Transform.World = transform;
Where sclX and sclY represent the world coordinates of the texture, and they are calculated as follows.
sclX = WorldXLoc / device.ViewPort.Width;
sclY = WorldYLoc / device.ViewPort.Height;
By doing this, the texture rotates about its center correctly, except it increases in length/width at different angles of rotation. I am wondering how I might solve this problem, as I have fiddled and fiddled but to no avail!
I hope I provided enough information to allow the more experienced people to help me, but if I have not please let me know what information is lacking and I will gladly provide it. This is my first post on Gamdev.net, and as I am not exactly experienced with MDX I am unsure what information is relevant..