zoukankan      html  css  js  c++  java
  • osg绘制胶囊体

    osg绘制胶囊体

    #include <iostream>
    #include <osgViewer/Viewer>
    #include <osg/Node>
    
    //#include <osgDB/ReadFile>
    //#include <osgDB/WriteFile>
    
    #include <osgUtilOptimizer>
    #include <osg/Geode>
    #include <osg/Group>
    #include <osg/ShapeDrawable>
    
    //绘制几何体
    osg::Geode* createShpe()
    {
        //
        osg::Geode *geode = new osg::Geode();
        //半径
        float radius = 0.8f;
        //高度
        float height = 1.8f;
    
        //精细度
        osg::TessellationHints* hints1 = new osg::TessellationHints();
        //设置精细度
        hints1->setDetailRatio(0.8f);
    
        //创建胶囊体
        osg::Capsule *capsule = new osg::Capsule(osg::Vec3(0.0f, 0.0f, 0.0f), radius, height);
        osg::ShapeDrawable *draw1 = new osg::ShapeDrawable(capsule, hints1);
    
        geode->addDrawable(draw1);
    
        return geode;
    }
    
    
    int main()
    {
        osgViewer::Viewer *viewer1 = new osgViewer::Viewer();
        osg::Group *root = new osg::Group();
    
        root->addChild(createShpe());
    
        osgUtil::Optimizer optimizer1;
        optimizer1.optimize(root);
    
        viewer1->setUpViewInWindow(200, 200, 700, 500, 0);
    
        //viewer1->addEventHandler(new osgViewer::GraphicsWindow::resized(0,0,640,480));
        viewer1->setSceneData(root);
    
        //viewer1->realize();
        viewer1->run();
        return 0;
    }

    ##################

    QQ 3087438119
  • 相关阅读:
    十进制数转换
    桶排序
    快速排序
    单词倒排
    (c++) string b; cin>>b; int i=strlen(b); 报错的原因。
    n的阶乘(1<n<10000)(结果超大……)
    2020软件工程最后一次作业
    2020软件工程第四次作业
    2020软件工程第三次作业
    2020软件工程第二次作业
  • 原文地址:https://www.cnblogs.com/herd/p/15124414.html
Copyright © 2011-2022 走看看