osg::Geomtery多图元重叠闪烁问题
来源:互联网 发布:淘宝卖家改地址 编辑:程序博客网 时间:2024/06/05 01:59
void DrawGeom()
{
if(!_geom.valid())
{
_geom = new osg::Geometry;
_geom->setDataVariance(osg::Object::DYNAMIC);\
_geom->getOrCreateStateSet()->setMode(GL_BLEND,osg::StateAttribute::ON);
_geom->getOrCreateStateSet()->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
osg::ref_ptr<osg::CullFace> cullface = new osg::CullFace(osg::CullFace::BACK);
_geom->getOrCreateStateSet()->setAttribute(cullface.get());
osg::PolygonOffset* polyoffset = new osg::PolygonOffset;
polyoffset->setFactor(-100.0f);
polyoffset->setUnits(-10.0f);
osg::PolygonMode* polymode = new osg::PolygonMode;
polymode->setMode(osg::PolygonMode::FRONT,osg::PolygonMode::FILL);
_geom->getOrCreateStateSet()->setAttributeAndModes(polyoffset,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
_geom->getOrCreateStateSet()->setAttributeAndModes(polymode,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON);
//定义颜色数组
osg::ref_ptr<osg::Vec4Array> c = new osg::Vec4Array;
_geom->setColorArray(c.get());
_geom->setColorBinding(osg::Geometry::BIND_OVERALL);
c->push_back(_LineColor);
//定义法线
osg::ref_ptr<osg::Vec3Array> n = new osg::Vec3Array;
_geom->setNormalArray(n.get());
_geom->setNormalBinding(osg::Geometry::BIND_OVERALL);
n->push_back(osg::Vec3(0.f, -1.f, 0.f));
_pointArray = new osg::Vec3Array;
_geom->setVertexArray(_pointArray.get());
osg::ref_ptr<osg::Geode> geode = new osg::Geode;
geode->addDrawable(_geom.get());
//geode->setUpdateCallback(new FadeCallback(_LineColor));
geode->getOrCreateStateSet()->setAttributeAndModes(new osg::BlendFunc);
geode->getOrCreateStateSet()->setMode(GL_BLEND,osg::StateAttribute::ON);
geode->getOrCreateStateSet()->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
_shapeGroup->addChild(geode.get());
primitiveSetCount = 0L;
}
_pointArray->push_back(wp1*mat);
_pointArray->push_back(wp2*mat);
_pointArray->push_back(wp3*mat);
_pointArray->push_back(wp4*mat);
_geom->addPrimitiveSet(
new osg::DrawArrays(osg::PrimitiveSet::QUADS, primitiveSetCount*4, 4));
primitiveSetCount++;
}
这样还是会有重叠的效果 试过很多方法 还是不行 没有好的opengl基础 真是空中楼阁 碰到点难得就不会 完全没有思路 跟着网上的东西走 心累 初学osg 记录自己的心路历程
阅读全文
0 0
- osg::Geomtery多图元重叠闪烁问题
- osg 模型显示不全,闪烁问题
- mfc 中child属性的两个窗口重叠 解决重叠部分不停闪烁问题
- CStatic子类化解决背景透明,文本重叠,刷新闪烁问题
- CStatic子类化解决背景透明,文本重叠,刷新闪烁问题
- 重叠问题
- OSG坐标问题
- osg vs2010 问题之一
- OSG问题记录
- osg问题积累
- OSG编译问题
- IE7重叠问题
- 重叠方框问题
- ImageView图片重叠问题
- margin重叠问题
- android 背景重叠问题
- 重叠子问题
- memcpy 内存重叠问题
- Nginx简介
- 剑指offer 和为S的两个数字(2)
- Cookies 和 Session的区别
- 6. 可视化实例
- C++ lambda 表达式
- osg::Geomtery多图元重叠闪烁问题
- 11.编写COM常用IDL指令和注意事项详解
- tensorflow学习1
- 文本处理工具
- Reading Note: Deformable Part-based Fully Convolutional Network for Object Detection
- Leetcode98. Validate Binary Search Tree
- SOD923/SOD523/SOD323封装是多大?
- HRBEU-贪心,区间-A公司的烦恼
- 冲突域、广播域,划分VLAN的缘由