zoukankan      html  css  js  c++  java
  • OSG程序设计之Hello World 3.0

      直接上代码:

    #include <osgDB/ReadFile>
    #include <osgViewer/Viewer>
    #include <osgViewer/ViewerEventHandlers>
    
    #include <osgGA/TrackballManipulator>
    #include <osgGA/FlightManipulator>
    #include <osgGA/DriveManipulator>
    #include <osgGA/KeySwitchMatrixManipulator>
    #include <osgGA/StateSetManipulator>
    #include <osgGA/AnimationPathManipulator>
    #include <osgGA/TerrainManipulator>
    
    void main()
    {
        osgViewer::Viewer viewer;
        viewer.setSceneData(osgDB::readNodeFile("glider.osg"));
        
        //添加状态事件
        viewer.addEventHandler(new osgGA::StateSetManipulator(viewer.getCamera()->getOrCreateStateSet()));
        //窗口大小变化事件
        viewer.addEventHandler(new osgViewer::WindowSizeHandler);
        //添加一些常用状态设置
        viewer.addEventHandler(new osgViewer::StatsHandler);
        
        //添加一些操作器
        osg::ref_ptr<osgGA::KeySwitchMatrixManipulator> keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator;
        keyswitchManipulator->addMatrixManipulator('1', "Trackball", new osgGA::TrackballManipulator());
        keyswitchManipulator->addMatrixManipulator('2', "Flight", new osgGA::FlightManipulator());
        keyswitchManipulator->addMatrixManipulator('3', "Drive", new osgGA::DriveManipulator());
        keyswitchManipulator->addMatrixManipulator('4', "Terrain", new osgGA::TerrainManipulator());
        viewer.setCameraManipulator(keyswitchManipulator.get());
        
        //添加路径记录
        viewer.addEventHandler(new osgViewer::RecordCameraPathHandler);
    
        viewer.realize();
        viewer.run();
    }

      3.0版本主要是添加了一些操作器。

      关于什么是操作器,菜鸟表示完全不懂。现在的理解就是:不同的操作器对应不同的交互模式。

      从Hello World1.0可知,用户通过鼠标可以操作模型。添加操作器之后,用户通过1 、2、3、4按键选择不同的操作器,就会对应不同的交互模式。

      

  • 相关阅读:
    杭电dp题集,附链接还有解题报告!!!!!
    js正則表達式语法
    java界面编程(8) ------ 组合框(下拉列表)
    四个好看的CSS样式表格
    搜集朋友写的几篇Android Elf相关的文档
    hadoop编程小技巧(5)---自己定义输入文件格式类InputFormat
    递归算法
    ua识别(浏览器标识识别)
    amazeui学习笔记一(开始使用5)--藏品collections
    amazeui学习笔记一(开始使用4)--Web App 相关
  • 原文地址:https://www.cnblogs.com/gattaca/p/4527353.html
Copyright © 2011-2022 走看看