![]() |
VR-Forces 4.0.4 Class Documentation
|
00001 /****************************************************************************** 00002 ** Copyright (c) 2011 MAK Technologies, Inc. 00003 ** All rights reserved. 00004 ******************************************************************************/ 00005 /****************************************************************************** 00006 ** $RCSfile: $ $Revision: $ $State: $ 00007 ******************************************************************************/ 00008 00012 00013 #pragma once 00014 #include <vrvOsg/vrvOsg.h> 00015 #include <vrvOsg/DtFastGroup.h> 00016 #include <osg/Vec3> 00017 #include <osg/MatrixTransform> 00018 #include <osgDB/Options> 00019 00020 namespace makVrv 00021 { 00022 class DtOsgCullVisitor; 00023 00028 class DT_DLL_VRVOSG DtHierarchicalPagedLod : public DtFastGroup 00029 { 00030 public: 00031 00033 DtHierarchicalPagedLod(const std::string& filename, 00034 float distanceNear, float distanceFar, float tileRadius, 00035 float childTileRadius, const osg::Vec3d& fileCenter, 00036 const osg::Vec3d& childrenCenter, bool sparseChildren, 00037 bool substitutiveChildren, const osg::Matrixd& fileTranslation, 00038 osgDB::Options* options); 00039 00041 virtual ~DtHierarchicalPagedLod(); 00042 00043 virtual const char* className() const { return "DtHierarchicalPagedLod"; } 00044 00049 void addChildHierarchy(DtHierarchicalPagedLod* child); 00050 00052 virtual void traverse(osg::NodeVisitor& nv); 00053 00055 virtual void traverseAll(osg::NodeVisitor& nv); 00056 00058 virtual void traverseActive(osg::NodeVisitor& nv); 00059 00062 virtual void cullActive(osg::NodeVisitor& nv); 00063 00065 void cullActive2D(DtOsgCullVisitor& nv); 00066 00068 void cullActive3D(osg::NodeVisitor& nv); 00069 00071 virtual osg::BoundingSphere computeBound() const; 00072 00075 virtual void traverseFile(osg::NodeVisitor& nv,float distance ); 00076 00079 virtual void traverseChildren(osg::NodeVisitor& nv); 00080 00082 virtual bool fileInRange(float distance) const; 00083 00085 virtual float fileRangeDistance(osg::NodeVisitor& nv) const; 00086 00088 virtual float childRangeDistance( osg::NodeVisitor& nv ) const; 00089 00091 void pageInFile(osg::NodeVisitor& nv, float distance); 00092 00095 void pageOutFile(int lastCullTime, osg::NodeList& toRemove); 00096 00099 bool fileNotLoaded() const; 00100 00102 bool fileIsPaging() const; 00103 00105 bool fileIsLoaded() const; 00106 00108 virtual bool fileInChildRange(float distance) const; 00109 00111 void pageInChildren(osg::NodeVisitor& nv, float distance); 00112 00114 void pageOutChildren(int lastCullTime, osg::NodeList& toRemove); 00115 00117 bool childrenLoaded() const; 00118 00121 osg::ref_ptr<osg::Node> fileNode(); 00122 00124 virtual bool addPagedInChild(Node* child); 00125 00127 virtual void adjustLOD( Node* child); 00128 00130 float fileRangeCullDistance2D(DtOsgCullVisitor& nv ); 00131 00133 bool fileInRange2D( float distance, float cull); 00134 00136 float childRangeCullDistance2D(DtOsgCullVisitor& nv ); 00137 00139 bool fileInChildRange2D( float cull, float lod ); 00140 00142 void setThreadSafeRefUnref(bool threadSafe); 00143 00145 virtual void resizeGLObjectBuffers(unsigned int maxSize); 00146 00150 virtual void releaseGLObjects(osg::State* state) const; 00151 00153 virtual std::string fileName() const; 00154 00156 virtual const std::vector<osg::ref_ptr<DtHierarchicalPagedLod> >& children() const; 00157 00160 virtual const osg::Matrix& fileTranslation() const; 00161 00162 protected: 00163 00164 enum FileState 00165 { 00166 NotLoaded = 0, 00167 Paging, 00168 Loaded 00169 }; 00170 00173 class DT_DLL_VRVOSG PagedFileRoot : public osg::MatrixTransform 00174 { 00175 public: 00176 PagedFileRoot(DtHierarchicalPagedLod& parent, const osg::Matrixd& m) 00177 : osg::MatrixTransform(m) 00178 , myParent(parent) 00179 { 00180 _parents.push_back(&parent); 00181 } 00182 00183 //Override Add child to inform DtHierarchicalPagedLod of page in. 00184 virtual bool addChild( Node *child ) 00185 { 00186 return myParent.addPagedInChild(child); 00187 } 00188 DtHierarchicalPagedLod& myParent; 00189 }; 00190 00191 osg::Vec3d myFileCenter; 00192 osg::Vec3d myChildrenCenter; 00193 00194 const float myRangeNear; 00195 const float myRangeFar; 00196 const float myTileRadius; 00197 const float myChildTileRadius; 00198 const bool myChildrenAreSparse; 00199 const bool myChildrenAreSubstitutive; 00200 00201 volatile int myCullTracking; 00202 std::string myFileName; 00203 FileState myFileState; 00204 osg::ref_ptr<PagedFileRoot> myFileRoot; 00205 std::vector<osg::ref_ptr<DtHierarchicalPagedLod> > myChildren; 00206 osg::ref_ptr<osg::Referenced> myPageRef; 00207 osg::ref_ptr<osgDB::Options> myOptions; 00208 }; 00209 }