I am loading large datasets(about 100,000) at runtime from a database to an earth file which is quite simple. For now, each data item is generally organised under a PagedLOD(some are simple models from .osg files, some are dynamically generated lines / shapes / annotations, and each with the maxRange property setted) under centain osgSwitch(depends on the type of the data), and the switches are added as children of the map root.
The issue is the loading speed is extremely slow(fps drops to 1 or 2 during and even after loading), and the UI hardly response to zooming or panning. It seems like even though the nodes are not visible at a long distance, but the nodes are still drawing at background. So I guess that the way I organise the nodes may be wrong since only adding PagedLODs will not enable paging or tiling or something that can implement a smart loading which occurs only when the nodes are in a visible range.
I'm not sure if the lack of paging and tiling stategy is the problem, and I was trying to use ModelLayer instead of osgSwitch for each kind of data, but I don't know how. I do find a constructor of ModelLayer with a osgNode parameter, but it seems like I can't apply a ModelLayerOption with paging settings to it at the mean time.
I'm quite a newbie to osgEarth and osg or even computer graphics, so any advice from you should be useful.
Thanks in advance.
Just guessing. But your problem is likely due to loading all those files in a flat hierarchy (under one group). Even if they are not drawn, OSG must check all of them every frame to see whether it needs to draw them. And for 100,000 nodes that is a lot of time.
You need to organize your data into a spatial hierarchy. This is a little beyond the scope of this forum, but you can look at somehting like the osgEarth::Util::HTMGroup for inspiration.