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

 

转载于:https://www.cnblogs.com/herd/p/11099518.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值