XNA matrix order problem
- by user1990950
I want a matrix that scales first and then rotates. I tried the code below, but it didn't work. zRotation, yRotation and xRotation are rotations that shouldn't be affected by the origin. allrot should be affected. xScale, yScale and zScale are the scaling variables. The code below works except that it rotates and then scales.
Matrix worldMatrix = (
Matrix.CreateRotationZ(MathHelper.ToRadians(zRotation)) *
Matrix.CreateRotationX(MathHelper.ToRadians(xRotation)) *
Matrix.CreateRotationY(MathHelper.ToRadians(yRotation))
) * (
Matrix.CreateTranslation(origin) *
Matrix.CreateRotationY(MathHelper.ToRadians(allrot)) *
Matrix.CreateScale(xScale, yScale, zScale)
);