How do you know that child 1 is a particle effect?
 
If it is not then your code will always fail, 
you need to track the osgParticle instances so that you can delete them or 
traverse the scene to find osgParticle nodes
 

Gordon

__________________________________________________________
Gordon Tomlinson

Product Manager 3D
Email  : gtomlinson @ overwatch.textron.com
__________________________________________________________


"Self defence is not a function of learning tricks 
but is a function of how quickly and intensely one 
can arouse one's instinct for survival" 
- Master Tambo Tetsura

 
 


________________________________

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of GuiYe
Sent: Thursday, October 09, 2008 3:53 AM
To: osg-users
Subject: Re: [osg-users] The Bug of osgparticleeffects??


 
 
Yes ,I konw it .But when I do this,it's wrong.Can you tell me why?
 
class PHandler : public osgGA::GUIEventHandler {
public: 
 PHandler() {}        
 bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa)
 {
  osgViewer::Viewer* viewer = dynamic_cast<osgViewer::Viewer*>(&aa);
  osg::Group* group = dynamic_cast<osg::Group*>(viewer->getSceneData()) ;
  group->setDataVariance(osg::Object::DYNAMIC) ;
  osgParticle::ExplosionEffect* ee 
=dynamic_cast<osgParticle::ExplosionEffect*>(group->getChild(1)) ;
  switch(ea.getEventType())
  {
  case(osgGA::GUIEventAdapter::PUSH):
   {
    if(ee->areAllParticlesDead())
    {
     group->removeChild(1) ;
    }
   }
   return false;
  default:
   return false;
  }
 }
}


________________________________

[广告] 特惠尝必胜客26道新品 <http://popme.163.com/link/004584_1007_8510.html> 
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to