OSG使用模板缓存
2024-08-25 13:03:16
参考帖子:
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
版权声明:本文为博主原创文章,转载请附上博文链接!
最新文章
- asp.net web api 的版本升级到 2.2的记录
- Linux的Shell
- IIS7.5 webapi 不支持 Delete、Put 解决方法
- Qweb Pdf 中添加 图片
- CentOS6.5安装配置SVN
- python virtualenv
- 《BI项目笔记》报到信息分析Cube
- a read only variable
- mysql中函数DISTINCT,group by,CONCAT及GROUP_CONCAT的使用
- Mirantis Fuel fundations
- 六行代码获取本地IP
- python request的运用
- docker dead but pid file exists 问题
- 关于Android SDK Manager无法获取更新列表的正确设置
- JavaScript面向对象(收集整理)
- java7 - JDK
- 我的博客:C# PHP J2ee Java Android js WP Asp.net mvc Python
- Ignatius and the Princess III(方案背包+搜索)
- spoj COT - Count on a tree (树上第K小 LCA+主席树)
- Installing Windows Features without Internet