VR-Forces Development_Version Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DtHierarchicalPagedLod.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2016 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 #include <vrvOsg/vrvOsg.h>
12 #include <vrvOsg/DtFastGroup.h>
13 #include <osg/Vec3>
14 #include <osg/MatrixTransform>
15 #include <osgDB/Options>
16 
17 #include <boost/signals.hpp>
18 
20 
21 #define DTHIERARCHICALPAGEDLOD_LOGGING 0
22 
23 namespace makVrv
24 {
25  class DtOsgCullVisitor;
26 
32  {
33  public:
34 
36  DtHierarchicalPagedLod(const std::string& filename,
37  float distanceNear, float distanceFar, float tileRadius,
38  float childTileRadius, const osg::Vec3d& fileCenter,
39  const osg::Vec3d& childrenCenter, bool sparseChildren,
40  bool substitutiveChildren, const osg::Matrixd& fileTranslation,
41  osgDB::Options* options);
42 
44  virtual ~DtHierarchicalPagedLod();
45 
46  virtual const char* className() const { return "DtHierarchicalPagedLod"; }
47 
52  void addChildHierarchy(DtHierarchicalPagedLod* child);
53 
55  virtual void traverse(osg::NodeVisitor& nv);
56 
58  virtual void traverseAll(osg::NodeVisitor& nv);
59 
61  virtual void traverseActive(osg::NodeVisitor& nv);
62 
65  virtual void cullActive(osg::NodeVisitor& nv);
66 
68  void cullActive2D(DtOsgCullVisitor& nv);
69 
71  void cullActive3D(osg::NodeVisitor& nv);
72 
74  virtual osg::BoundingSphere computeBound() const;
75 
78  virtual void traverseFile(osg::NodeVisitor& nv,float distance );
79 
82  virtual void traverseChildren(osg::NodeVisitor& nv);
83 
85  virtual bool fileInRange(float distance) const;
86 
88  virtual float fileRangeDistance(osg::NodeVisitor& nv) const;
89 
91  virtual float childRangeDistance( osg::NodeVisitor& nv ) const;
92 
94  void pageInFile(osg::NodeVisitor& nv, float distance);
95 
98  void pageOutFile(int lastCullTime, osg::NodeList& toRemove);
99 
102  bool fileNotLoaded() const;
103 
105  bool fileIsPaging() const;
106 
108  bool fileIsLoaded() const;
109 
111  virtual bool fileInChildRange(float distance) const;
112 
114  void pageInChildren(osg::NodeVisitor& nv, float distance);
115 
117  void pageOutChildren(int lastCullTime, osg::NodeList& toRemove);
118 
120  bool childrenLoaded() const;
121 
124  osg::ref_ptr<osg::Node> fileNode();
125 
127  virtual bool addPagedInChild(Node* child);
128 
130  virtual void adjustLOD( Node* child);
131 
133  float fileRangeCullDistance2D(DtOsgCullVisitor& nv );
134 
136  bool fileInRange2D( float distance, float cull);
137 
139  float childRangeCullDistance2D(DtOsgCullVisitor& nv );
140 
142  bool fileInChildRange2D( float cull, float lod );
143 
145  void setThreadSafeRefUnref(bool threadSafe);
146 
148  virtual void resizeGLObjectBuffers(unsigned int maxSize);
149 
153  virtual void releaseGLObjects(osg::State* state) const;
154 
156  virtual std::string fileName() const;
157 
159  virtual const std::vector<osg::ref_ptr<DtHierarchicalPagedLod> >& children() const;
160 
163  virtual const osg::Matrix& fileTranslation() const;
164 
173  boost::signal<void (osg::Group* page, osg::Node* child)> signal_childPagedIn;
174 
177  boost::signal<void (osg::Group* page, osg::Node* child)> signal_childAboutToPageOut;
178  protected:
179 
181  {
182  NotLoaded = 0,
184  Loaded
185  };
186 
189  class DT_DLL_VRVOSG PagedFileRoot : public osg::MatrixTransform
190  {
191  public:
192  PagedFileRoot(DtHierarchicalPagedLod& parent, const osg::Matrixd& m)
193  : osg::MatrixTransform(m)
194  , myParent(parent)
195  {
196  _parents.push_back(&parent);
197  }
198 
199  //Override Add child to inform DtHierarchicalPagedLod of page in.
200  virtual bool addChild( Node *child )
201  {
202  return myParent.addPagedInChild(child);
203  }
205  };
206 
207  osg::Vec3d myFileCenter;
208  osg::Vec3d myChildrenCenter;
209 
210  const float myRangeNear;
211  const float myRangeFar;
212  const float myTileRadius;
213  const float myChildTileRadius;
216 
217  volatile int myCullTracking;
218  std::string myFileName;
220  osg::ref_ptr<PagedFileRoot> myFileRoot;
221  std::vector<osg::ref_ptr<DtHierarchicalPagedLod> > myChildren;
222  osg::ref_ptr<osg::Referenced> myPageRef;
223  osg::ref_ptr<osgDB::Options> myOptions;
224 
225 #if DTHIERARCHICALPAGEDLOD_LOGGING
226  static int myHPLODRefCount;
227 #endif
228  };
229 }

Document ID: Generated on Mon Jul 4 01:00:18 EDT 2016 from SVN revision 166489
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)