openscenegraph
LOD
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
19namespace osg {
20
35class OSG_EXPORT LOD : public Group
36{
37 public :
38
44 LOD();
45
47 LOD(const LOD&,const CopyOp& copyop=CopyOp::SHALLOW_COPY);
48
50
53
54 virtual void traverse(NodeVisitor& nv);
55
57
58 virtual bool addChild(Node *child);
59
60 virtual bool addChild(Node *child, float rmin, float rmax);
61
62 template<class T> bool addChild( const ref_ptr<T>& child, float rmin, float rmax) { return addChild(child.get(), rmin, rmax); }
63
64 virtual bool removeChildren(unsigned int pos,unsigned int numChildrenToRemove=1);
65
66 typedef std::pair<float,float> MinMaxPair;
67 typedef std::vector<MinMaxPair> RangeList;
68
72 {
75 UNION_OF_BOUNDING_SPHERE_AND_USER_DEFINED
76 };
77
79 void setCenterMode(CenterMode mode) { _centerMode=mode; }
80
82 CenterMode getCenterMode() const { return _centerMode; }
83
89 inline void setCenter(const vec_type& center) { if (_centerMode!=UNION_OF_BOUNDING_SPHERE_AND_USER_DEFINED) { _centerMode=USER_DEFINED_CENTER; } _userDefinedCenter = center; }
90
92 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(); }
93
94
100 inline void setRadius(value_type radius) { _radius = radius; }
101
103 inline value_type getRadius() const { return _radius; }
104
107 {
109 PIXEL_SIZE_ON_SCREEN
110 };
111
113 void setRangeMode(RangeMode mode) { _rangeMode = mode; }
114
116 RangeMode getRangeMode() const { return _rangeMode; }
117
118
121 void setRange(unsigned int childNo, float min,float max);
122
124 inline float getMinRange(unsigned int childNo) const { return _rangeList[childNo].first; }
125
127 inline float getMaxRange(unsigned int childNo) const { return _rangeList[childNo].second; }
128
131 inline unsigned int getNumRanges() const { return static_cast<unsigned int>(_rangeList.size()); }
132
134 inline void setRangeList(const RangeList& rangeList) { _rangeList=rangeList; }
135
137 inline const RangeList& getRangeList() const { return _rangeList; }
138
140
141 protected :
142 virtual ~LOD() {}
143
147
150
151};
152
153}
154
155#endif
Definition BoundingSphere:35
VT vec_type
Definition BoundingSphere:37
VT::value_type value_type
Definition BoundingSphere:38
Definition CopyOp:41
Definition Group:29
virtual bool addChild(Node *child)
Definition LOD:36
void setCenterMode(CenterMode mode)
Definition LOD:79
RangeMode _rangeMode
Definition LOD:148
virtual bool addChild(Node *child)
const vec_type & getCenter() const
Definition LOD:92
RangeMode
Definition LOD:107
@ DISTANCE_FROM_EYE_POINT
Definition LOD:108
RangeList _rangeList
Definition LOD:149
virtual bool removeChildren(unsigned int pos, unsigned int numChildrenToRemove=1)
const RangeList & getRangeList() const
Definition LOD:137
value_type getRadius() const
Definition LOD:103
void setCenter(const vec_type &center)
Definition LOD:89
virtual bool addChild(Node *child, float rmin, float rmax)
RangeMode getRangeMode() const
Definition LOD:116
virtual ~LOD()
Definition LOD:142
std::pair< float, float > MinMaxPair
Definition LOD:66
void setRange(unsigned int childNo, float min, float max)
virtual BoundingSphere computeBound() const
osg::BoundingSphere::vec_type vec_type
Definition LOD:51
float getMinRange(unsigned int childNo) const
Definition LOD:124
CenterMode _centerMode
Definition LOD:144
float getMaxRange(unsigned int childNo) const
Definition LOD:127
LOD(const LOD &, const CopyOp &copyop=CopyOp::SHALLOW_COPY)
void setRangeMode(RangeMode mode)
Definition LOD:113
unsigned int getNumRanges() const
Definition LOD:131
void setRadius(value_type radius)
Definition LOD:100
osg::BoundingSphere::value_type value_type
Definition LOD:52
void setRangeList(const RangeList &rangeList)
Definition LOD:134
CenterMode
Definition LOD:72
@ USER_DEFINED_CENTER
Uses the user defined center as the center of object; the bounding sphere is determined by the user d...
Definition LOD:74
@ USE_BOUNDING_SPHERE_CENTER
Uses the bounding sphere's center as the center of object and the geometrical bounding sphere of the ...
Definition LOD:73
META_Node(osg, LOD)
CenterMode getCenterMode() const
Definition LOD:82
bool addChild(const ref_ptr< T > &child, float rmin, float rmax)
Definition LOD:62
virtual void traverse(NodeVisitor &nv)
vec_type _userDefinedCenter
Definition LOD:145
std::vector< MinMaxPair > RangeList
Definition LOD:67
value_type _radius
Definition LOD:146
Definition NodeVisitor:82
Definition Node:72
Definition ref_ptr:32
T * get() const
Definition ref_ptr:117
author: Julien Valentin 2017 (mp3butcher@hotmail.com)
Definition AlphaFunc:19
#define OSG_EXPORT
Definition osg/Export:39