Graphics › Coordinate spaces
World space
The scene's shared coordinate system. The model matrix takes each object out of its own little world and plants it here — positioned, rotated and scaled.
model matrix M = T · Ry · Rx · S
| 0.49 | 0.00 | 0.34 | 1.50 |
| 0.00 | 0.60 | 0.00 | 0.40 |
| -0.34 | 0.00 | 0.49 | 0.00 |
| 0.00 | 0.00 | 0.00 | 1.00 |
The dashed cube is the original; the solid one is M applied to it. Order matters — scale then rotate then translate is the usual recipe (read the matrices right-to-left).
The stage everything stands on
World space has one origin and one set of axes for the whole scene — metres from the centre of the level, say. Every object gets a model matrix M that maps its model-space vertices into world space: p_world = M · p_model. Change M and the object moves, turns, or resizes; the mesh data never changes.
The recipe
M = T · R · S — scale the model, then rotate it, then translate it into position. Read right-to-left because the vertex sits on the right.Hierarchies: a model matrix made of model matrices
A character's hand should follow its forearm, which follows the upper arm, which follows the torso. So each part's world matrix is its local matrix times its parent's world matrix: M_hand_world = M_torso · M_upperarm · M_forearm · M_hand_local. This is a scene graph — move the torso and the whole arm comes along, for free.
Why lighting often happens here
Lights, the sky, gravity, physics — they're all defined in world space, so it's a natural place to do lighting and collision maths. (Some engines do lighting in view spaceinstead; same physics, just a different — and equally valid — frame to measure from.)