首页 > 其他 > 详细

osg::NodeVisitor example

时间:2019-06-27 21:52:38      阅读:146      评论:0      收藏:0      [点我收藏+]

[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中结构

技术分享图片

 

osg::NodeVisitor example

原文:https://www.cnblogs.com/herd/p/11099518.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!