参考帖子:

https://blog.csdn.net/csxiaoshui/article/details/23457273

osg::Geometry *lineStripGeometry = new osg::Geometry;
osg::Vec3Array *lineVertexArray = new osg::Vec3Array;
double dRadius = 0.1;
for (float angle = 0.0; angle < 400.0; angle += 0.1)
{
lineVertexArray->push_back(osg::Vec3(dRadius * cos(angle), dRadius * sin(angle), ));
dRadius *= 1.002;
}
osg::Vec4Array *lineColorArray = new osg::Vec4Array;
lineColorArray->push_back(osg::Vec4(1.0, 1.0, 1.0, 1.0));
lineStripGeometry->setVertexArray(lineVertexArray);
lineStripGeometry->setColorArray(lineColorArray);
//OSG 3.2之后的版本在setColorArray中设置绑定方式
lineStripGeometry->setColorBinding(osg::Geometry::BIND_OVERALL);
lineStripGeometry->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINE_STRIP, , lineVertexArray->size()));
lineStripGeometry->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF); //添加模板测试
osg::Stencil *lineStripStencil = new osg::Stencil;
lineStripStencil->setFunction(osg::Stencil::NEVER, 0x0, 0x0);
lineStripStencil->setOperation(osg::Stencil::INCR, osg::Stencil::INCR, osg::Stencil::INCR);
lineStripGeometry->getOrCreateStateSet()->setAttributeAndModes(lineStripStencil);
////////////////////////////////////////////////////////////////////////// osg::Geometry *quadGeometry = new osg::Geometry; osg::Vec3Array *quadVertexArray = new osg::Vec3Array;
quadVertexArray->push_back(osg::Vec3(, , ));
quadVertexArray->push_back(osg::Vec3(, , ));
quadVertexArray->push_back(osg::Vec3(, , ));
quadVertexArray->push_back(osg::Vec3(, , )); osg::Vec4Array *quadColorArray = new osg::Vec4Array;
quadColorArray->push_back(osg::Vec4(0.0, 1.0, 1.0, 1.0)); quadGeometry->setVertexArray(quadVertexArray);
quadGeometry->setColorArray(quadColorArray);
quadGeometry->setColorBinding(osg::Geometry::BIND_OVERALL);
quadGeometry->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS, , ));
quadGeometry->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF); osg::Stencil *quadStencil = new osg::Stencil;
quadStencil->setFunction(osg::Stencil::NOTEQUAL, 0x1, 0x1);
quadStencil->setOperation(osg::Stencil::KEEP, osg::Stencil::KEEP, osg::Stencil::KEEP);
quadGeometry->getOrCreateStateSet()->setAttributeAndModes(quadStencil); osg::Geode *geode = new osg::Geode;
geode->addDrawable(lineStripGeometry);
geode->addDrawable(quadGeometry);
---------------------
作者:csxiaoshui
来源:CSDN
原文:https://blog.csdn.net/csxiaoshui/article/details/23457273
版权声明:本文为博主原创文章,转载请附上博文链接!

最新文章

  1. asp.net web api 的版本升级到 2.2的记录
  2. Linux的Shell
  3. IIS7.5 webapi 不支持 Delete、Put 解决方法
  4. Qweb Pdf 中添加 图片
  5. CentOS6.5安装配置SVN
  6. python virtualenv
  7. 《BI项目笔记》报到信息分析Cube
  8. a read only variable
  9. mysql中函数DISTINCT,group by,CONCAT及GROUP_CONCAT的使用
  10. Mirantis Fuel fundations
  11. 六行代码获取本地IP
  12. python request的运用
  13. docker dead but pid file exists 问题
  14. 关于Android SDK Manager无法获取更新列表的正确设置
  15. JavaScript面向对象(收集整理)
  16. java7 - JDK
  17. 我的博客:C# PHP J2ee Java Android js WP Asp.net mvc Python
  18. Ignatius and the Princess III(方案背包+搜索)
  19. spoj COT - Count on a tree (树上第K小 LCA+主席树)
  20. Installing Windows Features without Internet

热门文章

  1. poj很好很有层次感(转)
  2. ZooKeeper开发手册中文翻译
  3. springboot自定义http反馈状态码
  4. windows SVN 服务器搭建
  5. PL/SQL学习笔记之异常
  6. Android 利用二次贝塞尔曲线模仿购物车加入物品抛物线动画
  7. ios实例开发精品源码文章推荐(8.22)
  8. Kotlin VS Java:基本语法差异(转载)
  9. mysql 5.5.x zip直接解压版 报1076
  10. Innotop的安装和使用