Beispiel #1
0
Explosion::Explosion(const core::vector3df& position) : Effect(EXPLOSIONLENGTH), fireParticles(0), shockwave(0)
{
	//intialize particle system
	sound->play3D("res/sounds/reactor_explo.wav", position);
	fireParticles = scenemngr->addParticleSystemSceneNode(false, 0, -1, position);
	IParticleEmitter *emitter = fireParticles->createSphereEmitter(vector3df(0,0,0), 20,
		vector3df(0,0,0), 100, 200, video::SColor(0,255,255,255), video::SColor(0,255,255,255),
		2000, 4000, 0, dimension2df(75,75), dimension2df(150,150));
	fireParticles->setEmitter(emitter);

	fireParticles->setMaterialTexture(0, vdriver->getTexture("res/textures/engine_trails.pcx"));
	fireParticles->setMaterialFlag(video::EMF_LIGHTING, false);
	fireParticles->setMaterialType(video::EMT_TRANSPARENT_ADD_COLOR);

	IParticleAffector *af = fireParticles->createAttractionAffector(position, -100.f);
	fireParticles->addAffector(af);
	emitter->drop();
	af->drop();

	shockwave = scenemngr->addCubeSceneNode(5);
	shockwave->setScale(core::vector3df(5,0,5));
	shockwave->setMaterialTexture(0,vdriver->getTexture("res/textures/fx/shockwave.png"));
	shockwave->setMaterialType(video::EMT_TRANSPARENT_ALPHA_CHANNEL);
	shockwave->setPosition(position);
	shockwave->setMaterialFlag(video::EMF_LIGHTING, false);

}
/* ----------------------------------------------------------------------------
Creates a particle emitter for an animated mesh scene node

Parameters:
 node,:  Pointer to the animated mesh scene node to emit particles from
 useNormalDirection,:  If true, the direction of each particle created will be
						the normal of the vertex that it's emitting from. The
						normal is divided by the normalDirectionModifier
						parameter, which defaults to 100.0f.
 direction,:  Direction and speed of particle emission.
 normalDirectionModifier,:  If the emitter is using the normal direction then the
							normal of the vertex that is being emitted from is
							divided by this number.
 mbNumber,:  This allows you to specify a specific meshBuffer for the IMesh* to
			emit particles from. The default value is -1, which means a random
			meshBuffer picked from all of the meshes meshBuffers will be selected
			to pick a random vertex from. If the value is 0 or greater, it will
			only pick random vertices from the meshBuffer specified by this value.
 everyMeshVertex,:  If true, the emitter will emit between min/max particles every
					second, for every vertex in the mesh, if false, it will emit
					between min/max particles from random vertices in the mesh.
 minParticlesPerSecond,:  Minimal amount of particles emitted per second.
 maxParticlesPerSecond,:  Maximal amount of particles emitted per second.
 minStartColor,:  Minimal initial start color of a particle. The real color of every
				particle is calculated as random interpolation between minStartColor
				and maxStartColor.
 maxStartColor,:  Maximal initial start color of a particle. The real color of every
				particle is calculated as random interpolation between minStartColor
				and maxStartColor.
 lifeTimeMin,:  Minimal lifetime of a particle, in milliseconds.
 lifeTimeMax,:  Maximal lifetime of a particle, in milliseconds.
 maxAngleDegrees,:  Maximal angle in degrees, the emitting direction of the particle
					will differ from the orignial direction.

Returns:
Returns a pointer to the created particle emitter. To set this emitter as new
emitter of this particle system, just call setEmitter(). Note that you'll have
to drop() the returned pointer, after you don't need it any more, see
IReferenceCounted::drop() for more informations.
*/
IParticleEmitter * DLL_EXPORT IrrAddAnimatedMeshSceneNodeEmitter (
		IParticleSystemSceneNode* ps,
		IAnimatedMeshSceneNode* node,
		bool useNormalDirection,
		float normalDirectionModifier,
		bool emitFromEveryMeshVertex,
		IRR_PARTICLE_EMITTER prop )
{
	IParticleEmitter* em = ps->createAnimatedMeshSceneNodeEmitter(
			node,
			useNormalDirection,
			core::vector3df(prop.direction_x,prop.direction_y,prop.direction_z),
			normalDirectionModifier,
			-1,	// use a random meshbuffer from within the node
			emitFromEveryMeshVertex,
			prop.min_paritlcles_per_second,prop.max_paritlcles_per_second,
			video::SColor(0,prop.min_start_color_red,prop.min_start_color_green,prop.min_start_color_blue),
			video::SColor(0,prop.max_start_color_red,prop.max_start_color_green,prop.max_start_color_blue),
			prop.min_lifetime,prop.max_lifetime,
			prop.max_angle_degrees );

    em->setMinStartSize( dimension2d<f32>(prop.min_start_sizeX, prop.min_start_sizeY));
    em->setMaxStartSize( dimension2d<f32>(prop.max_start_sizeX, prop.max_start_sizeY));
	ps->setEmitter(em);
	em->drop();
	return em;
}
Beispiel #3
0
// Causes this object to explode, making it vanish, and return a particle
//	effect node animating the explosion effect in its current position.
void Soldier::createExplosionEffect(){
	// add a new explosion particle systems (for the two intermixed explosions)
    this->explosionParticleSystem =
		this->smgr->addParticleSystemSceneNode(false);
    this->explosionParticleSystemLarge =
        this->smgr->addParticleSystemSceneNode(false);
    
	// add an emitter for BLOODSPLOSION!!!!!!!!!!!!!!!
	IParticleEmitter *explosionEmitter =
	    this->explosionParticleSystem->createBoxEmitter(
		    aabbox3d<f32>(-5, 0, -5, 5, 1, 5),  // emitter size
		    vector3df(0.0f,0.0f,0.1f),          // direction + speed
		    2000, 5000,                       // min,max particles per second
		    SColor(0,255,255,255),              // darkest color
		    SColor(0,255,255,255),              // brightest color
		    200, 800,                          // min, max particle lifetime
		    360,                                // max angle degrees
		    dimension2df(40.0f, 40.0f),         // min start size
		    dimension2df(200.0f, 200.0f));        // max start size
	this->explosionParticleSystem->setEmitter(explosionEmitter);
	explosionEmitter->drop(); // drop (re-created later)
	
	//add gravity affector to BLOODSPLOSION!!!!!!!!!!!!
	IParticleGravityAffector* pgaf = explosionParticleSystem->createGravityAffector
											(vector3df(0.F,-0.2F,0.0F), 200U);
	explosionParticleSystem->addAffector(pgaf);
    pgaf->drop();

	// add fade-out affector to the BLOODSPLOSION!!!!!!!!!!!!
	IParticleAffector* explosionFadeOutAffector =
	    explosionParticleSystem->createFadeOutParticleAffector();
	this->explosionParticleSystem->addAffector(explosionFadeOutAffector);
	explosionFadeOutAffector->drop();
	
	// customize the particle system positioning, etc.
	vector3df explosionPos = this->sceneNode->getPosition();
	if(explosionPos.Y < 0) // adjust position: no explosions underground!
	    explosionPos.Y = 0;

	// adjust the blood
	this->explosionParticleSystem->setPosition(explosionPos);
	this->explosionParticleSystem->setScale(vector3df(45, 45, 45));
	this->explosionParticleSystem->setMaterialFlag(EMF_LIGHTING, false);
	this->explosionParticleSystem->setMaterialFlag(EMF_ZWRITE_ENABLE, false);
	this->explosionParticleSystem->setMaterialTexture(0,
	this->driver->getTexture("assets/textures/blood.bmp"));
	this->explosionParticleSystem->setMaterialType(EMT_TRANSPARENT_ADD_COLOR);
}
/* ----------------------------------------------------------------------------
create an emitter that can be added to a particle system
*/
IParticleEmitter * DLL_EXPORT IrrAddParticleEmitter( IParticleSystemSceneNode* ps, IRR_PARTICLE_EMITTER prop )
{
	IParticleEmitter* em = ps->createBoxEmitter(
		core::aabbox3d<f32>(prop.min_box_x,prop.min_box_y,prop.min_box_z,prop.max_box_x,prop.max_box_y,prop.max_box_z),
		core::vector3df(prop.direction_x,prop.direction_y,prop.direction_z),
		prop.min_paritlcles_per_second,prop.max_paritlcles_per_second,
		video::SColor(0,prop.min_start_color_red,prop.min_start_color_green,prop.min_start_color_blue),
		video::SColor(0,prop.max_start_color_red,prop.max_start_color_green,prop.max_start_color_blue),
		prop.min_lifetime,prop.max_lifetime,
		prop.max_angle_degrees );

    em->setMinStartSize( dimension2d<f32>(prop.min_start_sizeX, prop.min_start_sizeY));
    em->setMaxStartSize( dimension2d<f32>(prop.max_start_sizeX, prop.max_start_sizeY));
	ps->setEmitter(em);
	em->drop();
	return em;
}
//! constructor
CParticleSystemSceneNode::CParticleSystemSceneNode(bool createDefaultEmitter,
	ISceneNode* parent, ISceneManager* mgr, s32 id,
	const core::vector3df& position, const core::vector3df& rotation,
	const core::vector3df& scale)
	: IParticleSystemSceneNode(parent, mgr, id, position, rotation, scale),
	Emitter(0), ParticleSize(core::dimension2d<f32>(5.0f, 5.0f)), LastEmitTime(0),
	MaxParticles(0xffff), Buffer(0), ParticlesAreGlobal(true)
{
	#ifdef _DEBUG
	setDebugName("CParticleSystemSceneNode");
	#endif

	Buffer = new SMeshBuffer();
	if (createDefaultEmitter)
	{
		IParticleEmitter* e = createBoxEmitter();
		setEmitter(e);
		e->drop();
	}
}
//! constructor
CParticleSystemSceneNode::CParticleSystemSceneNode(bool createDefaultEmitter,
	ISceneNode* parent, ISceneManager* mgr, s32 id, 
	const core::vector3df& position, const core::vector3df& rotation,
	const core::vector3df& scale)
	: IParticleSystemSceneNode(parent, mgr, id, position, rotation, scale),
	Emitter(0), ParticlesAreGlobal(true)
{
	#ifdef _DEBUG
	setDebugName("CParticleSystemSceneNode");
	#endif

	if (createDefaultEmitter)
	{
		IParticleEmitter* e = createBoxEmitter();
		setEmitter(e);
		e->drop();
	}

	setParticleSize();
}
Beispiel #7
0
/******************************************************************************
 * Set the mood and visible state of the world to a light, happy "fabulous"
 * mode - bright pink sparkles lightly fall from the sky.
 *****************************************************************************/
void GameInstance::setWorldState_fabulous() {
  // add a particle system effect to rain pink debree:
  if(this->rainParticleSystem)
    this->rainParticleSystem->drop();
  this->createRainParticleSystem("assets/textures/pinkfire.bmp");

  // add the rain emitter to the rain particle system
  IParticleEmitter *rainEmitter =
    this->rainParticleSystem->createBoxEmitter(
        aabbox3d<f32>(-100, 0, -100, 100, 100, 100),  // emitter size
        vector3df(0.0f, -0.5f, 0.0f),          // direction + speed
        100, 200,                       // min,max particles per second
        SColor(0,255,255,255),              // darkest color
        SColor(0,255,255,255),              // brightest color
        500, 3000,                       // min, max particle lifetime
        0,                                // max angle degrees
        dimension2df(20.0f, 20.0f),         // min start size
        dimension2df(60.0f, 60.0f));        // max start size
  this->setRainEmitter(rainEmitter);
  rainEmitter->drop();

  // set the ambiance to pretty
  this->light->setAmbientLight(255, 172, 253);
}
Beispiel #8
0
    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;
    }