OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CollectOccludersVisitor.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_COLLECTOCCLUDERSVISITOR
15 #define OSG_COLLECTOCCLUDERSVISITOR 1
16 
17 #include <osg/NodeVisitor>
18 #include <osg/CullStack>
19 
20 #include <set>
21 
22 namespace osg {
23 
25 {
26  public:
27 
28 
29  typedef std::set<ShadowVolumeOccluder> ShadowVolumeOccluderSet;
30 
32  virtual ~CollectOccludersVisitor();
33 
35 
36  virtual Object* cloneType() const { return new CollectOccludersVisitor(); }
37 
38  virtual void reset();
39 
40  virtual float getDistanceToEyePoint(const Vec3& pos, bool withLODScale) const;
41  virtual float getDistanceToViewPoint(const Vec3& pos, bool withLODScale) const;
42 
43  virtual float getDistanceFromEyePoint(const Vec3& pos, bool withLODScale) const;
44 
45  virtual void apply(osg::Node&);
46  virtual void apply(osg::Transform& node);
47  virtual void apply(osg::Projection& node);
48 
49  virtual void apply(osg::Switch& node);
50  virtual void apply(osg::LOD& node);
51  virtual void apply(osg::OccluderNode& node);
52 
56  void setMinimumShadowOccluderVolume(float vol) { _minimumShadowOccluderVolume = vol; }
57  float getMinimumShadowOccluderVolume() const { return _minimumShadowOccluderVolume; }
58 
61  void setMaximumNumberOfActiveOccluders(unsigned int num) { _maximumNumberOfActiveOccluders = num; }
62  unsigned int getMaximumNumberOfActiveOccluders() const { return _maximumNumberOfActiveOccluders; }
63 
64  void setCreateDrawablesOnOccludeNodes(bool flag) { _createDrawables=flag; }
65  bool getCreateDrawablesOnOccludeNodes() const { return _createDrawables; }
66 
67  void setCollectedOccluderSet(const ShadowVolumeOccluderSet& svol) { _occluderSet = svol; }
68  ShadowVolumeOccluderSet& getCollectedOccluderSet() { return _occluderSet; }
69  const ShadowVolumeOccluderSet& getCollectedOccluderSet() const { return _occluderSet; }
70 
74  void removeOccludedOccluders();
75 
76 
77  protected:
78 
80  //CollectOccludersVisitor(const CollectOccludersVisitor&):osg::NodeVisitor(),osg::CullStack() {}
81 
83  CollectOccludersVisitor& operator = (const CollectOccludersVisitor&) { return *this; }
84 
86  {
87  /*osg::NodeCallback* callback = node.getCullCallback();
88  if (callback) (*callback)(&node,this);
89  else*/ if (node.getNumChildrenWithOccluderNodes()>0) traverse(node);
90  }
91 
92  inline void handle_cull_callbacks_and_accept(osg::Node& node,osg::Node* acceptNode)
93  {
94  /*osg::NodeCallback* callback = node.getCullCallback();
95  if (callback) (*callback)(&node,this);
96  else*/ if (node.getNumChildrenWithOccluderNodes()>0) acceptNode->accept(*this);
97  }
98 
102  ShadowVolumeOccluderSet _occluderSet;
103 
104 };
105 
106 }
107 
108 #endif
109 
#define OSG_EXPORT
Definition: Export.h:43
const ShadowVolumeOccluderSet & getCollectedOccluderSet() const
META_NodeVisitor(osg, CollectOccludersVisitor) virtual Object *cloneType() const
unsigned int getNumChildrenWithOccluderNodes() const
Definition: Node.h:329
void setCollectedOccluderSet(const ShadowVolumeOccluderSet &svol)
ShadowVolumeOccluderSet & getCollectedOccluderSet()
void handle_cull_callbacks_and_accept(osg::Node &node, osg::Node *acceptNode)
Definition: LOD.h:35
std::set< ShadowVolumeOccluder > ShadowVolumeOccluderSet
T * cloneType(const T *t)
Definition: Object.h:284
virtual void accept(NodeVisitor &nv)
void handle_cull_callbacks_and_traverse(osg::Node &node)
ShadowVolumeOccluderSet _occluderSet
unsigned int getMaximumNumberOfActiveOccluders() const
Definition: Node.h:71
Definition: AlphaFunc.h:19
void setMaximumNumberOfActiveOccluders(unsigned int num)
void setCreateDrawablesOnOccludeNodes(bool flag)