I don't really know exactly what your RelativePosition
and Model.Origin
stand for, so it's hard to say for certain, but usually the origin part should come at the beggining of the world matrix and be negated (i.e. Matrix.CreateTranslation(-player.Model.Origin)
).
Scaling, rotation and translation usually come in SRT order, which you did right.
As for the RelativePosition
I'm not sure what it is. But if that's like the transform of the parent object, then I think it needs to go at the end (at least that's how it worked for me here).
Anyway, for future reference, here's a rundown of what is usually the order for each situation:
Simple Transformations
The order of multiplication for a world matrix is typically:
// World Matrix
Scale * Rotation * Translation
And the order of multiplication for a view matrix is typically:
// View Matrix
-Translation * -Rotation * Zoom
Transformations with Origin
However, especially in 2D games, you frequently need to add an origin displacement to your transformation. That's usually added to the beggining, and must be negated too, so:
// World Matrix with Origin
-OriginTranslation * Scale * Rotation * PositionTranslation
The same thing can also be done with a view matrix, but you add it to the end and this time you don't negate it:
// View Matrix with Origin
-PositionTranslation * -Rotation * Zoom * OriginTranslation
Transformations with Selective Origin
There are also some cases where you want to have an origin displacement, but you want it to affect only your scale and rotation, but not your translation. The way to handle that is to undo the origin transformation before reaching the translation component. For example, with the world matrix:
// World Matrix with Origin for Scale and Rotation
-OriginTranslation * Scale * Rotation * OriginTranslation * PositionTranslation
And the view matrix:
// View Matrix with Origin
-PositionTranslation * -OriginTranslation * -Rotation * Zoom * OriginTranslation
Orbiting around Target
Finally, there's the special case where you want something that orbits around another point. In that situation, you simply switch rotation and translation and it becomes:
// Orbit matrix
Scale * Translation * Rotation