WorldViz User Forum  

Go Back   WorldViz User Forum > Plug-in development

Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
Old 03-22-2007, 10:40 PM
m7ossny m7ossny is offline
Join Date: Mar 2007
Posts: 3
Question How to access scene information in a C++ modifier


I am building a new C++ modifier for Vizard. I am intending to handle the whole scen at once.



Well, the last command calls a native code in the dlm file in the function named "void SceneModifier(void *modifier)"

In this function i can get the whole scene through the modifier parameter.
VizModifierObj* pscenemodifier=(VizModifierObj*)modifier;
osg::Node* pnode=pscenemodifier->node.get();

The question is how to get seperate nodes declared in this scene?

Thanks alot for time, Bye.
Reply With Quote
Old 03-23-2007, 11:02 AM
farshizzo farshizzo is offline
WorldViz Team Member
Join Date: Mar 2003
Posts: 2,849

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:
class VizNodeData : public osg::Referenced
	VizNodeData(int id) : m_id(id) {}
	int getID() const { return m_id; }
	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()
Then in your SceneModifier function you will need to apply this node visitor to the scene root:
VizardNodeVisitor vnv;
Let me know if you need anymore help.
Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -7. The time now is 05:17 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC