2003-07-08 22:44:00 +08:00
|
|
|
/* -*-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 :
|
|
|
|
|
2003-07-10 22:53:07 +08:00
|
|
|
PagedLOD();
|
2003-07-08 22:44:00 +08:00
|
|
|
|
|
|
|
/** 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);
|
|
|
|
|
2004-01-06 04:45:28 +08:00
|
|
|
virtual bool addChild(Node *child, float min, float max,const std::string& filename, float priorityOffset=0.0f, float priorityScale=1.0f);
|
2003-07-08 22:44:00 +08:00
|
|
|
|
|
|
|
virtual bool removeChild(Node *child);
|
|
|
|
|
|
|
|
|
2004-01-06 04:45:28 +08:00
|
|
|
struct PerRangeData
|
|
|
|
{
|
2004-01-07 16:39:33 +08:00
|
|
|
PerRangeData();
|
|
|
|
PerRangeData(const PerRangeData& prd);
|
|
|
|
PerRangeData& operator = (const PerRangeData& prd);
|
2003-07-08 22:44:00 +08:00
|
|
|
|
2004-01-06 04:45:28 +08:00
|
|
|
std::string _filename;
|
|
|
|
float _priorityOffset;
|
|
|
|
float _priorityScale;
|
|
|
|
double _timeStamp;
|
|
|
|
};
|
2003-07-08 22:44:00 +08:00
|
|
|
|
2004-01-06 04:45:28 +08:00
|
|
|
typedef std::vector<PerRangeData> PerRangeDataList;
|
2003-07-08 22:44:00 +08:00
|
|
|
|
2004-01-06 04:45:28 +08:00
|
|
|
void setFileName(unsigned int childNo, const std::string& filename) { expandPerRangeDataTo(childNo); _perRangeDataList[childNo]._filename=filename; }
|
|
|
|
const std::string& getFileName(unsigned int childNo) const { return _perRangeDataList[childNo]._filename; }
|
|
|
|
unsigned int getNumFileNames() const { return _perRangeDataList.size(); }
|
|
|
|
|
|
|
|
|
|
|
|
void setPriorityOffset(unsigned int childNo, float priorityOffset) { expandPerRangeDataTo(childNo); _perRangeDataList[childNo]._priorityOffset=priorityOffset; }
|
|
|
|
float getPriorityOffset(unsigned int childNo) const { return _perRangeDataList[childNo]._priorityOffset; }
|
|
|
|
unsigned int getNumPriorityOffsets() const { return _perRangeDataList.size(); }
|
|
|
|
|
|
|
|
void setPriorityScale(unsigned int childNo, float priorityScale) { expandPerRangeDataTo(childNo); _perRangeDataList[childNo]._priorityScale=priorityScale; }
|
|
|
|
float getPriorityScale(unsigned int childNo) const { return _perRangeDataList[childNo]._priorityScale; }
|
|
|
|
unsigned int getNumPriorityScales() const { return _perRangeDataList.size(); }
|
|
|
|
|
|
|
|
|
|
|
|
void setTimeStamp(unsigned int childNo, double timeStamp) { expandPerRangeDataTo(childNo); _perRangeDataList[childNo]._timeStamp=timeStamp; }
|
|
|
|
double getTimeStamp(unsigned int childNo) const { return _perRangeDataList[childNo]._timeStamp; }
|
|
|
|
unsigned int getNumTimeStamps() const { return _perRangeDataList.size(); }
|
2003-07-08 22:44:00 +08:00
|
|
|
|
2003-12-09 20:08:27 +08:00
|
|
|
|
|
|
|
/** Set the object-space reference radius of the volume enclosed by the PagedLOD.
|
|
|
|
* Used to detmine the bounding sphere of the PagedLOD in the absense of any children.*/
|
|
|
|
inline void setRadius(float radius) { _radius = radius; }
|
|
|
|
|
|
|
|
/** Get the object-space radius of the volume enclosed by the PagedLOD.*/
|
|
|
|
inline float getRadius() const { return _radius; }
|
|
|
|
|
|
|
|
|
|
|
|
/** Set the number of children that the PagedLOD must keep around, even if thay are older than their expiry time.*/
|
|
|
|
inline void setNumChildrenThatCannotBeExpired(unsigned int num) { _numChildrenThatCannotBeExpired = num; }
|
|
|
|
|
|
|
|
/** Get the number of children that the PagedLOD must keep around, even if thay are older than their expiry time.*/
|
|
|
|
unsigned int getNumChildrenThatCannotBeExpired() const { return _numChildrenThatCannotBeExpired; }
|
|
|
|
|
2003-07-09 22:55:39 +08:00
|
|
|
/** Remove the children from the PagedLOD which haven't be visited since specified expiry time.
|
|
|
|
The removed children are added the removeChildren list passed into the method,
|
|
|
|
this allows the children to be deleted later at the callers discression.*/
|
2003-12-04 05:28:42 +08:00
|
|
|
virtual void removeExpiredChildren(double expiryTime,NodeList& removedChildren);
|
2003-07-08 22:44:00 +08:00
|
|
|
|
|
|
|
protected :
|
|
|
|
|
|
|
|
virtual ~PagedLOD() {}
|
|
|
|
|
2003-12-09 20:08:27 +08:00
|
|
|
virtual bool computeBound() const;
|
|
|
|
|
2004-01-06 04:45:28 +08:00
|
|
|
virtual void childRemoved(unsigned int pos, unsigned int numChildrenToRemove);
|
|
|
|
virtual void childInserted(unsigned int pos);
|
|
|
|
|
|
|
|
virtual void rangeRemoved(unsigned int pos, unsigned int numChildrenToRemove);
|
|
|
|
virtual void rangeInserted(unsigned int pos);
|
|
|
|
|
|
|
|
void expandPerRangeDataTo(unsigned int pos);
|
|
|
|
|
2003-12-09 20:08:27 +08:00
|
|
|
float _radius;
|
|
|
|
unsigned int _numChildrenThatCannotBeExpired;
|
2004-01-06 04:45:28 +08:00
|
|
|
|
|
|
|
PerRangeDataList _perRangeDataList;
|
2003-07-08 22:44:00 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|