• osg::NodeVisitor


    [1]osg::Group
            [2]osg::PositionAttitudeTransform
            [2]osg::MatrixTransform
                    [3]osg::Geode
            [2]osg::MatrixTransform
            [2]osg::MatrixTransform
            [2]osg::MatrixTransform
            [2]osg::MatrixTransform
                    [3]osg::Geode
                    osg::Geometry
                            [4]osg::Geometry

    class BoundVisitor :public osg::NodeVisitor
    {
    public:
        //BoundVisitor():osg::NodeVisitor(TRAVERSE_ALL_CHILDREN), _indent(0)
        //{
            
        //}
    
        BoundVisitor() :osg::NodeVisitor(TRAVERSE_ALL_CHILDREN), _indent(0) 
        {
            std::cout << "--" << std::endl;
        }
    
        virtual void apply(osg::Node &node)
        {
            for (int i = 0; i < _indent; ++i)
            {
                std::cout << "	";
            }
            std::cout << "[" << _indent + 1 << "]" << node.libraryName()<< "::" << node.className() << std::endl;
    
            _indent++;
            traverse(node);
            _indent--;
        }
    
        virtual void apply(osg::Geode &geode)
        {
            for (int i = 0; i < _indent; ++i)
            {
                std::cout << "	";
            }
            std::cout << "[" << _indent + 1 << "]" << geode.libraryName()<< "::" << geode.className() << std::endl;
    
    
            //osg::Drawable *drawable1=  geode.getDrawable(0);
            unsigned int count = geode.getNumDrawables();
            for (int i = 0; i < count; i++)
            {
                osg::Drawable *drawable = geode.getDrawable(i);
                if (!drawable)
                {
                    continue;
                }
    
                osg::Geometry *geometry = geode.getDrawable(i)->asGeometry();
                if (!geometry)
                {
                    continue;
                }
    
                // 顶点数据
                osg::Vec3Array* vertices = dynamic_cast<osg::Vec3Array*>(geometry->getVertexArray());
                //osg::Vec3Array vertices = geometry->getVertexArray();
                int vertexlNum = vertices->size();
                //std::cout << "size:"<<vertexlNum <<"     "<< geometry->libraryName() <<"  "<< geometry->getNumChildrenRequiringEventTraversal() << std::endl;
                //geometry->libraryName();
                
                //for (int j = 0; j<100; j++) {
                    //dstSubset.vertexs.push_back(vertices->at(j).x());
                    //dstSubset.vertexs.push_back(vertices->at(j).y());
                    //dstSubset.vertexs.push_back(vertices->at(j).z());
                    //std::cout << "x:" << vertices->at(j).x() << "  y:" << vertices->at(j).y() << "  z:" << vertices->at(j).z() << std::endl;
                //}
    
                for (int i = 0; i < _indent; ++i)
                {
                    std::cout << "	";
                }
                std::cout << drawable->libraryName()
                    << "::" << drawable->className() << std::endl;
            }
        
            _indent++;
            traverse(geode);
            _indent--;
        }
    
    protected:
        int _indent;
    };
  • 相关阅读:
    Nginx中工作进程(work-process)为多少合适?
    Ubuntu中安装启动Nginx
    怎么获得类加载器?
    XML解析方式有哪些?
    HashMap常见面试题
    IO流分类
    集合之间的区别
    css布局2
    css布局1
    css3 总结01
  • 原文地址:https://www.cnblogs.com/herd/p/11099492.html
Copyright © 2020-2023  润新知