zoukankan      html  css  js  c++  java
  • OSG的“hello world”

    #include <osgViewer/Viewer>
    
    #include <osg/Node>
    #include <osg/Geode>
    #include <osg/Group>
    #include <osg/MatrixTransform>
    #include <osg/AnimationPath>
    
    #include <osgDB/ReadFile>
    #include <osgDB/WriteFile>
    
    #include <osgUtil/Optimizer>
    
    osg::ref_ptr<osg::Node> MatrixOperation()
    {
        osg::ref_ptr<osg::Group> group = new osg::Group();
        osg::ref_ptr<osg::MatrixTransform> matrix = new osg::MatrixTransform();
        osg::ref_ptr<osg::MatrixTransform> matrix1 = new osg::MatrixTransform();
        osg::ref_ptr<osg::Node> node = osgDB::readNodeFile("glider.osg");
    
        matrix->addChild(osgDB::readNodeFile("glider.osg"));
        //matrix->setMatrix(osg::Matrix::translate(5.0, 0.0, 0.0));
        matrix->setUpdateCallback(new osg::AnimationPathCallback(osg::Vec3(6.0, 0.0, 0.0), osg::Z_AXIS, 1.0));
        matrix->addChild(matrix1.get());
    
        matrix1->addChild(node.get());
        matrix1->setMatrix(osg::Matrix::translate(5.0, 0.0, 0.0));
    
    
        //group->addChild(osgDB::readNodeFile("glider.osg"));
        group->addChild(node.get());
        group->addChild(matrix.get());
    
        return group;
    }
    
    
    int main()
    {
        //创建场景对象  场景浏览器
        osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer;
        //创建场景组节点
        osg::ref_ptr<osg::Group>  group = new osg::Group;
        //创建一个节点 ,读取牛得模型
        osg::ref_ptr<osg::Node>  node = osgDB::readNodeFile("cow.osg");
        //添加到场景
        group->addChild(node);
        //优化场景数据
        osgUtil::Optimizer optimizer;
        optimizer.optimize(group.get());
    
        //设置场景数据
        viewer->setSceneData(MatrixOperation().get());
    
        //初始化并创建窗口
        viewer->realize();
        //开始渲染
        return viewer->run();
    
    }
  • 相关阅读:
    怎么让Windows10取消开机登录密码自动登录
    window查看无线网卡bssid以及相关信息命令
    kali-cdlinux-wifi-pj-nanke-心得
    html里文本保留换行格式
    window实用快捷键-ctrl篇
    mybatis 结果映射 collection oftype为string,integer等类型
    Redis集群下只有db0,不支持多db
    软件开发过程中所使用的生命周期模型比较
    简单Dos命令
    简单理解Mysql json数据类型
  • 原文地址:https://www.cnblogs.com/linxuemufeng/p/11235156.html
Copyright © 2011-2022 走看看