View Single Post
  #2  
Old 03-23-2007, 11:02 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

To get the root of each individual vizard node, you will need to create an osg::NodeVisitor that traverses the scenegraph and checks the user data of each node. Here is some sample code that will do this:
Code:
class VizNodeData : public osg::Referenced
{
public:
	VizNodeData(int id) : m_id(id) {}
	int getID() const { return m_id; }
private:
	int m_id;
};

class VizardNodeVisitor : public osg::NodeVisitor
{
public :
	VizardNodeVisitor() : osg::NodeVisitor( TRAVERSE_ALL_CHILDREN ) {}

	virtual void apply( osg::Node &node )
	{
		VizNodeData *data = dynamic_cast<VizNodeData*>(node.getUserData());
		if(data) {
			//This is the root of a Vizard node with ID: data->getID()
		}
		traverse(node);
	}
};
Then in your SceneModifier function you will need to apply this node visitor to the scene root:
Code:
VizardNodeVisitor vnv;
((VizModifierObj*)modifier)->node->accept(vnv);
Let me know if you need anymore help.
Reply With Quote