This code example shows a three-piece hierarchy showing how transforms concatenate.  
This shows a simple tank body-turret-barrel relationship.

Controls
--------
ESC: quit
I,J,K,L: translate tank in the XY plane
;,P: scale tank down, up
U,O: rotate tank around Z axis
A,D: rotate turret left/right
W,S: raise barrel up/down
SPACE: reset transforms