I've spend hours on reading the source code of the TeapotWars looking for the process of building the scene graph structure, and here is what I could find out:
1. The actor factory creates an actor along with a render component.
2. The actor factory calls Actor::PostInit(), which calls BaseRenderComponent::VPostInit().
3. BaseRenderComponent::VPostInit() triggers an event of EvtData_New_Render_Component.
4. The Scene is triggered by the event. Then the Scene calls Scene::NewRenderComponentDelegate(...). (The Scene is the only object that is listening to EvtData_New_Render_Component, if I didn't miss anything.)
5. In the delegate function, the SceneNode object (the kid) inside the render component is added to the RootNode object (the m_Root) inside the Scene as a child. That is, m_Root->VAddChild(kid) is called.
(If there is anything wrong here, please tell me! )
As I could find out, no SceneNode other than the RootNode has any child in TeapotWars. Is the scene graph structure sufficient for non-trivial games?
For example, in a turn based strategy game like Fire Emblem or Super Robot Wars, we have to draw units on the grid map, and draw stat bars on each unit. It seems to be natural to build a scene graph structure in which the stat bar is a child node of a unit which is a child node of a map which is a child node of the RootNode.
Is this structure good?
- If yes, when, where and how should we call SceneNode::VAddChild(...) (or, how can we build the structure)?
- If no, what is the better solution?
1. The actor factory creates an actor along with a render component.
2. The actor factory calls Actor::PostInit(), which calls BaseRenderComponent::VPostInit().
3. BaseRenderComponent::VPostInit() triggers an event of EvtData_New_Render_Component.
4. The Scene is triggered by the event. Then the Scene calls Scene::NewRenderComponentDelegate(...). (The Scene is the only object that is listening to EvtData_New_Render_Component, if I didn't miss anything.)
5. In the delegate function, the SceneNode object (the kid) inside the render component is added to the RootNode object (the m_Root) inside the Scene as a child. That is, m_Root->VAddChild(kid) is called.
(If there is anything wrong here, please tell me! )
As I could find out, no SceneNode other than the RootNode has any child in TeapotWars. Is the scene graph structure sufficient for non-trivial games?
For example, in a turn based strategy game like Fire Emblem or Super Robot Wars, we have to draw units on the grid map, and draw stat bars on each unit. It seems to be natural to build a scene graph structure in which the stat bar is a child node of a unit which is a child node of a map which is a child node of the RootNode.
Is this structure good?
- If yes, when, where and how should we call SceneNode::VAddChild(...) (or, how can we build the structure)?
- If no, what is the better solution?