mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-23 20:23:52 +00:00
93 lines
2.2 KiB
C++
93 lines
2.2 KiB
C++
#ifndef OPENMW_COMPONENTS_SCENEUTIL_VISITOR_H
|
|
#define OPENMW_COMPONENTS_SCENEUTIL_VISITOR_H
|
|
|
|
#include <osg/MatrixTransform>
|
|
#include <osg/NodeVisitor>
|
|
|
|
// Commonly used scene graph visitors
|
|
namespace SceneUtil
|
|
{
|
|
|
|
// Find a Group by name, case-insensitive
|
|
// If not found, mFoundNode will be NULL
|
|
class FindByNameVisitor : public osg::NodeVisitor
|
|
{
|
|
public:
|
|
FindByNameVisitor(const std::string& nameToFind)
|
|
: osg::NodeVisitor(TRAVERSE_ALL_CHILDREN)
|
|
, mNameToFind(nameToFind)
|
|
, mFoundNode(NULL)
|
|
{
|
|
}
|
|
|
|
virtual void apply(osg::Group& group);
|
|
virtual void apply(osg::MatrixTransform& node);
|
|
virtual void apply(osg::Geometry& node);
|
|
|
|
bool checkGroup(osg::Group& group);
|
|
|
|
std::string mNameToFind;
|
|
osg::Group* mFoundNode;
|
|
};
|
|
|
|
class FindByClassVisitor : public osg::NodeVisitor
|
|
{
|
|
public:
|
|
FindByClassVisitor(const std::string& nameToFind)
|
|
: osg::NodeVisitor(TRAVERSE_ALL_CHILDREN)
|
|
, mNameToFind(nameToFind)
|
|
{
|
|
}
|
|
|
|
virtual void apply(osg::Node &node);
|
|
|
|
std::string mNameToFind;
|
|
std::vector<osg::Node *> mFoundNodes;
|
|
};
|
|
|
|
// Disable freezeOnCull for all visited particlesystems
|
|
class DisableFreezeOnCullVisitor : public osg::NodeVisitor
|
|
{
|
|
public:
|
|
DisableFreezeOnCullVisitor()
|
|
: osg::NodeVisitor(TRAVERSE_ALL_CHILDREN)
|
|
{
|
|
}
|
|
|
|
virtual void apply(osg::MatrixTransform& node);
|
|
|
|
virtual void apply(osg::Drawable& drw);
|
|
};
|
|
|
|
/// Maps names to nodes
|
|
class NodeMapVisitor : public osg::NodeVisitor
|
|
{
|
|
public:
|
|
typedef std::map<std::string, osg::ref_ptr<osg::MatrixTransform> > NodeMap;
|
|
|
|
NodeMapVisitor(NodeMap& map)
|
|
: osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN)
|
|
, mMap(map)
|
|
{}
|
|
|
|
void apply(osg::MatrixTransform& trans);
|
|
|
|
private:
|
|
NodeMap& mMap;
|
|
};
|
|
|
|
/// Hides all attached drawables
|
|
class HideDrawablesVisitor : public osg::NodeVisitor
|
|
{
|
|
public:
|
|
HideDrawablesVisitor()
|
|
: osg::NodeVisitor(TRAVERSE_ALL_CHILDREN)
|
|
{
|
|
}
|
|
|
|
void apply(osg::Drawable& drawable) override;
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|