Hi,

Vincent Bourdier wrote:
> Hi,
> 
> I'm trying to make a Particle System.
> 
> It looks easy but I have a little problem : my ModularEmitter, my 
> ParticleSystemUpdater and my geode are on the same group.
> To have the particles on the viewer, I must add this group as a child of 
> the root group. If I put it child of another group, nothing appear...
> 
> I that normal ? 

It is the current behaviour. If it's normal is another question :)

 > Is it possible to had my particleSystemGroup as a child
 > of any other group in the scene graph ?

Yes, but you have to split up the particle system. One part must be 
connected to the thing that you are moving around and another part must 
be connected to some static point as far as I remember.

Look at the osgparticleeffects example around the line
if (handleMovingModels)
there is some explanation.

I also attach some code that I use when I load a model possibly 
containing a particle system. The visitor finds the particle system that 
you can then remove from the loaded model and attach to the root (or 
where you find appropriate).

regards
jp



---8<---
CViewParticleSystemGeodeFinder psgf = CViewParticleSystemGeodeFinder();

shape->accept(psgf);
if (psgf.foundGeode) {
        mParticleSystemGroup->addChild(psgf.foundGeode);
        ((osg::Group*)shape)->removeChild(psgf.foundGeode);
}


---8<---
#include <osg/NodeVisitor>
#include <osg/Geode>
#include <osgParticle/ParticleSystem>

class CViewParticleSystemGeodeFinder : public osg::NodeVisitor
{
  public:
         CViewParticleSystemGeodeFinder():
           osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN),
                   foundGeode(0) {}

     virtual void apply(osg::Node& node)
     {
                // if the node is a geode, check if it contains a particle 
system
                osg::Geode* geode = dynamic_cast<osg::Geode*>(&node);
                if (geode) {
                        for (unsigned int i=0; i<geode->getNumDrawables(); i++) 
{
                                osgParticle::ParticleSystem *psDrawable = 
dynamic_cast<osgParticle::ParticleSystem*>(geode->getDrawable(i));
                                if(psDrawable) {
                                        if (!foundGeode) foundGeode = geode;
                                }
                        }
                }
         traverse(node);
     }

        void reset() {foundGeode = 0;}

        osg::Geode *foundGeode;
};

> 
> Thanks.
> 
> Vincent.
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

-- 
This message is subject to the CSIR's copyright terms and conditions, e-mail 
legal notice, and implemented Open Document Format (ODF) standard. 
The full disclaimer details can be found at 
http://www.csir.co.za/disclaimer.html.

This message has been scanned for viruses and dangerous content by MailScanner, 
and is believed to be clean.  MailScanner thanks Transtec Computers for their 
support.

_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to