Added osg::PagedLOD and osgProducer::DatabasePager class, and linked up osgProducer::Viewer

to manage the pager.
This commit is contained in:
Robert Osfield
2003-07-08 14:44:00 +00:00
parent 9239173019
commit c2eabe1d4b
21 changed files with 810 additions and 59 deletions

View File

@@ -31,6 +31,7 @@ class MatrixTransform;
class PositionAttitudeTransform;
class Projection;
class LOD;
class PagedLOD;
class Switch;
class Impostor;
class ClearNode;
@@ -238,25 +239,49 @@ class SG_EXPORT NodeVisitor : public virtual Referenced
virtual void apply(Switch& node) { apply((Group&)node); }
virtual void apply(Sequence& node) { apply((Group&)node); }
virtual void apply(LOD& node) { apply((Group&)node); }
virtual void apply(PagedLOD& node) { apply((LOD&)node); }
virtual void apply(Impostor& node) { apply((LOD&)node); }
virtual void apply(ClearNode& node) { apply((Group&)node); }
virtual void apply(OccluderNode& node) { apply((Group&)node); }
/** callback for managing database paging, such as generated by PagedLOD nodes.*/
class DatabaseRequestHandler : public osg::Referenced
{
public:
virtual void requestNodeFile(const std::string& fileName,osg::Group* group) = 0;
protected:
virtual ~DatabaseRequestHandler() {}
};
/** Set the handler for database requests.*/
void setDatabaseRequestHandler(DatabaseRequestHandler* handler) { _databaseRequestHandler = handler; }
/** Get the handler for database requests.*/
DatabaseRequestHandler* getDatabaseRequestHandler() { return _databaseRequestHandler.get(); }
/** Get the const handler for database requests.*/
const DatabaseRequestHandler* getDatabaseRequestHandler() const { return _databaseRequestHandler.get(); }
protected:
VisitorType _visitorType;
int _traversalNumber;
VisitorType _visitorType;
int _traversalNumber;
ref_ptr<FrameStamp> _frameStamp;
ref_ptr<FrameStamp> _frameStamp;
TraversalMode _traversalMode;
Node::NodeMask _traversalMask;
Node::NodeMask _nodeMaskOverride;
TraversalMode _traversalMode;
Node::NodeMask _traversalMask;
Node::NodeMask _nodeMaskOverride;
NodePath _nodePath;
NodePath _nodePath;
ref_ptr<Referenced> _userData;
ref_ptr<Referenced> _userData;
ref_ptr<DatabaseRequestHandler> _databaseRequestHandler;
};

89
include/osg/PagedLOD Normal file
View File

@@ -0,0 +1,89 @@
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 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.
*/
#ifndef OSG_PagedLOD
#define OSG_PagedLOD 1
#include <osg/LOD>
namespace osg {
/** PagedLOD.
*/
class SG_EXPORT PagedLOD : public LOD
{
public :
PagedLOD() {}
/** Copy constructor using CopyOp to manage deep vs shallow copy.*/
PagedLOD(const PagedLOD&,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
META_Node(osg, PagedLOD);
virtual void traverse(NodeVisitor& nv);
virtual bool addChild(Node *child);
virtual bool addChild(Node *child, float min, float max);
virtual bool addChild(Node *child, float min, float max,const std::string& filename);
virtual bool removeChild(Node *child);
typedef std::vector<std::string> FileNameList;
void setFileName(unsigned int childNo, const std::string& filename);
const std::string& getFileName(unsigned int childNo) const { return _fileNameList[childNo]; }
/** returns the number of filenames currently set. */
inline unsigned int getNumFileNames() const { return _fileNameList.size(); }
/** return the list of filename.*/
inline FileNameList& getFileNameList() { return _fileNameList; }
/** return the list of filename.*/
inline const FileNameList& getFileNameList() const { return _fileNameList; }
typedef std::vector<double> TimeStampList;
void setTimeStamp(unsigned int childNo, double timeStamp);
double getTimeStamp(unsigned int childNo) const { return _timeStampList[childNo]; }
/** returns the number of filenames currently set. */
inline unsigned int getNumTimeStamps() const { return _fileNameList.size(); }
/** return the list of time stamps.*/
inline TimeStampList& getTimeStampList() { return _timeStampList; }
/** return the list of time stamps.*/
inline const TimeStampList& getTimeStampList() const { return _timeStampList; }
void removeExpiredChildren(double expiryTime);
protected :
virtual ~PagedLOD() {}
FileNameList _fileNameList;
TimeStampList _timeStampList;
};
}
#endif