IParticleSystemSceneNode* IrrFactory::addParticleSystemNode( const std::string& particleSystemFile ) { PropertyMap propMap; if( propMap.constructPropertyMap( SimFactory::TransformPath(particleSystemFile) ) ) { // default values const vector3df pos( 0, 0, 0 ); const vector3df rot( 0, 0, 0 ); const vector3df scale( 1, 1, 1 ); // create the particle system node IParticleSystemSceneNode* pSystem = mIrr.getSceneManager()->addParticleSystemSceneNode( false, 0, -1, pos, rot, scale ); Assert( pSystem ); // read some custom properties bool globalMovement = true; dimension2df particleSize( 5.0f, 5.0f ); propMap.getValue( globalMovement, "ParticleSystem.System.GlobalMovement" ); propMap.getValue( particleSize, "ParticleSystem.System.ParticleSize" ); pSystem->setParticlesAreGlobal(globalMovement); pSystem->setParticleSize(particleSize); /// ---- load the effectors ---- // get the gravity properties if( propMap.hasSection( "ParticleSystem.Gravity" ) ) { vector3df gravDir( 0, -1, 0 ); uint32_t affectorTimeMS(1000); // try to read params propMap.getValue( gravDir, "ParticleSystem.Gravity.Direction" ); propMap.getValue( affectorTimeMS, "ParticleSystem.Gravity.AffectorTimeMS" ); gravDir = ConvertNeroToIrrlichtPosition(gravDir); IParticleAffector* pGravity = pSystem->createGravityAffector( gravDir, affectorTimeMS ); Assert( pGravity ); pSystem->addAffector( pGravity ); pGravity->drop(); } // get the fade properties if( propMap.hasSection( "ParticleSystem.Fade" ) ) { SColor targetColor(0,0,0,0); uint32_t affectorTimeMS(1000); // try to read params propMap.getValue( targetColor, "ParticleSystem.Fade.TargetColor" ); propMap.getValue( affectorTimeMS, "ParticleSystem.Fade.AffectorTimeMS" ); IParticleAffector* pFade = pSystem->createFadeOutParticleAffector( targetColor, affectorTimeMS ); Assert( pFade ); pSystem->addAffector( pFade ); pFade->drop(); } // ---- load the emitters ---- // --- NOTE: WE ONLY DO BOX EMITTERS --- if( propMap.hasSection( "ParticleSystem.Emitter" ) ) { // default params aabbox3df box(-10, 28,-10, 10, 30, 10); vector3df dir( 0, .03f, 0 ); uint32_t minParticlesPerSecond = 5; uint32_t maxParticlesPerSecond = 10; SColor minStartColor( 255, 0, 0, 0 ); SColor maxStartColor( 255, 255, 255, 255 ); uint32_t lifeTimeMin = 2000; uint32_t lifeTimeMax = 4000; int32_t maxAngleDegrees = 0; // try to read custom params propMap.getValue( box, "ParticleSystem.Emitter.Box" ); propMap.getValue( dir, "ParticleSystem.Emitter.Direction" ); propMap.getValue( minParticlesPerSecond, "ParticleSystem.Emitter.MinParticlesPerSecond" ); propMap.getValue( maxParticlesPerSecond, "ParticleSystem.Emitter.MaxParticlesPerSecond" ); propMap.getValue( minStartColor, "ParticleSystem.Emitter.MinStartColor" ); propMap.getValue( maxStartColor, "ParticleSystem.Emitter.MaxStartColor" ); propMap.getValue( lifeTimeMin, "ParticleSystem.Emitter.LifetimeMin" ); propMap.getValue( lifeTimeMax, "ParticleSystem.Emitter.LifetimeMax" ); propMap.getValue( maxAngleDegrees, "ParticleSystem.Emitter.MaxAngleDegrees" ); // do coordinate system transformations dir = ConvertNeroToIrrlichtPosition(dir); // create the emitter IParticleEmitter* emit = pSystem->createBoxEmitter ( box, dir, minParticlesPerSecond, maxParticlesPerSecond, minStartColor, maxStartColor, lifeTimeMin, lifeTimeMax, maxAngleDegrees ); Assert( emit ); pSystem->setEmitter( emit ); emit->drop(); } else { LOG_F_WARNING( "render", "No emitter in particle system file - " << particleSystemFile ); } return pSystem; } return NULL; }