OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LOD.h
Go to the documentation of this file.
1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2  *
3  * This library is open source and may be redistributed and/or modified under
4  * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5  * (at your option) any later version. The full license is in LICENSE file
6  * included with this distribution, and on the openscenegraph.org website.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * OpenSceneGraph Public License for more details.
12 */
13 
14 #ifndef OSG_LOD
15 #define OSG_LOD 1
16 
17 #include <osg/Group>
18 
19 namespace osg {
20 
35 class OSG_EXPORT LOD : public Group
36 {
37  public :
38 
39  LOD();
40 
42  LOD(const LOD&,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
43 
44  META_Node(osg, LOD);
45 
48 
49  virtual void traverse(NodeVisitor& nv);
50 
51  virtual bool addChild(Node *child);
52 
53  virtual bool addChild(Node *child, float min, float max);
54 
55  virtual bool removeChildren(unsigned int pos,unsigned int numChildrenToRemove=1);
56 
57  typedef std::pair<float,float> MinMaxPair;
58  typedef std::vector<MinMaxPair> RangeList;
59 
62  {
65  UNION_OF_BOUNDING_SPHERE_AND_USER_DEFINED
66  };
67 
69  void setCenterMode(CenterMode mode) { _centerMode=mode; }
70 
72  CenterMode getCenterMode() const { return _centerMode; }
73 
76  inline void setCenter(const vec_type& center) { if (_centerMode!=UNION_OF_BOUNDING_SPHERE_AND_USER_DEFINED) { _centerMode=USER_DEFINED_CENTER; } _userDefinedCenter = center; }
77 
79  inline const vec_type& getCenter() const { if ((_centerMode==USER_DEFINED_CENTER)||(_centerMode==UNION_OF_BOUNDING_SPHERE_AND_USER_DEFINED)) return _userDefinedCenter; else return getBound().center(); }
80 
81 
84  inline void setRadius(value_type radius) { _radius = radius; }
85 
87  inline value_type getRadius() const { return _radius; }
88 
90  enum RangeMode
91  {
93  PIXEL_SIZE_ON_SCREEN
94  };
95 
97  void setRangeMode(RangeMode mode) { _rangeMode = mode; }
98 
100  RangeMode getRangeMode() const { return _rangeMode; }
101 
102 
105  void setRange(unsigned int childNo, float min,float max);
106 
108  inline float getMinRange(unsigned int childNo) const { return _rangeList[childNo].first; }
109 
111  inline float getMaxRange(unsigned int childNo) const { return _rangeList[childNo].second; }
112 
115  inline unsigned int getNumRanges() const { return static_cast<unsigned int>(_rangeList.size()); }
116 
118  inline void setRangeList(const RangeList& rangeList) { _rangeList=rangeList; }
119 
121  inline const RangeList& getRangeList() const { return _rangeList; }
122 
123  virtual BoundingSphere computeBound() const;
124 
125  protected :
126  virtual ~LOD() {}
127 
130  value_type _radius;
131 
133  RangeList _rangeList;
134 
135 };
136 
137 }
138 
139 #endif
#define OSG_EXPORT
Definition: Export.h:43
RangeMode getRangeMode() const
Definition: LOD.h:100
void setCenterMode(CenterMode mode)
Definition: LOD.h:69
RangeMode
Definition: LOD.h:90
value_type getRadius() const
Definition: LOD.h:87
std::pair< float, float > MinMaxPair
Definition: LOD.h:57
float getMaxRange(unsigned int childNo) const
Definition: LOD.h:111
void setRangeList(const RangeList &rangeList)
Definition: LOD.h:118
#define META_Node(library, name)
Definition: Node.h:59
void setCenter(const vec_type &center)
Definition: LOD.h:76
value_type _radius
Definition: LOD.h:130
const RangeList & getRangeList() const
Definition: LOD.h:121
virtual ~LOD()
Definition: LOD.h:126
void setRadius(value_type radius)
Definition: LOD.h:84
Definition: LOD.h:35
float getMinRange(unsigned int childNo) const
Definition: LOD.h:108
osg::BoundingSphere::vec_type vec_type
Definition: LOD.h:46
vec_type _userDefinedCenter
Definition: LOD.h:129
osg::BoundingSphere::value_type value_type
Definition: LOD.h:47
VT::value_type value_type
const vec_type & getCenter() const
Definition: LOD.h:79
RangeList _rangeList
Definition: LOD.h:133
Definition: Node.h:71
Definition: AlphaFunc.h:19
CenterMode
Definition: LOD.h:61
unsigned int getNumRanges() const
Definition: LOD.h:115
RangeMode _rangeMode
Definition: LOD.h:132
void setRangeMode(RangeMode mode)
Definition: LOD.h:97
CenterMode getCenterMode() const
Definition: LOD.h:72
std::vector< MinMaxPair > RangeList
Definition: LOD.h:58
CenterMode _centerMode
Definition: LOD.h:128