Hello all,
I am working on some code that utilizes OpenSceneGraph functions and am having problems with pointers. The function I want to use is of the form
Code:
writeNodeFile (const osg::Node &node, const std::string &filename)
I am trying to get a selected node (which is a pointer), find out how many children that node has, and then write each child to a file. My problem is that I cannot figure out how to make my osg::Node *child into const osg::Node& child for use in the function.
Code:
osg::Node *node = dynamic_cast<osg::Node *>(editor->getSelected()); //get selected node from scenegraph
for (int i = 0; i< ((osg::Group*)node)->getNumChildren(); i++){ //get number of children of selected node (children are also nodes)
//write children to .osg file
osg::Node *child = ((osg::Group*)node)->getChild(i); //returns osg::Node*
std::string childname = i + ".osg"; //filename for child
osgDB::writeNodeFile(child , childname); //save child <-----ERROR HERE
}
I get the error "cannot convert from 'osg::Node*' to 'osg::Node&'".
Does anyone have any suggestions?
Thanks,
JackR