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:
Code:
osg::Node* land1 = osgDB::readNodeFile("land1.obj");
osg::Node* land2 = osgDB::readNodeFile("land2.obj");
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);
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++;
}
}
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().
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).
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?
The mesh land1.obj is around 260kb and land2.obj is around 50kb.
Thanks!
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=35248#35248
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org