[osg-users] Creating a flame of rocket
Hi all, I am trying to create a exhaust flame of a moving rocket similar to one shown in attached image 1. I need only the exhaust plume of the rocket. The rocket is moving [b]fast[/b]. To do so, I used osgParticles to make the particle system as shown below in code: sg::ref_ptr ps =new osgParticle::ParticleSystem; ps->getDefaultParticleTemplate().setShape(osgParticle::Particle::QUAD); ps->getDefaultParticleTemplate().setLifeTime( 0.50f ); ps->getDefaultParticleTemplate().setSizeRange( osgParticle::rangef(0.5f, 0.1f) ); ps->getDefaultParticleTemplate().setAlphaRange( osgParticle::rangef(0.5f, 0.0f) ); ps->getDefaultParticleTemplate().setColorRange(osgParticle::rangev4(osg::Vec4(45.0/255.0f,179.0/255.0,217/255.0f,1.0f), osg::Vec4(172.0/255.0f,225.0/255.0f,240/255.0f,1.0f)) ); ps->setDefaultAttributes("smoke.rgb", true, false ); osg::ref_ptr rrc = new osgParticle::RandomRateCounter; rrc->setRateRange( 100, 200 ); //200-800 osg::ref_ptr emitter =new osgParticle::ModularEmitter; emitter->setParticleSystem( ps.get() ); emitter->setCounter( rrc.get() ); osg::ref_ptr shooter = new osgParticle::RadialShooter; shooter->setThetaRange(osg::DegreesToRadians(-0.50), osg::DegreesToRadians(0.50) ); shooter->setInitialSpeedRange( 1.5f, 1.0f ); emitter->setShooter( shooter.get() ); ps->setUseShaders(true); osg::ref_ptr program = new osgParticle::ModularProgram; program->setParticleSystem( ps.get() ); I observe that this creates a flame good for a stationary rocket. But as the rocket is moving fast, it leaves patches of Quad particle behind on it trail. Shown in attached image 2. I reuced the lifetime of particles, but it didn't help. I want to avoid making the trail. I need the particles to appear as in image 1, even when the rocket moves forward. How to do it?? I feel i need to make the emitted particles to also move along with rocket. The particle system is already a child of MatrixTransform that supplies motion to rocket. i read the osgparticleffect.cpp but the customization shown der didn't help much.. Any help on creating this effect??? ... Thank you! Cheers, Suraj -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=68734#68734 Attachments: http://forum.openscenegraph.org//files/cessna_on_fire_117.png http://forum.openscenegraph.org//files/299f509dab3e7b7cc670e8a999f2dcfe_715.png ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Creating a flame of rocket
Hi, The emitted particles following the node that they're attached to should be the default behaviour of osgParticle, so there is problem something wrong in your setup. What you are describing is what would happen if the Emitter was a child of the moving node, but the ParticleSystem itself is child of some stationary node. You are not showing the whole code, I can't tell you for sure if that is the problem, but it looks like it. Both the ParticleSystem and the Emitter should be a child of the moving node. Cheers, Jannik -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=68737#68737 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Creating a flame of rocket
Hi Suraj, For flames I wouldn't use osgParticle these days. Personal I'd implement it using shaders and perlin noise. In include/osgUtil/PerlinNoise you'll find a helper class from creating the image that you can assign to a texture. Also look online for tutorials on how to use Perlin noise, there are plenty out there and are fascinating to delver into. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Creating a flame of rocket
Hi Jannik, Here's my code i am using the create the particle system and emitter. I am creating two particle systems--one for each exhaust of the rocket.:-- int main() { osg::ref_ptr mt = new osg::MatrixTransform; osg::ref_ptr mt_2 = new osg::MatrixTransform; osg::ref_ptr trans= new osg::MatrixTransform; osg::ref_ptr lan = osgDB::readNodeFile("cessna.osg"); trans->setMatrix( osg::Matrix::translate(0.0f, 0.0f, 0.0f) ); trans->addChild(lan); //create two particle systems at different locations mt->setMatrix( osg::Matrix::translate(5.0f, -5.0f, 0.0f) ); osgParticle::ParticleSystem* ps = createParticleSystem( mt.get()); mt_2->setMatrix( osg::Matrix::translate(-5.0f, -5.0f, 0.0f) ); osgParticle::ParticleSystem* ps_2 = createParticleSystem( mt_2.get()); //attach the two Particle system to 'trans' node trans->addChild(mt.get()); trans->addChild(mt_2.get()); //give motion to 'trans' using osg::AnimationPath::LOOP trans->addUpdateCallback( createAnimationPathCallback(100.0f, 30.0) ); //add updater to each of the particle system osg::ref_ptr updater =new osgParticle::ParticleSystemUpdater; updater->addParticleSystem( ps ); updater->addParticleSystem( ps_2 ); //add the trans and updater to a group node called root osg::ref_ptr root = new osg::Group; root->addChild( updater.get() ); root->addChild(trans.get()); osgViewer::Viewer viewer; viewer.setSceneData( root.get() ); return viewer.run(); } /***end of main/ /createparticleSystem func ***/ osgParticle::ParticleSystem* createParticleSystem( osg::Group* parent ) { osg::ref_ptr ps =new osgParticle::ParticleSystem; ps->getDefaultParticleTemplate().setShape(osgParticle::Particle::QUAD); ps->getDefaultParticleTemplate().setLifeTime( 0.50f ); ps->getDefaultParticleTemplate().setSizeRange( osgParticle::rangef(0.5f, 0.1f) ); ps->getDefaultParticleTemplate().setAlphaRange( osgParticle::rangef(0.5f, 0.0f) ); ps->getDefaultParticleTemplate().setColorRange(osgParticle::rangev4(osg::Vec4(45.0/255.0f,179.0/255.0,217/255.0f,1.0f), osg::Vec4(172.0/255.0f,225.0/255.0f,240/255.0f,1.0f)) ); ps->setDefaultAttributes("smoke.rgb", true, false ); osg::ref_ptr rrc = new osgParticle::RandomRateCounter; rrc->setRateRange( 100, 200 ); osg::ref_ptr emitter =new osgParticle::ModularEmitter; emitter->setParticleSystem( ps.get() ); emitter->setCounter( rrc.get() ); osg::ref_ptr shooter = new osgParticle::RadialShooter; shooter->setThetaRange(osg::DegreesToRadians(-0.50), osg::DegreesToRadians(0.50) ); shooter->setInitialSpeedRange( 1.5f, 1.0f ); emitter->setShooter( shooter.get() ); ps->setUseShaders(true); osg::ref_ptr program = new osgParticle::ModularProgram; program->setParticleSystem( ps.get() ); osg::ref_ptr geode = new osg::Geode; geode->addDrawable( ps.get() ); parent->addChild( emitter.get() ); parent->addChild( program.get() ); parent->addChild( geode.get() ); return ps.get(); } ... Thank you! Cheers, Suraj -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=68760#68760 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org