On Sun, Jan 2, 2011 at 1:56 PM, Anders olofsson <
[email protected]> wrote:

> Hi,
>
> I have a set of terraintiles (wavefront obj meshes) with 2 lods wich I'm
> trying to use with the PagedLOD node like this:
>
>
> I know that you are trying to set up a simple test, but some aspects of
your test are quite far from the optimal scene graph usage, so you might
want to take those into account.

> Code:
>
> osg::Node* land1 = osgDB::readNodeFile("land1.obj");
> osg::Node* land2 = osgDB::readNodeFile("land2.obj");
>
> Here, I'm sure you know that you are sharing these two objects among all
the nodes in the scene graph, and they will only be loaded once. Also, OSG
will be able to optimize graphics state changes among the 2736 instances of
each model. The database pager, which you are using in your second example,
will load new files in each PagedLOD unless you use an object cache. Those
files will not share graphics state unless you use another option, the
SharedState manager.

> osg::PagedLOD* tiles[48*57];
> osg::MatrixTransform *xform[48*57];
> int i=0;
> for (int y=0;y<48;y++)
> {
>  for (int x=0;x<57;x++)
>  {
>    tiles[i]=new osg::PagedLOD;
>    tiles[i]->addChild(land1,0,20000);
>    tiles[i]->addChild(land2,20000,40000);
>
Note that PagedLOD expects the further (less detailed) LODs to come first in
the list. I think that you will force both files to be loaded even though
the less detailed LOD is the only one in range.

>    xform[i]=new osg::MatrixTransform;
>    xform[i]->setMatrix( osg::Matrix::translate(x*20000, y*20000, 0.0f) );
>    xform[i]->addChild(tiles[i]);
>    root->addChild(xform[i]);
>
The cull traversal will have to traverse 2736 nodes to determine visibility.
This is not considered a well-balanced scene graph. Usually we try to set up
a quad-tree organization in the scene graph.

>    i++;
>  }
> }
>
>

>
> I translate the tile because each tile is centered around 0,0,0. Now, this
> works just fine, no performance problem at all but as you can see I preload
> the meshes and use addChild().
>
> It's not clear what you mean by no performance problem :)

> I would like to use setFileName, something like this:
>
> Code:
>
> osg::PagedLOD* tiles[48*57];
> osg::MatrixTransform *xform[48*57];
> int i=0;
> for (int y=0;y<48;y++)
> {
>  for (int x=0;x<57;x++)
>  {
>    tiles[i]=new osg::PagedLOD;
>    tiles[i]->setFileName( 0, "land1.obj" );
>    tiles[i]->setRange( 0, 0, 20000);
>    tiles[i]->setFileName( 1, "land2.obj" );
>    tiles[i]->setRange( 1, 20000, 40000);
>    xform[i]=new osg::MatrixTransform;
>    xform[i]->setMatrix( osg::Matrix::translate(x*20000, y*20000, 0.0f) );
>    xform[i]->addChild(tiles[i]);
>    root->addChild(xform[i]);
>    i++;
>  }
> }
>
> This works too but performance is allot worse, the loading of the meshes is
> causing stuttering of the view/animation. And the tiles takes a long time to
> load (3 seconds before the first tile shows up).
>
> One thing you should do is manually set a bounding sphere on the PagedLOD
node. Otherwise OSG will need to load the file to calculate a bounding
sphere! Needless to say, you are loading a large number of files when OSG
starts up.

> I dont want to preload all the tiles since that kind of defeats the whole
> idea with PagedLODs. In the above example I use the same 2 lod meshes for
> all tiles, this will change if/when I get the setFileName example to work.
>
> Am I doing something utterly wrong?
>
> Hope this gives you some ideas...
Tim
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to