OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Impostor.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 OSGSIM_IMPOSTOR
15 #define OSGSIM_IMPOSTOR 1
16 
17 #include <osg/LOD>
18 #include <osg/buffered_value>
19 
20 #include <osgUtil/CullVisitor>
21 
22 #include <osgSim/ImpostorSprite>
23 
24 namespace osgSim {
25 
65 {
66  public :
67  Impostor();
68 
70  osg::LOD(es,copyop),
71  _impostorThreshold(es._impostorThreshold) {}
72 
74 
75  virtual void traverse(osg::NodeVisitor& nv);
76 
77  typedef std::vector< osg::ref_ptr<ImpostorSprite> > ImpostorSpriteList;
78 
83  inline void setImpostorThreshold(float distance) { _impostorThreshold = distance; }
84 
85  /* Get the Impostor threshold distance. */
86  inline float getImpostorThreshold() const { return _impostorThreshold; }
87 
91  inline void setImpostorThresholdToBound(float ratio=1.0f) { _impostorThreshold = getBound().radius()*ratio; }
92 
94  ImpostorSprite* findBestImpostorSprite(unsigned int contextID, const osg::Vec3& currLocalEyePoint) const;
95 
97  void addImpostorSprite(unsigned int contextID, ImpostorSprite* is);
98 
100  inline ImpostorSpriteList& getImpostorSpriteList(unsigned int contexID) { return _impostorSpriteListBuffer[contexID]; }
101 
103  inline const ImpostorSpriteList& getImpostorSpriteList(unsigned int contexID) const { return _impostorSpriteListBuffer[contexID]; }
104 
105  virtual osg::BoundingSphere computeBound() const;
106 
107  protected :
108 
109  virtual ~Impostor() {}
110 
112 
113  ImpostorSprite* createImpostorSprite(osgUtil::CullVisitor* cv);
114 
116 
117 };
118 
119 }
120 
121 #endif
#define OSGSIM_EXPORT
Definition: Export.h:38
const ImpostorSpriteList & getImpostorSpriteList(unsigned int contexID) const
Definition: Impostor.h:103
float getImpostorThreshold() const
Definition: Impostor.h:86
float _impostorThreshold
Definition: Impostor.h:115
void setImpostorThresholdToBound(float ratio=1.0f)
Definition: Impostor.h:91
#define META_Node(library, name)
Definition: Node.h:59
void setImpostorThreshold(float distance)
Definition: Impostor.h:83
Impostor(const Impostor &es, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
Definition: Impostor.h:69
Definition: LOD.h:35
osg::buffered_object< ImpostorSpriteList > _impostorSpriteListBuffer
Definition: Impostor.h:111
Definition: AlphaFunc.h:19
std::vector< osg::ref_ptr< ImpostorSprite > > ImpostorSpriteList
Definition: Impostor.h:77
ImpostorSpriteList & getImpostorSpriteList(unsigned int contexID)
Definition: Impostor.h:100
virtual ~Impostor()
Definition: Impostor.h:109