First cut of osgDB::ImagePager for updating osg::ImageSequence

This commit is contained in:
Robert Osfield
2008-07-21 09:47:39 +00:00
parent d17a255d8e
commit d12708e6f6
8 changed files with 70 additions and 0 deletions

View File

@@ -17,6 +17,7 @@
#include <osgGA/GUIEventHandler>
#include <osgGA/EventVisitor>
#include <osgDB/DatabasePager>
#include <osgDB/ImagePager>
#include <osgViewer/Export>
@@ -33,10 +34,17 @@ class OSGVIEWER_EXPORT Scene : public osg::Referenced
osg::Node* getSceneData();
const osg::Node* getSceneData() const;
void setDatabasePager(osgDB::DatabasePager* dp);
osgDB::DatabasePager* getDatabasePager() { return _databasePager.get(); }
const osgDB::DatabasePager* getDatabasePager() const { return _databasePager.get(); }
void setImagePager(osgDB::ImagePager* ip);
osgDB::ImagePager* getImagePager() { return _imagePager.get(); }
const osgDB::ImagePager* getImagePager() const { return _imagePager.get(); }
/** Get the Scene object that has the specified node assigned to it.
* return 0 if no Scene has yet been assigned the specified node.*/
static Scene* getScene(osg::Node* node);
@@ -55,6 +63,7 @@ class OSGVIEWER_EXPORT Scene : public osg::Referenced
osg::ref_ptr<osg::Node> _sceneData;
osg::ref_ptr<osgDB::DatabasePager> _databasePager;
osg::ref_ptr<osgDB::ImagePager> _imagePager;
};

View File

@@ -71,6 +71,7 @@ class OSGVIEWER_EXPORT View : public osg::View, public osgGA::GUIActionAdapter
/** Get the const View's scene graph.*/
const osg::Node* getSceneData() const { return _scene.valid() ? _scene->getSceneData() : 0; }
/** Set the View's database pager.*/
void setDatabasePager(osgDB::DatabasePager* dp);
@@ -80,6 +81,17 @@ class OSGVIEWER_EXPORT View : public osg::View, public osgGA::GUIActionAdapter
/** Get the const View's database pager.*/
const osgDB::DatabasePager* getDatabasePager() const;
/** Set the View's image pager.*/
void setImagePager(osgDB::ImagePager* ip);
/** Get the View's image pager.*/
osgDB::ImagePager* getImagePager();
/** Get the const View's image pager.*/
const osgDB::ImagePager* getImagePager() const;
/* Set the EventQueue that View uses to integrate external non window related events.*/
void setEventQueue(osgGA::EventQueue* eventQueue) { _eventQueue = eventQueue; }

View File

@@ -20,6 +20,7 @@ SET(LIB_PUBLIC_HEADERS
${HEADER_PATH}/FileNameUtils
${HEADER_PATH}/FileUtils
${HEADER_PATH}/ImageOptions
${HEADER_PATH}/ImagePager
${HEADER_PATH}/Input
${HEADER_PATH}/Output
${HEADER_PATH}/ParameterOutput
@@ -46,6 +47,7 @@ ADD_LIBRARY(${LIB_NAME}
FileNameUtils.cpp
FileUtils.cpp
ImageOptions.cpp
ImagePager.cpp
Input.cpp
Output.cpp
ReadFile.cpp

View File

@@ -1,3 +1,16 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#include <osgDB/DatabasePager>
#include <osgDB/WriteFile>
#include <osgDB/FileNameUtils>

View File

@@ -972,6 +972,12 @@ void CompositeViewer::updateTraversal()
scene->getDatabasePager()->updateSceneGraph(_frameStamp->getReferenceTime());
}
if (scene->getImagePager())
{
// synchronize changes required by the DatabasePager thread to the scene graph
scene->getImagePager()->updateSceneGraph(_frameStamp->getReferenceTime());
}
}
if (_updateOperations.valid())

View File

@@ -24,6 +24,7 @@ Scene::Scene():
osg::Referenced(true)
{
setDatabasePager(osgDB::DatabasePager::create());
setImagePager(new osgDB::ImagePager);
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(s_sceneCacheMutex);
s_sceneCache.push_back(this);
@@ -71,6 +72,11 @@ void Scene::setDatabasePager(osgDB::DatabasePager* dp)
_databasePager = dp;
}
void Scene::setImagePager(osgDB::ImagePager* ip)
{
_imagePager = ip;
}
Scene* Scene::getScene(osg::Node* node)
{

View File

@@ -298,6 +298,22 @@ const osgDB::DatabasePager* View::getDatabasePager() const
}
void View::setImagePager(osgDB::ImagePager* dp)
{
_scene->setImagePager(dp);
}
osgDB::ImagePager* View::getImagePager()
{
return _scene->getImagePager();
}
const osgDB::ImagePager* View::getImagePager() const
{
return _scene->getImagePager();
}
void View::setCameraManipulator(osgGA::MatrixManipulator* manipulator)
{
_cameraManipulator = manipulator;

View File

@@ -891,6 +891,12 @@ void Viewer::updateTraversal()
_scene->getDatabasePager()->updateSceneGraph(_frameStamp->getReferenceTime());
}
if (_scene->getImagePager())
{
// synchronize changes required by the DatabasePager thread to the scene graph
_scene->getImagePager()->updateSceneGraph(_frameStamp->getReferenceTime());
}
if (_updateOperations.valid())
{
_updateOperations->runOperations(this);