Wiki

Clone wiki

sig / Creating Your Own Scene Node

You can create your own scene node by deriving one of 5 main base nodes, as explained in the SnNode comments:

Defines a base class for all scene nodes.
- It cannot be directly instantiated by the user, and so there is no
  public constructor available.
- Scene nodes start with Sn (scene actions start with Sa, see sa_action.h).
- A reference counter is used for automatically deleting unused nodes,
  see ref() and unref() methods in the parent class GsShareable.
- Each node is of a given type among 5 possible ones:
1. a group manages a list of children nodes;
2. a transform defines a transformation to affect children nodes;
3. a shape defines a geometric shape to be rendered;
4. an editor node handles events, a transformation, and children nodes;
5. a material node gives material info to the next shapes for geometry sharing.

The functionality of your derived node will then be interpreted according to the base class you select. You may also derive from an existing scene node already derived from one of the 5 types listed above. For example, SnPrimitive derives SnModel in order to re-use the rendering calls from SnModel.

If you'd like to create your own shape node you have to derive SnShape, and in addition, provide a class to perform the rendering calls. You can see the needed classes in the self-contained example provided in examples\sigmynode.7z. A more complex shape node is SnModel, which uses class GlrModel for the OpenGL rendering calls.

Updated