Implementing transformation trees
A scene graph is typically used to represent spatial relationships. For the purpose of rendering, we must calculate a global affine 3D transformation for each of the scene graph nodes. This recipe will show you how to correctly calculate global transformations from local transformations without making any redundant calculations.
Getting ready
Using the previously defined Scene
structure, we will show you how to correctly recalculate global transformations. Please revisit the Using data-oriented design for a scene graph recipe before proceeding. To start this recipe, recall that we had the dangerous but tempting idea of using a recursive global transform calculator in the non-existent SceneNode::render()
method:
SceneNode::Render() {   mat4 parentTransform = parent ?    parent->globalTransform : identity();   this->globalTransform = parentTransform * localTransform;   ... rendering and...