Hi Everyone,
I was wondering if it would be feasible to add a Referenced* member
variable to osg::Node in the OSG base that could be used for arbitrary
information tagging?
I'm currently developing a project where picking specific nodes in the
scene needs to trigger specific actions in our GUI, and building the
connections between the node and the GUI is quite difficult. The
application is broken down into a system where some classes (call them
Foos) own nodes, and changes to the nodes are triggered through the Foo
interface. When a specific node is clicked, I want to notify its Foo.
I've tried implementing this with event callbacks and global maps from
nodes to Foos, but both of those solutions seem overly cumbersome.
We modified our version of OSG to have a tag field in osg::Node. For
simplicity, we only fill this field with types based of OsgTag
(inherited from osg::Referenced), which is a class we defined just for
this problem.
To pull it off, we added this chunk of code to the end of osg::Node's
class description:
public:
void setTag( osg::Referenced* tag ) { _tag = tag; }
osg::Referenced* getTag() { return _tag.get(); }
const osg::Referenced* getTag() const { return _tag.get(); }
private:
osg::ref_ptr<osg::Referenced> _tag;
I think this is a small change that won't impact too many other aspects
of the library, but can be very powerful if used cautiously. Also, when
I would rather not change the OSG code if I can help it, and if it's in
future releases, I won't have to.
Thanks,
Chase Bradford
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/