Thanks guys,
ProxyNode is what I was looking for.
-Colin
Tim Moore wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Colin Branch wrote:
Hi all,
What I'm trying to do:
Asynchronous model loading using OSG 2.2
How I'm currently doing it:
I'm trying to use the Database Pager's requestNodeFile.
I just did this for the FlightGear project and it works well there.
I created a new node class that I can add (as well as place temporary
objects) that I can add and will stay in the scene.
class DtDelayedModelNode : public osg::Group
{
...
DtDelayedModelNode(const std::string& filename, osgDB::DatabasePager*
pager) : osg::Group()
{
osg::FrameStamp fs;
fs.setFrameNumber(INT_MAX);
pager->requestNodeFile(filename,this,1.0,&fs);
}
...
};
For this application you probably do want to check out ProxyNode as Bryan Thrall
suggested. If I had known about ProxyNode I might have used it instead of
calling
requestNodeFile directly.
What you've done here won't reliably work. You need to call requestNodeFile
every frame
until your request is satisfied. You will only find this out by looking closely
at the
implementation of ProxyNode and PagedLOD or by googling in the mailing list :)
Problems:
#1 Very limited documentation of the Pager class and no example on how
to use it. I've searched the osgusers archive but haven't found
anything too helpful, the 1.x examples don't seem relevant anymore.
See above about ProxyNode and PagedLOD.
#2 Occasional texture corruption. This is difficult to reproduce
however it appears that sometimes the width of the texture is 1px
creating a streaking effect.
#3 Certain actions cause the main app to lock, for example bringing up
the Stats HUD.
The other thing to keep in mind is that readNodeFile and friends aren't
necessarily
thread safe, but you don't have access to the lock that the pager uses to
serialize
access to those functions. Either you stop doing any file loading calls from
your main
thread once the pager has started, or you need to do the locking yourself by
installing
read callback functions that do the locking. The bugs you're seeing sound like
random
corruption of this kind.
Questions:
Is the Database Pager the proper way to be doing this?
It works for the FlightGear flight simulator project. I created a very small
subclass
of DatabasePager in order to have access to the _childrenToDeleteList of the
pager.
What if any calls should I make to the pager around frame() (ie it
doesn't appear that startFrame endFrame are needed, any other calls)?
None if you're using osgViewer. Otherwise look closely at the osgViewer::Viewer
source
code.
The value of the frame stamp appears to control deletion of requests. Ie
if I pass in the current frame stamp, the model is actually deleted in
compileGLObjects. Unless I set it to some value in the future (currently
using INT_MAX) I can't guarantee it will load. Could someone explain the
purpose of the framestamp and the proper usage?
See above. Normally you check every frame if a request has been satisfied; if
not, you
make it again with the current frame stamp. The OSG clients of DatabasePager,
ProxyNode
and PagedLOD, make these requests from the cull traversal, so this usage gives
a way
to cancel a request if the object drops out of the field of view.
Is there anyway to get status feedback while a file loads?
You can tell if a load is completed by checking if an object has been added to
the group
you passed to requestNodeFile. Otherwise no, though you could arrange for the
readNodeFile
callback you're going to write :) to return an empty error object of some kind.
Tim
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org
iD8DBQFHY5HHeDhWHdXrDRURAqMHAJ9EwsSEmq/km+Kmm66vQR7QHypqxgCfXtcb
AYMB1dGywN0upP0wEE9JErc=
=mNg5
-----END PGP SIGNATURE-----
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org