I have a few different "scene graphs" in my engine, including Horde's one:
Code:
Horde Physics GUI
| | |
Group Nodes Bodies Node
| | |
Model Nodes Shapes Element
As well as different bits of middleware (graphics, physics, gui) having their own internal graphs, my game has an entity graph:
Code:
Game
|
Entities
|
Components
The game has a collection of entities. Entities have a collection of components (entities also inherit from component, so an entity can have a collection of entities too).
My "Horde model class" (
which owns a horde node handle -- i.e. owns a node in the horde scene graph) is a component. My "physics body class" (
which owns a node in the physics scene graph) is also a component.
The game can then compose components together into the "entity graph" without much knowledge of what's going on inside the graphics system (horde) or the physics system etc...
The game doesn't really care about any of the particular scene graphs -- it just creates components.
e.g. the game might make a player entity, which creates a model component, which inserts a model node into horde's scene graph. But the user doesn't have to know about horde's scene graph, all they know is "I created a player".
The player entity doesn't have a Draw or Render function (that's what Horde's scene graph is for).
The player entity can move around or enable/disable the model node (in horde), but that's about it. All of the game logic (moving around objects, etc...) happens in the "entity graph", which in turn updates variables of the model components, which then update Horde's actual model nodes. The game doesn't know how to render the player (or even if it can be rendered), it just updates it's components, and then later horde will render the whole scene by itself.