Hello,
I'm not sure I completely understand the question here, so I hope this answer is not too far off the point...... However, while this is fresh in my head, I just spent some time puzzling over PagedLOD and ProxyNode because I couldn't find any good examples. I think my initial confusion was do with trying to use ProxyNode for a purpose that it was not intended. The purpose being, to allow asynchronous loading of models while interacting with the scene. ProxyNode kind of does that, but it only really seems to be intended to 'proxy' the bounding box calculation, and does not provide a 'stand-in' visual object to display during the asychronous load. Enter the PagedLOD.... it seemed to me that everything I expected ProxyNode to do was actually implemented in PagedLOD!

Here's my test example that loads 10 cows asynchronously and shows stand-in cuboids for each cow until each cow model is loaded. (Note, I have specified the stand-in object as a LOD in the very far distance which means that hopefully it will only ever be seen until the 'real' model is loaded)

Chris.

static osg::Node* createCowLOD()
{
   osg::Shape* shape = new osg::Box(osg::Vec3(0, 0, 0), 9, 3, 5);
   osg::ShapeDrawable* shapeDrawable = new osg::ShapeDrawable(shape);
   osg::Geode* geode = new osg::Geode();
   geode->addDrawable(shapeDrawable);
   return geode;
}

int main( int argc, char **argv )
{

   osgViewer::Viewer viewer;

   osg::Group* root = new osg::Group();
   for (int y = 0; y < 5; y++)
   for (int x = 0; x < 2; x++)
   {
osg::MatrixTransform* transform = new osg::MatrixTransform(osg::Matrix::translate(x * 10, y * 4, 0));
       osg::PagedLOD* pagedLOD = new osg::PagedLOD();
       pagedLOD->addChild(createCowLOD(), 1e29, 1e30);
       pagedLOD->setFileName(1, "cow.osg");
       pagedLOD->setRange(1, 0, 1e29);
       transform->addChild(pagedLOD);
       root->addChild(transform);
   }

   viewer.setSceneData(root);

   viewer.realize();

   viewer.run();

   return 0;
}


Date: Wed, 1 Oct 2008 12:22:14 +0800 (CST)
From: Simba <[EMAIL PROTECTED]>
Subject: Re: [osg-users] DatabasePager - A little confused
To: "OpenSceneGraph Users" <[email protected]>
Message-ID:
<[EMAIL PROTECTED]>
Content-Type: text/plain; charset="gbk"


Hi,
I'm not sure whether I have understood your problem. But I think that if you want to use databasepager, you just have to make sure you have "pagedLOD" node in your models. If you do, then just use viewer.setScenedata(model.get()), so the osgViewer::Viewer will automatically do the rest.
  Hope this infomation may help~~~ :)

                                     Simbaforrest





?2008-10-01 07:06:58?"Alan Ott" <[EMAIL PROTECTED]> ???
Hello,

After much trying and failing, I think I have a fundamental
misunderstanding reagarding the DatabasePager. I have looked for
examples or code snippets and it seems that there are none. So here's
what I have.

I have a DatabasePager object that I use for terrain. When I need a new
chunk of terrain, I call requestNodeFile() with the name of the tile of
terrain that I want, and give it a group node to attach it to. Every
frame, I check my group nodes to see if they have a piece of terrain
attached to them (ie: see if the pager paged in the terrain and attached
it to my group). If a new piece of terrain has been loaded, I then
perform my initialization on it (lookup switch nodes, etc), and attach
it to my main scene. This gets the job done.

The problem now, is that every time a new tile is attached to the main
scene, the next frame takes a long time, and I have a missed frame. This
has to do with the new tile getting compiled (texture sent to OpenGL,
etc) when it's drawn the first time. To overcome this, I want
DatabasePager to do this for me, which it seems to be able to support,
but everything I try doesn't work in one way or another. I have
something like the following (roughly):

// Set up the pager
pager = osgDB::DatabasePager::create();
pager->setCompileGLObjectsForContextID (0, true);
pager->setDoPreCompile(true);
...

// My composite viewer
osgViewer::CompositeViewer *viewer = new osgViewer::CompositeViewer;
....

// Then for each View I have something like this.
view = new osgViewer::View;
view->setSceneData(root.get());
view->getScene()->setDatabasePager(pager);

So in this case, only what gets requested the first frame (before the
first draw) gets paged in. Anything requested after that never gets
loaded. If I take out the call to setCompileGLObjectsForContextID(), of
course, no precompiling happens. Other things happen if I take out the
getScene()->setDatabasePager().

From some of the code regarding PagedLOD's, I get the feeling I might
be going about this the wrong way entirely, and possibly using
DatabasePager in a way in which it was not designed.

So I guess my question is, does anyone have anything they can tell me
about how to use this class? Maybe some code snippets? Anything at all
would help. I've spent a lot of time searching online and digging
through the code, so if I've missed something obvious, please go easy :)

Alan.


_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to