• 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;
    };
  • 相关阅读:
    DOM的重点核心
    window的Navigator 对象
    meta标签的http-equiv与content解析
    深拷贝与浅拷贝
    web安全CSRF和XSS
    同源策略与跨域问题
    instanceof与constructor的区别
    javascript原型对象与原型链
    Dom事件
    CSS盒模型的介绍
  • 原文地址:https://www.cnblogs.com/herd/p/11099492.html
Copyright © 2020-2023  润新知