|
楼主 |
发表于 2009-8-5 15:26:23
|
显示全部楼层
FindNode.h
class FindNode : public osg::NodeVisitor
{
public:
typedef std::vector<osg::Node*> NodeList;
public:
FindNodeR1(const std::string &searchName);
~FindNodeR1(void);
virtual void apply(osg::Node &searchNode);
osg::Node* GetFirst();
NodeList& GetNodeList() { return m_vFoundNodeList; }
protected:
NodeList m_vFoundNodeList;
std::string m_strSearchName;
};
FindNode.cpp
FindNode::FindNode(const std::string &searchName) :
osg::NodeVisitor(TRAVERSE_ALL_CHILDREN),
m_strSearchName(searchName)
{
}
FindNode::~FindNode(void)
{
}
osg::Node* FindNode::GetFirst()
{
return *(m_vFoundNodeList.begin());
}
void FindNode::apply(osg::Node& searchNode)
{
if (m_strSearchName == searchNode->getName())
m_vFoundNodeList.push_back(geode);
traverse(searchNode);
}
这代码还真没啥花头,好像没有更简单的了。我实在想不出原因,会不会不是osg的问题,而是其他内存释放之类的问题? |
|