The scene graph is a tree of matrices
Parenting, local versus world transforms, and why your object moved somewhere you did not expect.
Every object holds a position, a quaternion and a scale, which compose into a local matrix. Its world matrix is the parent world matrix multiplied by that local one, all the way up to the scene root. That is the entire scene graph, and it is why parenting a camera to a moving object gives you a chase camera for free and why a rotated group makes its children orbit rather than spin.
The composition order is scale, then rotate, then translate, applied to the point in that sequence, which means the matrices are multiplied in the opposite order to how you would say the sentence. Rotate-then-translate and translate-then-rotate produce different results, and roughly half the confusing 3D bugs anyone ever files are that swap.
Two practical consequences. Non-uniform scale on a parent shears its children and breaks lighting, because normals do not transform by the same matrix as positions, if you find yourself scaling a group by (1, 3, 1), scale the geometry instead. And world matrices are only recomputed at render time, so reading a world position immediately after setting a local one gives you last frame answer unless you ask for the update explicitly.
You should now be able to
- Predict where a child lands when its parent rotates
- Distinguish a local transform from a world matrix
- Explain why transform order is not commutative
Loading…