170 lines
4.1 KiB
C++
Executable File
170 lines
4.1 KiB
C++
Executable File
#pragma once
|
|
|
|
#include <osg/Group>
|
|
#include <osg/NodeVisitor>
|
|
#include <osg/Geode>
|
|
#include <osg/Geometry>
|
|
#include <QtCore/QString>
|
|
|
|
namespace VCtrl
|
|
{
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
class FindByNameVisitor final : public osg::NodeVisitor
|
|
{
|
|
public:
|
|
|
|
std::vector<osg::Node *> mNodes;
|
|
QString mName;
|
|
explicit FindByNameVisitor(const QString &name)
|
|
: osg::NodeVisitor(TRAVERSE_ALL_CHILDREN)
|
|
, mName(name)
|
|
{}
|
|
|
|
void apply(osg::Node &node) override;
|
|
};
|
|
|
|
////////////////////////////////////////////////////////////////////////////
|
|
class FindExactNameVisitor final : public osg::NodeVisitor
|
|
{
|
|
public:
|
|
std::vector<osg::Node *> mNodes;
|
|
std::set<std::string> mNamesToSearch;
|
|
|
|
explicit FindExactNameVisitor(const std::set<std::string> &namesToSearch)
|
|
: osg::NodeVisitor(TRAVERSE_ALL_CHILDREN)
|
|
, mNamesToSearch(namesToSearch)
|
|
{}
|
|
|
|
void apply(osg::Node &node) override;
|
|
};
|
|
|
|
////////////////////////////////////////////////////////////////////////////
|
|
class SplitVisitor final : public osg::NodeVisitor
|
|
{
|
|
|
|
public:
|
|
std::vector<osg::ref_ptr<osg::Node> > _parts;
|
|
std::vector<float> _heights;
|
|
SplitVisitor()
|
|
: osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN)
|
|
{}
|
|
|
|
void apply(osg::Group &node) override;
|
|
};
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
class FindRoomComponentsVisitor final : public osg::NodeVisitor
|
|
{
|
|
|
|
public:
|
|
std::set<std::string> mNamesFound;
|
|
|
|
FindRoomComponentsVisitor()
|
|
: osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN)
|
|
{}
|
|
|
|
void apply(osg::Group &node) override;
|
|
|
|
};
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
class FindRoomNamesVisitor final : public osg::NodeVisitor
|
|
{
|
|
public:
|
|
|
|
std::vector<std::string> mNames;
|
|
|
|
// Default constructor - initialize searchForName to "" and
|
|
// set the traversal mode to TRAVERSE_ALL_CHILDREN
|
|
FindRoomNamesVisitor() : osg::NodeVisitor(TRAVERSE_ALL_CHILDREN)
|
|
{}
|
|
|
|
void apply(osg::Node &n) override;
|
|
};
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
class FindRoomByNumberVisitor final : public osg::NodeVisitor
|
|
{
|
|
public:
|
|
|
|
// Default constructor - initialize searchForName to "" and
|
|
// set the traversal mode to TRAVERSE_ALL_CHILDREN
|
|
FindRoomByNumberVisitor()
|
|
: osg::NodeVisitor(TRAVERSE_ALL_CHILDREN),
|
|
searchForName()
|
|
{}
|
|
|
|
// Constructor that accepts string argument
|
|
// Initializes searchForName to user string
|
|
// set the traversal mode to TRAVERSE_ALL_CHILDREN
|
|
explicit FindRoomByNumberVisitor(const std::string &searchName) :
|
|
osg::NodeVisitor(TRAVERSE_ALL_CHILDREN),
|
|
searchForName(searchName)
|
|
{
|
|
}
|
|
|
|
void apply(osg::Node &searchNode) override;
|
|
|
|
// Set the searchForName to user-defined string
|
|
void setNameToFind(const std::string &searchName)
|
|
{
|
|
searchForName = searchName;
|
|
foundNodeList.clear();
|
|
}
|
|
|
|
// Return a pointer to the first node in the list
|
|
// with a matching name
|
|
osg::Node *getFirst()
|
|
{
|
|
return *(foundNodeList.begin());
|
|
}
|
|
|
|
|
|
// typedef a vector of node pointers for convenience
|
|
using NodeList = std::vector<osg::Node *>;
|
|
|
|
// return a reference to the list of nodes we found
|
|
NodeList &getNodeList() { return foundNodeList; }
|
|
|
|
private:
|
|
|
|
// the name we are looking for
|
|
std::string searchForName;
|
|
|
|
// List of nodes with names that match the searchForName string
|
|
NodeList foundNodeList;
|
|
|
|
};
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
class ClearVertexColorsVisitor final : public osg::NodeVisitor
|
|
{
|
|
public:
|
|
|
|
ClearVertexColorsVisitor()
|
|
: osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN)
|
|
{}
|
|
|
|
void apply(osg::Geode &geode) override;
|
|
};
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
class SetWallsTransparentVisitor final : public osg::NodeVisitor
|
|
{
|
|
float mTransparency;
|
|
public:
|
|
|
|
explicit SetWallsTransparentVisitor(float transparency)
|
|
: osg::NodeVisitor(TRAVERSE_ALL_CHILDREN)
|
|
, mTransparency(transparency)
|
|
{
|
|
setNodeMaskOverride(0xFFFFFFFF);
|
|
}
|
|
|
|
void SetAlpha(osg::Node *node, float alpha);
|
|
|
|
void apply(osg::Node &node) override;
|
|
};
|
|
}
|