OSG粒子系统应用:喷泉效果
来源:互联网 发布:淘宝查号怎么查 截图 编辑:程序博客网 时间:2024/04/29 09:02
粒子系统主要分为两大类:
- 一是Effective中已有的效果,如雨雪的效果应用;
- 二类是一步步从模版,发射器等创建。
关于第一种的使用可以参见上一篇博客OSG粒子系统应用:雨雪效果。本篇博客来使用第二种方式创建一个喷泉的效果。
废话补多说,直接上代码:
osg::ref_ptr<osg::Node> Fountain::createFountain(osg::Group* parent){ // 设置粒子模板的参数,包括生命周期、颜色、透明度、半径、重量等 osgParticle::Particle pParticle; pParticle.setLifeTime(3); pParticle.setColorRange(osgParticle::rangev4( osg::Vec4(0.7, 1.0, 1.0, 1.0), osg::Vec4(0.8, 1.0, 1.0, 0.0))); pParticle.setSizeRange(osgParticle::rangef(0.1f, 0.1f)); pParticle.setAlphaRange(osgParticle::rangef(1.0f, 0.5f)); pParticle.setRadius(m_dParticlesSize); pParticle.setMass(0.05); osg::ref_ptr<osgParticle::ParticleSystem> pParticleSys = new osgParticle::ParticleSystem; pParticleSys->setDefaultAttributes("Image/smoke.rgb", false, false); pParticleSys->setDefaultParticleTemplate(pParticle); // 发射器 osg::ref_ptr<osgParticle::ModularEmitter> pEmitter = new osgParticle::ModularEmitter; pEmitter->setParticleSystem(pParticleSys); osg::ref_ptr<osgParticle::RandomRateCounter> pRandomCounter = new osgParticle::RandomRateCounter; pRandomCounter->setRateRange(osgParticle::rangef(m_dParticlesNum, m_dParticlesNum)); pEmitter->setCounter(pRandomCounter); // 粒子发射枪 osg::ref_ptr<osgParticle::RadialShooter> pShooter = new osgParticle::RadialShooter; pShooter->setInitialSpeedRange(m_dParticlesSpeed, 0); pEmitter->setShooter(pShooter); // 速度细节控制 osg::ref_ptr<osgParticle::ModularProgram> pProgram = new osgParticle::ModularProgram; pProgram->setParticleSystem(pParticleSys); osg::ref_ptr<osgParticle::AccelOperator> pAccelOperator = new osgParticle::AccelOperator; pAccelOperator->setToGravity(); pProgram->addOperator(pAccelOperator); osg::ref_ptr<osgParticle::FluidFrictionOperator> pOperator = new osgParticle::FluidFrictionOperator; pOperator->setFluidToAir(); pProgram->addOperator(pOperator); osg::ref_ptr<osg::Geode> pGeode = new osg::Geode; pGeode->addDrawable(pParticleSys); parent->addChild(pEmitter); parent->addChild(pProgram); parent->addChild(pGeode); osg::ref_ptr<osgParticle::ParticleSystemUpdater> pParticleSysUpdate = new osgParticle::ParticleSystemUpdater; pParticleSysUpdate->addParticleSystem(pParticleSys); return pParticleSysUpdate;}
创建粒子的时候传入一个osg::Group*参数,创建成功后,返回一个osg::Node*值,这个Node还可以成为传入参数的子节点。
PS:此篇博客代码以及前几篇的均已放在github,欢迎获取,欢迎交流!
1 0
- OSG粒子系统应用:喷泉效果
- OSG粒子系统应用:雨雪效果
- osg demo22 conduit 喷泉效果
- 基于 OGRE 粒子系统的喷泉模拟
- OSG中的粒子系统
- OSG 粒子系统 类图
- OSG-粒子系统和初步
- 模拟喷泉粒子
- osg粒子
- 用OpenGL构建粒子喷泉
- ActionScript实现喷泉效果
- 粒子系统应用浅析
- OSG向场景中添加osgParticle粒子效果
- OSG向场景中添加osgParticle粒子效果
- OSG向场景中添加osgParticle粒子效果
- 粒子系统----实现下雪效果
- 粒子系统制作流动效果
- 利用OSG实现模拟飞机尾迹-粒子系统
- 机房收费系统之组合查询
- Linux学习二
- NYOJ 737 — 石子合并(一) 区间dp
- VLC框架分析
- Android之Monkey全参数
- OSG粒子系统应用:喷泉效果
- OpenSAP网址收藏
- swift语言中一些常用的运算符
- HDU 1864
- Mooc认证
- Pow(x, n)
- 制作debian包
- Permutations II
- shell学习一