# How rotate a 3D cube at its center XNA?

I try to rotate a 3D cube on itself from its center, not the edge. Here is my code used.

public rotatemyCube()
{
...
Matrix newTransform = Matrix.CreateScale(scale) * Matrix.CreateRotationY(rotationLoot) * Matrix.CreateTranslation(translation);
my3Dcube.Transform = newTransform;
....

public void updateRotateCube()
{
rotationLoot += 0.01f;
}


My cube rotate fine, but not from the center. Here is a schematic that explains my problem.

And i need this:

• The order of your matrix multiplications matters. Translate first. – MichaelHouse Feb 19 '13 at 16:40
• I tried but it is not better damage... – Mehdi Bugnard Feb 19 '13 at 17:12
• Is my3Dcube your own 3D model (created in an external tool)? Your vertices might be in the 0-1 range instead of -.5-.5 range. So like Byte56 said, translate your Cube so that the center is at 0,0. before your rotate. – Luis Estrada Feb 19 '13 at 17:19

example: