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. pandas 3

    参考资料:https://mp.weixin.qq.com/s/9z3JVBkZpasC_F0ar_7JJA 删除多列:df.drop(col_names_list, axis=1, inplace= ...

  2. volatile相关知识

    C中的volatile变量是什么? 回答: 的易失性的关键字是类型限定符防止从编译器optimization.According至C标准的对象,具有挥发性限定类型可以以实施方式未知进行修改或具有其他未 ...

  3. python - scrapy 爬虫框架 ( redis去重 )

    1.  使用内置,并加以修改 ( 自定义 redis 存储的 keys ) settings 配置 # ############### scrapy redis连接 ################# ...

  4. hive on spark (spark2.0.0 hive2.3.3)

    hive on spark真的很折腾人啊!!!!!!! 一.软件准备阶段 maven3.3.9 spark2.0.0 hive2.3.3 hadoop2.7.6 二.下载源码spark2.0.0,编译 ...

  5. JAVA的循环结构进阶

    1.什么是二重循环:                        一个循环体内又包含另一个完整的循环结构                     语法:                       ...

  6. 18 | 为什么这些SQL语句逻辑相同,性能却差异巨大?

    在MySQL中,有很多看上去逻辑相同,但性能却差异巨大的SQL语句.对这些语句使用不当的话,就会不经意间导致整个数据库的压力变大. 我今天挑选了三个这样的案例和你分享.希望再遇到相似的问题时,你可以做 ...

  7. LOJ P10116 清点人数 题解

    每日一题 day13 打卡 Analysis 用简单的树状数组维护单点修改和查询就行了 #include<iostream> #include<cstdio> #include ...

  8. luogu 3702 [SDOI2017]序列计数 矩阵乘法+容斥

    现在看来这道题真的不难啊~ 正着求不好求,那就反着求:答案=总-全不是质数 这里有一个细节要特判:1不是质数,所以在算全不是质数的时候要特判1 code: #include <bits/stdc ...

  9. MySQL 环比计算

    SELECT t.*, CASE WHEN t.SaleDealMoney_last ,) END link_ratio FROM ( SELECT a.my_ym, FORMAT(a.SaleDea ...

  10. Java 集合介绍,常用集合类

    Java容器类类库的用途是“保存对象”,并将其划分为两个不同的概念: (1)Collection.一个独立元素的序列,这些元素都服从一条或多条规则.List必须按照插入的顺序保存元素,而Set不能有重 ...