zoukankan      html  css  js  c++  java
  • osg::NodeVisitor example

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

    class InfoVisitor : public osg::NodeVisitor
    {
    public:
        InfoVisitor()
            :osg::NodeVisitor(TRAVERSE_ALL_CHILDREN), _indent(0)
        {}
    
        virtual void apply(osg::Node& node)
        {
            for (int i = 0; i < _indent; i++)  std::cout << "    ";
            std::cout << "[" << _indent << "]" << node.libraryName()
                << "::" << node.className() << std::endl;
    
            _indent++;
            traverse(node);
            _indent--;
    
            for (int i = 0; i < _indent; i++)  std::cout << "    ";
            std::cout << "[" << _indent << "] " << node.libraryName()
                << "::" << node.className() << std::endl;
        }
    
        virtual void apply(osg::Geode& node)
        {
            for (int i = 0; i < _indent; i++)  std::cout << "    ";
            std::cout << "[" << _indent << "] " << node.libraryName()
                << "::" << node.className() << std::endl;
    
            _indent++;
    
            for (unsigned int n = 0; n < node.getNumDrawables(); n++)
            {
                osg::Drawable* draw = node.getDrawable(n);
                if (!draw)
                    continue;
                for (int i = 0; i < _indent; i++)  std::cout << "    ";
                std::cout << "[" << _indent << "]" << draw->libraryName() << "::"
                    << draw->className() << std::endl;
            }
    
            traverse(node);
            _indent--;
    
            for (int i = 0; i < _indent; i++)  std::cout << "    ";
            std::cout << "[" << _indent << "]" << node.libraryName()
                << "::" << node.className() << std::endl;
        }
    private:
        int _indent;
    };

     

    该模型在unity3d中结构

    该模型在3dmax中结构

  • 相关阅读:
    Eclipse中用两个控制台测试网络通信程序
    c++ primer 11 泛型算法
    c++ primer 10 关联容器
    c++ primer 9 顺序容器
    c++ primer 8 标准IO库
    安装使用
    InfluxDB介绍
    proxy.go
    monitor.go
    balancer.go
  • 原文地址:https://www.cnblogs.com/herd/p/11099518.html
Copyright © 2011-2022 走看看