I decided instead of using a really heavyweight engine like unreal that I am going to use SDL and Openscenegraph.
I would expect it to be something like:
osgObject* box = file->GetObject("Box");
To read a file, you need to use functions from osgDB::ReadFile.
osg::ref_ptr<Node> myNode = osgDB::readNodeFile(myFileName);
You can use that right away if the 'object' you want to use is at the root of your .osg database.
If you know that the node at the top is a group, and that group contains the 'object' you want, you do something like this:
osg::ref_ptr<Group> myGroup = osgDB::readNodeFile(myFileName).asGroup();
osg::ref_ptr<osg::Node> myNode;
for ( int i = 0; i < myGroup->getNumChildren(); ++i )
{
if ( myGroup->getChild( i )->getName() == "box" )
myNode = myGroup->getChild( i );
}
if ( !myNode )
{
std::cout << "Error: object not found()\n";
return;
}
And you could be fancy and write a visitor that does it:
class SearchNode : public osg::NodeVisitor
{
public:
SearchNode( const std::string& name ) :
osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN),
mName(name),
mNode(nullptr) {}
osg::Node* getNode() { return mNode; }
void apply( osg::Node& node ) {
if ( node.getName() == mName)
mNode = &node;
else
traverse( node );
}
private:
std::string mName;
osg::Node* mNode;
};