zoukankan      html  css  js  c++  java
  • osg create shape

    osg::ref_ptr<osg::Node> OSG_Qt_::createSimple()
    {
        osg::ref_ptr<osg::Geode> geode = new osg::Geode;
        osg::ref_ptr<osg::Geometry> geometry = new osg::Geometry;
    
        //申请顶点
        osg::ref_ptr<osg::Vec3Array> coords = new osg::Vec3Array;
        //申请颜色
        osg::ref_ptr<osg::Vec4Array> colors = new osg::Vec4Array;
        //申请法向量
        osg::ref_ptr<osg::Vec3Array> norms = new osg::Vec3Array;
    
        //设置顶点关联方式
        geometry->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::Mode::QUADS,0,4));
    
        coords->push_back(osg::Vec3(-10.0,0.0,-10.0));
        coords->push_back(osg::Vec3(10.0, 0.0, -10.0));
        coords->push_back(osg::Vec3(10.0, 0.0, 10.0));
        coords->push_back(osg::Vec3(-10.0, 0.0, 10.0));
    
        //颜色赋值
        colors->push_back(osg::Vec4f(1.0,0.0,0.0,1.0));
        colors->push_back(osg::Vec4f(0.0, 1.0, 0.0, 1.0));
        colors->push_back(osg::Vec4f(0.0, 0.0, 1.0, 1.0));
        colors->push_back(osg::Vec4f(1.0, 1.0, 0.0, 1.0));
    
        //法向量赋值
        norms->push_back(osg::Vec3(0.0,-1.0,0.0));
    
    
        //设置顶点
        geometry->setVertexArray(coords.get());
        //设置颜色
        geometry->setColorArray(colors.get());
        //颜色绑定方式
        geometry->setColorBinding(osg::Geometry::AttributeBinding::BIND_PER_VERTEX);
        //设置法向量
        geometry->setNormalArray(norms.get());
        //法向量绑定
        geometry->setNormalBinding(osg::Geometry::AttributeBinding::BIND_OVERALL);
    
        geode->addDrawable(geometry.get());
        return geode;
    }
  • 相关阅读:
    [Luogu1993] 小K的农场
    [Noip2013] 车站分级
    [Noip2003]加分二叉树
    [Luogu3797] 妖梦斩木棒
    UPC 6616 Small Mulitple
    STL容器之优先队列
    Dijkstra和Floyd算法
    最短路径问题---Dijkstra算法详解
    并查集
    洛谷 P1217
  • 原文地址:https://www.cnblogs.com/herd/p/11073983.html
Copyright © 2011-2022 走看看