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,,)); 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;
}

osg create shape的更多相关文章

  1. osg define shape(create box)

    #ifdef _WIN32 #include <Windows.h> #endif // _WIN32 #include <osgViewer/Viewer> #include ...

  2. 使用Object.create 克隆对象以及实现单继承

    var Plane = function () { this.blood = 100; this.attack = 1; this.defense = 1; }; var plane = new Pl ...

  3. 构造函数创建对象和Object.create()实现继承

    第一个方法用构造函数创建对象,实现方法的继承 /*创建一个对象把所有公用的属性和方法,放进去*/ function Person() { this.name = "W3cplus" ...

  4. 前端开发者进阶之ECMAScript新特性【一】--Object.create

    Object.create(prototype, descriptors) :创建一个具有指定原型且可选择性地包含指定属性的对象 参数:prototype 必需.  要用作原型的对象. 可以为 nul ...

  5. firefox-Developer开发者站点——关于Object.create()新方法的介绍

    https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Object/create Objec ...

  6. What Shape Layers Are-CAShapeLayer

    矢量图.gpu直接使用.占用内存小 What Shape Layers Are Shape layers are layers capable of defining shapes as vector ...

  7. ECMAScript新特性【一】--Object.create

    Object.create(prototype, descriptors) :创建一个具有指定原型且可选择性地包含指定属性的对象 参数: prototype 必需.  要用作原型的对象. 可以为 nu ...

  8. 转载:Object的create方法文档

    源地址:https://developer.mozilla.org/zh-CN/docs/JavaScript/Reference/Global_Objects/Object/create#.E4.B ...

  9. OSG学习:转动的小汽车示例

    由于只是简单的示例,所以小汽车的模型也比较简单,是由简单的几何体组成. 代码如下: #include <osg\ShapeDrawable> #include <osg\Animat ...

随机推荐

  1. Python3 acm基础输入输出

    案例一:输入字符串分割并转化成多个int数值 a, b= map(int, input().split()) try: while True: a, b= map(int, input().split ...

  2. docker 安装elk

    https://www.cnblogs.com/fbtop/p/11005469.html

  3. 第七届蓝桥杯C/C++程序设计本科B组决赛 ——凑平方数(填空题)

    凑平方数 把0~9这10个数字,分成多个组,每个组恰好是一个平方数,这是能够办到的.比如:0, 36, 5948721 再比如:10985247361, 25, 63907840, 4, 289, 1 ...

  4. Docker那些事儿之镜像创建

    之前已经了解了docker的基本使用方式,简单的上手,也能让大部分人了解到这个技术的使用方法,今天继续说明docker如何构建自己所需要的镜像,开发人员掌握使用基础即可,有兴趣的可以自行深入研究 前言 ...

  5. 网站入侵工具 SQL注入神器

    0x 00 前言 SQLMAP 0x 01 注入原理              不说了 *****************************************结束分割线********** ...

  6. 云计算(7)---the scheduler of Hadoop

    The scheduler of Hadoop Programming MapReduce 在有些情况下,reducer也可以先开始于Map.但为了便于理解,在这儿我们都是使reduce不会早于map ...

  7. seastar笔记

    1.seastar::A.then([]{B});C:的核心思想是说我们开始了A之后就开始B,开始B之后就开始C,而不需要等A做完了再做B,B做完再做C 2.通常的return是一个需要执行的函数,例 ...

  8. Miniprofiler 监控ef执行详解

    首先NuGet添加 相对应ef版本的Miniprofiler.ef引用 web.config文件中添加 <system.webServer> <handlers>  <a ...

  9. python类内置方法之__call__

    在python中自定义类时,如果该类实现了一个特殊方法__call__(),那么该类的实例则变成一个可调用的实例对象 如下 In [1]: class A():# 自定义一个A ...: def __ ...

  10. 后缀数组 1031: [JSOI2007]字符加密Cipher

    /*1031: [JSOI2007]字符加密Cipher Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 4926 Solved: 2020[Submit ...