OpenSceneGraph/include/osg/CollectOccludersVisitor

96 lines
3.4 KiB
Plaintext
Raw Normal View History

/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OSG_COLLECTOCCLUDERSVISITOR
#define OSG_COLLECTOCCLUDERSVISITOR 1
#include <osg/NodeVisitor>
#include <osg/CullStack>
#include <set>
namespace osg {
class SG_EXPORT CollectOccludersVisitor : public osg::NodeVisitor, public osg::CullStack
{
public:
typedef std::set<ShadowVolumeOccluder> ShadowVolumeOccluderSet;
CollectOccludersVisitor();
virtual ~CollectOccludersVisitor();
virtual CollectOccludersVisitor* cloneType() const { return new CollectOccludersVisitor(); }
virtual void reset();
virtual float getDistanceToEyePoint(const Vec3& pos, bool withLODScale) const;
virtual float getDistanceFromEyePoint(const Vec3& pos, bool withLODScale) const;
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
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; }
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();
protected:
/** prevent unwanted copy construction.*/
CollectOccludersVisitor(const CollectOccludersVisitor&):osg::NodeVisitor(),osg::CullStack() {}
/** prevent unwanted copy operator.*/
CollectOccludersVisitor& operator = (const CollectOccludersVisitor&) { return *this; }
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);
}
float _minimumShadowOccluderVolume;
bool _createDrawables;
ShadowVolumeOccluderSet _occluderSet;
};
}
#endif