2015-04-10 21:16:17 +00:00
|
|
|
#ifndef OPENMW_COMPONENTS_SCENEUTIL_VISITOR_H
|
|
|
|
#define OPENMW_COMPONENTS_SCENEUTIL_VISITOR_H
|
|
|
|
|
|
|
|
#include <osg/NodeVisitor>
|
|
|
|
|
2015-04-23 15:15:30 +00:00
|
|
|
#include <components/misc/stringops.hpp>
|
|
|
|
|
2015-04-10 21:16:17 +00:00
|
|
|
// Commonly used scene graph visitors
|
|
|
|
namespace SceneUtil
|
|
|
|
{
|
|
|
|
|
|
|
|
class FindByNameVisitor : public osg::NodeVisitor
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
FindByNameVisitor(const std::string& nameToFind)
|
|
|
|
: osg::NodeVisitor(TRAVERSE_ALL_CHILDREN)
|
|
|
|
, mNameToFind(nameToFind)
|
|
|
|
, mFoundNode(NULL)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-04-21 16:52:13 +00:00
|
|
|
virtual void apply(osg::Group& group)
|
2015-04-10 21:16:17 +00:00
|
|
|
{
|
2015-04-23 15:15:30 +00:00
|
|
|
if (Misc::StringUtils::ciEqual(group.getName(), mNameToFind))
|
2015-04-10 21:16:17 +00:00
|
|
|
{
|
2015-04-21 16:52:13 +00:00
|
|
|
mFoundNode = &group;
|
2015-04-10 21:16:17 +00:00
|
|
|
return;
|
|
|
|
}
|
2015-04-21 16:52:13 +00:00
|
|
|
traverse(group);
|
2015-04-10 21:16:17 +00:00
|
|
|
}
|
|
|
|
|
2015-04-19 12:25:36 +00:00
|
|
|
std::string mNameToFind;
|
2015-04-10 21:16:17 +00:00
|
|
|
osg::Group* mFoundNode;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|