Hi Robert,

> Perhaps a crude workaround would be to just render lots of frames till
> the pager quietens down, and don't issue a swap buffer till everything
> is ready.

Then my question is: how do I know when to stop rendering frames? DatabasePager::requiresUpdateSceneGraph() does not seem to be sufficient.

/John Vidar

Robert Osfield wrote:
Hi John,

The OSG's DatabasePager is built around assumption of a frame driven
app with continuously rendered frames, so using paged databases in an
event driven app will introduce problems such as the ones you are
seeing.

It should be technically possible to come up with a scheme in
DatabasePager where you request all the tiles at required resolution
and then wait till all tiles are loaded, it is rather complicated by
the pre compiling of OpenGL objects that the DatabasePager does in
collaboration with the active graphics contexts which are running in
separate threads.  If you switch off the precompile then the task
would be more straight forward, but it's still going to be a little
convoluted.

Perhaps a crude workaround would be to just render lots of frames till
the pager quietens down, and don't issue a swap buffer till everything
is ready.

The other way would be to just let the app render at a constant frame
rate until you eye point stops and the pager is quiet.

Robert.

On Wed, Oct 8, 2008 at 5:11 PM, John Vidar Larring
<[EMAIL PROTECTED]> wrote:
Hi all,

When "jumping" to a close-up view of a PagedLOD database you will see that
it takes a few frames before all the appropriate PagedLOD's have been loaded
and displayed.

This works well for active rendering, but is a bit problematic for passive /
lazy rendering.

What I'd like to do is to load close-up scene of a PagedLOD database, run a
visitor that makes sure that all necessary LOD's for current camera view is
loaded, and then render the scene (a delay is acceptible).

When a new close-up view of a scene is specified I attempt to do the
following before the scene is rendered:

[...snip...]
osgDB::DatabasePager* pager =
osgDB::Registry::instance()->getOrCreateDatabasePager();

// Use this PagedLODVistor to generate database requests for loading
// needed PagedLOD children for viewing first frame in full detail
PagedLODVisitor visitor(eye_point, camera->getLODScale());
visitor.setDatabaseRequestHandler(pager);
terrain_->accept(visitor);

// Then make sure that all necessary requests are handled before the
// first frame is drawn.
while(pager->requiresUpdateSceneGraph())
{
   pager->updateSceneGraph(*(osg_viewer_->getFrameStamp()));
}
[...snip...]

The PagedLODVistor looks like the following:

class PagedLODVisitor : public osg::NodeVisitor
{
public:
   PagedLODVisitor(const osg::Vec3& eye_point, double lod_scale):
       osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ACTIVE_CHILDREN),
       eye_point_(eye_point),
       lod_scale_(lod_scale)
       {}

   void apply(osg::PagedLOD& node)
       {
           traverse(node);
       }

   float getDistanceToViewPoint(const osg::Vec3& pos, bool withLODScale)
const
       {
           if (withLODScale)
               return (pos-eye_point_).length()*lod_scale_;
           else
               return (pos-eye_point_).length();
       }

   osg::Vec3 eye_point_;
   double lod_scale_;
};


This obviously fails, since I am writing this post and exposing myself as
moron;)

It seems to fail because PagedLOD::traverse() does not create any
DatabaseRequests (which i was hoping it would). But the conditions to
requesting children to loaded are not met because _rangeList.size() is
always equal to _children.size() when the PagedLODVisitor is run.

I hope someone can enlighten me with the correct approach for doing this.

Best regards,
John

--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

_______________________________________________
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



--
Best regards,
John
WeatherOne


--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

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

Reply via email to