Loading a new .earth file at runtime

classic Classic list List threaded Threaded
2 messages Options
Miles Miles
Reply | Threaded
Open this post in threaded view

Loading a new .earth file at runtime

Hey all,

I am trying to attempt to swap .earth files during runtime via a function call. Whether than be via a keypress or something else. I have been coopting the command line arguments to work with our own software but the main thing here is just the .earth itself. Nothing else should need to change.

Right now this is how I am initializing everything currently:

osg::Node *MapHelperNode;
MapNode *MapNodePtr;
char *ViewArgs[4];
osg::Group* Root = new osg::Group();
ViewArgs[0] = strdup (argv[0]);
ViewArgs[1] = strdup (EarthFileName);
osg::ArgumentParser Arguments (&argc ,ViewArgs);
osgViewer::Viewer Viewer(Arguments);
MapHelperNode = MapNodeHelper ().load (Arguments, &Viewer);
Root->addChild (MapHelperNode);
MapNodePtr = MapNode::findMapNode(MapHelperNode);
Viewer.setSceneData (Root);

Would it be possible to use the MapNodeHelper().parse function to change the MapHelperNode. If so, what do you put in Container/LabelControl?

Or would using the MapNodeHelper().load function again after changing ViewArgs[1] and then just going through a similar process with a new MapHelperNode and replacing it in the Root group?

Using osgEarth to create a full functioning 3D modelling apparatus for simulation with TBE.
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view

Re: Loading a new .earth file at runtime

MapNodeHelper exists specifically to support the osgEarth samples (which is why it lives in the ExampleResources header). If you building a custom app we would usually recommend writing your own code - you can refer to MapNodeHelper for example code that you really need in your own app.

If you still want to use it, yes, you can load .earth files with a simple osgDB::readRefNodeFile call, and you can call MapNodeHelper::parse or ::configureView directly and pass in a nullptr if you are not using Controls.

On a side note, we are no longer maintaining the Controls library moving as of version 3.2. It won't go away but we will focus on ImGui in the future. -gw
Glenn Waldron / Pelican Mapping