/* ---------------------------------------------------------------------------- Add an affector to the particle system to alter their position with gravity */ IParticleGravityAffector* DLL_EXPORT IrrAddGravityParticleAffector( IParticleSystemSceneNode* ps, float x, float y, float z, unsigned int timeForceLost ) { IParticleGravityAffector* paf = ps->createGravityAffector(vector3df(x,y,z), timeForceLost); ps->addAffector(paf); paf->drop(); return paf; }
// 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); }