2002-07-17 04:07:32 +08:00
|
|
|
//C++ header - Open Scene Graph - Copyright (C) 1998-2002 Robert Osfield
|
2002-06-10 21:50:25 +08:00
|
|
|
//Distributed under the terms of the GNU Library General Public License (LGPL)
|
|
|
|
//as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
#ifndef OSG_COLLECTOCCLUDERSVISITOR
|
|
|
|
#define OSG_COLLECTOCCLUDERSVISITOR 1
|
|
|
|
|
|
|
|
#include <osg/NodeVisitor>
|
|
|
|
#include <osg/CullStack>
|
|
|
|
|
2002-06-19 06:35:48 +08:00
|
|
|
#include <set>
|
|
|
|
|
2002-06-10 21:50:25 +08:00
|
|
|
namespace osg {
|
|
|
|
|
|
|
|
class SG_EXPORT CollectOccludersVisitor : public osg::NodeVisitor, public osg::CullStack
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
2002-06-19 06:35:48 +08:00
|
|
|
typedef std::set<ShadowVolumeOccluder> ShadowVolumeOccluderSet;
|
|
|
|
|
2002-06-10 21:50:25 +08:00
|
|
|
CollectOccludersVisitor();
|
|
|
|
virtual ~CollectOccludersVisitor();
|
|
|
|
|
2002-07-21 07:54:55 +08:00
|
|
|
virtual CollectOccludersVisitor* cloneType() const { return osgNew CollectOccludersVisitor(); }
|
2002-06-10 21:50:25 +08:00
|
|
|
|
|
|
|
virtual void reset();
|
|
|
|
|
|
|
|
virtual void apply(osg::Node&);
|
|
|
|
virtual void apply(osg::Transform& node);
|
|
|
|
virtual void apply(osg::Projection& node);
|
|
|
|
|
|
|
|
virtual void apply(osg::Switch& node);
|
|
|
|
virtual void apply(osg::LOD& node);
|
|
|
|
virtual void apply(osg::OccluderNode& node);
|
|
|
|
|
2002-06-14 07:46:02 +08:00
|
|
|
|
2002-06-15 20:14:42 +08:00
|
|
|
void setMinimumShadowOccluderVolume(float vol) { _minimumShadowOccluderVolume = vol; }
|
|
|
|
float getMinimumShadowOccluderVolume() const { return _minimumShadowOccluderVolume; }
|
|
|
|
|
2002-06-14 07:46:02 +08:00
|
|
|
void setCreateDrawablesOnOccludeNodes(bool flag) { _createDrawables=flag; }
|
|
|
|
bool getCreateDrawablesOnOccludeNodes() const { return _createDrawables; }
|
|
|
|
|
2002-06-19 06:35:48 +08:00
|
|
|
void setCollectedOcculderList(const ShadowVolumeOccluderSet& svol) { _occluderSet = svol; }
|
|
|
|
ShadowVolumeOccluderSet& getCollectedOccluderSet() { return _occluderSet; }
|
|
|
|
const ShadowVolumeOccluderSet& getCollectedOccluderSet() const { return _occluderSet; }
|
|
|
|
|
|
|
|
/** remove occluded occluders for the collected occluders list.*/
|
|
|
|
void removeOccludedOccluders();
|
2002-06-10 21:50:25 +08:00
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
/** prevent unwanted copy construction.*/
|
|
|
|
CollectOccludersVisitor(const CollectOccludersVisitor&):osg::NodeVisitor(),osg::CullStack() {}
|
|
|
|
|
|
|
|
/** prevent unwanted copy operator.*/
|
|
|
|
CollectOccludersVisitor& operator = (const CollectOccludersVisitor&) { return *this; }
|
|
|
|
|
2002-06-14 21:49:59 +08:00
|
|
|
inline void handle_cull_callbacks_and_traverse(osg::Node& node)
|
|
|
|
{
|
|
|
|
/*osg::NodeCallback* callback = node.getCullCallback();
|
|
|
|
if (callback) (*callback)(&node,this);
|
|
|
|
else*/ if (node.getNumChildrenWithOccluderNodes()>0) traverse(node);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void handle_cull_callbacks_and_accept(osg::Node& node,osg::Node* acceptNode)
|
|
|
|
{
|
|
|
|
/*osg::NodeCallback* callback = node.getCullCallback();
|
|
|
|
if (callback) (*callback)(&node,this);
|
|
|
|
else*/ if (node.getNumChildrenWithOccluderNodes()>0) acceptNode->accept(*this);
|
|
|
|
}
|
2002-06-15 20:14:42 +08:00
|
|
|
|
|
|
|
float _minimumShadowOccluderVolume;
|
|
|
|
bool _createDrawables;
|
2002-06-19 06:35:48 +08:00
|
|
|
ShadowVolumeOccluderSet _occluderSet;
|
2002-06-15 20:14:42 +08:00
|
|
|
|
2002-06-10 21:50:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|