VR-Forces 4.3 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) 2011 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 /******************************************************************************
6 ** $RCSfile: $ $Revision: $ $State: $
7 ******************************************************************************/
8 
12 
13 #pragma once
14 #include <vrvOsg/vrvOsg.h>
15 #include <vrvOsg/DtFastGroup.h>
16 #include <osg/Vec3>
17 #include <osg/MatrixTransform>
18 #include <osgDB/Options>
19 
20 namespace makVrv
21 {
22  class DtOsgCullVisitor;
23 
29  {
30  public:
31 
33  DtHierarchicalPagedLod(const std::string& filename,
34  float distanceNear, float distanceFar, float tileRadius,
35  float childTileRadius, const osg::Vec3d& fileCenter,
36  const osg::Vec3d& childrenCenter, bool sparseChildren,
37  bool substitutiveChildren, const osg::Matrixd& fileTranslation,
38  osgDB::Options* options);
39 
41  virtual ~DtHierarchicalPagedLod();
42 
43  virtual const char* className() const { return "DtHierarchicalPagedLod"; }
44 
49  void addChildHierarchy(DtHierarchicalPagedLod* child);
50 
52  virtual void traverse(osg::NodeVisitor& nv);
53 
55  virtual void traverseAll(osg::NodeVisitor& nv);
56 
58  virtual void traverseActive(osg::NodeVisitor& nv);
59 
62  virtual void cullActive(osg::NodeVisitor& nv);
63 
65  void cullActive2D(DtOsgCullVisitor& nv);
66 
68  void cullActive3D(osg::NodeVisitor& nv);
69 
71  virtual osg::BoundingSphere computeBound() const;
72 
75  virtual void traverseFile(osg::NodeVisitor& nv,float distance );
76 
79  virtual void traverseChildren(osg::NodeVisitor& nv);
80 
82  virtual bool fileInRange(float distance) const;
83 
85  virtual float fileRangeDistance(osg::NodeVisitor& nv) const;
86 
88  virtual float childRangeDistance( osg::NodeVisitor& nv ) const;
89 
91  void pageInFile(osg::NodeVisitor& nv, float distance);
92 
95  void pageOutFile(int lastCullTime, osg::NodeList& toRemove);
96 
99  bool fileNotLoaded() const;
100 
102  bool fileIsPaging() const;
103 
105  bool fileIsLoaded() const;
106 
108  virtual bool fileInChildRange(float distance) const;
109 
111  void pageInChildren(osg::NodeVisitor& nv, float distance);
112 
114  void pageOutChildren(int lastCullTime, osg::NodeList& toRemove);
115 
117  bool childrenLoaded() const;
118 
121  osg::ref_ptr<osg::Node> fileNode();
122 
124  virtual bool addPagedInChild(Node* child);
125 
127  virtual void adjustLOD( Node* child);
128 
130  float fileRangeCullDistance2D(DtOsgCullVisitor& nv );
131 
133  bool fileInRange2D( float distance, float cull);
134 
136  float childRangeCullDistance2D(DtOsgCullVisitor& nv );
137 
139  bool fileInChildRange2D( float cull, float lod );
140 
142  void setThreadSafeRefUnref(bool threadSafe);
143 
145  virtual void resizeGLObjectBuffers(unsigned int maxSize);
146 
150  virtual void releaseGLObjects(osg::State* state) const;
151 
153  virtual std::string fileName() const;
154 
156  virtual const std::vector<osg::ref_ptr<DtHierarchicalPagedLod> >& children() const;
157 
160  virtual const osg::Matrix& fileTranslation() const;
161 
162  protected:
163 
165  {
166  NotLoaded = 0,
168  Loaded
169  };
170 
173  class DT_DLL_VRVOSG PagedFileRoot : public osg::MatrixTransform
174  {
175  public:
176  PagedFileRoot(DtHierarchicalPagedLod& parent, const osg::Matrixd& m)
177  : osg::MatrixTransform(m)
178  , myParent(parent)
179  {
180  _parents.push_back(&parent);
181  }
182 
183  //Override Add child to inform DtHierarchicalPagedLod of page in.
184  virtual bool addChild( Node *child )
185  {
186  return myParent.addPagedInChild(child);
187  }
189  };
190 
191  osg::Vec3d myFileCenter;
192  osg::Vec3d myChildrenCenter;
193 
194  const float myRangeNear;
195  const float myRangeFar;
196  const float myTileRadius;
197  const float myChildTileRadius;
200 
201  volatile int myCullTracking;
202  std::string myFileName;
204  osg::ref_ptr<PagedFileRoot> myFileRoot;
205  std::vector<osg::ref_ptr<DtHierarchicalPagedLod> > myChildren;
206  osg::ref_ptr<osg::Referenced> myPageRef;
207  osg::ref_ptr<osgDB::Options> myOptions;
208  };
209 }

Document ID: Generated on Wed Mar 11 21:20:57 EDT 2015 from SVN revision 150940
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)