Scene graphs
Scene graphs allow the composition of visual output from simple shapes like triangles, quads etc. Those shapes are predefined in ILNumerics.Drawing and can be freely positioned in 2D or 3D world. That way, more complicated hence flexible graphs can be created. The class design allows for reusing those compositions as well as for dynamically changing visual output.
Advantages of scene graphs
- Configurability: Because in a scene graph, the overall scene is assembled
out of individual objects (
ILShape), each shape can be configured individually. - Transparency: For transparency to work correctly, the shapes need to be drawn from back to front. Therefore the order for rendering must adopt for changing camera positions. Scene graphs automatically draw all contained objects in the correct order.
- Dynamic changes: Objects in a scene graph are hold in a tree data structure. This gives best performance, if any parts of a scene are to be dynamically altered at runtime. Dynamically changing parts can happily live next to static objects in the same scene. Only the changing parts need to be refreshed than. The user can (not 'must') increase this advantage by carefully designing the scene, keeping dynamic parts seperate from static parts.
- Extensibility: With scene graphs it is very easy and convenient to create custom graphs. A bar graph, for example, can simply be assembled out of several quads. A contour plot is constructed out of several polygon and line objects. Custom graphs can be wrapped into a custom class and get reused.
Drawbacks of scene graphs
- Rendering performance: The flexibility of having individual shapes building the scene comes with a slight performance drop.
However, it is possible for the user to optimize the scene rendering, by building the scene from composite shapes
(i.e. shapes derived from
ILCompositeShape). An example of a composite shape is a sphere, constructed out of several quads. Those quads all share the same configuration (color, transparency) and therefore can be rendered very fast. However, for transparency of the whole scene to work correctly, it is necessary for all parts of a composite shape to exist 'near' or 'next' to each other. - Memory usage: Scene graphs consume significantly more memory than other graphs in ILNumerics. This is due to the higher configurability and several caching mechanisms.
In the following chapters, both types of shapes as basic elements for scene graphs will be presented: Simple shapes and composite shapes. The techniques used to alter the way shapes are rendered and to create dynamically updatable graphs is discussed and a guideline for custom graph creation is given at the end of the chapter.
The documentation for scene graphs is not completed yet! Only the documentation for scene graph overview and simple shapes exists so far. (However, the functionality is complete.)
Contents of the chapter: