-
Notifications
You must be signed in to change notification settings - Fork 21
Scenes, Nodes and Components
This tutorial should give an overview about architectural principles of the engine. You will not learn how to program a game from this tutorial, though you are encouraged to get to know the engine a bit first. You have been warned! For a list of all tutorials visit the Tutorials page in this wiki.
A node is nothing more than a segment of the scene tree. There is the root node in each Scene
, and other nodes can be attached to it as children. The depth of this tree is unlimited, and each node can have unlimited children.
Each node will have a position, rotation and scale. All child nodes inherit these from their parent and add their relative position, rotation and scale.
A scene is basically a node that has an associated Ogre::SceneManager
and a PhysicsWorld
. Scenes are held by State
s.
Components are modifiers for Nodes. Each node can have many different components adding functionality to the otherwise empty Node. This can be for example Meshes or Sounds in 3D space or other functionality modifying the properties or appearance of the Node.
The components may trigger custom callbacks, e.g. a TriggerComponent
waiting for a player to appear in a specified area can call the Triggered callback. There are 2 ways of subscribing to the callback:
This method should be prefered.
TriggerComponent* comp = new TriggerComponent();
comp.BindSlot("Triggered", boost::bind(&MyClass::MyCallback));
mNode.AddComponent(comp);
Using boost::bind it is possible to create a signal for the Triggered slot.
This should only be used when the callback should do the same for many instances of the Component. Inherit from the Component and overwrite the virtual OnTriggered() method.
class CustomTriggerComponent : public TriggerComponent {
// make your own constructor etc. here
virtual void OnTriggered() {
// do your custom stuff
}
}
mNode.AddComponent(new CustomTriggerComponent());