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