|
我创建复杂的粒子系统,代码如下:
osgParticle:articleSystem *create_complex_particle_system(osg::Group *root)
{
osgParticle::Particle ptemplate;
ptemplate.setLifeTime(2);
ptemplate.setSizeRange(osgParticle::rangef(0.75f, 0.75f));
ptemplate.setAlphaRange(osgParticle::rangef(0.2f, 0.2f));
ptemplate.setColorRange(osgParticle::rangev4(
osg::Vec4(1, 1, 1, 0.5f), //1,0.5f,0.3f,0.5f
osg::Vec4(1, 1, 1, 0.5f)));//0,0.7f,1.0f,0.5f
ptemplate.setRadius(0.001f); // 5 cm wide particles
ptemplate.setMass(0.05f);
osgParticle::ParticleSystem *ps = new osgParticle::ParticleSystem;
ps->setDefaultAttributes("Images/particle.rgb", false, false);
ps->setDefaultParticleTemplate(ptemplate);
osgParticle::ModularEmitter *emitter = new osgParticle::ModularEmitter;
emitter->setParticleSystem(ps);
osgParticle::RandomRateCounter *counter = new osgParticle::RandomRateCounter;
counter->setRateRange(2, 2);
emitter->setCounter(counter);
osgParticle::PointPlacer *placer= new osgParticle::PointPlacer;
placer->setCenter(223.0,29.0,95.0);
emitter->setPlacer(placer);
osgParticle::RadialShooter *shooter = new osgParticle::RadialShooter;
shooter->setInitialSpeedRange(3, 3);
emitter->setShooter(shooter);
root->addChild(emitter);
osg::Geode *geode = new osg::Geode;
geode->addDrawable(ps);
root->addChild(geode);
return ps;
osgParticle::ParticleSystemUpdater *psu = new osgParticle::ParticleSystemUpdater;
psu->addParticleSystem(_ps);
}
我想在程序启动时,先隐藏该粒子效果,在操作用时再显示该粒子效果,我使用psu->setNodeMask(0);想隐藏,可是osgParticle::ParticleSystemUpdater没有setNodeMask成员,有什么办法?谢谢! |
|