osgParticle.ParticleSystem是OpenSceneGraph(OSG)中的一个粒子系统节点,用于创建和控制粒子系统。
osgParticle::ParticleSystem(osg::ref_ptr<osgParticle::ParticleSystemUpdater> updater = 0);
构造一个粒子系统节点。
使用osgParticle::Emitter设置发射器,并使用addOperator添加发射器到该粒子系统:
osg::ref_ptr<osgParticle::ParticleSystem> particleSystem = new osgParticle::ParticleSystem;
osg::ref_ptr<osgParticle::Emitter> emitter = new osgParticle::PointEmitter;
particleSystem->addOperator(emitter);
使用addOperator添加操作器,如:osgParticle::AccelOperator、osgParticle::ColorInterpolator、osgParticle::ExplosionDebrisEffect等等,可以实现许多有趣的效果。
osg::ref_ptr<osgParticle::ParticleSystem> particleSystem = new osgParticle::ParticleSystem;
particleSystem->addOperator(new osgParticle::AccelOperator);
particleSystem->addOperator(new osgParticle::ColorInterpolator);
particleSystem->addOperator(new osgParticle::ExplosionDebrisEffect);
通过调用ParticleSystemUpdater的update方法更新粒子系统。
osg::ref_ptr<osgParticle::ParticleSystem> particleSystem = new osgParticle::ParticleSystem;
osg::ref_ptr<osgParticle::ParticleSystemUpdater> updater = new osgParticle::ParticleSystemUpdater;
updater->addParticleSystem(particleSystem);
...
updater->update(deltaTime);