zoukankan      html  css  js  c++  java
  • osg::NodeVisitor osg3.4.0

    x:-89.4588 y:-12.1245 z:-11.7807
    x:-89.4588 y:-6.44823 z:-11.7807
    x:-89.2164 y:-9.07239 z:-11.811
    x:-89.4588 y:-12.1245 z:-11.7807
    x:-89.2164 y:-9.07239 z:-11.811
    x:-89.2164 y:-15.9458 z:-11.811
    x:-89.4588 y:-6.44823 z:-11.7807
    x:-89.2164 y:-2.19896 z:-11.811
    x:-89.2164 y:-9.07239 z:-11.811
    x:-89.4588 y:-6.44823 z:-11.7807
    x:-89.4959 y:-2.57999 z:-11.7705
    x:-89.2164 y:-2.19896 z:-11.811
    x:-89.6451 y:-4.75968 z:-11.7127
    x:-89.4959 y:-2.57999 z:-11.7705
    x:-89.4588 y:-6.44823 z:-11.7807
    x:-89.6451 y:-4.75968 z:-11.7127
    x:-89.7325 y:1.15286 z:-11.6649
    x:-89.4959 y:-2.57999 z:-11.7705
    x:-89.7325 y:1.15286 z:-11.6649
    x:-89.6451 y:-4.75968 z:-11.7127
    x:-89.8026 y:-2.48957 z:-11.6174
    x:-89.8026 y:-2.48957 z:-11.6174
    x:-89.8883 y:1.02162 z:-11.5459

    #ifdef _WIN32
    #include <Windows.h>
    #endif // _WIN32
    #include<iostream>
    
    #include <osgViewer/Viewer>
    #include <osgViewer/ViewerEventHandlers> 
    #include <osgViewer/CompositeViewer> 
    #include <osgDB/ReadFile>
    #include <osg/Geode>
    #include <osg/Node>
    #include <osg/Geometry>
    #include <osgGA/TrackballManipulator>
    #include <osg/GraphicsContext>
    #include <osg/ShapeDrawable>
    #include <osg/Material>
    #include <osg/Image>
    #include <osg/Texture2D>
    #include <osg/TexEnv>
    #include <osg/TexGen>
    #include <osg/NodeVisitor>
    #include <osg/MatrixTransform>
    #include <osg/PositionAttitudeTransform>
    #include <osg/AnimationPath>
    #include <osg/Matrixd>
    
    #include <osgGA/GUIEventHandler>
    #include <osgGA/CameraManipulator>
    #include <osgGA/StandardManipulator>
    #include <osgGA/OrbitManipulator>
    #include <osgGA/TrackballManipulator>
    #include <osgUtil/IntersectionVisitor>
    #include <osgUtil/LineSegmentIntersector>
    
    class BoundVisitor :public osg::NodeVisitor
    {
    public:
        BoundVisitor() :osg::NodeVisitor(TRAVERSE_ALL_CHILDREN), _indent(0) 
        {
            std::cout << "--" << std::endl;
        }
    
    
        virtual void apply(osg::Geode &geode)
        {
            //osg::Drawable *drawable1=  geode.getDrawable(0);
            unsigned int count = geode.getNumDrawables();
            for (int i = 0; i < count; i++)
            {
                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();
                for (int j = 0; j<vertexlNum; 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;
                }
            }
        }
    
    protected:
        int _indent;
    };
    
    
    int main()
    {
        osg::ref_ptr<osgViewer::Viewer> viewer1 = new osgViewer::Viewer;
        osg::ref_ptr<osg::Node> node1 = osgDB::readNodeFile("D:\参考手册\BIM\osg\build1.OSGB");
        BoundVisitor bv;
    
        node1->accept(bv);
        viewer1->setSceneData(node1);
        
    
        viewer1->setUpViewInWindow(200, 200, 800, 600, 0);
    
        return viewer1->run();
    }

  • 相关阅读:
    asp.net中virtual和abstract的区别分析
    .NET中的Timer类型用法详解
    类型参数的约束(C# 编程指南)T
    SELECT INTO 和 INSERT INTO SELECT 两种表复制语句
    jquery的$.extend和$.fn.extend作用及区别
    类型参数约束 : Controller where T : class,new()
    asp.net获取当前网址url的各种属性(文件名、参数、域名 等)的代码
    字符串一级指针的内存模型图(盲点,以前自己懵懂)
    字符串的基本操作,初始化和赋值之类的区别,和数据名是一个常量指针不可以改变和赋值(盲点众多)
    关于内存四区和指针的修改问题
  • 原文地址:https://www.cnblogs.com/herd/p/11099269.html
Copyright © 2011-2022 走看看