|
楼主 |
发表于 2014-5-13 20:03:43
|
显示全部楼层
这是代码,改变这个参数(shooter->setPhiRange(osgParticle::rangef(-0.1,0.1));),没有多大的影响。。。。谢谢。。
osg::ref_ptr<osg::Group> CreateMultiSegmentPlacerPlacer()
{
osgParticle:article ptemplate;
ptemplate.setLifeTime(3);
ptemplate.setSizeRange(osgParticle::rangef(0.75f, 1.0f));
ptemplate.setAlphaRange(osgParticle::rangef(0.0f, 1.0f));
ptemplate.setRadius(0.07f);
ptemplate.setMass(0.05f);
//ptemplate.setAngle(osg::Vec3(1,1,0));
osg::ref_ptr<osg::Group> root = new osg::Group() ;
osg::ref_ptr<osgParticle::ParticleSystem> ps = new osgParticle::ParticleSystem();
ps->setDefaultAttributes("Images/Particle.rgb",true,false);
ps->setDefaultParticleTemplate(ptemplate);
osgParticle::ModularEmitter * emitter = new osgParticle::ModularEmitter;
emitter->setParticleSystem(ps.get());
osgParticle::RandomRateCounter *rrc = static_cast<osgParticle::RandomRateCounter *> (emitter->getCounter());
rrc->setRateRange(1000,1000);
osgParticle::MultiSegmentPlacer *pp = new osgParticle::MultiSegmentPlacer;
pp->addVertex(-5,5,0);
pp->addVertex(30,5,0);
emitter->setPlacer(pp);
osg::ref_ptr<osgParticle::RadialShooter> shooter =new osgParticle::RadialShooter();
shooter->setInitialSpeedRange(100,0);
shooter->setThetaRange(0.05,0.1);
shooter->setPhiRange(osgParticle::rangef(-0.1,0.1));
//shooter->setInitialRotationalSpeedRange(osg::Vec3(1,1,0) ,osg::Vec3(1,0,0));
emitter->setShooter(shooter.get());
root->addChild(emitter);
osg::ref_ptr<osgParticle::ModularProgram> program = new osgParticle::ModularProgram();
program->setParticleSystem(ps.get());
osg::ref_ptr<osgParticle::AccelOperator> ap = new osgParticle::AccelOperator();
ap->setToGravity(0);
program->addOperator(ap.get());
osg::ref_ptr<osgParticle::FluidFrictionOperator> ffo = new osgParticle::FluidFrictionOperator();
//ffo->setFluidToAir();
//ffo->setWind(osg::Vec3(0,-10,-10));
//program->addOperator(ffo.get());
root->addChild(program.get());
osg::ref_ptr<osgParticle::ParticleSystemUpdater> psu = new osgParticle::ParticleSystemUpdater();
psu->addParticleSystem(ps.get());
osg::ref_ptr<osg::Geode> geode = new osg::Geode;
geode->addDrawable(ps);
root->addChild(geode.get());
root->addChild(psu.get());
return root.get();
} |
|