Why does Mesh need to update its children? This is the job of the renderer.
This is how my engine does it: (simplified, but this is the general idea)
[source lang="cpp"]struct Object{ Shape* shape; Transformation3D transform; // 3x3 rotation, position, scale, gets converted to 4x4 matrix later, defined relative to parent Object or world space. std::vector<Object*> children;};// Base for different shape types (static mesh, animated mesh, heightfield, procedural sphere, cylinder, box, etc).struct Shape{ // Get the best mesh suited for the camera's viewpoint, allows LOD. virtual const MeshChunk* getMesh( const Camera& camera ) const = 0;};struct MeshChunk{ VertexBuffer* vertices; // hardware vertex buffer containing shader vertex attributes. IndexBuffer* indices; // hardware index buffer Material* material; // shader, uniform variables Matrix4x4 transform; // transformation from mesh to camera space.};// Find the objects that are visible to the given cameravoid cullObjects( const Scene& scene, // some representation of the scene, usually a list of Object* const Camera& camera, vector<Object*>& visibleObjects );// This is a class in my engine but a function here for simplicity.void flattenHierarchy( const vector<Object*>& visibleObjects, vector<const MeshChunk*>& visibleChunks ){ // recursively combine the object/shape transformations, calling getMesh() for each // object's shape, then place the output chunks in the output vector.}// could be a virtual method of a class as you have above.// The application renderer iterates over the list of mesh chunks and renders them using this function.void renderMeshChunk( const MeshChunk& chunk );[/source]
Notice that the objects are mostly data (with methods to operate on it, not shown). While simplified, this is a good starting point for a graphics engine. This architecture as-is doesn't really allow you to have global shader attributes (shadow maps, for example). My engine solves this by keeping a cache of global shader attributes which is updated lazily whenever mesh chunks need that information. This cache is passed into renderMeshChunk() which then uses the cache to provide shader attributes that aren't explicitly specified in the Material object.
Edited by Aressera, 20 September 2012 - 11:35 PM.