ok.
class BaseParticle
{
public:
osgParticle::Particle *ptemplate;
osgParticle::ParticleSystem *ps;
osgParticle::ModularEmitter *emitter;
osgParticle::RandomRateCounter *rrc;
osgParticle::ParticleSystemUpdater *psu;
osg::MatrixTransform* particleMatrix;
};
std::map <std::string, BaseParticle*> particles;
...
particles[Name] = new BaseParticle;
particles[Name]->particleMatrix = new osg::MatrixTransform();
particles[Name]->particleMatrix->setName (Name);
particles[Name]->ptemplate = new osgParticle::Particle;
particles[Name]->ptemplate->setLifeTime(3); // 3 seconds of life
particles[Name]->ptemplate->setSizeRange(osgParticle::rangef(0.75f, 3.0f));
particles[Name]->ptemplate->setAlphaRange(osgParticle::rangef(0.0f, 1.5f));
particles[Name]->ptemplate->setColorRange(osgParticle::rangev4(
osg::Vec4(1, 0.5f, 0.3f, 1.5f),
osg::Vec4(0, 0.0f, 0.0f, 0.0f)));
// these are physical properties of the particle
particles[Name]->ptemplate->setRadius(0.05f); // 5 cm wide particles
particles[Name]->ptemplate->setMass(0.05f); // 50 g heavy
particles[Name]->ps = new osgParticle::ParticleSystem;
particles[Name]->ps->setDefaultAttributes("D:/DEVELOP/OSG/OpenSceneGraph-2.6.0/bin/Images/smoke.rgb",
false, false);
// assign the particle template to the system.
particles[Name]->ps->setDefaultParticleTemplate(*particles[Name]->ptemplate);
particles[Name]->emitter = new osgParticle::ModularEmitter;
particles[Name]->emitter->setParticleSystem(particles[Name]->ps);
particles[Name]->rrc = static_cast<osgParticle::RandomRateCounter
*>(particles[Name]->emitter->getCounter());
particles[Name]->rrc->setRateRange(40, 60); // generate 20 to 30 particles
per second
particles[Name]->particleMatrix->addChild(particles[Name]->emitter);
osg::Geode *geode = new osg::Geode;
geode->addDrawable(particles[Name]->ps);
particles[Name]->particleMatrix->addChild(geode);
particles[Name]->psu = new osgParticle::ParticleSystemUpdater;
particles[Name]->psu->addParticleSystem(particles[Name]->ps);
particles[Name]->particleMatrix->addChild(particles[Name]->psu);
root->addChild(particles[Name]->particleMatrix);
It works
...
after adding particles into scene group (root) I lost ability to change some
properties don't work:
particles[Name]->ptemplate->setLifeTime(300);
or
particles[Name]->ptemplate->setRadius(0.5f);
or
particles[Name]->ptemplate->setColorRange ...
or
particles[Name]->ptemplate->setMass(0.5f);
11.08.08, 15:28, "Paul Melis" <[EMAIL PROTECTED]>:
> GMD GammerMaxyandex.ru wrote:
> > Hi, I have a question about osgParticle::Particle.
> >
> > I get code from example osgParticle. It works, but there is one problem:
> > after adding particles into scene group (root) I lost ability to change some
> > properties - methods setLifeTime, setSizeRange, setAlphaRange,
> > setColorRange,
> > setRadius don't work. Nevertheless, osgParticle::ParticleSystem
> > (setDefaultAttributes)
> > and osgParticle::RandomRateCounter (setRateRange) works (I see result in
> > screen).
> >
> Do you have a simplified example showing the problem?
> Paul
> > So, why can't I change properties of osgParticle::Particle after adding it
> > in scene
> > or how should I do that right?
> > _______________________________________________
> > osg-users mailing list
> > [email protected]
> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> >
> >
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
--
Жизнь без спама на Яндекс.Почте http://mail.yandex.ru/nospam
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org