Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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. enter image description here

And i need this: enter image description here

share|improve this question
The order of your matrix multiplications matters. Translate first. – Byte56 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
ok thanks i'm going try this – Mehdi Bugnard Feb 19 '13 at 20:56
up vote 5 down vote accepted

If you want to rotate an object around.Center must be at the point(0,0,0) To achieve that simply Translate the object to point(0,0,0) Rotate and Translate back

share|improve this answer
i have try this :var rotationCenter = new Vector3(0.2f, 0.2f, 0.2f); Matrix transformation = Matrix.CreateTranslation(translation - rotationCenter) * Matrix.CreateScale(scale) * Matrix.CreateRotationY(rotationLoot) * Matrix.CreateTranslation(translation + rotationCenter) ; but not work.. – Mehdi Bugnard Feb 19 '13 at 21:58
Try this -> Matrix.CreateTranslation(-rotationCenter) * Matrix.CreateScale(scale) * Matrix.CreateRotationY(rotationLoot) * Matrix.CreateTranslation(translation) – Blau Feb 20 '13 at 0:41
thanks amigo ^^ all it's work fine now – Mehdi Bugnard Feb 20 '13 at 8:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.