CollectOccludersVisitor
Go to the documentation of this file.
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 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 OSG_EXPORT CollectOccludersVisitor : public osg::NodeVisitor, public osg::CullStack
{
public:
typedef std::set<ShadowVolumeOccluder> ShadowVolumeOccluderSet;
CollectOccludersVisitor();
virtual ~CollectOccludersVisitor();
META_NodeVisitor(osg, CollectOccludersVisitor)
virtual Object* cloneType() const { return new CollectOccludersVisitor(); }
virtual void reset();
virtual float getDistanceToEyePoint(const Vec3& pos, bool withLODScale) const;
virtual float getDistanceToViewPoint(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);
void setMinimumShadowOccluderVolume(float vol) { _minimumShadowOccluderVolume = vol; }
float getMinimumShadowOccluderVolume() const { return _minimumShadowOccluderVolume; }
void setMaximumNumberOfActiveOccluders(unsigned int num) { _maximumNumberOfActiveOccluders = num; }
unsigned int getMaximumNumberOfActiveOccluders() const { return _maximumNumberOfActiveOccluders; }
void setCreateDrawablesOnOccludeNodes(bool flag) { _createDrawables=flag; }
bool getCreateDrawablesOnOccludeNodes() const { return _createDrawables; }
void setCollectedOccluderSet(const ShadowVolumeOccluderSet& svol) { _occluderSet = svol; }
ShadowVolumeOccluderSet& getCollectedOccluderSet() { return _occluderSet; }
const ShadowVolumeOccluderSet& getCollectedOccluderSet() const { return _occluderSet; }
void removeOccludedOccluders();
protected:
//CollectOccludersVisitor(const CollectOccludersVisitor&):osg::NodeVisitor(),osg::CullStack() {}
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;
unsigned _maximumNumberOfActiveOccluders;
bool _createDrawables;
ShadowVolumeOccluderSet _occluderSet;
};
}
#endif
CullStack
NodeVisitor
osg::CollectOccludersVisitor::getMinimumShadowOccluderVolume
float getMinimumShadowOccluderVolume() const
Definition CollectOccludersVisitor:57
osg::CollectOccludersVisitor::handle_cull_callbacks_and_traverse
void handle_cull_callbacks_and_traverse(osg::Node &node)
Definition CollectOccludersVisitor:85
osg::CollectOccludersVisitor::setCollectedOccluderSet
void setCollectedOccluderSet(const ShadowVolumeOccluderSet &svol)
Definition CollectOccludersVisitor:67
osg::CollectOccludersVisitor::getDistanceFromEyePoint
virtual float getDistanceFromEyePoint(const Vec3 &pos, bool withLODScale) const
osg::CollectOccludersVisitor::apply
virtual void apply(osg::OccluderNode &node)
osg::CollectOccludersVisitor::getCollectedOccluderSet
const ShadowVolumeOccluderSet & getCollectedOccluderSet() const
Definition CollectOccludersVisitor:69
osg::CollectOccludersVisitor::apply
virtual void apply(osg::Transform &node)
osg::CollectOccludersVisitor::~CollectOccludersVisitor
virtual ~CollectOccludersVisitor()
osg::CollectOccludersVisitor::apply
virtual void apply(osg::Projection &node)
osg::CollectOccludersVisitor::getCollectedOccluderSet
ShadowVolumeOccluderSet & getCollectedOccluderSet()
Definition CollectOccludersVisitor:68
osg::CollectOccludersVisitor::setCreateDrawablesOnOccludeNodes
void setCreateDrawablesOnOccludeNodes(bool flag)
Definition CollectOccludersVisitor:64
osg::CollectOccludersVisitor::apply
virtual void apply(osg::LOD &node)
osg::CollectOccludersVisitor::getMaximumNumberOfActiveOccluders
unsigned int getMaximumNumberOfActiveOccluders() const
Definition CollectOccludersVisitor:62
osg::CollectOccludersVisitor::META_NodeVisitor
META_NodeVisitor(osg, CollectOccludersVisitor) virtual Object *cloneType() const
Definition CollectOccludersVisitor:34
osg::CollectOccludersVisitor::_minimumShadowOccluderVolume
float _minimumShadowOccluderVolume
Definition CollectOccludersVisitor:99
osg::CollectOccludersVisitor::_occluderSet
ShadowVolumeOccluderSet _occluderSet
Definition CollectOccludersVisitor:102
osg::CollectOccludersVisitor::setMinimumShadowOccluderVolume
void setMinimumShadowOccluderVolume(float vol)
Definition CollectOccludersVisitor:56
osg::CollectOccludersVisitor::removeOccludedOccluders
void removeOccludedOccluders()
osg::CollectOccludersVisitor::apply
virtual void apply(osg::Switch &node)
osg::CollectOccludersVisitor::setMaximumNumberOfActiveOccluders
void setMaximumNumberOfActiveOccluders(unsigned int num)
Definition CollectOccludersVisitor:61
osg::CollectOccludersVisitor::CollectOccludersVisitor
CollectOccludersVisitor()
osg::CollectOccludersVisitor::ShadowVolumeOccluderSet
std::set< ShadowVolumeOccluder > ShadowVolumeOccluderSet
Definition CollectOccludersVisitor:29
osg::CollectOccludersVisitor::reset
virtual void reset()
osg::CollectOccludersVisitor::getDistanceToViewPoint
virtual float getDistanceToViewPoint(const Vec3 &pos, bool withLODScale) const
osg::CollectOccludersVisitor::handle_cull_callbacks_and_accept
void handle_cull_callbacks_and_accept(osg::Node &node, osg::Node *acceptNode)
Definition CollectOccludersVisitor:92
osg::CollectOccludersVisitor::_maximumNumberOfActiveOccluders
unsigned _maximumNumberOfActiveOccluders
Definition CollectOccludersVisitor:100
osg::CollectOccludersVisitor::_createDrawables
bool _createDrawables
Definition CollectOccludersVisitor:101
osg::CollectOccludersVisitor::getCreateDrawablesOnOccludeNodes
bool getCreateDrawablesOnOccludeNodes() const
Definition CollectOccludersVisitor:65
osg::CollectOccludersVisitor::apply
virtual void apply(osg::Node &)
osg::CollectOccludersVisitor::getDistanceToEyePoint
virtual float getDistanceToEyePoint(const Vec3 &pos, bool withLODScale) const
osg::CullStack
Definition CullStack:28
osg::LOD
Definition LOD:36
osg::NodeVisitor
Definition NodeVisitor:82
osg::NodeVisitor::traverse
void traverse(Node &node)
Definition NodeVisitor:274
osg::Node
Definition Node:72
osg::Node::getNumChildrenWithOccluderNodes
unsigned int getNumChildrenWithOccluderNodes() const
Definition Node:340
osg::Node::accept
virtual void accept(NodeVisitor &nv)
osg::Object
Definition Object:61
osg::Object::cloneType
virtual Object * cloneType() const =0
osg::OccluderNode
Definition OccluderNode:27
osg::Projection
Definition Projection:25
osg::Switch
Definition Switch:27
osg::Transform
Definition Transform:75
osg
Definition AlphaFunc:19
osg::Vec3
Vec3f Vec3
Definition Vec3:21
OSG_EXPORT
#define OSG_EXPORT
Definition osg/Export:39