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;
    }
  • 相关阅读:
    vs 2015 安装
    NPOI封装
    c#事件求解
    一个ERP系统的磕磕碰碰
    谁动了我的产品
    MVC Sesion丢失问题
    设计模式之类关系
    免费的SqlServer优化辅助工具:SqlOptimize (原创)
    Entity Framework Linq 简单笔记
    RhinoMocks简单范例
  • 原文地址:https://www.cnblogs.com/herd/p/11073983.html
Copyright © 2011-2022 走看看