void ParticleRenderer::PrepareForRendering() { PROFILE3("prepare particles"); // Can't load the shader in the constructor because it's called before the // renderer initialisation is complete, so load it the first time through here if (!m->shader) { typedef std::map<CStr, CStr> Defines; Defines defNull; m->shader = g_Renderer.GetShaderManager().LoadProgram("particle", defNull); m->shaderSolid = g_Renderer.GetShaderManager().LoadProgram("particle_solid", defNull); } { PROFILE("update emitters"); for (size_t i = 0; i < m->emitters.size(); ++i) { CParticleEmitter* emitter = m->emitters[i]; emitter->UpdateArrayData(); } } { // Sort back-to-front by distance from camera PROFILE("sort emitters"); CMatrix3D worldToCam; g_Renderer.GetViewCamera().m_Orientation.GetInverse(worldToCam); std::stable_sort(m->emitters.begin(), m->emitters.end(), SortEmitterDistance(worldToCam)); } // TODO: should batch by texture here when possible, maybe }
int CParticleSystem::Render (void) { if (!m_bValid) return 0; int h = 0; if (m_emitters.Buffer ()) { if (!particleImageManager.Load (m_nType)) return 0; if ((m_nObject >= 0) && (m_nObject < 0x70000000) && ((OBJECTS [m_nObject].info.nType == OBJ_NONE) || (OBJECTS [m_nObject].info.nSignature != m_nSignature) || (particleManager.GetObjectSystem (m_nObject) < 0))) SetLife (0); CParticleEmitter *emitterP = m_emitters.Buffer (); for (int i = m_nEmitters; i; i--, emitterP++) h += emitterP->Render (-1); } #if DBG if (!h) return 0; #endif return h; }
void ParticleRenderer::RenderParticles(bool solidColor) { CShaderTechniquePtr shader = solidColor ? m->shaderSolid : m->shader; shader->BeginPass(); shader->GetShader()->Uniform(str_transform, g_Renderer.GetViewCamera().GetViewProjection()); if (!solidColor) glEnable(GL_BLEND); glDepthMask(0); for (size_t i = 0; i < m->emitters.size(); ++i) { CParticleEmitter* emitter = m->emitters[i]; emitter->Bind(shader->GetShader()); emitter->RenderArray(shader->GetShader()); } CVertexBuffer::Unbind(); pglBlendEquationEXT(GL_FUNC_ADD); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDisable(GL_BLEND); glDepthMask(1); shader->EndPass(); }
int CParticleSystem::Update (void) { CParticleEmitter *emitterP; int i = 0; if ((m_nObject == 0x7fffffff) && (m_nType == SMOKE_PARTICLES) && (gameStates.app.nSDLTicks - m_nBirth > (MAX_SHRAPNEL_LIFE / I2X (1)) * 1000)) SetLife (0); #if DBG if ((m_nObject >= 0) && (m_nObject < 0x70000000) && (OBJECTS [m_nObject].info.nType == 255)) i = i; #endif if ((emitterP = m_emitters.Buffer ())) { bool bKill = (m_nObject < 0) || ((m_nObject < 0x70000000) && ((OBJECTS [m_nObject].info.nSignature != m_nSignature) || (OBJECTS [m_nObject].info.nType == OBJ_NONE))); for (i = 0; i < m_nEmitters; ) { if (!m_emitters) return 0; if (emitterP->IsDead (gameStates.app.nSDLTicks)) { if (!RemoveEmitter (i)) { //particleManager.Destroy (m_nId); m_bDestroy = true; break; } } else { if (bKill) emitterP->SetLife (0); emitterP->Update (gameStates.app.nSDLTicks, -1); emitterP++, i++; } } } return i; }
void ParticleRenderer::RenderBounds() { for (size_t i = 0; i < m->emitters.size(); ++i) { CParticleEmitter* emitter = m->emitters[i]; CBoundingBoxAligned bounds = emitter->m_Type->CalculateBounds(emitter->GetPosition(), emitter->GetParticleBounds()); bounds.Render(); } }
void ParticleRenderer::RenderParticles(bool solidColor) { CShaderProgramPtr shader = solidColor ? m->shaderSolid : m->shader; shader->Bind(); if (!solidColor) glEnable(GL_BLEND); glDepthMask(0); glEnableClientState(GL_VERTEX_ARRAY); if (!solidColor) glEnableClientState(GL_COLOR_ARRAY); pglClientActiveTextureARB(GL_TEXTURE1); glEnableClientState(GL_TEXTURE_COORD_ARRAY); pglClientActiveTextureARB(GL_TEXTURE0); glEnableClientState(GL_TEXTURE_COORD_ARRAY); for (size_t i = 0; i < m->emitters.size(); ++i) { CParticleEmitter* emitter = m->emitters[i]; emitter->Bind(); emitter->RenderArray(); } CVertexBuffer::Unbind(); pglBlendEquationEXT(GL_FUNC_ADD); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_COLOR_ARRAY); pglClientActiveTextureARB(GL_TEXTURE1); glDisableClientState(GL_TEXTURE_COORD_ARRAY); pglClientActiveTextureARB(GL_TEXTURE0); glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisable(GL_BLEND); glDepthMask(1); shader->Unbind(); }
void EnemyStateDamage::Enter(const SEnterArg& enterArg) { IEnemyState::Enter(enterArg); dmgCollisionGroupID = enterArg.arg[0]; enemy->PlayAnimationForce(Enemy::enAnimDamage); const EnemyParam* enemyParam = enemy->GetEnemyParam(); CMatrix* m = enemy->FindBoneWorldMatrix(enemyParam->bloodEffectBoneName); if (m != NULL) { //パーティクルエミッターを登録。 for (SParicleEmitParameter& param : bloodEmitterParam) { CParticleEmitter* particleEmitter = NewGO<CParticleEmitter>(0); CVector3 pos; pos.Set(m->m[3][0], m->m[3][1], m->m[3][2]); particleEmitter->Init(g_random, g_camera->GetCamera(), param, pos); particleEmitterList.push_back(particleEmitter); } } }
void CBulletManager::Update(float _ElapsedTime) { CBullet * l_pBullet = NULL; for (uint32 i=0 ; i < m_ResourcesVector.size(); i++ ) { l_pBullet = this->GetResourceById(i); l_pBullet->Update(_ElapsedTime); if(l_pBullet->IsEnded()) { m_ResourcesVector.erase(m_ResourcesVector.begin()+i); m_ResourcesMap.erase(l_pBullet->GetName()); CHECKED_DELETE(l_pBullet); } } //damage particles for (tdParticlesMap::iterator it = m_particles.begin(); it != m_particles.end();) { CSoldier* pSoldier = it->second.first; if (it->second.second.second <= 0.f) { CORE->GetParticleManager()->RemoveParticleEmitterInstance(it->first); it = m_particles.erase(it); } else { if (pSoldier != NULL) { bool bSecondFloor = pSoldier->GetPosition().y >= SECON_FLOOR_HEIGHT; float fy = (bSecondFloor ? (pSoldier->GetPosition().y + it->second.second.first - SECON_FLOOR_HEIGHT) : (pSoldier->GetPosition().y + it->second.second.first)); Vect3f new_pos = Vect3f(pSoldier->GetPosition().x, fy, pSoldier->GetPosition().z); CParticleEmitter* pEmitter = CORE->GetParticleManager()->GetParticleEmitter(it->first); if (pEmitter != NULL) pEmitter->SetPos(new_pos); } it->second.second.second -= _ElapsedTime; ++it; } } }
void ParticleRenderer::PrepareForRendering(const CShaderDefines& context) { PROFILE3("prepare particles"); // Can't load the shader in the constructor because it's called before the // renderer initialisation is complete, so load it the first time through here if (!m->shader) { // Only construct the shaders when shaders are supported and enabled; otherwise // RenderParticles will never be called so it's safe to leave the shaders as null if (g_Renderer.GetRenderPath() == CRenderer::RP_SHADER) { m->shader = g_Renderer.GetShaderManager().LoadEffect(str_particle, context, CShaderDefines()); m->shaderSolid = g_Renderer.GetShaderManager().LoadEffect(str_particle_solid, context, CShaderDefines()); } } { PROFILE("update emitters"); for (size_t i = 0; i < m->emitters.size(); ++i) { CParticleEmitter* emitter = m->emitters[i]; emitter->UpdateArrayData(); } } { // Sort back-to-front by distance from camera PROFILE("sort emitters"); CMatrix3D worldToCam; g_Renderer.GetViewCamera().m_Orientation.GetInverse(worldToCam); std::stable_sort(m->emitters.begin(), m->emitters.end(), SortEmitterDistance(worldToCam)); } // TODO: should batch by texture here when possible, maybe }
CParticleEmitter* CParticleSystemConfig::parseEmitter(IrrXMLReader* xml, CParticleSystem *o_pParent, bool emitterLoop) { bool finished = false; std::string colorBase, colorCourse; CParticleEmitter* emitter = NULL; CParticleType* particle = NULL; bool particleAdditive; std::string particleTexture; while(!finished && xml && xml->read()) { switch (xml -> getNodeType()) { case EXN_ELEMENT: if (!strcmp("color", xml->getNodeName())) { colorBase = xml->getAttributeValue("base"); colorCourse = xml->getAttributeValue("course"); } // if else if (!strcmp("particle", xml->getNodeName())) { particleTexture = xml->getAttributeValue("texture"); convert(xml->getAttributeValue("additive"), particleAdditive); particle = new CParticleType(); particle->SetAdditive(particleAdditive); particle->SetTexture((char*)(effectPath + particleTexture).c_str()); parseParticle(xml, o_pParent, particle); if (!particle) { printd(ERROR,"CParticleSystemConfig::parseEmitter(): ERROR WHILE PARSING PARTICLE!\n"); return NULL; } // if emitter = new CParticleEmitter(o_pParent, particle); emitter->SetLoop(emitterLoop); } // else if else if (!strcmp("emission", xml->getNodeName())) { parseEmission(xml, emitter); } // else if break; case EXN_ELEMENT_END: if (!strcmp("emitter", xml->getNodeName())) { emitter->SetLength(calculateSceneLength(emitter)); assert(convertImageToColorTimeline(emitter->GetColor(), (char*)(effectPath + colorBase).c_str(), emitter->rGetLength())); assert(convertImageToColorTimeline(emitter->pGetParticleType()->GetColorChange(), (char*)(effectPath + colorCourse).c_str(), 1.0f)); assert(emitter->bInitialize()); finished = true; } // if break; default: break; } // switch } // while return emitter; } // parseEmitter
void DoPlayerSmoke (CObject *objP, int nPlayer) { int nObject, nSmoke, d, nParts, nType; float nScale; CParticleEmitter *emitterP; CFixVector fn, mn, vDir, *vDirP; tThrusterInfo ti; static int bForward = 1; if (nPlayer < 0) nPlayer = objP->info.nId; if ((gameData.multiplayer.players [nPlayer].flags & PLAYER_FLAGS_CLOAKED) || (automap.m_bDisplay && IsMultiGame && !AM_SHOW_PLAYERS)) { KillObjectSmoke (nPlayer); return; } nObject = objP->Index (); if (gameOpts->render.particles.bDecreaseLag && (nPlayer == gameData.multiplayer.nLocalPlayer)) { fn = objP->info.position.mOrient.FVec (); mn = objP->info.position.vPos - objP->info.vLastPos; CFixVector::Normalize (fn); CFixVector::Normalize (mn); d = CFixVector::Dot (fn, mn); if (d >= -I2X (1) / 2) bForward = 1; else { if (bForward) { if ((nSmoke = particleManager.GetObjectSystem (nObject)) >= 0) { KillObjectSmoke (nObject); particleManager.Destroy (nSmoke); } bForward = 0; nScale = 0; return; } } } #if 0 if (EGI_FLAG (bThrusterFlames, 1, 1, 0)) { if ((a <= I2X (1) / 4) && (a || !gameStates.input.bControlsSkipFrame)) //no thruster flames if moving backward DropAfterburnerBlobs (objP, 2, I2X (1), -1, gameData.objs.consoleP, 1); //I2X (1) / 4); } #endif if ((gameData.app.nGameMode & GM_NETWORK) && !gameData.multiplayer.players [nPlayer].connected) nParts = 0; else if (objP->info.nFlags & (OF_SHOULD_BE_DEAD | OF_DESTROYED)) nParts = 0; else if ((nPlayer == gameData.multiplayer.nLocalPlayer) && (gameStates.app.bPlayerIsDead || (gameData.multiplayer.players [nPlayer].shields < 0))) nParts = 0; else { nSmoke = X2IR (gameData.multiplayer.players [nPlayer].shields); nParts = 10 - nSmoke / 5; nScale = X2F (objP->info.xSize); if (nSmoke <= 25) nScale /= 1.5; else if (nSmoke <= 50) nScale /= 2; else nScale /= 3; if (nParts <= 0) { nType = 2; //nParts = (gameStates.entropy.nTimeLastMoved < 0) ? 250 : 125; } else { CreateDamageExplosion (nParts, nObject); nType = (nSmoke > 25); nParts *= 25; nParts += 75; } nParts = objP->mType.physInfo.thrust.IsZero () ? SHIP_MAX_PARTS : SHIP_MAX_PARTS / 2; if (SHOW_SMOKE && nParts && gameOpts->render.particles.bPlayers) { if (gameOpts->render.particles.bSyncSizes) { nParts = -MAX_PARTICLES (nParts, gameOpts->render.particles.nDens [0]); nScale = PARTICLE_SIZE (gameOpts->render.particles.nSize [0], nScale); } else { nParts = -MAX_PARTICLES (nParts, gameOpts->render.particles.nDens [1]); nScale = PARTICLE_SIZE (gameOpts->render.particles.nSize [1], nScale); } if (!objP->mType.physInfo.thrust.IsZero ()) vDirP = NULL; else { // if the ship is standing still, let the thruster smoke move away from it nParts /= 2; nScale /= 2; vDir = OBJPOS (objP)->mOrient.FVec () * (I2X (1) / 8); vDir = -vDir; vDirP = &vDir; } if (0 > (nSmoke = particleManager.GetObjectSystem (nObject))) { //PrintLog ("creating CPlayerData smoke\n"); nSmoke = particleManager.Create (&objP->info.position.vPos, vDirP, NULL, objP->info.nSegment, 2, nParts, nScale, gameOpts->render.particles.nSize [1], 2, PLR_PART_LIFE / (nType + 1) * (vDirP ? 2 : 1), PLR_PART_SPEED, SMOKE_PARTICLES, nObject, smokeColors + nType, 1, -1); if (nSmoke < 0) return; particleManager.SetObjectSystem (nObject, nSmoke); } else { if (vDirP) particleManager.SetDir (nSmoke, vDirP); particleManager.SetLife (nSmoke, PLR_PART_LIFE / (nType + 1) * (vDirP ? 2 : 1)); particleManager.SetType (nSmoke, SMOKE_PARTICLES); particleManager.SetScale (nSmoke, -nScale); particleManager.SetDensity (nSmoke, nParts, gameOpts->render.particles.bSyncSizes ? -1 : gameOpts->render.particles.nSize [1]); particleManager.SetSpeed (particleManager.GetObjectSystem (nObject), objP->mType.physInfo.thrust.IsZero () ? PLR_PART_SPEED * 2 : PLR_PART_SPEED); } CalcThrusterPos (objP, &ti, 0); for (int i = 0; i < 2; i++) if ((emitterP = particleManager.GetEmitter (nSmoke, i))) emitterP->SetPos (ti.vPos + i, NULL, objP->info.nSegment); DoGatlingSmoke (objP); return; } } KillObjectSmoke (nObject); KillGatlingSmoke (objP); }
CParticleEmitter *CParticleSystemManager::LoadEmitter( std::string szEmitterScript ) { if ( !SETS->PARTICLES_ON ) return NULL; FILE *pFile = fopen( szEmitterScript.c_str(), "rt" ); if ( !pFile ) return NULL; std::string in = ReadLine( pFile ); while ( in != "<<<EOF>>>" && in != "[emitter]" ) in = ReadLine( pFile ); EmitterType eType = NONE; float fTypeParameter = 0.0f; unsigned int iMaxParticles = 50; unsigned int iLifespan = 6000; unsigned int iSpawnrate = 10; float fRadius = 0.0f; CTokenizer tokenizer; std::vector<std::string> tokens; std::map<std::string, int> vParticles; std::map<std::string,int>::iterator particleIt; while ( in != "<<<EOF>>>" && in != "" ) { tokens = tokenizer.GetTokens( in, " ,;:\"" ); if ( tokens.size() > 0 ) { if ( tokens[0] == "direction" ) { if ( tokens[2] == "arc" ) { eType = ARC; fTypeParameter = (float)atof(tokens[3].c_str()); } else if ( tokens[2] == "line" ) { eType = LINE; fTypeParameter = (float)atof(tokens[3].c_str()); } else { eType = NONE; fTypeParameter = 0.0f; } } else if ( tokens[0] == "maxparticles" ) iMaxParticles = atoi(tokens[2].c_str()); else if ( tokens[0] == "lifespan" ) iLifespan = atoi(tokens[2].c_str()); else if ( tokens[0] == "spawnrate" ) iSpawnrate = atoi(tokens[2].c_str()); else if ( tokens[0] == "radius" ) fRadius = (float)atof(tokens[2].c_str()); else if ( tokens[0] == "particles" ) { int particles = (tokens.size() - 2) / 2; for ( int i = 0; i<particles * 2; i+=2 ) { std::string name = tokens[i + 2]; int chance = atoi(tokens[i + 3].c_str()); vParticles[name] = chance; } } } in = ReadLine( pFile ); } fclose( pFile ); CParticleEmitter *pEmitter = new CParticleEmitter( eType, fTypeParameter, iMaxParticles, iLifespan, iSpawnrate, fRadius ); for ( particleIt = vParticles.begin(); particleIt != vParticles.end(); particleIt++ ) { std::string name = (*particleIt).first; int chance = (*particleIt).second; CParticle *pParticle = ReadParticle( szEmitterScript, name, pEmitter ); pEmitter->AddToFactory( pParticle, chance ); } m_vEmitters.push_back( pEmitter ); return pEmitter; }
bool CParticleEmitterManager::Reload() { CXMLTreeNode newFile; if (!newFile.LoadFile(m_Filename.c_str())) { std::string msg_error = "CParticleEmitterManager::Load->Error al intentar leer el archivo xml: " + m_Filename; LOGGER->AddNewLog(ELL_ERROR, msg_error.c_str()); return false; } CXMLTreeNode l_xml = newFile["particle_emitters"]; if( l_xml.Exists() ) { uint16 l_Count = l_xml.GetNumChildren(); for(uint16 i=0; i<l_Count; ++i) { std::string l_Type = l_xml(i).GetName(); if( l_Type == "emitter" ) { std::string name = l_xml(i).GetPszProperty("name", "", true); std::string systemName = l_xml(i).GetPszProperty("system_name", "", true); std::string type = l_xml(i).GetPszProperty("type", "", true); Vect3f initPos = l_xml(i).GetVect3fProperty("initialPosition", Vect3f(0, 0, 0), true); bool onLoop = l_xml(i).GetBoolProperty("on_loop", true, false); bool useDis = l_xml(i).GetBoolProperty("use_dis", true, false); float particlesPerSecond = l_xml(i).GetFloatProperty("particlesPerSecond", 0, true) / CORE->GetConfig().particle_level; uint32 pej = (uint32)l_xml(i).GetIntProperty("ejection_count", 0, !onLoop) / CORE->GetConfig().particle_level; particlesPerSecond = particlesPerSecond == 0.0f ? 1.0f : particlesPerSecond; pej = pej == 0 ? 1 : pej; CParticleSystem* system = CORE->GetParticleSystemManager()->GetResource(systemName); assert(system); CParticleEmitter* emitter = NULL; if(type == "point") { CParticleEmitterPoint* point = new CParticleEmitterPoint(name, system, particlesPerSecond, initPos, useDis); emitter = point; } else if(type == "ring") { bool horizontal = l_xml(i).GetBoolProperty("horizontal", false, true); float radius = l_xml(i).GetFloatProperty("radius", 0, true); float height = l_xml(i).GetFloatProperty("height", 0, true); float width = l_xml(i).GetFloatProperty("width", 0, true); CParticleEmitterRing* ring = new CParticleEmitterRing(name, system, particlesPerSecond, initPos, useDis, horizontal, radius, height, width); emitter = ring; } else if(type == "line") { Vect3f lineStart = l_xml(i).GetVect3fProperty("line_start", v3fZERO); Vect3f lineEnd = l_xml(i).GetVect3fProperty("line_end", v3fZERO); CParticleEmitterLine* line = new CParticleEmitterLine(name, system, particlesPerSecond, initPos, useDis, lineStart, lineEnd); emitter = line; } else if(type == "box") { Vect3f boxMin = l_xml(i).GetVect3fProperty("box_min", v3fZERO); Vect3f boxMax = l_xml(i).GetVect3fProperty("box_max", v3fZERO); CParticleEmitterBox* box = new CParticleEmitterBox(name, system, particlesPerSecond, initPos, useDis, boxMin, boxMax); emitter = box; } else if(type == "sphere") { float radius = l_xml(i).GetFloatProperty("radius", 1.f); CParticleEmitterSphere *sphere = new CParticleEmitterSphere(name, system, particlesPerSecond, initPos, useDis, radius); emitter = sphere; } assert(emitter); emitter->SetOnLoop(onLoop); emitter->SetParticlesEjectionCount(pej); bool isOk = this->AddResource(name, emitter); assert(isOk); } } } else { return false; } return true; }
void CParticleEmitter::Copy(CParticleEmitter &other) { m_vPos = other.GetPos(); m_Type = other.GetType(); m_fMinTimeLife = other.GetMinTimeLife(); m_fMaxTimeLife = other.GetMaxTimeLife(); m_fMinEmitRate = other.GetMinRate(); m_fMaxEmitRate = other.GetMaxRate(); m_bGravity = other.GetGravity(); m_fAngle = other.GetAngle(); std::vector<SColor> l_ColorVector = other.GetColorVector(); for(unsigned int i=0; i<l_ColorVector.size(); i++) { m_vColors.push_back(SColor()); m_vColors[m_vColors.size()-1].time = l_ColorVector[i].time; m_vColors[m_vColors.size()-1].col1 = l_ColorVector[i].col1; m_vColors[m_vColors.size()-1].col2 = l_ColorVector[i].col2; } std::vector<SDirection> l_DirectionVector = other.GetDirectionVector(); for(unsigned int i=0; i<l_DirectionVector.size(); i++) { m_vDirections.push_back(SDirection()); m_vDirections[m_vDirections.size()-1].time = l_DirectionVector[i].time; m_vDirections[m_vDirections.size()-1].dir1 = l_DirectionVector[i].dir1; m_vDirections[m_vDirections.size()-1].dir2 = l_DirectionVector[i].dir2; } std::vector<SSize> l_SizeVector = other.GetSizeVector(); for(unsigned int i=0; i<l_SizeVector.size(); i++) { m_vSizes.push_back(SSize()); m_vSizes[m_vSizes.size()-1].time = l_SizeVector[i].time; m_vSizes[m_vSizes.size()-1].size1 = l_SizeVector[i].size1; m_vSizes[m_vSizes.size()-1].size2 = l_SizeVector[i].size2; } std::vector<SAceleration> l_AcelVector = other.GetAcelerationVector(); for(unsigned int i=0; i<l_AcelVector.size(); i++) { m_vAcelerations.push_back(SAceleration()); m_vAcelerations[m_vAcelerations.size()-1].time = l_AcelVector[i].time; m_vAcelerations[m_vAcelerations.size()-1].acel1 = l_AcelVector[i].acel1; m_vAcelerations[m_vAcelerations.size()-1].acel2 = l_AcelVector[i].acel2; } m_fNumNewPartsExcess = other.GetNumNewPartsExcess(); m_sTexture = other.GetTexture(); }
void addExplosion(const irr::core::vector3df& pos, const irr::core::vector3df& rot, const irr::u32& scale, irr::scene::ISceneManager* smgr, const irr::core::plane3df& p, irr::scene::ITriangleSelector* selector) { irr::scene::CParticleSystem* system = new irr::scene::CParticleSystem(smgr->getRootSceneNode(), smgr, 6); system->setPosition(pos); system->setRotation(rot); system->setScale(irr::core::vector3df((irr::f32)scale)); system->updateAbsolutePosition(); ///Spark Trails CParticleDrawer* drawer = system->addTrailParticleDrawer(); SParticleUV uv(irr::core::vector2df(0.75f,0.75f), irr::core::vector2df(1.0f,0.75f), irr::core::vector2df(0.75f,1.0f), irr::core::vector2df(1.0f,1.0f)); uv.turnRight(); drawer->addUVCoords(uv); CParticleEmitter* emitter = new CParticleEmitterPoint(irr::core::vector3df(0,0,0), irr::core::vector3df(0,0,0), irr::core::vector3df(0,15,0), irr::core::vector3di(180, 0, 180), 0, 500, 30, 500, 1200, irr::core::vector2df(1.0), irr::core::vector2df(1.5), irr::core::vector2df(0,0), irr::video::SColor(255,255,255,0), irr::video::SColor(255,255,255,0)); drawer->setEmitter(emitter); emitter->drop(); CParticleAffector* affector = new ColorAffector(irr::video::SColor(0,100,50,0)); drawer->addAffector(affector); affector->drop(); ///Smoke Trails drawer = system->addTrailParticleDrawer(); uv = SParticleUV(irr::core::vector2df(0.0f,0.5f), irr::core::vector2df(0.5f, 0.5f), irr::core::vector2df(0.0f,0.5f+0.125f), irr::core::vector2df(0.5f,0.5f+0.125f)); uv.turnRight(); drawer->addUVCoords(uv); uv = SParticleUV(irr::core::vector2df(0.0f,0.5f+0.125f), irr::core::vector2df(0.5f, 0.5f+0.125f), irr::core::vector2df(0.0f,0.5f+0.125f+0.125f), irr::core::vector2df(0.5f,0.5f+0.125f+0.125f)); uv.turnRight(); drawer->addUVCoords(uv); uv = SParticleUV(irr::core::vector2df(0.0f,0.5f+0.125f+0.125f), irr::core::vector2df(0.5f, 0.5f+0.125f+0.125f), irr::core::vector2df(0.0f,0.5f+0.125f+0.125f+0.125f), irr::core::vector2df(0.5f,0.5f+0.125f+0.125f+0.125f)); uv.turnRight(); drawer->addUVCoords(uv); emitter = new CParticleEmitterPoint(irr::core::vector3df(0,0,0), irr::core::vector3df(0,0,0), irr::core::vector3df(0,10,0), irr::core::vector3di(180, 0, 180), 0, 500, 10, 400, 600, irr::core::vector2df(0.25,1.0), irr::core::vector2df(0.25,1.0), irr::core::vector2df(2.f), irr::video::SColor(255,255,128,50), irr::video::SColor(255,255,128,50)); drawer->setEmitter(emitter); emitter->drop(); affector = new ColorAffectorQ(irr::video::SColor(128,128,128,50), irr::video::SColor(0,0,0,0)); drawer->addAffector(affector); affector->drop(); ///Debris drawer = system->addParticleDrawer(); drawer->addUVCoords(SParticleUV(irr::core::vector2df(0.5f,0.5f), irr::core::vector2df(0.5f+0.0833f,0.5f), irr::core::vector2df(0.5f,0.5f+0.0833f), irr::core::vector2df(0.5f+0.0833f,0.5f+0.0833f))); drawer->addUVCoords(SParticleUV(irr::core::vector2df(0.5f+0.0833f,0.5f), irr::core::vector2df(0.5f+0.0833f+0.0833f,0.5f), irr::core::vector2df(0.5f+0.0833f,0.5f+0.0833f), irr::core::vector2df(0.5f+0.0833f+0.0833f,0.5f+0.0833f))); drawer->addUVCoords(SParticleUV(irr::core::vector2df(0.5f+0.0833f+0.0833f,0.5f), irr::core::vector2df(0.5f+0.0833f+0.0833f+0.0833f,0.5f), irr::core::vector2df(0.5f+0.0833f+0.0833f,0.5f+0.0833f), irr::core::vector2df(0.5f+0.0833f+0.0833f+0.0833f,0.5f+0.0833f))); drawer->addUVCoords(SParticleUV(irr::core::vector2df(0.5f,0.5f+0.0833f), irr::core::vector2df(0.5f+0.0833f,0.5f+0.0833f), irr::core::vector2df(0.5f,0.5f+0.0833f+0.0833f), irr::core::vector2df(0.5f+0.0833f,0.5f+0.0833f+0.0833f))); drawer->addUVCoords(SParticleUV(irr::core::vector2df(0.5f,0.5f+0.0833f+0.0833f), irr::core::vector2df(0.5f+0.0833f,0.5f+0.0833f+0.0833f), irr::core::vector2df(0.5f,0.5f+0.0833f+0.0833f+0.0833f), irr::core::vector2df(0.5f+0.0833f,0.5f+0.0833f+0.0833f+0.0833f))); emitter = new CParticleEmitterPoint(irr::core::vector3df(0,0,0), irr::core::vector3df(1,0,0), irr::core::vector3df(0,12,0), irr::core::vector3di(45, 0, 45), 0, 400, 10, 2000, 3000, irr::core::vector2df(0.2f,0.2f), irr::core::vector2df(0.5f,0.5f), irr::core::vector2df(0,0), irr::video::SColor(255,255,100,0), irr::video::SColor(255,255,100,0)); drawer->setEmitter(emitter); emitter->drop(); affector = new ColorAffectorQ(irr::video::SColor(255,50,50,50), irr::video::SColor(255,50,50,50)); drawer->addAffector(affector); affector->drop(); affector = new GravityAffector(irr::core::vector3df(0.f,-15.0f,0.f)); drawer->addAffector(affector); affector->drop(); affector = new PlaneCollisionAffector(p); drawer->addAffector(affector); affector->drop(); ///Wave Emitter drawer = system->addOrientedParticleDrawer(); drawer->getMaterial().BackfaceCulling = false; drawer->addUVCoords(SParticleUV(irr::core::vector2df(0.75f,0.5f), irr::core::vector2df(1.0f,0.5f), irr::core::vector2df(0.75f,0.75f), irr::core::vector2df(1.0f,0.75f))); emitter = new CParticleEmitterPoint(irr::core::vector3df(0,0,0), irr::core::vector3df(0,0,0), irr::core::vector3df(0,0,0), irr::core::vector3di(0), 20, 50, 1, 500, 500, irr::core::vector2df(2.5,2.5), irr::core::vector2df(2.5,2.5), irr::core::vector2df(15), irr::video::SColor(255,200,100,0), irr::video::SColor(255,200,128,0)); drawer->setEmitter(emitter); emitter->drop(); affector = new ColorAffector(irr::video::SColor(0,100,10,0)); drawer->addAffector(affector); affector->drop(); ///Fire/Smoke drawer = system->addParticleDrawer(); drawer->addUVCoords(SParticleUV(irr::core::vector2df(0.0f,0.0f), irr::core::vector2df(0.25f,0.0f), irr::core::vector2df(0.0f,0.25f), irr::core::vector2df(0.25f,0.25f))); drawer->addUVCoords(SParticleUV(irr::core::vector2df(0.25f,0.25f), irr::core::vector2df(0.5f,0.25f), irr::core::vector2df(0.25f,0.5f), irr::core::vector2df(0.5f,0.5f))); drawer->addUVCoords(SParticleUV(irr::core::vector2df(0.25f,0.0f), irr::core::vector2df(0.5f,0.0f), irr::core::vector2df(0.25f,0.25f), irr::core::vector2df(0.5f,0.25f))); drawer->addUVCoords(SParticleUV(irr::core::vector2df(0.0f,0.25f), irr::core::vector2df(0.25f,0.25f), irr::core::vector2df(0.0f,0.5f), irr::core::vector2df(0.25f,0.5f))); emitter = new CParticleEmitterPoint(irr::core::vector3df(0,0,0), irr::core::vector3df(1,0,0), irr::core::vector3df(2,0,0), irr::core::vector3di(0, 180, 0), 200, 400, 50, 1000, 1200, irr::core::vector2df(1,1), irr::core::vector2df(2,2), irr::core::vector2df(2), irr::video::SColor(255,200,180,0), irr::video::SColor(255,200,180,0)); drawer->setEmitter(emitter); emitter->drop(); affector = new ColorAffectorQ(irr::video::SColor(255, 100, 0, 0), irr::video::SColor(0,0,0,0)); drawer->addAffector(affector); affector->drop(); affector = new GravityAffector(irr::core::vector3df(0.f,10.0f,0.f)); drawer->addAffector(affector); affector->drop(); ///Spark Emitter drawer = system->addParticleDrawer(); drawer->addUVCoords(SParticleUV(irr::core::vector2df(0.5f,0.75f), irr::core::vector2df(0.75f,0.75f), irr::core::vector2df(0.5f,1.0f), irr::core::vector2df(0.75f,1.0f))); emitter = new CParticleEmitterPoint(irr::core::vector3df(0,0,0), irr::core::vector3df(0,0,0), irr::core::vector3df(0,6,0), irr::core::vector3di(90, 0, 90), 20, 50, 10, 1000, 1200, irr::core::vector2df(1.5, 1.5), irr::core::vector2df(2.0, 2.0), irr::core::vector2df(1,1), irr::video::SColor(255,255,128,0), irr::video::SColor(255,255,128,0)); drawer->setEmitter(emitter); emitter->drop(); affector = new GravityAffector(irr::core::vector3df(0.f,0.8f,0.f)); drawer->addAffector(affector); affector->drop(); affector = new ColorAffector(irr::video::SColor(0,255,128,0)); drawer->addAffector(affector); affector->drop(); ///Flash Emitter drawer = system->addParticleDrawer(); drawer->addUVCoords(SParticleUV(irr::core::vector2df(0.5,0), irr::core::vector2df(0.75,0), irr::core::vector2df(0.5,0.25), irr::core::vector2df(0.75f,0.25f))); drawer->addUVCoords(SParticleUV(irr::core::vector2df(0.5+0.25f,0), irr::core::vector2df(0.75+0.25f,0), irr::core::vector2df(0.5+0.25f,0.25), irr::core::vector2df(0.75f+0.25f,0.25f))); emitter = new CParticleEmitterPoint(irr::core::vector3df(0,0,0), irr::core::vector3df(0,0,0), irr::core::vector3df(0,0,0), irr::core::vector3di(0), 20, 50, 5, 200, 300, irr::core::vector2df(1,1), irr::core::vector2df(1,1), irr::core::vector2df(3), irr::video::SColor(255,255,255,100), irr::video::SColor(255,255, 255,100)); drawer->setEmitter(emitter); emitter->drop(); affector = new ColorAffector(irr::video::SColor(0,255, 255,100)); drawer->addAffector(affector); affector->drop(); for (irr::u32 i=0; i<system->getMaterialCount(); ++i) { system->getMaterial(i).MaterialType = irr::video::EMT_ONETEXTURE_BLEND; system->getMaterial(i).setTexture(0, smgr->getVideoDriver()->getTexture("export\\fig7_alpha.png")); system->getMaterial(i).setFlag(irr::video::EMF_LIGHTING, false); system->getMaterial(i).setFlag(irr::video::EMF_ZWRITE_ENABLE, false); system->getMaterial(i).MaterialTypeParam = irr::video::pack_textureBlendFunc (irr::video::EBF_SRC_ALPHA, irr::video::EBF_ONE_MINUS_SRC_ALPHA, irr::video::EMFN_MODULATE_1X, irr::video::EAS_VERTEX_COLOR | irr::video::EAS_TEXTURE ); } irr::scene::ISceneNodeAnimator* anim = smgr->createDeleteAnimator(3000); system->addAnimator(anim); anim->drop(); system->drop(); }