Hi Sukender, The way I'd tackle something like this would be to have a ComponentContainer subclass from osg::Referenced, and then just directly attach this to the Node/Object/Drawable/StateSet via the existing UserData field. The intention of the UserData is to facilitate this type of user extension of the scene graph.
Robert. On Thu, Aug 13, 2009 at 12:26 PM, Sukender<[email protected]> wrote: > Hi all, > > I'm working on a project that needs to add various data/metadata to the > nodes. I was wondering: > 1. Does something already exists for this (more flexible than the description > string list)? > 2. How would you implement this? > > Personnally, I was looking towards aggregation. See > http://cowboyprogramming.com/2007/01/05/evolve-your-heirachy/ and other > similar articles to know what I mean. So I suggest to add something to nodes, > using a compile-time option (in order to be able to turn it on or off when > running CMake). For instance, there would be: > - A Component abstract class (a very simple one) > - A list of components in nodes (directly in the Node class, or by making > Node inherit from something like a ComponentContainer class). Something like > the nodes list in osg::Group sounds good (as it will be familiar to OSG > users). > - And a ComponentManager class, which references the components (weak > references) by type, so that you can easily and quickly iterate over all > "Physics" components, "AI" components, or whatever-components. > > That way, you may add whaterver component you need to any node. Say you need > to add a meta to a node? Create a MetaComponent (Name + value), and call > node->addComponent(new MetaComponent("Creation date", "2009-08-13")); > > I already coded something, but it's not really clean right now. Depending on > your answers and on the moment my code will be cleaned, I'll send code to > osg-submissions. > > Thanks. > > Sukender > PVLE - Lightweight cross-platform game engine - http://pvle.sourceforge.net/ > _______________________________________________ > osg-users mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

