Hello Peter,

basically you can do it via UpdateCallback.
Therefore simply write a NodeCallback and check if the particles are still active like this:

class EffectUpdateCallback: public osg::NodeCallback
{
public:

EffectUpdateCallback(EffectManager& effect_manager_ref, const EffectDescriptor& effect_descriptor)
        :NodeCallback()
{
    ...
}

virtual void operator()( osg::Node *n, osg::NodeVisitor *nv)
    {
osgParticle::ParticleEffect* particle = dynamic_cast<osgParticle::ParticleEffect*>(n);

        if (particle)
        {
            double frame_time = nv->getFrameStamp()->getSimulationTime();
double end_time = particle->getStartTime() + particle->getEmitterDuration() + mEffectDescriptor.mDurationAfterParticleDeath;
            if (particle->getProgram()->getCurrentTime() > end_time
                &&
                particle->areAllParticlesDead()
                )
            {
mrEffectManager.removeEffect(mEffectDescriptor.mParent);
                n->setUpdateCallback(NULL);
            }
        nv->traverse(*n);
}

};

The constructed ParticleEffect then gets the callback:

particleEffect->setUpdateCallback(new EffectUpdateCallback(effect_man, effect_descriptor));

In my project I use a custom EffectManager, which holds the effects and some meta information in order to manage them properly. The update callback also yields some additional value, as you can, for instance modify the wind influence and query other properties.


hth
Sebastian
Hi,

can see this was posted in 2011... and no reply.

well,... i have the same question? is there a flag we can set or do we really 
need to poll the particle system if it's alive and remove it ourselves?

Thank you!

Cheers,
Peter

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=53449#53449





_______________________________________________
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

Reply via email to